Class FWPipeLineHelper
java.lang.Object
net.simplace.pipe.control.FWPipeLineHelper
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
FieldsModifier and TypeFieldDescriptionControl parameters removed from the result of a pipeline byfilterParameters(FWObservable). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendAccessLog(String aPipeLineID, String aString) Appends a line with the current time and the given text to the access log of the pipeline (seegetPipeLineAccessFile(String)); the log is limited to 1000 lines.static booleancheckIfExpression(String aExpression, net.simplace.core.FWObservable aObservable) Evaluates the if-expression of a function or processor (attributeif) as JEXL expression, e.g.static voidfillParameterMapFromFormElement(Map<String, Object> aParameterMap, org.jdom2.Element aSettingElement) Fills the parameter map with the values of the form fields of a settings element (recursively throughgroupandtableelements,labelelements are skipped).static net.simplace.core.FWObservablefilterParameters(net.simplace.core.FWObservable aOutput) Removes the control parameters listed inPARAM_TO_REMOVE_AT_END.static URLgetConnectorRessource(String aResourceName) Looks up a resource in the system class path.static org.jdom2.ElementgetInitElementFromFile(String aInitFileName) Parses a pipeline definition file from the class path.static longgetLastCallMillis(String aPipeID) Reads the time of the last call of the pipeline from the last line of its access log.static final FilegetPipeLineAccessFile(String aPipeID) 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.FWObservableperformChannelReplacements(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,cto a list,Map$%k1=v1,k2=v2to a map andDate$%...to a date.static net.simplace.core.FWObservableprocessPipeLine(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.
-
Field Details
-
PARAM_TO_REMOVE_AT_END
Control parameters removed from the result of a pipeline byfilterParameters(FWObservable).
-
-
Constructor Details
-
FWPipeLineHelper
public FWPipeLineHelper()
-
-
Method Details
-
appendAccessLog
Appends a line with the current time and the given text to the access log of the pipeline (seegetPipeLineAccessFile(String)); the log is limited to 1000 lines.- Parameters:
aPipeLineID- id of the pipelineaString- text to be appended
-
getConnectorRessource
Looks up a resource in the system class path.- Parameters:
aResourceName- name of the resource- Returns:
- URL of the resource, or
nullif not found - Throws:
PipeLineException- declared, not thrown
-
getLastCallMillis
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 readParseException- 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,cto a list,Map$%k1=v1,k2=v2to a map andDate$%...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 throughgroupandtableelements,labelelements are skipped). The value is the element's text or its attributedefault; parameters already set are not overwritten.- Parameters:
aParameterMap- the map to fill (key = attributeidof the form field)aSettingElement- the element containing the form fields
-
getPipeLineAccessFile
-
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 containeraPipeLineID- id of the pipelineaNumberOfSteps- maximum number of processors to run- Returns:
- the result of the pipeline
- Throws:
PipeLineException- if the pipeline cannot be found or failsDatabaseInUseException- if the error message says that the database is already in use
-
getInitElementFromFile
Parses a pipeline definition file from the class path.- Parameters:
aInitFileName- name of the file (class path resource)- Returns:
- the root element, or
nullif 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 (attributeif) as JEXL expression, e.g.${a} eq ${b},!${flag}orfile:exists('sim/sim_resource.zip'), seeFWObservable.evaluateBoolean(String, boolean).- Parameters:
aExpression- the expression, ornullaObservable- the parameters- Returns:
trueif the function or processor should run;trueif 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 inPARAM_TO_REMOVE_AT_END.- Parameters:
aOutput- the parameters, changed in place- Returns:
aOutput
-