Class EasyExecutor
- java.lang.Object
-
- net.ssehub.easy.producer.core.mgmt.EasyExecutor
-
public class EasyExecutor extends java.lang.ObjectDefines a configurable executor class to run the main steps of EASy-Producer in a convenient manner. Besides configuration options, the following methods must be called in the given sequence to run EASy-ProducersetupLocations()loadIvmlModel()#reasonOnIvmlModel()executeVil()discardLocations()
execute()instead, which performs exactly this sequence. In particular, configuration methods are stated in builder style, while the calls mentioned above may return the specific results. This class requires that EASy-Producer is loaded and initialized, either through an EASy-Loader, e.g., the ListLoader, through Eclipse plugins or, directly, through manually calling the required registration classes.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceEasyExecutor.LoggerDefines a simple logger frontend interface.
-
Field Summary
Fields Modifier and Type Field Description private java.io.Filebaseprivate net.ssehub.easy.varModel.confModel.Configurationcfgprivate java.util.List<java.io.File>ivmlFolderprivate java.lang.StringivmlModelNameprivate EasyExecutor.Loggerloggerprivate net.ssehub.easy.basics.progress.ProgressObserverobserverprivate net.ssehub.easy.reasoning.core.reasoner.ReasonerConfigurationrCfgprivate net.ssehub.easy.instantiation.core.model.execution.TracerFactorytracerFactoryprivate java.util.Map<java.lang.String,java.lang.Object>vilArgumentsprivate java.io.FilevilFolderprivate java.lang.StringvilModelNameprivate java.io.FilevilSourceprivate java.lang.StringvilStartRuleNameprivate java.io.FilevilTargetprivate java.io.FilevtlFolder
-
Constructor Summary
Constructors Constructor Description EasyExecutor()Creates an instance of the executor with no folders/model names set.EasyExecutor(java.io.File project, java.io.File modelFolder, java.lang.String modelName)Creates an instance of the executor with basic information absolutely required to execute EASy-Producer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EasyExecutoraddIvmlFolder(java.io.File ivmlFolder)Adds an additional IVML folder.EasyExecutoraddVilArgument(java.lang.String name, java.lang.Object value)Adds a custom VIL start rule argument.voidclearModels()Clears model caches (IVML, VIL, VTL) and implicitly forces a re-resolution, in particular of wildcard imports.voiddiscardLocations()Discards the EASy-Producer locations set up insetupLocations().EasyExecutorexecute()Executes all steps as described above.voidexecuteVil()Executes VIL on the model.net.ssehub.easy.varModel.confModel.ConfigurationgetConfiguration()Returns the configuration used by this executor.net.ssehub.easy.varModel.confModel.ConfigurationloadIvmlModel()Loads the IVML model and creates a configuration instance.EasyExecutorprependIvmlFolder(java.io.File ivmlFolder)Adds this folder as main IVML model folder and turns all known folders to dependent locations.voidprintConfiguration()Convenience method to print the contained configuration toSystem.out.voidprintConfiguration(java.io.PrintStream out)Convenience method to print the contained configuration.static voidprintConfiguration(java.io.PrintStream out, net.ssehub.easy.varModel.confModel.Configuration cfg)Convenience method to print the configuration.static voidprintConfiguration(net.ssehub.easy.varModel.confModel.Configuration cfg)Convenience method to print the given configuration toSystem.out.static voidprintReasoningMessages(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult rRes)Convenience method to print the relevant information from reasoning messages toSystem.out.static voidprintReasoningMessages(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult rRes, java.io.PrintStream out)Convenience method to print the relevant information from reasoning messages.net.ssehub.easy.reasoning.core.reasoner.ReasoningResultpropagateOnIvmlModel()Executes the reasoning on the IVML configuration built byloadIvmlModel(), here in terms of the propagation reasoning mode.voidsetConfiguration(net.ssehub.easy.varModel.confModel.Configuration cfg)Replaces the configuration stored in this class.EasyExecutorsetIvmlFolder(java.io.File ivmlFolder)Sets the IVML model folder where to load the IVML model from.EasyExecutorsetIvmlModelName(java.lang.String ivmlModelName)Sets the IVML model name.EasyExecutorsetLogger(EasyExecutor.Logger logger)Sets the logger instance.EasyExecutorsetProgressObserver(net.ssehub.easy.basics.progress.ProgressObserver observer)Sets the progress observer instance.EasyExecutorsetProjectBase(java.io.File base)Sets the project base needed to interpret relative path names correctly.EasyExecutorsetReasonerConfiguration(net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration rCfg)Sets the reasoner configuration instance.EasyExecutorsetTracerFactory(net.ssehub.easy.instantiation.core.model.execution.TracerFactory tracerFactory)Sets the tracer factory.voidsetupLocations()Sets up the EASy-Producer locations containing the model files.EasyExecutorsetVilFolder(java.io.File vilFolder)Sets the VIL model folder where to load the VIL model from.EasyExecutorsetVilModelName(java.lang.String vilModelName)Sets the VIL model name.EasyExecutorsetVilSource(java.io.File vilSource)Sets the VIL project source folder.EasyExecutorsetVilStartRuleName(java.lang.String vilStartRuleName)Sets the VIL start rule name.EasyExecutorsetVilTarget(java.io.File vilTarget)Sets the VIL project target folder.EasyExecutorsetVtlFolder(java.io.File vtlFolder)Sets the VTL model folder where to load the VTL models from.
-
-
-
Field Detail
-
base
private java.io.File base
-
ivmlFolder
private java.util.List<java.io.File> ivmlFolder
-
vilFolder
private java.io.File vilFolder
-
vtlFolder
private java.io.File vtlFolder
-
vilSource
private java.io.File vilSource
-
vilTarget
private java.io.File vilTarget
-
ivmlModelName
private java.lang.String ivmlModelName
-
vilModelName
private java.lang.String vilModelName
-
vilStartRuleName
private java.lang.String vilStartRuleName
-
vilArguments
private java.util.Map<java.lang.String,java.lang.Object> vilArguments
-
cfg
private net.ssehub.easy.varModel.confModel.Configuration cfg
-
observer
private net.ssehub.easy.basics.progress.ProgressObserver observer
-
rCfg
private net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration rCfg
-
tracerFactory
private net.ssehub.easy.instantiation.core.model.execution.TracerFactory tracerFactory
-
logger
private EasyExecutor.Logger logger
-
-
Constructor Detail
-
EasyExecutor
public EasyExecutor()
Creates an instance of the executor with no folders/model names set. Only the progress observer (set toProgressObserver.NO_OBSERVER), a default reasoner configuration, theconsole tracer factoryand anEASyLoggerFactory.EASyLoggerare assigned.
-
EasyExecutor
public EasyExecutor(java.io.File project, java.io.File modelFolder, java.lang.String modelName)Creates an instance of the executor with basic information absolutely required to execute EASy-Producer. The progress observer is set toProgressObserver.NO_OBSERVER, a default reasoner configuration, theconsole tracer factoryand anEASyLoggerFactory.EASyLoggerare assigned.- Parameters:
project- the basic project folder to which paths in VIL are assumed to be relative. Also used as project folders for VIL for a self-instantiation (acts assetProjectBase(File),setVilSource(File)andsetVilTarget(File)).modelFolder- the folder where IVML, VIL and VTL model files are located, usually a sub-folder ofbase(acts assetIvmlFolder(File),setVilFolder(File)andsetVtlFolder(File).modelName- the name of the model to load, assuming that IVML and VIL models have the same name (acts assetIvmlModelName(String)andsetVilModelName(String)).
-
-
Method Detail
-
setProjectBase
public EasyExecutor setProjectBase(java.io.File base)
Sets the project base needed to interpret relative path names correctly.- Parameters:
base- the base folder- Returns:
- this (builder style)
-
setIvmlFolder
public EasyExecutor setIvmlFolder(java.io.File ivmlFolder)
Sets the IVML model folder where to load the IVML model from. This is initially set to the common model folder. Further folders are added as dependent locations.- Parameters:
ivmlFolder- the folder- Returns:
- this (builder style)
-
prependIvmlFolder
public EasyExecutor prependIvmlFolder(java.io.File ivmlFolder)
Adds this folder as main IVML model folder and turns all known folders to dependent locations.- Parameters:
ivmlFolder- the new main IVML model folder- Returns:
- this (builder style)
-
addIvmlFolder
public EasyExecutor addIvmlFolder(java.io.File ivmlFolder)
Adds an additional IVML folder. Additional folders are added as dependent locations.- Parameters:
ivmlFolder- the additional IVML folder- Returns:
- this (builder style)
-
setVilFolder
public EasyExecutor setVilFolder(java.io.File vilFolder)
Sets the VIL model folder where to load the VIL model from. This is initially set to the common model folder.- Parameters:
vilFolder- the folder- Returns:
- this (builder style)
-
setVtlFolder
public EasyExecutor setVtlFolder(java.io.File vtlFolder)
Sets the VTL model folder where to load the VTL models from. This is initially set to the common model folder.- Parameters:
vtlFolder- the folder- Returns:
- this (builder style)
-
setVilSource
public EasyExecutor setVilSource(java.io.File vilSource)
Sets the VIL project source folder. This is initially set to the common project folder.- Parameters:
vilSource- the folder- Returns:
- this (builder style)
-
setVilTarget
public EasyExecutor setVilTarget(java.io.File vilTarget)
Sets the VIL project target folder. This is initially set to the common project folder. May be the same assetVilTarget(File)for a self-instantiation or it may differ.- Parameters:
vilTarget- the folder- Returns:
- this (builder style)
-
setIvmlModelName
public EasyExecutor setIvmlModelName(java.lang.String ivmlModelName)
Sets the IVML model name. This is initially set to the common model name.- Parameters:
ivmlModelName- the model name- Returns:
- this (builder style)
-
setVilModelName
public EasyExecutor setVilModelName(java.lang.String vilModelName)
Sets the VIL model name. This is initially set to the common model name.- Parameters:
vilModelName- the model name- Returns:
- this (builder style)
-
addVilArgument
public EasyExecutor addVilArgument(java.lang.String name, java.lang.Object value)
Adds a custom VIL start rule argument. If not called, no (additional) arguments will be passed to VIL (except for the default VIL arguments of source, target and configuration) - don't try to specify those arguments here. Custom arguments must be declared in the VIL script.- Parameters:
name- the name of the custom argumentvalue- the value of the custom argument- Returns:
- this (builder style)
-
setVilStartRuleName
public EasyExecutor setVilStartRuleName(java.lang.String vilStartRuleName)
Sets the VIL start rule name. If not called, the default start rule namemainis used.- Parameters:
vilStartRuleName- the VIL start rule name (must be a non-empty string)- Returns:
- this (builder style)
-
setProgressObserver
public EasyExecutor setProgressObserver(net.ssehub.easy.basics.progress.ProgressObserver observer)
Sets the progress observer instance. This is initially set toProgressObserver.NO_OBSERVER.- Parameters:
observer- the observer instance- Returns:
- this (builder style)
-
setReasonerConfiguration
public EasyExecutor setReasonerConfiguration(net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration rCfg)
Sets the reasoner configuration instance. This is initially set to an instance created byReasonerConfiguration().- Parameters:
rCfg- the configuration instance- Returns:
- this (builder style)
-
setTracerFactory
public EasyExecutor setTracerFactory(net.ssehub.easy.instantiation.core.model.execution.TracerFactory tracerFactory)
Sets the tracer factory. Initially, theconsole tracer factoryis set.- Parameters:
tracerFactory- the factory instance (null for the default one)- Returns:
- this (builder style)
-
setLogger
public EasyExecutor setLogger(EasyExecutor.Logger logger)
Sets the logger instance. Initially, the logger delegates to anEASyLoggerFactory.EASyLogger.- Parameters:
logger- the logger instance- Returns:
- this (builder style)
-
setupLocations
public void setupLocations() throws net.ssehub.easy.basics.modelManagement.ModelManagementExceptionSets up the EASy-Producer locations containing the model files.- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- in case that setting up a folders fails for some reasons
-
loadIvmlModel
public net.ssehub.easy.varModel.confModel.Configuration loadIvmlModel() throws net.ssehub.easy.basics.modelManagement.ModelManagementExceptionLoads the IVML model and creates a configuration instance.setupLocations()must be called before.- Returns:
- the configuration instance including the IVML model instance
- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- if loading the IVML model fails
-
propagateOnIvmlModel
public net.ssehub.easy.reasoning.core.reasoner.ReasoningResult propagateOnIvmlModel()
Executes the reasoning on the IVML configuration built byloadIvmlModel(), here in terms of the propagation reasoning mode.loadIvmlModel()must have been called before.- Returns:
- the reasoning result provided by the reasoner
- Throws:
java.lang.IllegalStateException- ifloadIvmlModel()has not been called before
-
executeVil
public void executeVil() throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilExceptionExecutes VIL on the model.- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- in case that the VIL model cannot be loadednet.ssehub.easy.instantiation.core.model.common.VilException- if executing VIL fails for some reasonjava.lang.IllegalStateException- ifloadIvmlModel()has not been called before
-
discardLocations
public void discardLocations() throws net.ssehub.easy.basics.modelManagement.ModelManagementExceptionDiscards the EASy-Producer locations set up insetupLocations().- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- in case that setting up a folders fails for some reasons
-
clearModels
public void clearModels()
Clears model caches (IVML, VIL, VTL) and implicitly forces a re-resolution, in particular of wildcard imports.
-
execute
public EasyExecutor execute() throws net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.instantiation.core.model.common.VilException
Executes all steps as described above.- Returns:
- this (builder style)
- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- if a model location cannot be set or a model cannot be loadednet.ssehub.easy.instantiation.core.model.common.VilException- if executing VIL fails
-
getConfiguration
public net.ssehub.easy.varModel.confModel.Configuration getConfiguration()
Returns the configuration used by this executor.- Returns:
- the configuration
-
setConfiguration
public void setConfiguration(net.ssehub.easy.varModel.confModel.Configuration cfg)
Replaces the configuration stored in this class.- Parameters:
cfg- the configuration (if null further processing is disabled andIllegalStateExceptionmay be thrown)
-
printConfiguration
public static void printConfiguration(net.ssehub.easy.varModel.confModel.Configuration cfg)
Convenience method to print the given configuration toSystem.out.- Parameters:
cfg- the configuration to print
-
printConfiguration
public static void printConfiguration(java.io.PrintStream out, net.ssehub.easy.varModel.confModel.Configuration cfg)Convenience method to print the configuration.- Parameters:
cfg- the configuration to printout- the target output stream
-
printConfiguration
public void printConfiguration(java.io.PrintStream out)
Convenience method to print the contained configuration.- Parameters:
out- the target output stream
-
printConfiguration
public void printConfiguration()
Convenience method to print the contained configuration toSystem.out.
-
printReasoningMessages
public static void printReasoningMessages(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult rRes, java.io.PrintStream out)Convenience method to print the relevant information from reasoning messages.- Parameters:
rRes- the reasoning result to printout- the target output stream
-
printReasoningMessages
public static void printReasoningMessages(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult rRes)
Convenience method to print the relevant information from reasoning messages toSystem.out.- Parameters:
rRes- the reasoning result to print
-
-