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

Commit e9a298f

Browse files
authored
Fix/ua nodeset fixes (#41)
* Fix QualifierType * Fix for Operations * Fixes for Optional Category and AdministrativeInformation * Updated NodeSet * Operation Mapping * Update Opc.Ua.I4AAS_V3Draft.NodeSet2.xml * Folders are optional now, only created when list is not empty * fix IdShort in test objects * first adjustments to AASUtils resolve * fix for NPE when no implementation class is available * optimized logger statement * Changed UAObject as Key since Reference Object might be duplicates * experimental tests and adjustments * Fix LangString for DisplayName * Comment IDShort of CD * Comment on missing mapping rule for KeyElements of CD * Added missing ValueTypeParser * Update ValueTypeMapper.java * Test Updates with Validation * Update IntegrationTests.java * Added License Header
1 parent f99a58c commit e9a298f

34 files changed

Lines changed: 481 additions & 172 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ local.properties
3434
**.flattened-pom.xml
3535
nbactions.xml
3636
testJsonSerialization.json
37+
dataformat-uanodeset/jsonExpected.json
38+
dataformat-uanodeset/jsonActual.json

dataformat-core/src/main/java/io/adminshell/aas/v3/dataformat/core/util/AasUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ public static <T extends Referable> T resolve(Reference reference, AssetAdminist
513513
int i = reference.getKeys().size() - 1;
514514
if (type != null) {
515515
Class<?> actualType = keyTypeToClass(reference.getKeys().get(i).getType());
516+
if (actualType == null) {
517+
log.warn("reference {} could not be resolved as key type has no known class.",
518+
asString(reference));
519+
return null;
520+
}
516521
if (!type.isAssignableFrom(actualType)) {
517522
log.warn("reference {} could not be resolved as target type is not assignable from actual type (target: {}, actual: {})",
518523
asString(reference), type.getName(), actualType.getName());

dataformat-uanodeset/nodeset/i4aas/Opc.Ua.I4AAS_V3Draft.NodeSet2.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ AASIdentifiableType_Identification,5037,Object
9191
AASKeyDataType_Encoding_DefaultBinary,5038,Object
9292
AASKeyDataType_Encoding_DefaultXml,5039,Object
9393
AASKeyDataType_Encoding_DefaultJson,5040,Object
94+
AASOperationType_InputVariable,5041,Object
9495
AASOrderedSubmodelElementCollectionType_SubmodelElement,5042,Object
9596
AASCustomConceptDescriptionType_DataSpecification,5043,Object
9697
AASIrdiConceptDescriptionType_IsCaseOf,5044,Object
@@ -100,6 +101,8 @@ AASEnvironmentType_AAS_AssetInformation_BillOfMaterial,5047,Object
100101
AASCustomConceptDescriptionType_IsCaseOf,5048,Object
101102
AASAssetInformationType_SpecificAssetId,5049,Object
102103
AASAssetAdministrationShellType_AssetInformation_SpecificAssetId,5050,Object
104+
AASOperationType_OutputVariable,5051,Object
105+
AASOperationType_InOutputVariable,5052,Object
103106
AASEnvironmentType_AAS_Identification,5101,Object
104107
AASEnvironmentType_Asset,5103,Object
105108
AASEnvironmentType_Asset_Administration,5150,Object

dataformat-uanodeset/nodeset/i4aas/Opc.Ua.I4AAS_V3Draft.NodeSet2.xml

Lines changed: 87 additions & 67 deletions
Large diffs are not rendered by default.

dataformat-uanodeset/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@
2424
<classifier>tests</classifier>
2525
<scope>test</scope>
2626
</dependency>
27+
<dependency>
28+
<groupId>io.admin-shell.aas</groupId>
29+
<artifactId>dataformat-json</artifactId>
30+
<version>${revision}</version>
31+
<scope>test</scope>
32+
</dependency>
33+
<dependency>
34+
<groupId>io.admin-shell.aas</groupId>
35+
<artifactId>validator</artifactId>
36+
<version>${revision}</version>
37+
<scope>test</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.skyscreamer</groupId>
41+
<artifactId>jsonassert</artifactId>
42+
<version>${jsonassert.version}</version>
43+
<scope>test</scope>
44+
</dependency>
2745
<dependency>
2846
<groupId>javax.xml.bind</groupId>
2947
<artifactId>jaxb-api</artifactId>

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/AssetAdministrationShellMapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import io.adminshell.aas.v3.model.AssetAdministrationShell;
2424
import io.adminshell.aas.v3.model.AssetInformation;
2525

26-
public class AssetAdministrationShellMapper extends IdentifiableMapper<AssetAdministrationShell> implements HasDataSpecificationMapper {
26+
public class AssetAdministrationShellMapper extends IdentifiableMapper<AssetAdministrationShell>
27+
implements HasDataSpecificationMapper {
2728

2829
public AssetAdministrationShellMapper(AssetAdministrationShell src, MappingContext ctx) {
2930
super(src, ctx);
@@ -47,14 +48,15 @@ protected void mapAndAttachChildren() {
4748

4849
private void mapAsset() {
4950
AssetInformation assetInformation = source.getAssetInformation();
50-
if (assetInformation != null) {
51+
if (assetInformation != null) {
5152
UAObject uaAsset = new AssetInformationMapper(assetInformation, ctx).map();
5253
attachAsComponent(target, uaAsset);
5354
}
5455
}
5556

5657
private void mapSubmodels() {
57-
UAObject smFolder = createReferenceList(AAS_SUBMODELREFERENCES_LIST_BROWSENAME);
58+
UAObject smFolder = source.getSubmodels().isEmpty() ? null
59+
: createReferenceList(AAS_SUBMODELREFERENCES_LIST_BROWSENAME);
5860
List<io.adminshell.aas.v3.model.Reference> submodels = source.getSubmodels();
5961
for (int i = 0; i < submodels.size(); i++) {
6062
io.adminshell.aas.v3.model.Reference reference = submodels.get(i);

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/AssetInformationMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ protected void mapAndAttachChildren() {
5555
attachAsComponent(target, uaIdentification);
5656
}
5757

58-
UAObject uaBomList = createReferenceList(ASSETINFO_BILL_OF_MATERIAL_BROWSENAME);
5958
List<Reference> billOfMaterials = source.getBillOfMaterials();
59+
UAObject uaBomList = billOfMaterials.isEmpty() ? null : createReferenceList(ASSETINFO_BILL_OF_MATERIAL_BROWSENAME);
6060
for (int i = 0; i < billOfMaterials.size(); i++) {
6161
Reference reference = billOfMaterials.get(i);
6262
UAObject uaBomListEntry = new ReferenceMapper(reference, ctx, ASSETINFO_BILL_OF_MATERIAL_BROWSENAME + "_" + i).map();
@@ -70,7 +70,7 @@ protected void mapAndAttachChildren() {
7070
attachAsComponent(target, uaThumbnail);
7171
}
7272

73-
UAObject folder = createIdentifierKeyValuePairList(ASSETINFO_SPECIFIC_ASSET_ID_BROWSENAME);
73+
UAObject folder = source.getSpecificAssetIds().isEmpty() ? null : createIdentifierKeyValuePairList(ASSETINFO_SPECIFIC_ASSET_ID_BROWSENAME);
7474
for (IdentifierKeyValuePair identifierKeyValuePair : source.getSpecificAssetIds()) {
7575
UAObject uaIdKVP = new IdentifierKeyValuePairMapper(identifierKeyValuePair, ctx).map();
7676
attachAsComponent(folder, uaIdKVP);

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/ConceptDescriptionMapper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import io.adminshell.aas.v3.model.IdentifierType;
2424
import io.adminshell.aas.v3.model.Reference;
2525

26-
public class ConceptDescriptionMapper extends IdentifiableMapper<ConceptDescription> implements HasDataSpecificationMapper {
26+
public class ConceptDescriptionMapper extends IdentifiableMapper<ConceptDescription>
27+
implements HasDataSpecificationMapper {
2728

2829
public ConceptDescriptionMapper(ConceptDescription src, MappingContext ctx) {
2930
super(src, ctx);
@@ -43,12 +44,12 @@ protected UAObject createTargetObject() {
4344
} else if (IdentifierType.CUSTOM == idType) {
4445
addTypeReference(I4AASIdentifier.AASCustomConceptDescriptionType);
4546
}
46-
if (identification.getIdentifier() != null) {
47-
//conflict: I4AAS says idshort, OPC UA says value
48-
target.setBrowseName(createModelBrowseName(identification.getIdentifier()));
49-
}
47+
// if (identification.getIdentifier() != null) {
48+
// // TODO: I4AAS says idshort, OPC UA says value. Currently there is no mapping target for IdShort of ConceptDescription
49+
// target.setBrowseName(createModelBrowseName(identification.getIdentifier()));
50+
// }
5051
}
51-
52+
5253
return target;
5354
}
5455

@@ -58,12 +59,11 @@ protected void mapAndAttachChildren() {
5859

5960
mapDataSpecification(source, target, ctx);
6061

61-
UAObject createFolder = createReferenceList("IsCaseOf");
62+
UAObject createFolder = source.getIsCaseOfs().isEmpty() ? null : createReferenceList("IsCaseOf");
6263
for (Reference reference : source.getIsCaseOfs()) {
6364
UAObject uaRef = new ReferenceMapper(reference, ctx, reference.getKeys().get(0).getValue()).map();
6465
attachAsComponent(createFolder, uaRef);
6566
}
6667
}
6768

68-
6969
}

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/HasDataSpecificationMapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ public interface HasDataSpecificationMapper {
3131

3232
public default void mapDataSpecification(HasDataSpecification source, UAObject target, MappingContext ctx) {
3333

34-
UAObject folder = I4AASMapper.createFolder(target, I4AASConstants.DATASPECIFICATION_BROWSENAME, ctx,
35-
I4AASIdentifier.AASReferenceList);
34+
UAObject folder = source.getEmbeddedDataSpecifications().isEmpty() ? null
35+
: I4AASMapper.createFolder(target, I4AASConstants.DATASPECIFICATION_BROWSENAME, ctx,
36+
I4AASIdentifier.AASReferenceList);
3637

3738
List<EmbeddedDataSpecification> embeddedDataSpecifications = source.getEmbeddedDataSpecifications();
3839
for (int i = 0; i < embeddedDataSpecifications.size(); i++) {

dataformat-uanodeset/src/main/java/io/adminshell/aas/v3/dataformat/i4aas/mappers/I4AASEnumMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ protected String deriveDefaultName() {
8585
if (source instanceof io.adminshell.aas.v3.model.IdentifierType) {
8686
return IDENTIFICATION_IDTYPE_BROWSENAME;
8787
}
88+
if (source instanceof io.adminshell.aas.v3.model.DataTypeIEC61360) {
89+
return IDENTIFICATION_DATATYPE_BROWSENAME;
90+
}
8891
return source.getClass().getSimpleName();
8992
}
9093

0 commit comments

Comments
 (0)