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
    • 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
    • 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.
        Parameters:
        ivmlFolder - the folder
        Returns:
        this (builder style)
      • addIvmlFolder

        public EasyExecutor addIvmlFolder​(java.io.File ivmlFolder)
        Adds an additional IVML folder.
        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)
      • setReasonerConfiguration

        public EasyExecutor setReasonerConfiguration​(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​(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)
      • propagateOnIvmlModel

        public 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
      • getConfiguration

        public Configuration getConfiguration()
        Returns the configuration used by this executor.
        Returns:
        the configuration
      • setConfiguration

        public void setConfiguration​(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​(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,
                                              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​(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​(ReasoningResult rRes)
        Convenience method to print the relevant information from reasoning messages to System.out.
        Parameters:
        rRes - the reasoning result to print