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

Commit 99c216f

Browse files
committed
updated dataformat-core, dataformat-aml, dataformat-xml
1 parent 645d08c commit 99c216f

66 files changed

Lines changed: 1416 additions & 913 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 0 additions & 83 deletions
This file was deleted.

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

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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;
17+
18+
public class AmlDeserializationConfig {
19+
20+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import io.adminshell.aas.v3.dataformat.DeserializationException;
1919
import io.adminshell.aas.v3.dataformat.Deserializer;
20-
import io.adminshell.aas.v3.dataformat.aml.aml2aas.Aml2AasObjectMapper;
20+
import io.adminshell.aas.v3.dataformat.aml.aml2aas.Aml2AasMapper;
2121
import io.adminshell.aas.v3.dataformat.aml.model.caex.CAEXFile;
2222
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
2323
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
@@ -38,7 +38,7 @@ public AssetAdministrationShellEnvironment read(String value) throws Deserializa
3838
Unmarshaller unmarshaller = JAXBContextFactory.createContext(new Class[]{CAEXFile.class}, null).createUnmarshaller();
3939
StringReader reader = new StringReader(value);
4040
CAEXFile aml = (CAEXFile) unmarshaller.unmarshal(reader);
41-
Aml2AasObjectMapper mapper = new Aml2AasObjectMapper(new Aml2AasConfig());
41+
Aml2AasMapper mapper = new Aml2AasMapper(new AmlDeserializationConfig());
4242
return mapper.map(aml);
4343
} catch (JAXBException ex) {
4444
throw new DeserializationException("error deserializing AssetAdministrationShellEnvironment", ex);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
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+
*/
116
package io.adminshell.aas.v3.dataformat.aml;
217

318
public class AmlDocumentInfo {
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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;
17+
18+
import io.adminshell.aas.v3.dataformat.aml.header.WriterInfo;
19+
import io.adminshell.aas.v3.dataformat.aml.id.UuidGenerator;
20+
import io.adminshell.aas.v3.dataformat.aml.id.IdGenerator;
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.List;
24+
25+
public class AmlSerializationConfig {
26+
27+
public static final String DEFAULT_SCHEMA_VERSION = "2.15";
28+
public static final String DEFAULT_AML_VERSION = "2.0";
29+
public static final String DEFAULT_FILENAME = "AssetAdministrationShellEnvironment.aml";
30+
public static final AmlSerializationConfig DEFAULT = new Builder().build();
31+
32+
public static Builder builder() {
33+
return new Builder();
34+
}
35+
36+
private final IdGenerator idGenerator;
37+
private final String schemaVersion;
38+
private final String amlVersion;
39+
private final String filename;
40+
private final boolean includeLibraries;
41+
private final WriterInfo writerInfo;
42+
private final List<Object> additionalInformation;
43+
44+
private AmlSerializationConfig(
45+
IdGenerator idGenerator,
46+
String schemaVersion,
47+
String amlVersion,
48+
String filename,
49+
boolean includeLibraries,
50+
WriterInfo writerInfo,
51+
List<Object> additionalInformation) {
52+
this.idGenerator = idGenerator;
53+
this.schemaVersion = schemaVersion;
54+
this.amlVersion = amlVersion;
55+
this.filename = filename;
56+
this.includeLibraries = includeLibraries;
57+
this.writerInfo = writerInfo;
58+
this.additionalInformation = additionalInformation;
59+
}
60+
61+
public boolean isIncludeLibraries() {
62+
return includeLibraries;
63+
}
64+
65+
public IdGenerator getIdGenerator() {
66+
return idGenerator;
67+
}
68+
69+
public List<Object> getAdditionalInformation() {
70+
return additionalInformation;
71+
}
72+
73+
public String getSchemaVersion() {
74+
return schemaVersion;
75+
}
76+
77+
public String getAmlVersion() {
78+
return amlVersion;
79+
}
80+
81+
public WriterInfo getWriterInfo() {
82+
return writerInfo;
83+
}
84+
85+
public static class Builder {
86+
87+
private IdGenerator idGenerator = new UuidGenerator();
88+
private String schemaVersion = DEFAULT_SCHEMA_VERSION;
89+
private String amlVersion = DEFAULT_AML_VERSION;
90+
private String filename = DEFAULT_FILENAME;
91+
private boolean includeLibraries = true;
92+
private WriterInfo writerInfo = null;
93+
private List<Object> additionalInformation = new ArrayList<>();
94+
95+
public AmlSerializationConfig build() {
96+
return new AmlSerializationConfig(
97+
idGenerator,
98+
schemaVersion,
99+
amlVersion,
100+
filename,
101+
includeLibraries,
102+
writerInfo,
103+
additionalInformation);
104+
}
105+
106+
public Builder includeLibraries() {
107+
this.includeLibraries = true;
108+
return this;
109+
}
110+
111+
public Builder excludeLibraries() {
112+
this.includeLibraries = true;
113+
return this;
114+
}
115+
116+
public Builder idGenerator(IdGenerator idGenerator) {
117+
this.idGenerator = idGenerator;
118+
return this;
119+
}
120+
121+
public Builder schemaVersion(String value) {
122+
this.schemaVersion = value;
123+
return this;
124+
}
125+
126+
public Builder amlVersion(String value) {
127+
this.amlVersion = value;
128+
return this;
129+
}
130+
131+
public Builder filename(String value) {
132+
this.filename = value;
133+
return this;
134+
}
135+
136+
public Builder writerInfo(WriterInfo value) {
137+
this.writerInfo = value;
138+
return this;
139+
}
140+
141+
public Builder additionalInformation(Object... values) {
142+
this.additionalInformation.addAll(Arrays.asList(values));
143+
return this;
144+
}
145+
}
146+
147+
public String getFilename() {
148+
return filename;
149+
}
150+
}

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import io.adminshell.aas.v3.dataformat.SerializationException;
2020
import io.adminshell.aas.v3.dataformat.Serializer;
2121
import io.adminshell.aas.v3.dataformat.aml.header.AutomationMLVersion;
22-
import io.adminshell.aas.v3.dataformat.aml.header.WriterHeader;
22+
import io.adminshell.aas.v3.dataformat.aml.header.WriterInfo;
2323
import io.adminshell.aas.v3.dataformat.aml.model.caex.CAEXFile;
2424
import io.adminshell.aas.v3.dataformat.mapping.MappingException;
2525
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
@@ -42,23 +42,21 @@ public AmlSerializer() {
4242

4343
@Override
4444
public String write(AssetAdministrationShellEnvironment aasEnvironment) throws SerializationException {
45-
return write(aasEnvironment, Aas2AmlConfig.DEFAULT);
45+
return write(aasEnvironment, AmlSerializationConfig.DEFAULT);
4646
}
4747

48-
public String write(AssetAdministrationShellEnvironment aasEnvironment, Aas2AmlConfig config) throws SerializationException {
49-
AasToAmlMapper mapper = new AasToAmlMapper(config);
48+
public String write(AssetAdministrationShellEnvironment aasEnvironment, AmlSerializationConfig config) throws SerializationException {
5049
try {
51-
CAEXFile aml = mapper.map(aasEnvironment);
50+
CAEXFile aml = new AasToAmlMapper().map(aasEnvironment, config);
5251
if (config.isIncludeLibraries()) {
5352
aml = addAASLibrary(aml);
5453
}
55-
Marshaller marshaller = JAXBContextFactory.createContext(
56-
new Class[]{
57-
CAEXFile.class,
58-
AutomationMLVersion.class,
59-
WriterHeader.class,
60-
WriterHeader.Wrapper.class
61-
},
54+
Marshaller marshaller = JAXBContextFactory.createContext(new Class[]{
55+
CAEXFile.class,
56+
AutomationMLVersion.class,
57+
WriterInfo.class,
58+
WriterInfo.Wrapper.class
59+
},
6260
null).createMarshaller();
6361
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
6462
StringWriter writer = new StringWriter();

0 commit comments

Comments
 (0)