Class ModelModifier
java.lang.Object
eu.qualimaster.easy.extension.modelop.ModelModifier
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 ClassesModifier and TypeClassDescriptionstatic interfaceConnection to functionalities of the QM-IConf platform. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Fileprivate static final StringDestination of the pruned configuration / projects.private static final booleanAdds freeze blocks to the configuration projects.private Fileprivate static final booleanSpecifies whether elements shall be deleted, which are not necessary for runtime:truedelete frozen and unused elements,falsedo not delete anything.private final ModelModifier.QMPlatformProviderprivate static final booleanSaves the configured values (stores the into the models), before pruning.private net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptorprivate Fileprivate Fileprivate final net.ssehub.easy.varModel.model.Projectprivate static final booleanSaves the pruned configuration (writes it to disk). -
Constructor Summary
ConstructorsConstructorDescriptionModelModifier(File targetFolder, net.ssehub.easy.varModel.model.Project toplevelProject, File baseLocation, ModelModifier.QMPlatformProvider qmApp) Single constructor for this class. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddOrRemoveLocation(File folder, boolean add) Shortcut foraddOrRemoveLocation(File, boolean)to (un-)load all models an once.private voidaddOrRemoveLocation(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.voidclear()Restores the old state inside the tooling after instantiation (should be called aftercreateExecutor()was used for instantiation).private FileCreates a copy of the build model and place the files parallel to the copied variability model files.net.ssehub.easy.instantiation.core.model.execution.ExecutorPrepares the underlying IVMLProjectand VIL, VTLScriptmodels for instantiation and generates a pruned and frozenConfiguration, which should be used for the instantiation of the QM model.private voidfreezeProject(net.ssehub.easy.varModel.model.Project baseProject) Adds freezes blocks to the configuration projects.net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptorReturns the internally usedIProjectDescriptorused by the executor returned by thecreateExecutor()method.private <M extends net.ssehub.easy.basics.modelManagement.IModel>
MLoads the main model.private net.ssehub.easy.varModel.confModel.ConfigurationprepareConfig(File targetLocation) Prepares the underlying IVMLProjectfor instantiation and generates a prunedConfiguration, which should be used for the instantiation of the QM model.private voidsaveValues(net.ssehub.easy.varModel.model.Project project, Set<net.ssehub.easy.varModel.model.Project> done) Saves the values of configuration projects(recursive function).
-
Field Details
-
FREEZE
private static final boolean FREEZEAdds freeze blocks to the configuration projects.- See Also:
-
SAVE_VALUES
private static final boolean SAVE_VALUESSaves 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_CONFIGSaves the pruned configuration (writes it to disk).- See Also:
-
PRUNE_CONFIG
private static final boolean PRUNE_CONFIGSpecifies whether elements shall be deleted, which are not necessary for runtime:truedelete frozen and unused elements,falsedo not delete anything.- See Also:
-
COPIED_MODELS_LOCATION
Destination of the pruned configuration / projects.- See Also:
-
targetFolder
-
source
private net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source -
orgModelsFolder
-
tempModelsFolder
-
toplevelProject
private final net.ssehub.easy.varModel.model.Project toplevelProject -
baseLocation
-
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 artifactstoplevelProject- 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 IVMLProjectand VIL, VTLScriptmodels for instantiation and generates a pruned and frozenConfiguration, 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 usedIProjectDescriptorused by the executor returned by thecreateExecutor()method.- Returns:
- The internally used source descriptor or
nullif 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- EitherProjectorScript.- Parameters:
management- EitherVarModel.INSTANCEorBuildModel.INSTANCEfileEnding- Either.ivmlor_0.vil.- Returns:
- The loaded model or
nullif it was not found.
-
clear
public void clear()Restores the old state inside the tooling after instantiation (should be called aftercreateExecutor()was used for instantiation). -
addOrRemoveLocation
Shortcut foraddOrRemoveLocation(File, boolean)to (un-)load all models an once.- Parameters:
folder- The folder to (un-)registeradd-truethe folder will be added as possible location for models,falsethe 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, orTemplateModel.INSTANCEfolder- The folder to (un-)registeradd-truethe folder will be added as possible location for models,falsethe folder will be removed.
-
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
Prepares the underlying IVMLProjectfor instantiation and generates a prunedConfiguration, 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).
-