Class AbstractPersistenceRecipe

  • All Implemented Interfaces:
    de.iip_ecosphere.platform.support.aas.PersistenceRecipe
    Direct Known Subclasses:
    AasxPersistenceRecipe, JsonPersistenceRecipe, XmlPersistenceRecipe

    public abstract class AbstractPersistenceRecipe
    extends java.lang.Object
    implements de.iip_ecosphere.platform.support.aas.PersistenceRecipe
    Basic supporting functions for persistency.
    Author:
    Holger Eichelberger, SSE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<de.iip_ecosphere.platform.support.FileFormat> formats  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractPersistenceRecipe​(de.iip_ecosphere.platform.support.FileFormat... formats)
      Creates a persistence recipe instance with given file formats.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static <T> void addAsset​(de.iip_ecosphere.platform.support.aas.Aas aas, java.util.Collection<T> assetList, java.lang.Class<T> assetCls)
      Adds the asset from aas to assetList if feasible.
      protected static org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell ensureLocal​(org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell aas)
      Returns that the result is a local AAS, e.g., a connected AAS is turned transparently into a local copy.
      protected static org.eclipse.basyx.submodel.metamodel.map.Submodel ensureLocal​(org.eclipse.basyx.submodel.metamodel.api.ISubmodel submodel)
      Returns that the result is a local submodel, e.g., a connected submodel is turned transparently into a local copy.
      java.util.Collection<de.iip_ecosphere.platform.support.FileFormat> getSupportedFormats()  
      protected static boolean isValidForWriting​(org.eclipse.basyx.aas.metamodel.api.parts.asset.IAsset asset)
      Returns whether the given asset is valid for writing.
      protected void transform​(java.util.List<? extends org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell> aas, java.util.List<? extends org.eclipse.basyx.submodel.metamodel.api.ISubmodel> submodels, java.util.List<? extends org.eclipse.basyx.aas.metamodel.api.parts.asset.IAsset> assets, java.util.List<de.iip_ecosphere.platform.support.aas.Aas> result)
      Transforms a list of related aas and submodels to a list of Aas instances of the abstraction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface de.iip_ecosphere.platform.support.aas.PersistenceRecipe

        readFrom, writeTo
    • Field Detail

      • formats

        private java.util.List<de.iip_ecosphere.platform.support.FileFormat> formats
    • Constructor Detail

      • AbstractPersistenceRecipe

        protected AbstractPersistenceRecipe​(de.iip_ecosphere.platform.support.FileFormat... formats)
        Creates a persistence recipe instance with given file formats.
        Parameters:
        formats - the supported formats
    • Method Detail

      • getSupportedFormats

        public java.util.Collection<de.iip_ecosphere.platform.support.FileFormat> getSupportedFormats()
        Specified by:
        getSupportedFormats in interface de.iip_ecosphere.platform.support.aas.PersistenceRecipe
      • transform

        protected void transform​(java.util.List<? extends org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell> aas,
                                 java.util.List<? extends org.eclipse.basyx.submodel.metamodel.api.ISubmodel> submodels,
                                 java.util.List<? extends org.eclipse.basyx.aas.metamodel.api.parts.asset.IAsset> assets,
                                 java.util.List<de.iip_ecosphere.platform.support.aas.Aas> result)
                          throws java.io.IOException
        Transforms a list of related aas and submodels to a list of Aas instances of the abstraction.
        Parameters:
        aas - the AAS to transform
        submodels - the sub-models to transform/link to aas
        assets - the assets to transform/link to aas
        result - the resulting Aas instances (to be modified as a side effect)
        Throws:
        java.io.IOException - in case that something goes wrong
      • addAsset

        protected static <T> void addAsset​(de.iip_ecosphere.platform.support.aas.Aas aas,
                                           java.util.Collection<T> assetList,
                                           java.lang.Class<T> assetCls)
        Adds the asset from aas to assetList if feasible.
        Type Parameters:
        T - the type of the asset
        Parameters:
        aas - the AAS to take the asset from
        assetList - the asset list to be modified as a side effect
        assetCls - the asset class
        Throws:
        java.lang.IllegalArgumentException - if the wrong asset instance comes in
        See Also:
        isValidForWriting(IAsset)
      • isValidForWriting

        protected static boolean isValidForWriting​(org.eclipse.basyx.aas.metamodel.api.parts.asset.IAsset asset)
        Returns whether the given asset is valid for writing.
        Parameters:
        asset - the asset to check
        Returns:
        true if valid, false else
      • ensureLocal

        protected static org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell ensureLocal​(org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell aas)
        Returns that the result is a local AAS, e.g., a connected AAS is turned transparently into a local copy.
        Parameters:
        aas - the AAS to check
        Returns:
        the local AAS (null if aas is neither a local nor a connected AAS)
      • ensureLocal

        protected static org.eclipse.basyx.submodel.metamodel.map.Submodel ensureLocal​(org.eclipse.basyx.submodel.metamodel.api.ISubmodel submodel)
        Returns that the result is a local submodel, e.g., a connected submodel is turned transparently into a local copy.
        Parameters:
        submodel - the submodel to check
        Returns:
        the local submodel (null if submodel is neither a local nor a connected submodel)