Search in sources :

Example 1 with DefaultAssetAdministrationShellEnvironment

use of io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment in project FAAAST-Service by FraunhoferIOSB.

the class AASEnvironmentFactory method guessDeserializerAndTryToParse.

private AssetAdministrationShellEnvironment guessDeserializerAndTryToParse(String envFilePath, String env) {
    Deserializer approxDeserializer = null;
    String fileEnding = envFilePath.split("\\.")[1];
    if (!envFilePath.equalsIgnoreCase(Application.DEFAULT_AASENV_PATH)) {
        LOGGER.debug("Looking for Deserializer for file ending '" + fileEnding + "'");
        approxDeserializer = deserializer.getOrDefault(deserializer.keySet().stream().filter(x -> x.equalsIgnoreCase(fileEnding)).findFirst().orElseGet(null), null);
    }
    if (approxDeserializer != null) {
        try {
            LOGGER.debug("Try resolving with '" + approxDeserializer.getClass().getSimpleName() + "'");
            AssetAdministrationShellEnvironment environment = approxDeserializer.read(env);
            // but returns an empty AASEnvironment
            if (!Objects.equals(environment, new DefaultAssetAdministrationShellEnvironment())) {
                return environment;
            }
        } catch (Exception ignored) {
            LOGGER.debug("Resolving with '" + approxDeserializer.getClass().getSimpleName() + "' was not successfull. Try other Deserializers.");
        }
    }
    return null;
}
Also used : DefaultAssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment) JsonDeserializer(io.adminshell.aas.v3.dataformat.json.JsonDeserializer) AmlDeserializer(io.adminshell.aas.v3.dataformat.aml.AmlDeserializer) Deserializer(io.adminshell.aas.v3.dataformat.Deserializer) I4AASDeserializer(io.adminshell.aas.v3.dataformat.i4aas.I4AASDeserializer) XmlDeserializer(io.adminshell.aas.v3.dataformat.xml.XmlDeserializer) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) DefaultAssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment) DeserializationException(io.adminshell.aas.v3.dataformat.DeserializationException) IOException(java.io.IOException)

Example 2 with DefaultAssetAdministrationShellEnvironment

use of io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment in project FAAAST-Service by FraunhoferIOSB.

the class StarterTest method testGetAASEnvironmentDefault.

@Test
public void testGetAASEnvironmentDefault() {
    AssetAdministrationShellEnvironment expected = new DefaultAssetAdministrationShellEnvironment();
    AssetAdministrationShellEnvironment actual = environmentFactory.getEmptyAASEnvironment();
    Assert.assertEquals(expected, actual);
}
Also used : DefaultAssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment) AssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment) DefaultAssetAdministrationShellEnvironment(io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment) Test(org.junit.Test)

Aggregations

AssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment)2 DefaultAssetAdministrationShellEnvironment (io.adminshell.aas.v3.model.impl.DefaultAssetAdministrationShellEnvironment)2 DeserializationException (io.adminshell.aas.v3.dataformat.DeserializationException)1 Deserializer (io.adminshell.aas.v3.dataformat.Deserializer)1 AmlDeserializer (io.adminshell.aas.v3.dataformat.aml.AmlDeserializer)1 I4AASDeserializer (io.adminshell.aas.v3.dataformat.i4aas.I4AASDeserializer)1 JsonDeserializer (io.adminshell.aas.v3.dataformat.json.JsonDeserializer)1 XmlDeserializer (io.adminshell.aas.v3.dataformat.xml.XmlDeserializer)1 IOException (java.io.IOException)1 Test (org.junit.Test)1