Class AbstractIvmlModifier

java.lang.Object
de.iip_ecosphere.platform.configuration.easyProducer.ivml.AbstractIvmlModifier
All Implemented Interfaces:
DecisionVariableProvider
Direct Known Subclasses:
AasIvmlMapper

public abstract class AbstractIvmlModifier extends Object implements DecisionVariableProvider
Maps an IVML configuration generically into an AAS.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Some part listening on configuration changes.
    protected static class 
    Stores original and copied file.
    private static enum 
    Generic IVML type indicators.
    private static class 
    Represents runtime (collected) information steering the template instantiation.
    private static enum 
    Instantiation modes to enable reuse of the respective methods by separating creation and value setting so that reference substitutions can be established during creating and used/applied during setting the value.
    private static interface 
    Defines an internal type creation function.
    private static class 
    Applies substitutions and value adjustments to values.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private static final net.ssehub.easy.varModel.persistency.IVMLWriter.EmitFilter
     
     
     
    static final Predicate<net.ssehub.easy.varModel.model.Project>
     
    static final Predicate<net.ssehub.easy.varModel.model.Project>
     
    private Set<String>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a mapper with default settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected net.ssehub.easy.varModel.model.Project
    adaptTarget(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.Project project)
    Allows to adapt a target IVML project, e.g., in testing context.
    void
    Adds a graph format.
    protected static void
    addImport(net.ssehub.easy.varModel.model.Project target, String imp, net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.Project res)
    Adds an import statement, if needed, temporarily resolved to be able to create expressions and constraints.
    private void
    addNameAdjustment(net.ssehub.easy.varModel.confModel.IDecisionVariable decVar, String varName, AbstractIvmlModifier.InstantiationContext context)
    Adds an adjustment for the name of decVar if enabled by #enableNameAdjustment.
    void
    Changes a given set of values and performs reasoning before committing the values into the actual configuration.
    private Set<net.ssehub.easy.varModel.confModel.IDecisionVariable>
    collectConstants(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project prj)
    Collects constants in a given project.
    private void
    collectTypes(net.ssehub.easy.varModel.confModel.IDecisionVariable var, Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> result)
    Collects types that are used in a service/connector var.
    Copies file to temp if file exists.
    protected net.ssehub.easy.varModel.model.Constraint
    createAssignment(net.ssehub.easy.varModel.model.AbstractVariable varDecl, String valueEx, net.ssehub.easy.varModel.model.Project prj)
    Creates an assignment of valueEx to varDecl and adds it to prj.
    protected net.ssehub.easy.varModel.cst.ConstraintSyntaxTree
    createExpression(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String expression, net.ssehub.easy.varModel.model.Project scope)
    Creates an IVML expression syntax tree for expression.
    protected abstract File
    createIvmlConfigPath(String subpath, net.ssehub.easy.varModel.model.Project project)
    Creates an IVML configuration (not meta-model) model path with subpath and for project p.
    void
    createVariable(String varName, String type, boolean asConst, String valueEx)
    Creates an IVML variable.
    void
    Deletes an IVML variable.
    private net.ssehub.easy.varModel.model.datatypes.IDatatype
    findType(net.ssehub.easy.varModel.model.Project scope, String type)
    Finds an IVML type by also resolving AbstractIvmlModifier.GenericTypeIndicator.
    getGraph(String varName, String format)
    Returns a graph structure in IVML.
    Returns the factory to use to crate graphs.
    protected GraphFormat
    Returns a graph format instance.
    protected abstract net.ssehub.easy.varModel.confModel.Configuration
    Returns the actual IVML configuration.
    protected File
    getIvmlFile(net.ssehub.easy.varModel.model.Project project)
    Returns the filename/path for project.
    protected abstract String
    getIvmlSubpath(net.ssehub.easy.varModel.model.Project project)
    Returns the IVML subpath for the given project.
    private static de.iip_ecosphere.platform.support.logging.Logger
    Returns the logger.
    protected IvmlGraphMapper
    Returns the graph mapper.
    private static String
    getName(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String dflt)
    Returns the oktoflow element name from a given decision variable.
    Returns the names of the IVML variables that still need values in the template represented by the IVML variable varName.
    private static <K, V> V
    getOrCreate(HashMap<K,V> hash, K key, Supplier<V> creator)
    Gets a value from hash, if not adds a value for key as created by creator.
    Returns the IVML variable names representing application templates.
    static String
    getType(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
    Returns the type of var as string.
    net.ssehub.easy.varModel.confModel.IDecisionVariable
    getVariable(String qualifiedVarName)
    Returns a decision variable for a given variable name.
    protected net.ssehub.easy.varModel.confModel.IDecisionVariable
    getVariable(net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration cfg, String qualifiedVarName)
    Returns an IVML variable.
    getVariableName(String type, String elementName, String elementVersion)
    Turns a type name and an element name into a valid IVML variable name.
    protected net.ssehub.easy.varModel.model.Project
    getVariableTarget(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.datatypes.IDatatype type, String name, List<String> meshes)
    Returns the target for a variable to be created.
    protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration
    Returns the actual VIL configuration.
    private void
    instantiateMeshes(Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> meshes, AbstractIvmlModifier.Mode mode, AbstractIvmlModifier.InstantiationContext context)
    Instantiates the given meshes.
    instantiateTemplate(String varName, String appName, Map<String,String> adjustments)
    Instantiates the template by the IVML variable varName to an application with given appName.
    private net.ssehub.easy.varModel.confModel.IDecisionVariable
    instantiateTemplateVariable(net.ssehub.easy.varModel.confModel.IDecisionVariable decVar, String targetType, String varName, AbstractIvmlModifier.Mode mode, AbstractIvmlModifier.InstantiationContext context)
    Instantiates a template application/mesh variable.
    private void
    instantiateVariables(Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> vars, String targetPrj, AbstractIvmlModifier.InstantiationContext context)
    Integrates given variables vars into targetPrj.
    protected boolean
    isAllowedForModification(net.ssehub.easy.varModel.model.Project prj)
    Returns whether the given project is allowed for modification (other than root).
    (package private) static boolean
    Limits valid identifiers.
    private Map<String,net.ssehub.easy.varModel.confModel.IDecisionVariable>
    mapElementsByName(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project prj)
    Maps model elements/abstract variables by their name taken from a given project.
    protected void
    notifyChange(net.ssehub.easy.varModel.confModel.IDecisionVariable var, de.iip_ecosphere.platform.configuration.cfg.ConfigurationChangeType type)
    Notifies a potential change listener about a configuration change.
    protected void
    notifyChange(net.ssehub.easy.varModel.model.Project prj, de.iip_ecosphere.platform.configuration.cfg.ConfigurationChangeType type)
    Notifies a potential change listener about changing a whole project the same way.
    protected void
    reloadAndValidate(Map<net.ssehub.easy.varModel.model.Project,AbstractIvmlModifier.CopiedFile> copies)
    Reloads the and validates the model, in case of problems, restore changed files from copies.
    protected abstract void
    Reloads the configuration model.
    protected void
    removeConstraintsForVariable(net.ssehub.easy.varModel.model.Project prj, net.ssehub.easy.varModel.model.AbstractVariable var)
    Removes assignment constraints for a given var.
    void
    renameVariable(String varName, String newVarName)
    Renames an IVML variable.
    protected static void
    saveTo(net.ssehub.easy.varModel.model.Project prj, File file)
    Saving model project prj to file.
    protected void
    setValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String expression, net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor eval, net.ssehub.easy.varModel.confModel.AssignmentState state)
    Changes the value of the decision variable var by parsing expression and evaluating it through eval.
    protected void
    setValue(net.ssehub.easy.varModel.model.AbstractVariable var, String expression)
    Changes the value of the variable declaration var by parsing expression.
    private void
    setValue(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, net.ssehub.easy.varModel.model.values.Value val, AbstractIvmlModifier.InstantiationContext context)
    Sets the configured value for var as val considering substitutions and adjustments from context.
    protected void
    throwIfFails(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, boolean reloadIfFail)
    Throws an ExecutionException if the reasoning result res indicates a problem.
    protected static String
    Helper to turn str into a Java identifier.
    protected static String
    Helper to turn the first char of str into upper case and str into an identifier..
    protected net.ssehub.easy.reasoning.core.reasoner.ReasoningResult
    Validates the model and propagates values within the model.
    protected abstract net.ssehub.easy.reasoning.core.reasoner.ReasoningResult
    validateAndPropagate(Predicate<net.ssehub.easy.varModel.model.Project> projectFilter)
    Validates the model and propagates values within the model.
    private static void
    write(net.ssehub.easy.varModel.model.Project prj, Writer out)
    Writes prj to out.

    Methods inherited from class java.lang.Object

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

    • NO_PROJECT_FILTER

      public static final Predicate<net.ssehub.easy.varModel.model.Project> NO_PROJECT_FILTER
    • NO_TEMPLATE_FILTER

      public static final Predicate<net.ssehub.easy.varModel.model.Project> NO_TEMPLATE_FILTER
    • EMIT_FILTER

      private static final net.ssehub.easy.varModel.persistency.IVMLWriter.EmitFilter EMIT_FILTER
    • graphMapper

      private IvmlGraphMapper graphMapper
    • graphFormats

      private Map<String,GraphFormat> graphFormats
    • changeListener

    • reservedVariableNames

      private Set<String> reservedVariableNames
  • Constructor Details

  • Method Details

    • addGraphFormat

      public void addGraphFormat(GraphFormat format)
      Adds a graph format.
      Parameters:
      format - the format
    • getGraphFactory

      public GraphFactory getGraphFactory()
      Returns the factory to use to crate graphs.
      Returns:
      the factory
    • saveTo

      protected static void saveTo(net.ssehub.easy.varModel.model.Project prj, File file) throws ExecutionException
      Saving model project prj to file.
      Parameters:
      prj - the project
      file - the file to write to
      Throws:
      ExecutionException - if writing fails
    • write

      private static void write(net.ssehub.easy.varModel.model.Project prj, Writer out)
      Writes prj to out.
      Parameters:
      prj - the project to write
      out - the writer to write the project to
    • getIvmlSubpath

      protected abstract String getIvmlSubpath(net.ssehub.easy.varModel.model.Project project)
      Returns the IVML subpath for the given project.
      Parameters:
      project - the project
      Returns:
      the subpath, may be null for a top-level or a non-writable project, may be empty for the top-level folder or a sub-folder
    • createIvmlConfigPath

      protected abstract File createIvmlConfigPath(String subpath, net.ssehub.easy.varModel.model.Project project)
      Creates an IVML configuration (not meta-model) model path with subpath and for project p.
      Parameters:
      subpath - the subpath, may be null for none
      project - the project to create the path for
      Returns:
      the file name/path
      See Also:
    • getIvmlFile

      protected File getIvmlFile(net.ssehub.easy.varModel.model.Project project)
      Returns the filename/path for project.
      Parameters:
      project - the project
      Returns:
      the filename/path
      See Also:
    • isAllowedForModification

      protected boolean isAllowedForModification(net.ssehub.easy.varModel.model.Project prj)
      Returns whether the given project is allowed for modification (other than root).
      Parameters:
      prj - the project
      Returns:
      true allowed, false else
      See Also:
    • deleteVariable

      public void deleteVariable(String varName) throws ExecutionException
      Deletes an IVML variable. In case of a graph, this may subsequently delete further variables. IVML reference to a variable shall be cleaned up before. Left-over references shall lead to a syntax error and to no modification of the model. [public for testing]
      Parameters:
      varName - the qualified IVML variable name to delete
      Throws:
      ExecutionException - if creating the variable fails
    • getTemplates

      public String getTemplates() throws ExecutionException
      Returns the IVML variable names representing application templates.
      Returns:
      the IVML variable names as JSON array
      Throws:
      ExecutionException - if the execution of the operation fails
    • getOrCreate

      private static <K, V> V getOrCreate(HashMap<K,V> hash, K key, Supplier<V> creator)
      Gets a value from hash, if not adds a value for key as created by creator.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      hash - the has to query/modify
      key - the key value
      creator - the creator for new values
      Returns:
      the retrieved or created value
    • instantiateMeshes

      private void instantiateMeshes(Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> meshes, AbstractIvmlModifier.Mode mode, AbstractIvmlModifier.InstantiationContext context) throws ExecutionException, net.ssehub.easy.varModel.confModel.ConfigurationException, net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException
      Instantiates the given meshes.
      Parameters:
      meshes - the meshes
      mode - the instantiation mode
      context - the instantiation context
      Throws:
      ExecutionException - if setting IVML values fails
      net.ssehub.easy.varModel.confModel.ConfigurationException - if setting IVML values fails
      net.ssehub.easy.varModel.model.ModelQueryException - if obtaining IVML types fails
      net.ssehub.easy.basics.modelManagement.ModelManagementException - if model management operations fail
    • instantiateTemplate

      public String instantiateTemplate(String varName, String appName, Map<String,String> adjustments) throws ExecutionException
      Instantiates the template by the IVML variable varName to an application with given appName.
      Parameters:
      varName - the name of the IVML variable representing the template
      appName - the (display) name of the application, may be used to derive id/variable name
      adjustments - variable settings, as variable=value or variable.field=value, may be null; shall be filled with variable values from getOpenTemplateVariables(String), otherwise the instantiation will fail
      Returns:
      the IVML variable name of the instantiated application
      Throws:
      ExecutionException - if the execution of the operation fails
    • collectTypes

      private void collectTypes(net.ssehub.easy.varModel.confModel.IDecisionVariable var, Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> result)
      Collects types that are used in a service/connector var.
      Parameters:
      var - the variable to inspect
      result - the types to be modified as a side effect
    • collectConstants

      private Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> collectConstants(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project prj)
      Collects constants in a given project.
      Parameters:
      cfg - the configuration to resolve decision variables
      prj - the project to scan
      Returns:
      the identified constants, may be empty
    • mapElementsByName

      private Map<String,net.ssehub.easy.varModel.confModel.IDecisionVariable> mapElementsByName(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project prj)
      Maps model elements/abstract variables by their name taken from a given project.
      Parameters:
      cfg - the configuration to resolve decision variables
      prj - the project to scan
      Returns:
      the identified name-element mappings
    • getName

      private static String getName(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String dflt)
      Returns the oktoflow element name from a given decision variable.
      Parameters:
      var - the decision variable
      dflt - the value to take if no name is found
      Returns:
      the value or dflt
    • instantiateVariables

      private void instantiateVariables(Set<net.ssehub.easy.varModel.confModel.IDecisionVariable> vars, String targetPrj, AbstractIvmlModifier.InstantiationContext context) throws net.ssehub.easy.varModel.confModel.ConfigurationException, ExecutionException
      Integrates given variables vars into targetPrj.
      Parameters:
      vars - the variables
      targetPrj - the target project to integrate the variables into
      context - the instantiation context, to be modified as a side effect
      Throws:
      net.ssehub.easy.varModel.confModel.ConfigurationException - if setting IVML values fails
      ExecutionException - if setting IVML values fails
    • setValue

      private void setValue(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, net.ssehub.easy.varModel.model.values.Value val, AbstractIvmlModifier.InstantiationContext context) throws ExecutionException
      Sets the configured value for var as val considering substitutions and adjustments from context.
      Parameters:
      var - the variable to configure
      val - the (basic) value to set
      context - the context driving the adjustment of individual values
      Throws:
      ExecutionException - if setting the value fails
    • instantiateTemplateVariable

      private net.ssehub.easy.varModel.confModel.IDecisionVariable instantiateTemplateVariable(net.ssehub.easy.varModel.confModel.IDecisionVariable decVar, String targetType, String varName, AbstractIvmlModifier.Mode mode, AbstractIvmlModifier.InstantiationContext context) throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.varModel.confModel.ConfigurationException, ExecutionException
      Instantiates a template application/mesh variable.
      Parameters:
      decVar - the variable representing the template
      targetType - target type of the variable
      varName - the name of the variable to create/instantiate (uses AbstractIvmlModifier.InstantiationContext.currentTemplateVariable if null)
      context - the instantiation context, may be modified as a side effect
      Returns:
      the instantiated IVML variable
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - if model management operations fail
      net.ssehub.easy.varModel.model.ModelQueryException - if obtaining IVML types fails
      net.ssehub.easy.varModel.confModel.ConfigurationException - if setting IVML values fails
      ExecutionException - if adapting the target project fails
    • addNameAdjustment

      private void addNameAdjustment(net.ssehub.easy.varModel.confModel.IDecisionVariable decVar, String varName, AbstractIvmlModifier.InstantiationContext context)
      Adds an adjustment for the name of decVar if enabled by #enableNameAdjustment.
      Parameters:
      decVar - the decision variable to get the value for the adjustment from. If set up, AbstractIvmlModifier.InstantiationContext.prefixVarName(String) will be applied to the value.
      varName - the original name of the variable
      context - the context to modify
    • getOpenTemplateVariables

      public String getOpenTemplateVariables(String varName) throws ExecutionException
      Returns the names of the IVML variables that still need values in the template represented by the IVML variable varName.
      Parameters:
      varName - the name of the IVML variable representing the template
      Returns:
      the open variables as JSON array
      Throws:
      ExecutionException - if the execution of the operation fails
    • throwIfFails

      protected void throwIfFails(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult res, boolean reloadIfFail) throws ExecutionException
      Throws an ExecutionException if the reasoning result res indicates a problem.
      Parameters:
      res - the reasoning result
      reloadIfFail - reload the model if there is a failure
      Throws:
      ExecutionException - the exception if reasoning failed
    • removeConstraintsForVariable

      protected void removeConstraintsForVariable(net.ssehub.easy.varModel.model.Project prj, net.ssehub.easy.varModel.model.AbstractVariable var)
      Removes assignment constraints for a given var.
      Parameters:
      prj - the project to start searching for constraints within
      var - the variable to remove constraints for
    • getVariableTarget

      protected net.ssehub.easy.varModel.model.Project getVariableTarget(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.datatypes.IDatatype type, String name, List<String> meshes) throws ExecutionException
      Returns the target for a variable to be created.
      Parameters:
      root - the root project (may be used as default)
      type - the actual type of the variable to be created, may be null then anyway no variable will be created
      name - optional name if the name may influence the target, may be null
      meshes - mesh project names in case of an application project, else ignored; may be null
      Returns:
      the target project
      Throws:
      ExecutionException - if model management operations fail
      See Also:
    • adaptTarget

      protected net.ssehub.easy.varModel.model.Project adaptTarget(net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.Project project) throws ExecutionException
      Allows to adapt a target IVML project, e.g., in testing context.
      Parameters:
      root - the root project (for type resolution)
      project - the project to be adapted
      Returns:
      the adapted project
      Throws:
      ExecutionException - if adapting fails
    • isValidIdentifier

      static boolean isValidIdentifier(String name)
      Limits valid identifiers.
      Parameters:
      name - the name
      Returns:
      true for valid identifier, false else
    • getVariableName

      public String getVariableName(String type, String elementName, String elementVersion)
      Turns a type name and an element name into a valid IVML variable name. Potentially adds a number.
      Parameters:
      type - the IVML type name to use, may but shall not contain whitespaces an non-identifier characters
      elementName - the element name to use, may contain whitespaces an non-identifier characters
      elementVersion - the element version to use, may contain whitespaces an non-identifier characters
      Returns:
      the usable variable name
    • renameVariable

      public void renameVariable(String varName, String newVarName) throws ExecutionException
      Renames an IVML variable. [public for testing]
      Parameters:
      varName - the IVML variable name
      newVarName - the new IVML variable name
      Throws:
      ExecutionException - if creating the variable fails
    • createVariable

      public void createVariable(String varName, String type, boolean asConst, String valueEx) throws ExecutionException
      Creates an IVML variable. [public for testing]
      Parameters:
      varName - the IVML variable name
      type - the (qualified) IVML type
      valueEx - the value as IVML expression
      Throws:
      ExecutionException - if creating the variable fails
    • findType

      private net.ssehub.easy.varModel.model.datatypes.IDatatype findType(net.ssehub.easy.varModel.model.Project scope, String type) throws net.ssehub.easy.varModel.model.ModelQueryException
      Finds an IVML type by also resolving AbstractIvmlModifier.GenericTypeIndicator.
      Parameters:
      scope - the scope
      type - the type as string
      Returns:
      the found type
      Throws:
      net.ssehub.easy.varModel.model.ModelQueryException - if finding the type fails
    • changeValues

      public void changeValues(Map<String,String> values) throws ExecutionException
      Changes a given set of values and performs reasoning before committing the values into the actual configuration. For compounds/containers it is advisable to assign complete values to avoid illegal re-assignments. [public for testing]
      Parameters:
      values - the values, given as qualified IVML variables names mapped to serialized values
      Throws:
      ExecutionException - if changing values fails
    • setValue

      protected void setValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String expression, net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor eval, net.ssehub.easy.varModel.confModel.AssignmentState state) throws ExecutionException
      Changes the value of the decision variable var by parsing expression and evaluating it through eval.
      Parameters:
      var - the variable to change, may be a top-level variable and expression may be a compound value expression
      expression - the IVML expression
      eval - the expression evaluator to reuse, may be null to create a temporary one within
      state - the assignment state to apply
      Throws:
      ExecutionException - if parsing, evaluating or assigning fails
    • createExpression

      protected net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createExpression(net.ssehub.easy.varModel.model.datatypes.IDatatype type, String expression, net.ssehub.easy.varModel.model.Project scope) throws ExecutionException
      Creates an IVML expression syntax tree for expression.
      Parameters:
      type - the target type, may be null for none
      expression - the expression
      scope - the resolution scope, may be null for the root project
      Returns:
      the syntax tree
      Throws:
      ExecutionException - if the expression cannot be created, e.g., due to syntactic or semantic errors
    • createAssignment

      protected net.ssehub.easy.varModel.model.Constraint createAssignment(net.ssehub.easy.varModel.model.AbstractVariable varDecl, String valueEx, net.ssehub.easy.varModel.model.Project prj) throws ExecutionException
      Creates an assignment of valueEx to varDecl and adds it to prj.
      Parameters:
      varDecl - the variable declaration
      valueEx - the IVML value expression
      prj - the project to add the constraint to
      Returns:
      the created constraint
      Throws:
      ExecutionException - if creating the constraint fails
    • setValue

      protected void setValue(net.ssehub.easy.varModel.model.AbstractVariable var, String expression) throws ExecutionException
      Changes the value of the variable declaration var by parsing expression.
      Parameters:
      var - the variable to change, may be a top-level variable and expression may be a compound value expression
      expression - the IVML expression
      Throws:
      ExecutionException - if parsing, evaluating or assigning fails
    • copyToTmp

      protected static AbstractIvmlModifier.CopiedFile copyToTmp(File file) throws ExecutionException
      Copies file to temp if file exists.
      Parameters:
      file - the file to copy
      Returns:
      the copied file, else null
      Throws:
      ExecutionException - if copying failed
    • reloadAndValidate

      protected void reloadAndValidate(Map<net.ssehub.easy.varModel.model.Project,AbstractIvmlModifier.CopiedFile> copies) throws ExecutionException
      Reloads the and validates the model, in case of problems, restore changed files from copies.
      Parameters:
      copies - copied files to be restored
      Throws:
      ExecutionException - if reasoning/restoring fails
    • getGraph

      public String getGraph(String varName, String format) throws ExecutionException
      Returns a graph structure in IVML. [public for testing]
      Parameters:
      varName - the IVML variable holding the graph
      format - the format of the graph to return
      Returns:
      the graph in the specified format
      Throws:
      ExecutionException - if reading the graph structure fails
    • getGraphFormat

      protected GraphFormat getGraphFormat(String format) throws ExecutionException
      Returns a graph format instance.
      Parameters:
      format - the unique name of the graph format
      Returns:
      the graph format instance
      Throws:
      ExecutionException - if the format instance cannot be found
    • getMapper

      protected IvmlGraphMapper getMapper()
      Returns the graph mapper.
      Returns:
      the graph mapper
    • getVariable

      public net.ssehub.easy.varModel.confModel.IDecisionVariable getVariable(String qualifiedVarName) throws ExecutionException
      Description copied from interface: DecisionVariableProvider
      Returns a decision variable for a given variable name.
      Specified by:
      getVariable in interface DecisionVariableProvider
      Parameters:
      qualifiedVarName - the variable name
      Returns:
      the associated decision variable, may be null for node
      Throws:
      ExecutionException - if retrieving the node fails
    • getVariable

      protected net.ssehub.easy.varModel.confModel.IDecisionVariable getVariable(net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration cfg, String qualifiedVarName) throws ExecutionException
      Returns an IVML variable.
      Parameters:
      cfg - the configuration to take the variable from
      qualifiedVarName - the (qualified) variable name
      Returns:
      the variable
      Throws:
      ExecutionException - if querying the variable fails
    • addImport

      protected static void addImport(net.ssehub.easy.varModel.model.Project target, String imp, net.ssehub.easy.varModel.model.Project root, net.ssehub.easy.varModel.model.Project res) throws net.ssehub.easy.basics.modelManagement.ModelManagementException
      Adds an import statement, if needed, temporarily resolved to be able to create expressions and constraints.
      Parameters:
      target - the target project where to add the import to
      imp - the imported name, may be a wildcard
      root - the root project where to resolve projects from
      res - already resolved project, takes precedence over resolving imp from root; use to temporarily resolve wildcard imports with one concrete project
      Throws:
      net.ssehub.easy.basics.modelManagement.ModelManagementException - if resolving/setting the resolved project fails
    • toIdentifierFirstUpper

      protected static String toIdentifierFirstUpper(String str)
      Helper to turn the first char of str into upper case and str into an identifier..
      Parameters:
      str - the string
      Returns:
      the identifier
    • toIdentifier

      protected static String toIdentifier(String str)
      Helper to turn str into a Java identifier.
      Parameters:
      str - the text
      Returns:
      the identifier
    • getVilConfiguration

      protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.configuration.Configuration getVilConfiguration()
      Returns the actual VIL configuration. Shall be consistent with getIvmlConfiguration().
      Returns:
      the configuration
    • getIvmlConfiguration

      protected abstract net.ssehub.easy.varModel.confModel.Configuration getIvmlConfiguration()
      Returns the actual IVML configuration. Shall be consistent with getVilConfiguration().
      Returns:
      the configuration
    • validateAndPropagate

      protected net.ssehub.easy.reasoning.core.reasoner.ReasoningResult validateAndPropagate()
      Validates the model and propagates values within the model.
      Returns:
      the reasoning result
    • validateAndPropagate

      protected abstract net.ssehub.easy.reasoning.core.reasoner.ReasoningResult validateAndPropagate(Predicate<net.ssehub.easy.varModel.model.Project> projectFilter)
      Validates the model and propagates values within the model.
      Parameters:
      projectFilter - optional filter on projects to reason on, may be null
      Returns:
      the reasoning result
    • reloadConfiguration

      protected abstract void reloadConfiguration()
      Reloads the configuration model.
    • notifyChange

      protected void notifyChange(net.ssehub.easy.varModel.confModel.IDecisionVariable var, de.iip_ecosphere.platform.configuration.cfg.ConfigurationChangeType type)
      Notifies a potential change listener about a configuration change.
      Parameters:
      var - the variable (may not be part of any configuration anymore)
      type - the change type
    • notifyChange

      protected void notifyChange(net.ssehub.easy.varModel.model.Project prj, de.iip_ecosphere.platform.configuration.cfg.ConfigurationChangeType type)
      Notifies a potential change listener about changing a whole project the same way.
      Parameters:
      prj - the project
      type - the change type
    • getType

      public static String getType(net.ssehub.easy.varModel.confModel.IDecisionVariable var)
      Returns the type of var as string.
      Parameters:
      var - the variable
      Returns:
      the type
    • getLogger

      private static de.iip_ecosphere.platform.support.logging.Logger getLogger()
      Returns the logger.
      Returns:
      the logger