Skip to content

Commit

Permalink
Updating to v3.0RC02 (#18)
Browse files Browse the repository at this point in the history
* Upgrade the model module to version 1.2.0 (latest one already published on MAVEN CENTRAL).

* Adjusting the groupIds in the child poms.

* RC02 Upgrades in terms of compilable code of:
* AASX
* JSON
* AML
* XML

* Version 0.2.0-SNAPSHOT for the dataformat modules and the validator

* Version 1.3.RC02-SNAPSHOT for the model

* adjusting the package names from org.eclipse.aas4j to org.eclipse.digitaltwin.aas4j

* Adding the newly created JSON and XML schemas

* Adding default values where the metamodel defines them

* Fixing the behaviour for HasDataSpecification.embeddedDataSpecfication for the DataSpecificationIEC61360.

* Fix the package path, removed the rc02 part

* Fix the representation of langStrings in JSON

* upgrade to minor version 0.2.0-SNAPSHOT

* removing AML serialization until official specification is available

* removing OPC UA nodeset serialization until official specification is available

* Adjusting the files paths in AASSimple to match the new pattern

* Adjust the ValueList according to the metamodel

* Fix: example files to the file pattern and the ModelReferences

* Fix: Change SubmodelElementCollections which are ordered to SubmodelElementLists for the AASFull test objects.

* add test case for empty SubmodelElementList

* Fix plural field names where the schemas use singular

* Fix AasUtils enum name deserialization

* add initial AAS Full RDF Parser UnitTest

* fix qualifier deserialization bug

Co-authored-by: Sebastian Bader <[email protected]>
Co-authored-by: Chang Qin <[email protected]>
Co-authored-by: Frank Schnicke <[email protected]>
  • Loading branch information
4 people authored Dec 14, 2022
1 parent 001dcec commit 86126fb
Show file tree
Hide file tree
Showing 1,580 changed files with 49,904 additions and 303,958 deletions.
13 changes: 0 additions & 13 deletions dataformat-aasx/license-header.txt

This file was deleted.

8 changes: 5 additions & 3 deletions dataformat-aasx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.admin-shell.aas</groupId>
<groupId>org.eclipse.digitaltwin.aas4j</groupId>
<artifactId>dataformat-parent</artifactId>
<version>${revision}</version>
</parent>
Expand All @@ -13,12 +13,12 @@

<dependencies>
<dependency>
<groupId>io.admin-shell.aas</groupId>
<groupId>${groupId}</groupId>
<artifactId>dataformat-xml</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.admin-shell.aas</groupId>
<groupId>${groupId}</groupId>
<artifactId>dataformat-core</artifactId>
<version>${revision}</version>
<classifier>tests</classifier>
Expand All @@ -41,4 +41,6 @@
<version>${commons-io.version}</version>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aasx;
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -29,14 +29,14 @@
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;

import io.adminshell.aas.v3.dataformat.DeserializationException;
import io.adminshell.aas.v3.dataformat.Serializer;
import io.adminshell.aas.v3.dataformat.xml.XmlDeserializer;
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
import io.adminshell.aas.v3.model.File;
import io.adminshell.aas.v3.model.Submodel;
import io.adminshell.aas.v3.model.SubmodelElement;
import io.adminshell.aas.v3.model.SubmodelElementCollection;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlDeserializer;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.File;
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;

/**
* The AASX package converter converts a aasx package into a list of aas, a list
Expand All @@ -49,7 +49,7 @@ public class AASXDeserializer {

private XmlDeserializer deserializer = new XmlDeserializer();

private AssetAdministrationShellEnvironment environment;
private Environment environment;
private final OPCPackage aasxRoot;

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ public AASXDeserializer(XmlDeserializer deserializer, InputStream inputStream) t
* @throws IOException if creating input streams for aasx fails
* @throws DeserializationException if deserialization of the serialized aas environment fails
*/
public AssetAdministrationShellEnvironment read() throws InvalidFormatException, IOException, DeserializationException {
public Environment read() throws InvalidFormatException, IOException, DeserializationException {
// If the XML was already parsed return cached environment
if (environment != null) {
return environment;
Expand Down Expand Up @@ -160,15 +160,10 @@ private List<String> parseElements(Collection<SubmodelElement> elements) {
for (SubmodelElement element : elements) {
if (element instanceof File) {
File file = (File) element;
// If the path contains a "://", we can assume, that the Path is a link to an
// other server
// e.g. http://localhost:8080/aasx/...
if (!file.getValue().contains("://")) {
paths.add(file.getValue());
}
paths.add(file.getValue());
} else if (element instanceof SubmodelElementCollection) {
SubmodelElementCollection collection = (SubmodelElementCollection) element;
paths.addAll(parseElements(collection.getValues()));
paths.addAll(parseElements(collection.getValue()));
}
}
return paths;
Expand All @@ -192,7 +187,7 @@ public List<InMemoryFile> getRelatedFiles() throws InvalidFormatException, IOExc
}

private InMemoryFile readFile(OPCPackage aasxRoot, String filePath) throws InvalidFormatException, IOException {
PackagePart part = aasxRoot.getPart(PackagingURIHelper.createPartName(filePath));
PackagePart part = aasxRoot.getPart(PackagingURIHelper.createPartName(AASXUtils.getPathFromURL(filePath)));
InputStream stream = part.getInputStream();
return new InMemoryFile(stream.readAllBytes(), filePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aasx;
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;

import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -30,17 +30,19 @@
import org.apache.poi.openxml4j.opc.RelationshipSource;
import org.apache.poi.openxml4j.opc.TargetMode;
import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.adminshell.aas.v3.dataformat.SerializationException;
import io.adminshell.aas.v3.dataformat.Serializer;
import io.adminshell.aas.v3.dataformat.xml.XmlSerializer;
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
import io.adminshell.aas.v3.model.File;
import io.adminshell.aas.v3.model.Submodel;
import io.adminshell.aas.v3.model.SubmodelElement;
import io.adminshell.aas.v3.model.SubmodelElementCollection;
import org.eclipse.digitaltwin.aas4j.v3.model.File;
import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection;

import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.Serializer;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlSerializer;

/**
* This class can be used to generate an .aasx file from Metamodel Objects and
Expand Down Expand Up @@ -87,7 +89,7 @@ public AASXSerializer(Serializer xmlSerializer) {
* @throws SerializationException if serializing the given elements fails
* @throws IOException if creating output streams for aasx fails
*/
public void write(AssetAdministrationShellEnvironment environment, Collection<InMemoryFile> files, OutputStream os)
public void write(Environment environment, Collection<InMemoryFile> files, OutputStream os)
throws SerializationException, IOException {
prepareFilePaths(environment.getSubmodels());

Expand Down Expand Up @@ -117,15 +119,15 @@ public void write(AssetAdministrationShellEnvironment environment, Collection<In
* @param xmlPart the Part the files should be related to
*/
private void storeFilesInAASX(List<Submodel> submodelList, Collection<InMemoryFile> files, OPCPackage rootPackage,
PackagePart xmlPart) {
PackagePart xmlPart) {

for (Submodel sm : submodelList) {
for (File file : findFileElements(sm.getSubmodelElements())) {
String filePath = file.getValue();
String filePath = AASXUtils.getPathFromURL(file.getValue());
try {
InMemoryFile content = findFileByPath(files, filePath);
logger.trace("Writing file '" + filePath + "' to .aasx.");
createAASXPart(rootPackage, xmlPart, filePath, file.getMimeType(), AASSUPPL_RELTYPE, content.getFileContent());
createAASXPart(rootPackage, xmlPart, filePath, file.getContentType(), AASSUPPL_RELTYPE, content.getFileContent());
} catch (RuntimeException e) {
// Log that a file is missing and continue building the .aasx
logger.warn("Could not add File '" + filePath + "'. It was not contained in given InMemoryFiles.");
Expand Down Expand Up @@ -218,7 +220,7 @@ private Collection<File> findFileElements(Collection<SubmodelElement> elements)
files.add((File) element);
} else if (element instanceof SubmodelElementCollection) {
// Recursive call to deal with SubmodelElementCollections
files.addAll(findFileElements(((SubmodelElementCollection) element).getValues()));
files.addAll(findFileElements(((SubmodelElementCollection) element).getValue()));
}
}

Expand All @@ -244,59 +246,25 @@ private void prepareFilePaths(Collection<Submodel> submodels) {
*/
private InMemoryFile findFileByPath(Collection<InMemoryFile> files, String path) {
for (InMemoryFile file : files) {
if (preparePath(file.getPath()).equals(path)) {
if (AASXUtils.getPathFromURL(file.getPath()).equals(path)) {
return file;
}
}
throw new RuntimeException("The wanted file '" + path + "' was not found in the given files.");
}

/**
* Removes the serverpart from a path and ensures it starts with a slash
* Removes the serverpart from a path and ensures it starts with "file://"
*
* @param path the path to be prepared
* @return the prepared path
*/
private String preparePath(String path) {
String newPath = getPathFromURL(path);
if (!newPath.startsWith("/")) {
newPath = "/" + newPath;
String newPath = AASXUtils.getPathFromURL(path);
if (!newPath.startsWith("file://")) {
newPath = "file://" + newPath;
}
return newPath;
}

/**
* Gets the path from a URL e.g "http://localhost:8080/path/to/test.file"
* results in "/path/to/test.file"
*
* @param url
* @return the path from the URL
*/
private String getPathFromURL(String url) {
if (url == null) {
return null;
}

if (url.contains("://")) {

// Find the ":" and and remove the "http://" from the url
int index = url.indexOf(":") + 3;
url = url.substring(index);

// Find the first "/" from the URL (now without the "http://") and remove
// everything before that
index = url.indexOf("/");
url = url.substring(index);

// Recursive call to deal with more than one server parts
// (e.g. basyx://127.0.0.1:6998//https://localhost/test/)
return getPathFromURL(url);
} else {
// Make sure the path has a / at the start
if (!url.startsWith("/")) {
url = "/" + url;
}
return url;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;

public class AASXUtils {


/**
* Gets the path from a URL e.g "http://localhost:8080/path/to/test.file"
* results in "/path/to/test.file"
*
* @param url
* @return the path from the URL
*/
public static String getPathFromURL(String url) {
if (url == null) {
return null;
}

if (url.contains("://")) {

// Find the ":" and and remove the "http://" from the url
int index = url.indexOf(":") + 3;
url = url.substring(index);

// Find the first "/" from the URL (now without the "http://") and remove
// everything before that
index = url.indexOf("/");
url = url.substring(index);

// Recursive call to deal with more than one server parts
// (e.g. basyx://127.0.0.1:6998//https://localhost/test/)
return getPathFromURL(url);
} else {
// Make sure the path has a / at the start
if (!url.startsWith("/")) {
url = "/" + url;
}
return url;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aasx;
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -22,7 +22,7 @@
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.xml.sax.SAXException;

import io.adminshell.aas.v3.dataformat.xml.XmlSchemaValidator;
import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlSchemaValidator;

/**
* Class to validate the XML file inside an AASX-package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.adminshell.aas.v3.dataformat.aasx;
package org.eclipse.digitaltwin.aas4j.v3.dataformat.aasx;

import java.util.Arrays;

Expand Down

This file was deleted.

Loading

0 comments on commit 86126fb

Please sign in to comment.