Skip to content

Commit 04d2957

Browse files
Merge pull request #260 from eclipse-basyx/development
BaSyx Java 1.4.0 release
2 parents cc8c441 + a79f7c4 commit 04d2957

File tree

48 files changed

+1978
-165
lines changed

Some content is hidden

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

48 files changed

+1978
-165
lines changed

.github/workflows/maven-publish-snapshot.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ jobs:
2626
distribution: 'adopt'
2727
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
2828
settings-path: ${{ github.workspace }} # location for the settings.xml file
29-
30-
- name: Build with Maven
31-
run: mvn -B package --file pom.xml
32-
29+
3330
- name: Delete old sdk package
3431
uses: actions/delete-package-versions@v3
3532
continue-on-error: true
3633
with:
3734
package-name: 'org.eclipse.basyx.basyx.sdk'
3835

3936
- name: Publish to GitHub Packages Apache Maven
40-
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
37+
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -DskipTests
4138
env:
4239
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/maven-run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
distribution: 'adopt'
2222
cache: maven
2323
- name: Build with Maven
24-
run: mvn -B package --file pom.xml
24+
run: mvn -B install --file pom.xml

pom.xml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.eclipse.basyx</groupId>
77
<artifactId>basyx.sdk</artifactId>
8-
<version>1.3.1</version>
8+
<version>1.4.0</version>
99
<name>BaSyx SDK</name>
1010
<description>BaSyx Software Development Kit</description>
1111
<url>https://www.eclipse.org/basyx/</url>
@@ -46,7 +46,7 @@
4646
<properties>
4747
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4848
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
49-
<spring-security-version>5.8.1</spring-security-version>
49+
<spring-security-version>5.8.2</spring-security-version>
5050
</properties>
5151

5252
<repositories>
@@ -65,7 +65,7 @@
6565
<!-- Compile Sources using Java 11 -->
6666
<plugin>
6767
<artifactId>maven-compiler-plugin</artifactId>
68-
<version>3.10.1</version>
68+
<version>3.11.0</version>
6969
<configuration>
7070
<source>11</source>
7171
<target>11</target>
@@ -110,7 +110,7 @@
110110
<plugin>
111111
<groupId>org.apache.maven.plugins</groupId>
112112
<artifactId>maven-surefire-plugin</artifactId>
113-
<version>3.0.0-M8</version>
113+
<version>3.0.0</version>
114114
<configuration>
115115
<excludes>
116116
<exclude>**/*HTTP*</exclude>
@@ -126,7 +126,7 @@
126126
<plugin>
127127
<groupId>org.apache.maven.plugins</groupId>
128128
<artifactId>maven-failsafe-plugin</artifactId>
129-
<version>3.0.0-M8</version>
129+
<version>3.0.0</version>
130130
<configuration>
131131
<includes>
132132
<include>**/*HTTP*</include>
@@ -147,7 +147,7 @@
147147
<plugin>
148148
<groupId>org.apache.maven.plugins</groupId>
149149
<artifactId>maven-javadoc-plugin</artifactId>
150-
<version>3.4.1</version>
150+
<version>3.5.0</version>
151151
<configuration>
152152
<source>8</source>
153153
</configuration>
@@ -169,7 +169,7 @@
169169
<dependency>
170170
<groupId>ch.qos.logback</groupId>
171171
<artifactId>logback-classic</artifactId>
172-
<version>1.4.5</version>
172+
<version>1.4.6</version>
173173
</dependency>
174174

175175
<!-- JUnit 4 for running JUnit tests -->
@@ -184,7 +184,7 @@
184184
<dependency>
185185
<groupId>org.mockito</groupId>
186186
<artifactId>mockito-core</artifactId>
187-
<version>5.1.1</version>
187+
<version>5.2.0</version>
188188
<scope>test</scope>
189189
</dependency>
190190

@@ -234,21 +234,21 @@
234234
<dependency>
235235
<groupId>org.glassfish.jersey.core</groupId>
236236
<artifactId>jersey-client</artifactId>
237-
<version>2.38</version>
237+
<version>2.39.1</version>
238238
</dependency>
239239

240240
<!-- Jersey InjectionManager (for Jersey client) -->
241241
<dependency>
242242
<groupId>org.glassfish.jersey.inject</groupId>
243243
<artifactId>jersey-hk2</artifactId>
244-
<version>2.38</version>
244+
<version>2.39.1</version>
245245
</dependency>
246246

