Class EasyExecutor


  • public class EasyExecutor
    extends java.lang.Object
    Defines 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-Producer
    1. setupLocations()
    2. loadIvmlModel()
    3. #reasonOnIvmlModel()
    4. executeVil()
    5. discardLocations()
    You may call these methods individually and handle the exceptions or you may call 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 interface  EasyExecutor.Logger
      Defines a simple logger frontend interface.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File base  
      private net.ssehub.easy.varModel.confModel.Configuration cfg  
      private java.util.List<java.io.File> ivmlFolder  
      private java.lang.String ivmlModelName  
      private EasyExecutor.Logger logger  
      private net.ssehub.easy.basics.progress.ProgressObserver observer  
      private net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration rCfg  
      private net.ssehub.easy.instantiation.core.model.execution.TracerFactory tracerFactory  
      private java.util.Map<java.lang.String,​java.lang.Object> vilArguments  
      private java.io.File vilFolder  
      private java.lang.String vilModelName  
      private java.io.File vilSource  
      private java.lang.String vilStartRuleName  
      private java.io.File vilTarget  
      private java.io.File vtlFolder  
    • 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
      EasyExecutor addIvmlFolder​(java.io.File ivmlFolder)
      Adds an additional IVML folder.
      EasyExecutor addVilArgument​(java.lang.String name, java.lang.Object value)
      Adds a custom VIL start rule argument.
      void clearModels()
      Clears model caches (IVML, VIL, VTL) and implicitly forces a re-resolution, in particular of wildcard imports.
      void discardLocations()
      Discards the EASy-Producer locations set up in setupLocations().
      EasyExecutor execute()
      Executes all steps as described above.
      void executeVil()
      Executes VIL on the model.
      net.ssehub.easy.varModel.confModel.Configuration getConfiguration()
      Returns the configuration used by this executor.
      net.ssehub.easy.varModel.confModel.Configuration loadIvmlModel()
      Loads the IVML model and creates a configuration instance.
      EasyExecutor prependIvmlFolder​(java.io.File ivmlFolder)
      Adds this folder as main IVML model folder and turns all known folders to dependent locations.
      void printConfiguration()
      Convenience method to print the contained configuration to System.out.
      void printConfiguration​(java.io.PrintStream out)
      Convenience method to print the contained configuration.
      static void printConfiguration​(java.io.PrintStream out, net.ssehub.easy.varModel.confModel.Configuration cfg)
      Convenience method to print the configuration.
      static void printConfiguration​(net.ssehub.easy.varModel.confModel.Configuration cfg)
      Convenience method to print the given configuration to System.out.
      static void printReasoningMessages​(net.ssehub.easy.reasoning.core.reasoner.ReasoningResult rRes)
      Convenience method to print the relevant information from reasoning messages to System.out.
      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.
      net.ssehub.easy.reasoning.core.reasoner.ReasoningResult propagateOnIvmlModel()
      Executes the reasoning on the IVML configuration built by loadIvmlModel(), here in terms of the propagation reasoning mode.
      void setConfiguration​(net.ssehub.easy.varModel.confModel.Configuration cfg)
      Replaces the configuration stored in this class.
      EasyExecutor setIvmlFolder​(java.io.File ivmlFolder)
      Sets the IVML model folder where to load the IVML model from.
      EasyExecutor setIvmlModelName​(java.lang.String ivmlModelName)
      Sets the IVML model name.
      EasyExecutor setLogger​(EasyExecutor.Logger logger)
      Sets the logger instance.
      EasyExecutor setProgressObserver​(net.ssehub.easy.basics.progress.ProgressObserver observer)
      Sets the progress observer instance.
      EasyExecutor setProjectBase​(java.io.File base)
      Sets the project base needed to interpret relative path names correctly.
      EasyExecutor setReasonerConfiguration​(net.ssehub.easy.reasoning.core.reasoner.ReasonerConfiguration rCfg)
      Sets the reasoner configuration instance.
      EasyExecutor setTracerFactory​(net.ssehub.easy.instantiation.core.model.execution.TracerFactory tracerFactory)
      Sets the tracer factory.
      void setupLocations()
      Sets up the EASy-Producer locations containing the model files.
      EasyExecutor setVilFolder​(java.io.File vilFolder)
      Sets the VIL model folder where to load the VIL model from.
      EasyExecutor setVilModelName​(java.lang.String vilModelName)
      Sets the VIL model name.
      EasyExecutor setVilSource​(java.io.File vilSource)
      Sets the VIL project source folder.
      EasyExecutor setVilStartRuleName​(java.lang.String vilStartRuleName)
      Sets the VIL start rule name.
      EasyExecutor setVilTarget​(java.io.File vilTarget)
      Sets the VIL project target folder.
      EasyExecutor setVtlFolder​(java.io.File vtlFolder)
      Sets the VTL model folder where to load the VTL models from.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • EasyExecutor

        public EasyExecutor()
        Creates an instance of the executor with no folders/model names set. Only the progress observer (set to ProgressObserver.NO_OBSERVER), a default reasoner configuration, the console tracer factory and an EASyLoggerFactory.EASyLogger are 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 to ProgressObserver.NO_OBSERVER, a default reasoner configuration, the console tracer factory and an EASyLoggerFactory.EASyLogger are 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 as setProjectBase(File), setVilSource(File) and setVilTarget(File)).
        modelFolder - the folder where IVML, VIL and VTL model files are located, usually a sub-folder of base (acts as setIvmlFolder(File), setVilFolder(File) and setVtlFolder(File).
        modelName - the name of the model to load, assuming that IVML and VIL models have the same name (acts as setIvmlModelName(String) and setVilModelName(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 as setVilTarget(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 argument
        value - 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 name main is 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 to ProgressObserver.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 by ReasonerConfiguration().
        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, the console tracer factory is 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 an EASyLoggerFactory.EASyLogger.
        Parameters:
        logger - the logger instance
        Returns:
        this (builder style)
      • setupLocations

        public void setupLocations()
                            throws net.ssehub.easy.basics.modelManagement.ModelManagementException
        Sets 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.ModelManagementException
        Loads 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 by loadIvmlModel(), 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 - if loadIvmlModel() has not been called before
      • executeVil

        public void executeVil()
                        throws net.ssehub.easy.basics.modelManagement.ModelManagementException,
                               net.ssehub.easy.instantiation.core.model.common.VilException
        Executes VIL on the model.
        Throws:
        net.ssehub.easy.basics.modelManagement.ModelManagementException - in case that the VIL model cannot be loaded
        net.ssehub.easy.instantiation.core.model.common.VilException - if executing VIL fails for some reason
        java.lang.IllegalStateException - if loadIvmlModel() has not been called before
      • discardLocations

        public void discardLocations()
                              throws net.ssehub.easy.basics.modelManagement.ModelManagementException
        Discards the EASy-Producer locations set up in setupLocations().
        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 loaded
        net.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 and IllegalStateException may be thrown)
      • printConfiguration

        public static void printConfiguration​(net.ssehub.easy.varModel.confModel.Configuration cfg)
        Convenience method to print the given configuration to System.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 print
        out - 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 to System.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 print
        out - 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 to System.out.
        Parameters:
        rRes - the reasoning result to print