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

Commit dcd741c

Browse files
committed
Fixed Missing Asset Test Case
1 parent 529d659 commit dcd741c

3 files changed

Lines changed: 55 additions & 5 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.i4aas.mappers;
17+
18+
import org.opcfoundation.ua._2011._03.uanodeset.UAObject;
19+
20+
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.I4AASIdentifier;
21+
import io.adminshell.aas.v3.model.Asset;
22+
23+
public class AssetMapper extends IdentifiableMapper<Asset> implements HasDataSpecificationMapper {
24+
25+
public AssetMapper(Asset src, MappingContext ctx) {
26+
super(src, ctx);
27+
}
28+
29+
@Override
30+
protected UAObject createTargetObject() {
31+
super.createTargetObject();
32+
addTypeReference(I4AASIdentifier.AASAssetType);
33+
return target;
34+
}
35+
36+
@Override
37+
protected void mapAndAttachChildren() {
38+
super.mapAndAttachChildren();
39+
mapDataSpecification(source, target, ctx);
40+
}
41+
42+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.I4AASIdentifier;
2323
import io.adminshell.aas.v3.dataformat.i4aas.mappers.utils.UaIdentifier;
24+
import io.adminshell.aas.v3.model.Asset;
2425
import io.adminshell.aas.v3.model.AssetAdministrationShell;
2526
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
2627
import io.adminshell.aas.v3.model.ConceptDescription;
@@ -66,5 +67,9 @@ protected void mapAndAttachChildren() {
6667
UAObject aasUaObject = new AssetAdministrationShellMapper(assetAdministrationShell, ctx).map();
6768
attachAsComponent(target, aasUaObject);
6869
}
70+
for (Asset asset : source.getAssets()) {
71+
UAObject aasUaObject = new AssetMapper(asset, ctx).map();
72+
attachAsComponent(target, aasUaObject);
73+
}
6974
}
7075
}

dataformat-uanodeset/src/test/java/io/adminshell/aas/v3/dataformat/i4aas/AASSimple.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Arrays;
2121
import java.util.List;
2222

23+
import io.adminshell.aas.v3.model.Asset;
2324
import io.adminshell.aas.v3.model.AssetAdministrationShell;
2425
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
2526
import io.adminshell.aas.v3.model.AssetKind;
@@ -32,6 +33,7 @@
3233
import io.adminshell.aas.v3.model.ModelingKind;
3334
import io.adminshell.aas.v3.model.Submodel;
3435
import io.adminshell.aas.v3.model.impl.DefaultAdministrativeInformation;
36+
import io.adminshell.aas.v3.model.impl.DefaultAsset;
3537
import io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShell;
3638
import io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment;
3739
import io.adminshell.aas.v3.model.impl.DefaultAssetInformation;
@@ -78,7 +80,7 @@ public class AASSimple {
7880
private static final String TITEL = "Titel";
7981
private static final String WWW_VDI2770_COM_BLATT1_ENTWURF_OKT18_CD_DESCRIPTION_TITLE = "www.vdi2770.com/blatt1/Entwurf/Okt18/cd/Description/Title";
8082
private static final String TITLE = "Title";
81-
//private static final String SERVO_DC_MOTOR = "ServoDCMotor";
83+
private static final String SERVO_DC_MOTOR = "ServoDCMotor";
8284
private static final String HTTPS_GITHUB_COM_ADMIN_SHELL_IO_BLOB_MASTER_VERWALTUNGSSCHALE_DETAIL_PART1_PNG = "https://github.com/admin-shell/io/blob/master/verwaltungsschale-detail-part1.png";
8385
private static final String IMAGE_PNG = "image/png";
8486
private static final String THUMBNAIL = "thumbnail";
@@ -165,10 +167,10 @@ public AASSimple() {
165167
.value(SUBMODEL_DOCUMENTATION_ID).idType(KeyType.IRI).build()).build())
166168
.build();
167169

168-
// public static final Asset ASSET = new DefaultAsset.Builder().idShort(SERVO_DC_MOTOR)
169-
// .identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI)
170-
// .identifier(HTTP_CUSTOMER_COM_ASSETS_KHBVZJSQKIY).build())
171-
// .build();
170+
public static final Asset ASSET = new DefaultAsset.Builder().idShort(SERVO_DC_MOTOR)
171+
.identification(new DefaultIdentifier.Builder().idType(IdentifierType.IRI)
172+
.identifier(HTTP_CUSTOMER_COM_ASSETS_KHBVZJSQKIY).build())
173+
.build();
172174

173175
public static final Submodel SUBMODEL_TECHNICAL_DATA = new DefaultSubmodel.Builder()
174176
.semanticId(new DefaultReference.Builder().key(new DefaultKey.Builder().type(KeyElements.GLOBAL_REFERENCE)
@@ -328,6 +330,7 @@ public AASSimple() {
328330
.conceptDescriptions(CONCEPT_DESCRIPTION_DIGITALFILE)
329331
.conceptDescriptions(CONCEPT_DESCRIPTION_MAXROTATIONSPEED)
330332
.conceptDescriptions(CONCEPT_DESCRIPTION_ROTATIONSPEED).conceptDescriptions(CONCEPT_DESCRIPTION_DOCUMENT)
333+
.assets(ASSET)
331334
.build();
332335

333336
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {

0 commit comments

Comments
 (0)