Package adams.flow.transformer
Class AbstractDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.core.AbstractActor
-
- adams.flow.transformer.AbstractTransformer
-
- adams.flow.transformer.AbstractDbTransformer
-
- adams.flow.transformer.AbstractDataContainerDbWriter<T>
-
- Type Parameters:
T
- the type of data to write to the database
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,DatabaseConnectionUser
,VariableChangeListener
,Actor
,ErrorHandler
,InputConsumer
,OutputProducer
,DataContainerDbWriter<T>
,Serializable
,Comparable
public abstract class AbstractDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler> extends AbstractDbTransformer implements DataContainerDbWriter<T>
Abstract ancestor for actors that import data containers into the database.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_KeepReport
whether to keep any existing report.protected boolean
m_OutputContainer
whether to output the container rather then the ID.protected boolean
m_OverwriteExisting
whether to replace existing containers with the new one (otherwise, nothing happens).protected AbstractDataContainerPreProcessor
m_PreProcessor
the pre-processor to apply to the data.-
Fields inherited from class adams.flow.transformer.AbstractDbTransformer
m_DatabaseConnection
-
Fields inherited from class adams.flow.transformer.AbstractTransformer
BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description AbstractDataContainerDbWriter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Class[]
accepts()
Returns the class that the consumer accepts.Integer
add(DataProvider provider, T cont)
Adds the container to the database.void
cleanUp()
Cleans up after the execution has finished.void
defineOptions()
Adds options to the internal list of options.boolean
exists(DataProvider provider, T cont)
Returns whether the container already exists in the database.abstract Class[]
generates()
Returns the class of objects that it generates.abstract DataProvider<T>
getDataProvider(T cont)
Returns the data provider to use for storing the container in the database.boolean
getKeepReport()
Returns whether to keep an existing report in the database.boolean
getOutputContainer()
Returns whether to output the container rather than the ID.boolean
getOverwriteExisting()
Returns whether to remove existing containers.AbstractDataContainerPreProcessor
getPreProcessor()
Returns the pre-processor in use.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
keepReportTipText()
Returns the tip text for this property.T
load(DataProvider provider, T cont)
Loads the container from the database.abstract String
outputContainerTipText()
Returns the tip text for this property.abstract String
overwriteExistingTipText()
Returns the tip text for this property.protected T
preProcess(T cont)
Performs preprocessing on the container.String
preProcessorTipText()
Returns the tip text for this property.protected String
queryDatabase()
Executes the flow item.boolean
remove(DataProvider provider, T cont)
Removes the container from the database.void
setKeepReport(boolean value)
Sets whether to keep an existing report in the database.void
setOutputContainer(boolean value)
Sets whether to output the container rather than the ID.void
setOverwriteExisting(boolean value)
Sets whether to remove existing containers.void
setPreProcessor(AbstractDataContainerPreProcessor value)
Sets the pre-processor to apply to the data.protected Integer
store(T cont)
Stores the data container.-
Methods inherited from class adams.flow.transformer.AbstractDbTransformer
doExecute, getDatabaseConnection, getDefaultDatabaseConnection, initialize, setUpDatabaseConnection, wrapUp
-
Methods inherited from class adams.flow.transformer.AbstractTransformer
backupState, currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, restoreState
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged, wrapUp
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
m_PreProcessor
protected AbstractDataContainerPreProcessor m_PreProcessor
the pre-processor to apply to the data.
-
m_OverwriteExisting
protected boolean m_OverwriteExisting
whether to replace existing containers with the new one (otherwise, nothing happens).
-
m_KeepReport
protected boolean m_KeepReport
whether to keep any existing report.
-
m_OutputContainer
protected boolean m_OutputContainer
whether to output the container rather then the ID.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
setPreProcessor
public void setPreProcessor(AbstractDataContainerPreProcessor value)
Sets the pre-processor to apply to the data.- Parameters:
value
- the pre-processor
-
getPreProcessor
public AbstractDataContainerPreProcessor getPreProcessor()
Returns the pre-processor in use.- Returns:
- the pre-processor
-
preProcessorTipText
public String preProcessorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOverwriteExisting
public void setOverwriteExisting(boolean value)
Sets whether to remove existing containers.- Parameters:
value
- true if to remove existing containers
-
getOverwriteExisting
public boolean getOverwriteExisting()
Returns whether to remove existing containers.- Returns:
- true if to remove existing containers
-
overwriteExistingTipText
public abstract String overwriteExistingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setKeepReport
public void setKeepReport(boolean value)
Sets whether to keep an existing report in the database.- Parameters:
value
- true if to keep
-
getKeepReport
public boolean getKeepReport()
Returns whether to keep an existing report in the database.- Returns:
- true if keep
-
keepReportTipText
public String keepReportTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOutputContainer
public void setOutputContainer(boolean value)
Sets whether to output the container rather than the ID.- Parameters:
value
- true if to output the container
-
getOutputContainer
public boolean getOutputContainer()
Returns whether to output the container rather than the ID.- Returns:
- true if to output the container
-
outputContainerTipText
public abstract String outputContainerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
accepts
public abstract Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
accepts
in interfaceInputConsumer
- Returns:
- the type of data to store
-
generates
public abstract Class[] generates()
Returns the class of objects that it generates.- Specified by:
generates
in interfaceOutputProducer
- Returns:
- the classes
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
getDataProvider
public abstract DataProvider<T> getDataProvider(T cont)
Returns the data provider to use for storing the container in the database.- Specified by:
getDataProvider
in interfaceDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- Parameters:
cont
- the current container- Returns:
- the data provider
-
exists
public boolean exists(DataProvider provider, T cont)
Returns whether the container already exists in the database.- Specified by:
exists
in interfaceDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- Parameters:
provider
- the provider to use for checkingcont
- the container to look for- Returns:
- true if already stored in database
-
remove
public boolean remove(DataProvider provider, T cont)
Removes the container from the database.- Specified by:
remove
in interfaceDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- Parameters:
provider
- the provider to use for removingcont
- the container to remove- Returns:
- true if successfully removed
-
add
public Integer add(DataProvider provider, T cont)
Adds the container to the database.- Specified by:
add
in interfaceDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- Parameters:
provider
- the provider to usecont
- the container to store- Returns:
- the database ID,
Constants.NO_ID
if failed
-
load
public T load(DataProvider provider, T cont)
Loads the container from the database.- Specified by:
load
in interfaceDataContainerDbWriter<T extends DataContainer & DatabaseIDHandler>
- Parameters:
provider
- the provider to usecont
- the container to store- Returns:
- the container, null if failed to load
-
store
protected Integer store(T cont)
Stores the data container.- Parameters:
cont
- the container- Returns:
- the database ID, null in case of error
-
preProcess
protected T preProcess(T cont)
Performs preprocessing on the container.- Parameters:
cont
- the container to preprocess- Returns:
- the processed container
-
queryDatabase
protected String queryDatabase()
Executes the flow item.- Specified by:
queryDatabase
in classAbstractDbTransformer
- Returns:
- null if everything is fine, otherwise error message
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUp
in interfaceActor
- Specified by:
cleanUp
in interfaceCleanUpHandler
- Overrides:
cleanUp
in classAbstractActor
-
-