247247
<!-- Tomcat 8 for HTTP server resource -->
248248
<dependency>
249249
<groupId>org.apache.tomcat</groupId>
250250
<artifactId>tomcat-catalina</artifactId>
251-
<version>9.0.71</version>
251+
<version>9.0.73</version>
252252
</dependency>
253253

254254
<!-- Used for creating .aasx files -->
@@ -349,6 +349,19 @@
349349
<version>5.9.0</version>
350350
<scope>test</scope>
351351
</dependency>
352+
353+
<dependency>
354+
<groupId>org.apache.httpcomponents.client5</groupId>
355+
<artifactId>httpclient5</artifactId>
356+
<version>5.2.1</version>
357+
<scope>test</scope>
358+
</dependency>
359+
360+
<dependency>
361+
<groupId>org.apache.tika</groupId>
362+
<artifactId>tika-core</artifactId>
363+
<version>2.7.0</version>
364+
</dependency>
352365
</dependencies>
353366

354367
<dependencyManagement>

src/main/java/org/eclipse/basyx/aas/aggregator/AASAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private MultiSubmodelProvider createMultiSubmodelProvider(AssetAdministrationShe
162162
IConnectorFactory connectorFactory = new HTTPConnectorFactory();
163163
IAASAPI aasApi = aasApiFactory.create(aas);
164164
AASModelProvider contentProvider = new AASModelProvider(aasApi);
165-
return new MultiSubmodelProvider(contentProvider, registry, connectorFactory, aasApiFactory, submodelAggregatorFactory.create());
165+
return new MultiSubmodelProvider(contentProvider, registry, connectorFactory, aasApiFactory, submodelAggregatorFactory.create(aas.getIdentification()));
166166
}
167167

168168
@Override

src/main/java/org/eclipse/basyx/aas/factory/aasx/AASXToMetamodelConverter.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
import java.util.Collection;
4141
import java.util.List;
4242
import java.util.Set;
43+
4344
import javax.xml.parsers.ParserConfigurationException;
45+
4446
import org.apache.commons.io.FileUtils;
4547
import org.apache.commons.io.IOUtils;
4648
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -75,6 +77,7 @@ public class AASXToMetamodelConverter {
7577

7678
private static final String XML_TYPE = "http://www.admin-shell.io/aasx/relationships/aas-spec";
7779
private static final String AASX_ORIGIN = "/aasx/aasx-origin";
80+
public static final String TEMP_DIRECTORY = "basyx-temp";
7881

7982
private String aasxPath;
8083
private OPCPackage aasxRoot;
@@ -136,6 +139,13 @@ public <T extends AASBundle> Set<T> retrieveAASBundles() throws IOException, Par
136139
return (Set<T>) bundles;
137140
}
138141

