Class ModelModifier

java.lang.Object
eu.qualimaster.easy.extension.modelop.ModelModifier

public class ModelModifier extends Object
This class should modify and prune the model and it's configuration before instantiation. Specifically, this modifier does the following:
  • Dynamically freeze values (false)
  • Stores propagated values inside the configuration (true)
  • Optimizes the model for runtime (prune config) (true)
  • Saves the modified configuration to "QM-Model" (true)
  • Saves the VIL model to "QM-Model"
Author:
El-Sharkawy
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Connection to functionalities of the QM-IConf platform.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final File
     
    private static final String
    Destination of the pruned configuration / projects.
    private static final boolean
    Adds freeze blocks to the configuration projects.
    private File
     
    private static final boolean
    Specifies whether elements shall be deleted, which are not necessary for runtime: true delete frozen and unused elements, false do not delete anything.
     
    private static final boolean
    Saves the configured values (stores the into the models), before pruning.
    private net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor
     
    private File
     
    private File
     
    private final net.ssehub.easy.varModel.model.Project
     
    private static final boolean
    Saves the pruned configuration (writes it to disk).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModelModifier(File targetFolder, net.ssehub.easy.varModel.model.Project toplevelProject, File baseLocation, ModelModifier.QMPlatformProvider qmApp)
    Single constructor for this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    addOrRemoveLocation(File folder, boolean add)
    Shortcut for addOrRemoveLocation(File, boolean) to (un-)load all models an once.
    private void
    addOrRemoveLocation(net.ssehub.easy.basics.modelManagement.ModelManagement<? extends net.ssehub.easy.basics.modelManagement.IModel> modelManagement, File folder, boolean add)
    Removed or adds a (temporary) folder for loading models from this locations.
    void
    Restores the old state inside the tooling after instantiation (should be called after createExecutor() was used for instantiation).
    private File
    Creates a copy of the build model and place the files parallel to the copied variability model files.
    net.ssehub.easy.instantiation.core.model.execution.Executor
    Prepares the underlying IVML Project and VIL, VTL Script models for instantiation and generates a pruned and frozen Configuration, which should be used for the instantiation of the QM model.
    private void
    freezeProject(net.ssehub.easy.varModel.model.Project baseProject)
    Adds freezes blocks to the configuration projects.
    net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor
    Returns the internally used IProjectDescriptor used by the executor returned by the createExecutor() method.
    private <M extends net.ssehub.easy.basics.modelManagement.IModel>
    M
    load(net.ssehub.easy.basics.modelManagement.ModelManagement<M> management, String fileEnding)
    Loads the main model.
    private net.ssehub.easy.varModel.confModel.Configuration
    prepareConfig(File targetLocation)
    Prepares the underlying IVML Project for instantiation and generates a pruned Configuration, which should be used for the instantiation of the QM model.
    private void
    saveValues(net.ssehub.easy.varModel.model.Project project, Set<net.ssehub.easy.varModel.model.Project> done)
    Saves the values of configuration projects(recursive function).

    Methods inherited from class java.lang.Object

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

    • FREEZE

      private static final boolean FREEZE
      Adds freeze blocks to the configuration projects.
      See Also:
    • SAVE_VALUES

      private static final boolean SAVE_VALUES
      Saves the configured values (stores the into the models), before pruning.
      This is necessary as some values are set by constraints (which shall be removed).
      See Also:
    • WRITE_MODIFIED_CONFIG

      private static final boolean WRITE_MODIFIED_CONFIG
      Saves the pruned configuration (writes it to disk).
      See Also:
    • PRUNE_CONFIG

      private static final boolean PRUNE_CONFIG
      Specifies whether elements shall be deleted, which are not necessary for runtime: true delete frozen and unused elements, false do not delete anything.
      See Also:
    • COPIED_MODELS_LOCATION

      private static final String COPIED_MODELS_LOCATION
      Destination of the pruned configuration / projects.
      See Also:
    • targetFolder

      private File targetFolder
    • source

      private net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source
    • orgModelsFolder

      private File orgModelsFolder
    • tempModelsFolder

      private File tempModelsFolder
    • toplevelProject

      private final net.ssehub.easy.varModel.model.Project toplevelProject
    • baseLocation

      private final File baseLocation
    • qmApp

      private final ModelModifier.QMPlatformProvider qmApp
  • Constructor Details

    • ModelModifier

      public ModelModifier(File targetFolder, net.ssehub.easy.varModel.model.Project toplevelProject, File baseLocation, ModelModifier.QMPlatformProvider qmApp)
      Single constructor for this class.
      Parameters:
      targetFolder - The destination folder where to instantiate all artifacts
      toplevelProject - base project, which imports all other projects, e.g., VariabilityModel.Definition.TOP_LEVEL.getConfiguration().getProject()
      baseLocation - The folder where all EASy files (VTL, VIL, IVML) are placed in, e.g., Location.getModelLocationFile()
      qmApp - Optional instance of the application to show error dialogs and to allow reasoning (validation of the generated configuration).
  • Method Details

    • createExecutor

      public net.ssehub.easy.instantiation.core.model.execution.Executor createExecutor()
      Prepares the underlying IVML Project and VIL, VTL Script models for instantiation and generates a pruned and frozen Configuration, which should be used for the instantiation of the QM model.
      Returns:
      Configuration, which should be used for the instantiation of the QM model
    • getSourceDescriptor

      public net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor getSourceDescriptor()
      Returns the internally used IProjectDescriptor used by the executor returned by the createExecutor() method.
      Returns:
      The internally used source descriptor or null if also no executor is returned.
    • load

      private <M extends net.ssehub.easy.basics.modelManagement.IModel> M load(net.ssehub.easy.basics.modelManagement.ModelManagement<M> management, String fileEnding)
      Loads the main model.
      Type Parameters:
      M - Either Project or Script.
      Parameters:
      management - Either VarModel.INSTANCE or BuildModel.INSTANCE
      fileEnding - Either .ivml or _0.vil.
      Returns:
      The loaded model or null if it was not found.
    • clear

      public void clear()
      Restores the old state inside the tooling after instantiation (should be called after createExecutor() was used for instantiation).
    • addOrRemoveLocation

      private void addOrRemoveLocation(File folder, boolean add)
      Shortcut for addOrRemoveLocation(File, boolean) to (un-)load all models an once.
      Parameters:
      folder - The folder to (un-)register
      add - true the folder will be added as possible location for models, false the folder will be removed.
    • addOrRemoveLocation

      private void addOrRemoveLocation(net.ssehub.easy.basics.modelManagement.ModelManagement<? extends net.ssehub.easy.basics.modelManagement.IModel> modelManagement, File folder, boolean add)
      Removed or adds a (temporary) folder for loading models from this locations.
      Parameters:
      modelManagement - VarModel.INSTANCE, BuildModel.INSTANCE, or TemplateModel.INSTANCE
      folder - The folder to (un-)register
      add - true the folder will be added as possible location for models, false the folder will be removed.
    • copyBuildModel

      private File copyBuildModel()
      Creates a copy of the build model and place the files parallel to the copied variability model files.
      Returns:
      The root folder of the copied model files.
    • prepareConfig

      private net.ssehub.easy.varModel.confModel.Configuration prepareConfig(File targetLocation)
      Prepares the underlying IVML Project for instantiation and generates a pruned Configuration, which should be used for the instantiation of the QM model.
      Parameters:
      targetLocation - The destination folder where to instantiate all artifacts
      Returns:
      Configuration, which should be used for the instantiation of the QM model
    • saveValues

      private void saveValues(net.ssehub.easy.varModel.model.Project project, Set<net.ssehub.easy.varModel.model.Project> done)
      Saves the values of configuration projects(recursive function).
      Parameters:
      project - The copied QM model (the starting point, which imports all the other models).
      done - The list of already saved projects, should be empty at the beginning.
    • freezeProject

      private void freezeProject(net.ssehub.easy.varModel.model.Project baseProject)
      Adds freezes blocks to the configuration projects.
      Parameters:
      baseProject - The copied QM model (the starting point, which imports all the other models).