Class FWPipeLineHelper

java.lang.Object
net.simplace.pipe.control.FWPipeLineHelper

public class FWPipeLineHelper extends Object
Static helper functions of the pipeline engine: running a pipeline, reading the pipeline definition, access logs, if-expressions and parameter conversions.
Author:
Andreas Enders
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<String>
    Control parameters removed from the result of a pipeline by filterParameters(FWObservable).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    appendAccessLog(String aPipeLineID, String aString)
    Appends a line with the current time and the given text to the access log of the pipeline (see getPipeLineAccessFile(String)); the log is limited to 1000 lines.
    static boolean
    checkIfExpression(String aExpression, net.simplace.core.FWObservable aObservable)
    Evaluates the if-expression of a function or processor (attribute if) as JEXL expression, e.g.
    static void
    fillParameterMapFromFormElement(Map<String,Object> aParameterMap, org.jdom2.Element aSettingElement)
    Fills the parameter map with the values of the form fields of a settings element (recursively through group and table elements, label elements are skipped).
    static net.simplace.core.FWObservable
    filterParameters(net.simplace.core.FWObservable aOutput)
    Removes the control parameters listed in PARAM_TO_REMOVE_AT_END.
    static URL
    Looks up a resource in the system class path.
    static org.jdom2.Element
    Parses a pipeline definition file from the class path.
    static long
    Reads the time of the last call of the pipeline from the last line of its access log.
    static final File
    Returns the access log file of the pipeline, <temp dir root>/log/<pipe id>.accesslog; the log directory is created if necessary.
    static net.simplace.core.FWObservable
    performChannelReplacements(net.simplace.core.FWObservable aObservable)
    Performs replacements on all string parameters (called for the in parameters of every processor): values containing ${_TEMPDIR_} or ${TEMPDIR} get their tokens replaced, and typed values of the form <Type>$%<value> are converted: List$%a,b,c to a list, Map$%k1=v1,k2=v2 to a map and Date$%... to a date.
    static net.simplace.core.FWObservable
    processPipeLine(FWPipeLinesContainer aContainer, String aPipeLineID, int aNumberOfSteps)
    Runs the pipeline synchronously with the initial parameters of the container and writes the result and duration to the access log.

    Methods inherited from class Object

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

  • Constructor Details

    • FWPipeLineHelper

      public FWPipeLineHelper()
  • Method Details

    • appendAccessLog

      public static void appendAccessLog(String aPipeLineID, String aString)
      Appends a line with the current time and the given text to the access log of the pipeline (see getPipeLineAccessFile(String)); the log is limited to 1000 lines.
      Parameters:
      aPipeLineID - id of the pipeline
      aString - text to be appended
    • getConnectorRessource

      public static URL getConnectorRessource(String aResourceName) throws PipeLineException
      Looks up a resource in the system class path.
      Parameters:
      aResourceName - name of the resource
      Returns:
      URL of the resource, or null if not found
      Throws:
      PipeLineException - declared, not thrown
    • getLastCallMillis

      public static long getLastCallMillis(String aPipeID) throws IOException, ParseException
      Reads the time of the last call of the pipeline from the last line of its access log.
      Parameters:
      aPipeID - id of the pipeline
      Returns:
      time of the last call in milliseconds since the epoch
      Throws:
      IOException - if the access log cannot be read
      ParseException - if the time in the last line cannot be parsed
    • performChannelReplacements

      public static net.simplace.core.FWObservable performChannelReplacements(net.simplace.core.FWObservable aObservable)
      Performs replacements on all string parameters (called for the in parameters of every processor): values containing ${_TEMPDIR_} or ${TEMPDIR} get their tokens replaced, and typed values of the form <Type>$%<value> are converted: List$%a,b,c to a list, Map$%k1=v1,k2=v2 to a map and Date$%... to a date.
      Parameters:
      aObservable - the parameters, changed in place
      Returns:
      aObservable
    • fillParameterMapFromFormElement

      public static void fillParameterMapFromFormElement(Map<String,Object> aParameterMap, org.jdom2.Element aSettingElement)
      Fills the parameter map with the values of the form fields of a settings element (recursively through group and table elements, label elements are skipped). The value is the element's text or its attribute default; parameters already set are not overwritten.
      Parameters:
      aParameterMap - the map to fill (key = attribute id of the form field)
      aSettingElement - the element containing the form fields
    • getPipeLineAccessFile

      public static final File getPipeLineAccessFile(String aPipeID)
      Returns the access log file of the pipeline, <temp dir root>/log/<pipe id>.accesslog; the log directory is created if necessary.
      Parameters:
      aPipeID - id of the pipeline
      Returns:
      the access log file
    • processPipeLine

      public static net.simplace.core.FWObservable processPipeLine(FWPipeLinesContainer aContainer, String aPipeLineID, int aNumberOfSteps) throws PipeLineException, DatabaseInUseException
      Runs the pipeline synchronously with the initial parameters of the container and writes the result and duration to the access log.
      Parameters:
      aContainer - the pipeline container
      aPipeLineID - id of the pipeline
      aNumberOfSteps - maximum number of processors to run
      Returns:
      the result of the pipeline
      Throws:
      PipeLineException - if the pipeline cannot be found or fails
      DatabaseInUseException - if the error message says that the database is already in use
    • getInitElementFromFile

      public static org.jdom2.Element getInitElementFromFile(String aInitFileName)
      Parses a pipeline definition file from the class path.
      Parameters:
      aInitFileName - name of the file (class path resource)
      Returns:
      the root element, or null if the file cannot be read (error is logged)
    • checkIfExpression

      public static boolean checkIfExpression(String aExpression, net.simplace.core.FWObservable aObservable) throws PipeLineException
      Evaluates the if-expression of a function or processor (attribute if) as JEXL expression, e.g. ${a} eq ${b}, !${flag} or file:exists('sim/sim_resource.zip'), see FWObservable.evaluateBoolean(String, boolean).
      Parameters:
      aExpression - the expression, or null
      aObservable - the parameters
      Returns:
      true if the function or processor should run; true if there is no expression or it cannot be evaluated
      Throws:
      PipeLineException - declared, not thrown
    • filterParameters

      public static net.simplace.core.FWObservable filterParameters(net.simplace.core.FWObservable aOutput)
      Removes the control parameters listed in PARAM_TO_REMOVE_AT_END.
      Parameters:
      aOutput - the parameters, changed in place
      Returns:
      aOutput