java.lang.Object
de.iip_ecosphere.platform.configuration.ivml.TypeMapper

class TypeMapper extends Object
Maps types to IVML.
Author:
Holger Eichelberger, SSE
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder
     
    private net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration
     
    private Set<net.ssehub.easy.varModel.model.Project>
     
    private Set<String>
     
     
    static final int
     
    static final int
     
    private Map<String,Integer>
     
    private Predicate<net.ssehub.easy.varModel.model.AbstractVariable>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TypeMapper(net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration cfg, Predicate<net.ssehub.easy.varModel.model.AbstractVariable> variableFilter, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder, Function<String,String> metaShortId)
    Creates a type mapper instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    add(Map<Integer,List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder>> src, List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> tgt, int start, int inc)
    Adds all entries from src with matching key to tgt.
    (package private) static void
    addMetaDefault(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.AbstractVariable decl, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder varBuilder, Function<String,String> metaShortId)
    Adds the default value of var if there is a default value.
    (package private) static void
    addMetaDefault(net.ssehub.easy.varModel.confModel.IDecisionVariable var, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder varBuilder, Function<String,String> metaShortId)
    Adds the default value of var if there is a default value.
    static void
    addTypeKind(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder typeB, IvmlTypeKind kind, Function<String,String> metaShortId)
    Adds an AAS type kind property.
    static void
    addTypeKind(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder typeB, net.ssehub.easy.varModel.model.datatypes.IDatatype type, Function<String,String> metaShortId)
    Adds an AAS type kind property.
    private void
    collectMemberNames(net.ssehub.easy.varModel.model.datatypes.Compound type, List<String> result, Set<String> done)
    Collects the member names for type.
    private void
    collectMemberNamesContainer(net.ssehub.easy.varModel.model.IDecisionVariableContainer cnt, List<String> result, Set<String> done)
    Collects the member names for the given container.
    private Object
    Returns the top-most collected assignment value.
    private static String
    getRefines(net.ssehub.easy.varModel.model.datatypes.Compound type)
    Returns the refined type of type as comma-separated string list.
    int
    getUiGroup(String type, String slot)
    Returns the recorded UI group.
    private boolean
    Returns whether typeId represents a done type (in doneTypes).
    private void
    mapCompoundSlot(net.ssehub.easy.varModel.model.DecisionVariableDeclaration slot, net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
    Map a compound slot.
    private void
    mapCompoundSlots(net.ssehub.easy.varModel.model.IDecisionVariableContainer cnt, net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
    Maps slots of a compound type including annotation assignments.
    private void
    mapCompoundType(net.ssehub.easy.varModel.model.datatypes.Compound type)
    Maps a compound type.
    private void
    mapDerivedType(net.ssehub.easy.varModel.model.datatypes.DerivedDatatype type)
    Maps a derived type.
    private void
    mapEnumType(net.ssehub.easy.varModel.model.datatypes.Enum type)
    Maps an IVML enum type.
    private void
    Maps a primitive type.
    private void
    mapRefines(net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
    Maps refines of a compound type.
    (package private) void
    mapType(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
    Maps an IVML type.
    (package private) void
    Maps all types.
    private void
    mapTypes(net.ssehub.easy.varModel.model.Project project)
    Maps all types declared in project and imported projects.
    private List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder>
    sortMembers(net.ssehub.easy.varModel.model.datatypes.Compound type, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> slots)
    Sort members for display sequence in UI.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UIGROUP_SPACING

      public static final int UIGROUP_SPACING
      See Also:
    • UIGROUP_POS_FRONT

      public static final int UIGROUP_POS_FRONT
      See Also:
    • cfg

      private net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration cfg
    • doneProjects

      private Set<net.ssehub.easy.varModel.model.Project> doneProjects
    • doneTypes

      private Set<String> doneTypes
    • builder

      private de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder
    • variableFilter

      private Predicate<net.ssehub.easy.varModel.model.AbstractVariable> variableFilter
    • assignments

      private Stack<Map<String,Object>> assignments
    • metaShortId

      private Function<String,String> metaShortId
    • uiGroups

      private Map<String,Integer> uiGroups
  • Constructor Details

    • TypeMapper

      TypeMapper(net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration cfg, Predicate<net.ssehub.easy.varModel.model.AbstractVariable> variableFilter, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder builder, Function<String,String> metaShortId)
      Creates a type mapper instance.
      Parameters:
      cfg - the configuration to map the declared types for
      variableFilter - a variable filter to exclude certain variables/types
      builder - the builder to place AAS elements into
      metaShortId - function to build a meta shortId property name
  • Method Details

    • mapTypes

      void mapTypes()
      Maps all types.
    • mapTypes

      private void mapTypes(net.ssehub.easy.varModel.model.Project project)
      Maps all types declared in project and imported projects.
      Parameters:
      project - the project to map
    • mapPrimitiveType

      private void mapPrimitiveType(String name)
      Maps a primitive type.
      Parameters:
      name - the name of the primitive type.
    • addTypeKind

      public static void addTypeKind(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder typeB, net.ssehub.easy.varModel.model.datatypes.IDatatype type, Function<String,String> metaShortId)
      Adds an AAS type kind property.
      Parameters:
      typeB - the type builder
      type - the type
      metaShortId - function to build a meta shortId property name
    • addTypeKind

      public static void addTypeKind(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder typeB, IvmlTypeKind kind, Function<String,String> metaShortId)
      Adds an AAS type kind property.
      Parameters:
      typeB - the type builder
      kind - the type kind
      metaShortId - function to build a meta shortId property name
    • mapCompoundType

      private void mapCompoundType(net.ssehub.easy.varModel.model.datatypes.Compound type)
      Maps a compound type. May be called for duplicates but leads only to one entry.
      Parameters:
      type - the compound type
    • sortMembers

      private List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> sortMembers(net.ssehub.easy.varModel.model.datatypes.Compound type, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> slots)
      Sort members for display sequence in UI.
      Parameters:
      type - the type to sort the members for
      slots - the SME builders per slot
      Returns:
      the sorted members
    • add

      private void add(Map<Integer,List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder>> src, List<de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> tgt, int start, int inc)
      Adds all entries from src with matching key to tgt. Assumption: There are no holes between the groups.
      Parameters:
      src - source structure
      tgt - target structure
      start - the start ui group/key
      inc - the increment, terminate immediately after first transfer if 0
    • collectMemberNames

      private void collectMemberNames(net.ssehub.easy.varModel.model.datatypes.Compound type, List<String> result, Set<String> done)
      Collects the member names for type.
      Parameters:
      type - the compound type
      result - the resulting name sequence
      done - the done names
    • collectMemberNamesContainer

      private void collectMemberNamesContainer(net.ssehub.easy.varModel.model.IDecisionVariableContainer cnt, List<String> result, Set<String> done)
      Collects the member names for the given container.
      Parameters:
      cnt - the container
      result - the resulting name sequence
      done - the done names
    • mapType

      void mapType(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
      Maps an IVML type. May be called for duplicates but leads only to one entry.
      Parameters:
      type - the IVML type
    • mapEnumType

      private void mapEnumType(net.ssehub.easy.varModel.model.datatypes.Enum type)
      Maps an IVML enum type.
      Parameters:
      type - the type
    • isDoneType

      private boolean isDoneType(String typeId)
      Returns whether typeId represents a done type (in doneTypes). If not, adds typeId to doneTypes.
      Parameters:
      typeId - the type id to search for
      Returns:
      true if the type is considered as done, false else
    • mapDerivedType

      private void mapDerivedType(net.ssehub.easy.varModel.model.datatypes.DerivedDatatype type)
      Maps a derived type. May be called for duplicates but leads only to one entry.
      Parameters:
      type - the derived type
    • getRefines

      private static String getRefines(net.ssehub.easy.varModel.model.datatypes.Compound type)
      Returns the refined type of type as comma-separated string list.
      Parameters:
      type - the type to refine
      Returns:
      the refined types
    • mapRefines

      private void mapRefines(net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
      Maps refines of a compound type.
      Parameters:
      type - the type
      topType - the top-level type the mapping started with
      typeB - the type builder
      doneSlots - already done slot names
    • mapCompoundSlots

      private void mapCompoundSlots(net.ssehub.easy.varModel.model.IDecisionVariableContainer cnt, net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
      Maps slots of a compound type including annotation assignments.
      Parameters:
      cnt - the container (compound or annotation assignment)
      type - the containing compound type
      topType - the top-level type the mapping started with
      typeB - the type builder
      doneSlots - already done slot names
    • addMetaDefault

      static void addMetaDefault(net.ssehub.easy.varModel.confModel.IDecisionVariable var, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder varBuilder, Function<String,String> metaShortId)
      Adds the default value of var if there is a default value.
      Parameters:
      var - the variable to take the default value from
      varBuilder - the variable builder to add the meta-value to
      metaShortId - function to build a meta shortId property name
    • addMetaDefault

      static void addMetaDefault(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.AbstractVariable decl, de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder varBuilder, Function<String,String> metaShortId)
      Adds the default value of var if there is a default value.
      Parameters:
      cfg - the configuration to use for reasoning/expression evaluation
      decl - the variable declaration to take the default value from
      varBuilder - the variable builder to add the meta-value to
      metaShortId - function to build a meta shortId property name
    • mapCompoundSlot

      private void mapCompoundSlot(net.ssehub.easy.varModel.model.DecisionVariableDeclaration slot, net.ssehub.easy.varModel.model.datatypes.Compound type, net.ssehub.easy.varModel.model.datatypes.Compound topType, de.iip_ecosphere.platform.support.aas.SubmodelElementCollection.SubmodelElementCollectionBuilder typeB, Map<String,de.iip_ecosphere.platform.support.aas.SubmodelElementList.SubmodelElementListBuilder> doneSlots)
      Map a compound slot.
      Parameters:
      slot - the slot to map
      type - the containing compound type
      topType - the top-level type the mapping started with
      typeB - the type builder
      doneSlots - already done slot names
    • getUiGroup

      public int getUiGroup(String type, String slot)
      Returns the recorded UI group.
      Parameters:
      type - the type name
      slot - the name of the slot within type
      Returns:
      the uiGroup value, defaults to 100
    • getAssignmentValue

      private Object getAssignmentValue(String name)
      Returns the top-most collected assignment value.
      Parameters:
      name - the name of the assignment variable
      Returns:
      the value or null for none