Class FWProcessor
java.lang.Object
net.simplace.pipe.control.FWProcessor
- Direct Known Subclasses:
AsciiToDatabaseTableProcessor, BrowseFolderProcessor, CopyFolderProcessor, CopyTableProcessor, CreateDBConnectionProcessor, CreateFileListProcessor, DeleteFilesProcessor, DownloadFileProcessor, EncodingConverterProcessor, FWLoopProcessor, JDOMParserProcessor, JDOMUnparseProcessor, MoveFileProcessor, ReadFileProcessor, ReleaseDBConnectionProcessor, RuleProcessor, RunAppProcessor, SaveProjectTemplateProcessor, SolutionToXMLProcessor, SQLStatementProcessor, UnzipFolderProcessor, WriteFileProcessor, WriteProjectXMLProcessor, XSLTTransformerProcessor
Abstract superclass for all standard and custom processors. A processor is one step of a
FWPipeLine; it is
declared as <processor class="..." progressid="..." if="..."> with <parameter
key="...">value</parameter> children (initial parameters) and an optional
<configuration> element. When piped, it works on a copy of the incoming parameters (plus its
initial parameters) and writes its results to the outgoing observable.- Author:
- Andreas Enders
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intNumber of loops this processor was run through (index of the current progress task).protected FWPipeLinesContainerThe pipeline container this processor belongs to.protected net.simplace.core.FWObservableMap of parameters worked with in this processor.protected net.simplace.core.FWObservableMap of parameters put to output for next processor.protected ArrayList<FWProgressTask> The progressTasks of this Processor. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCan be overridden to perform semantic checks on the input parameters beforeprocess().protected booleanCan be overridden to perform semantic checks on the output afterprocess().clone()Creates a new instance of the same class with the same container, configuration, if-expression and end-of-pipe flag.protected booleancontainsParameter(String aSourceKey) static FWProcessorcreateProcessor(String aClassName) Creates an uninitialised processor of the given class (no container, parameters or configuration).static FWProcessorcreateProcessor(org.jdom2.Element aProcessorElement, FWPipeLinesContainer aContainer) Creates a processor by instantiating the class given in the attributeclassof the element and initialises it (parameters, loop settings, progress task, configuration, if-expression).protected voidfireTaskEvent(JPanel aSourcePanel) Fires a task event for the current progress task to the listeners of the container (does nothing if the processor has no progress task).getAllStringInParameters(String aKeyPrefix, boolean aElimKeyPrefix) Returns all string in parameters, whose keys start with a given prefix.protected org.jdom2.ElementReturns the configuration of the processor.protected ObjectgetInParameter(String aKey) protected ObjectgetInParameter(String aKey, Object aDefault) protected net.simplace.core.FWObservableAdds a clone of the first progress task (for a further loop).protected ObjectgetOutParameter(String aKey) protected FWPipeLinegetPipeLine(String aPipeLineID) protected StringgetStringInParameter(String aKey) Returns the value of the parameter as string, with parameter tokens replaced (seeFWObservable.getStringParameterValue(String)).protected StringgetStringInParameter(String aKey, String aDefault) Returns the value of the parameter if it is a string (no token replacement).protected Stringprotected booleanbooleannet.simplace.core.FWObservablePipes the observable through this processor: builds the in parameters (copy ofaObservabeplus initial parameters), evaluates the if-expression (if false, the observable is returned unchanged), performs the channel replacements, checks the input, runsprocess()and checks the output.protected abstract booleanprocess()Must be overridden to implement the concrete processing step.protected voidremoveOutParameter(String aElement) Removes a parameter from the outgoing observable.protected voidsetConfiguration(String aClassname, org.jdom2.Element aConfigurationElement) Passes a configuration to a following processor as out parameterCONFIGURATION_<class name>.protected voidSets the end of pipe flag.protected voidsetInitialParameters(Map<String, Object> aInitialParameterMap) protected voidsetInParameterMap(net.simplace.core.FWObservable aObservable) protected voidsetLoopedCount(int aNumberOfAllreadyLooped) Sets the loop count; has to be set by the looping processor because of thread safety.protected voidsetOutParameter(String aKey, Object aValue) Sets a parameter in the outgoing observable (created from the initial parameters if not yet set).protected voidsetStateOfTask(String aStatusOfTask) Sets the state of the current progress task and fires a task event (does nothing without progress task).protected voidsetStateProgressing(int aPercentDone, String aMessage) Sets the current progress task to progressing and fires a task event (does nothing without progress task).org.jdom2.ElementtoXML()
-
Field Details
-
iContainer
The pipeline container this processor belongs to. -
iProgressTasks
The progressTasks of this Processor. -
iInObservable
protected net.simplace.core.FWObservable iInObservableMap of parameters worked with in this processor. -
iObservable
protected net.simplace.core.FWObservable iObservableMap of parameters put to output for next processor. -
iAllreadyLoopedCount
protected int iAllreadyLoopedCountNumber of loops this processor was run through (index of the current progress task).
-
-
Constructor Details
-
FWProcessor
public FWProcessor()
-
-
Method Details
-
createProcessor
public static FWProcessor createProcessor(org.jdom2.Element aProcessorElement, FWPipeLinesContainer aContainer) throws PipeLineCreationException Creates a processor by instantiating the class given in the attributeclassof the element and initialises it (parameters, loop settings, progress task, configuration, if-expression).- Parameters:
aProcessorElement- theprocessorelementaContainer- the pipeline container the processor belongs to- Returns:
- the created processor
- Throws:
PipeLineCreationException- if the class cannot be instantiated or a parameter has no key
-
createProcessor
Creates an uninitialised processor of the given class (no container, parameters or configuration).- Parameters:
aClassName- fully qualified name of the processor class- Returns:
- the created processor
- Throws:
PipeLineCreationException- if the class cannot be instantiated
-
clone
Creates a new instance of the same class with the same container, configuration, if-expression and end-of-pipe flag. The list of progress tasks and the map of initial parameters are shared with the original on purpose: the progress view adds one task per clone to the shared list (getNewProgressTask()), and each clone uses its task by its loop count; access to the list is synchronized. The initial parameters are not changed after the pipeline is created.- Overrides:
clonein classObject- Throws:
RuntimeException- if the class cannot be instantiated
-
setInitialParameters
-
getInitialParameters
-
process
Must be overridden to implement the concrete processing step. Reads from the in parameters and writes results withsetOutParameter(String, Object).- Returns:
trueon success;falsemakespipe(FWObservable, Integer)fail- Throws:
PipeLineException- if processing fails
-
checkInParameterMap
protected boolean checkInParameterMap()Can be overridden to perform semantic checks on the input parameters beforeprocess().- Returns:
trueif the input is valid; the default returnstrue
-
containsParameter
- Parameters:
aSourceKey- parameter key- Returns:
trueif the parameter is set in the in parameters
-
setEndOfPipeFlag
protected void setEndOfPipeFlag()Sets the end of pipe flag. Pipe line is aborted after this processor. -
isEndOfPipe
public boolean isEndOfPipe()- Returns:
trueif the end of pipe flag is set, i.e. the pipeline is aborted after this processor
-
checkOutParameterMap
protected boolean checkOutParameterMap()Can be overridden to perform semantic checks on the output afterprocess().- Returns:
trueif the output is valid; the default returnstrue
-
getInParameter
-
getInParameters
protected net.simplace.core.FWObservable getInParameters()- Returns:
- the in parameters (copy of the incoming parameters plus the initial parameters)
-
getInParameter
-
getStringInParameter
Returns the value of the parameter if it is a string (no token replacement).- Parameters:
aKey- parameter keyaDefault- value returned if the parameter is not set or not a string- Returns:
- the string value from the in parameters, or
aDefault
-
getAllStringInParameters
Returns all string in parameters, whose keys start with a given prefix.- Parameters:
aKeyPrefix- prefix the "wanted" parameters must start withaElimKeyPrefix- iffalsethe keys of the found parameters are used unchanged for the returned map. Iftruethe prefix is eliminated for the use in the destination map.- Returns:
- an empty map, when
aKeyPrefixisnull
-
getStringInParameter
-
setOutParameter
-
setInParameterMap
protected void setInParameterMap(net.simplace.core.FWObservable aObservable) - Parameters:
aObservable- the new in parameters
-
getOutParameter
-
getOutParameterKeys
-
removeOutParameter
Removes a parameter from the outgoing observable.- Parameters:
aElement- parameter key
-
pipe
public net.simplace.core.FWObservable pipe(net.simplace.core.FWObservable aObservabe, Integer aAllreadyLoopedCount) throws PipeLineException Pipes the observable through this processor: builds the in parameters (copy ofaObservabeplus initial parameters), evaluates the if-expression (if false, the observable is returned unchanged), performs the channel replacements, checks the input, runsprocess()and checks the output. Progress task states are updated along the way.- Parameters:
aObservabe- the incoming observable; also used as outgoing observableaAllreadyLoopedCount- number of loops already run; the processor's loop count is set to this value + 1- Returns:
- the outgoing observable
- Throws:
PipeLineException- if the input check, processing or output check fails
-
getConfiguration
protected org.jdom2.Element getConfiguration()Returns the configuration of the processor. A configuration passed as in parameterCONFIGURATION_<class name>(orCONFIGURATION_<progress id>) replaces the one from theconfigurationelement.- Returns:
- the configuration element, or
null
-
setConfiguration
Passes a configuration to a following processor as out parameterCONFIGURATION_<class name>.- Parameters:
aClassname- class name (or progress id) of the target processoraConfigurationElement- the configuration element
-
hasConfiguration
protected boolean hasConfiguration()- Returns:
trueif the processor has a configuration element
-
fireTaskEvent
Fires a task event for the current progress task to the listeners of the container (does nothing if the processor has no progress task).- Parameters:
aSourcePanel- panel to show in the progress view, ornull
-
getNewProgressTask
Adds a clone of the first progress task (for a further loop). Synchronized on the task list, which is shared with the clones of this processor (seeclone()).- Returns:
- the new progress task, or
nullif the processor has no progress task
-
getProgressTask
- Returns:
- the progress task for the current loop count, or
nullif there is none
-
getPipeLine
- Parameters:
aPipeLineID- id of the pipeline- Returns:
- a clone of the pipeline from the container (see
FWPipeLinesContainer.getPipeLine(String))
-
getSystemID
- Returns:
- the system id of the pipeline container, or of the in parameters if there is no container
-
setStateProgressing
Sets the current progress task to progressing and fires a task event (does nothing without progress task).- Parameters:
aPercentDone- progress in percent (0-100)aMessage- message to show
-
setStateOfTask
Sets the state of the current progress task and fires a task event (does nothing without progress task).- Parameters:
aStatusOfTask- the new state, one of the constants inFWProgressTask.State
-
setLoopedCount
protected void setLoopedCount(int aNumberOfAllreadyLooped) Sets the loop count; has to be set by the looping processor because of thread safety.- Parameters:
aNumberOfAllreadyLooped- number of loops already run
-
toXML
public org.jdom2.Element toXML()- Returns:
- an XML description of the processor; not implemented, always
null
-