142+
public InputStream retrieveFileInputStream(String path) throws InvalidFormatException, IOException {
143+
loadAASX();
144+
PackagePart filePart = aasxRoot.getPart(PackagingURIHelper.createPartName(path));
145+
closeOPCPackage();
146+
return filePart.getInputStream();
147+
}
148+
139149
private void loadAASX() throws IOException, InvalidFormatException {
140150
if (aasxInputStream == null) {
141151
aasxInputStream = FileLoaderHelper.getInputStream(aasxPath);
@@ -270,7 +280,7 @@ private List<String> parseElements(Collection<ISubmodelElement> elements) {
270280
* @throws InvalidFormatException
271281
*/
272282
public void unzipRelatedFiles() throws IOException, ParserConfigurationException, SAXException, URISyntaxException, InvalidFormatException {
273-
unzipRelatedFiles(getRootFolder());
283+
unzipRelatedFiles(getTemporaryDirPath());
274284
}
275285

276286
/**
@@ -294,14 +304,27 @@ public void unzipRelatedFiles(Path pathToDirectory) throws InvalidFormatExceptio
294304
closeOPCPackage();
295305
}
296306

307+
/**
308+
* Creates a temporary directory to hold the unpackaged files.
309+
*
310+
* @return Path of the temporary directory
311+
*
312+
*/
313+
protected Path getTemporaryDirPath() {
314+
return Paths.get(FileUtils.getTempDirectory().getAbsolutePath(), TEMP_DIRECTORY);
315+
}
316+
297317
/**
298318
* Create a folder to hold the unpackaged files The folder has the path
299319
* \target\classes\docs
300320
*
301321
* @throws IOException
302322
* @throws URISyntaxException
323+
*
324+
* @deprecated This method is deprecated. Please use the {@link AASXToMetamodelConverter#getTemporaryDirPath()}
303325
*/
304-
protected Path getRootFolder() throws IOException, URISyntaxException {
326+
@Deprecated(since = "1.4.0", forRemoval = true)
327+
protected Path getRootFolder() throws URISyntaxException, IOException {
305328
URI uri = AASXToMetamodelConverter.class.getProtectionDomain().getCodeSource().getLocation().toURI();
306329
URI parent = new File(uri).getParentFile().toURI();
307330
return Paths.get(parent);
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*******************************************************************************
2+
* Copyright (C) 2023 the Eclipse BaSyx Authors
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
* SPDX-License-Identifier: MIT
24+
******************************************************************************/
25+
package org.eclipse.basyx.aas.factory.json;
26+
27+
import java.util.List;
28+
import java.util.Map;
29+
import java.util.stream.Collectors;
30+
31+
import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
32+
import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
33+
import org.eclipse.basyx.submodel.metamodel.api.ISubmodel;
34+
import org.eclipse.basyx.submodel.metamodel.api.reference.IKey;
35+
import org.eclipse.basyx.submodel.metamodel.map.Submodel;
36+
import org.eclipse.basyx.submodel.metamodel.map.reference.Key;
37+
import org.eclipse.basyx.vab.coder.json.serialization.DefaultTypeFactory;
38+
import org.eclipse.basyx.vab.coder.json.serialization.GSONTools;
39+
40+
/**
41+
* Serializes and deserializes shells and submodels to and from json
42+
*
43+
* @author jungjan
44+
*
45+
*/
46+
public class BidirectionalJSONConverter {
47+
private static GSONTools gsonTools = new GSONTools(new DefaultTypeFactory());
48+
49+
public static String serializeSubmodel(ISubmodel submodel) {
50+
return gsonTools.serialize(submodel);
51+
}
52+
53+
@SuppressWarnings("unchecked")
54+
public static ISubmodel deserializeSubmodel(String jsonSubmodel) {
55+
return Submodel.createAsFacade((Map<String, Object>) gsonTools.deserialize(jsonSubmodel));
56+
}
57+
58+
public static String serializeShell(AssetAdministrationShell shell) {
59+
return gsonTools.serialize(shell);
60+
}
61+
62+
@SuppressWarnings("unchecked")
63+
public static AssetAdministrationShell deserializeShell(String jsonShell) {
64+
return AssetAdministrationShell.createAsFacade((Map<String, Object>) gsonTools.deserialize(jsonShell));
65+
}
66+
67+
public static <T> String serializeObject(T object) {
68+
return gsonTools.serialize(object);
69+
}
70+
71+
@SuppressWarnings("unchecked")
72+
public static <T> T deserializeJSON(String json) {
73+
T retrieved = (T) gsonTools.deserialize(json);
74+
return retrieved;
75+
}
76+
77+
@SuppressWarnings("unchecked")
78+
public static AASDescriptor deserializeAASDescriptor(String json) {
79+
return AASDescriptor.createAsFacade((Map<String, Object>) gsonTools.deserialize(json));
80+
}
81+
82+
/**
83+
*
84+
* @param submodel
85+
* @return the semanticId of a submodel serialized according to the following schema:
86+
* {@code {type:<type>;value:<value>;idType:<idType>[/]}}.
87+
* Example: {@code type:Submodel;value:a value;idType:Custom/type:Submodel;value:another value;idType:Custom}
88+
*/
89+
public static String semanticIdAsSString(ISubmodel submodel) {
90+
if (submodel.getSemanticId() == null) {
91+
return null;
92+
}
93+
List<IKey> keys = submodel.getSemanticId().getKeys();
94+
return semanticIdKeysToString(keys);
95+
}
96+
97+
public static String semanticIdKeysToString(List<IKey> keys) {
98+
return keys.stream().map(k ->
99+
Key.TYPE + ":" + k.getType() + ";"
100+
/* + Key.LOCAL + ":" + k.isLocal() + ";" */ //ignoring local since it won't be relevant for V3
101+
+ Key.VALUE + ":" + k.getValue() + ";"
102+
+ Key.IDTYPE + ":" + k.getIdType())
103+
.collect(Collectors.joining("/"));
104+
}
105+
106+
}

0 commit comments

Comments
 (0)