Package adams.flow.transformer
Class AbstractDataContainerFileImport<T extends DataContainer>
- 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.AbstractDataProcessor
-
- adams.flow.transformer.AbstractDbDataProcessor
-
- adams.flow.transformer.AbstractDataContainerFileImport<T>
-
- Type Parameters:
T
- the type of data that is imported
- All Implemented Interfaces:
AdditionalInformationHandler
,AtomicMoveSupporter
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,DatabaseConnectionUser
,VariableChangeListener
,Actor
,ErrorHandler
,InputConsumer
,OutputProducer
,Serializable
,Comparable
public abstract class AbstractDataContainerFileImport<T extends DataContainer> extends AbstractDbDataProcessor
Abstract ancestor for actors that import data containers.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKUP_CONTAINERS
the key for storing the current containers in the backup.static String
BACKUP_IDS
the key for storing the current ids in the backup.protected List<T>
m_Containers
the containers that have been read.protected boolean
m_Forward
whether to forward the containers instead of the IDs.protected List<Integer>
m_IDs
the IDs of the containers that have been imported.protected boolean
m_Import
whether to import the containers into the database.protected AbstractDataContainerReader<T>
m_Reader
the reader to use for processing the containers.-
Fields inherited from class adams.flow.transformer.AbstractDbDataProcessor
m_DatabaseConnection
-
Fields inherited from class adams.flow.transformer.AbstractDataProcessor
m_AtomicMove, m_DestinationFile, m_Failed, m_Processed, m_ProcessError, m_Processing, m_TimestampDirFormat, m_UseTimestampDirs
-
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 AbstractDataContainerFileImport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.void
defineOptions()
Adds options to the internal list of options.String
forwardTipText()
Returns the tip text for this property.Class[]
generates()
Returns the class of objects that it generates.protected abstract Class
getDataContainerClass()
Returns the data container class in use.protected abstract DataProvider<T>
getDataProvider()
Returns the report provider to use for writing the reports to the database.protected abstract AbstractDataContainerReader<T>
getDefaultReader()
Returns the default reader for loading the data.boolean
getForward()
Returns whether to forward the containers or the IDs.boolean
getImport()
Returns whether to import the containers into the database.AbstractDataContainerReader
getReader()
Returns the reader in use.boolean
hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.String
importTipText()
Returns the tip text for this property.Token
output()
Returns the generated token.protected boolean
processData(File file)
Processes the given data.protected void
pruneBackup()
Removes entries from the backup.String
readerTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.void
setForward(boolean value)
Sets whether to forward the containers instead of the IDs.void
setImport(boolean value)
Sets whether to import the containers into the database.void
setReader(AbstractDataContainerReader value)
Sets the reader to use.protected String
setUpDatabaseConnection()
Configures the database connection if necessary.-
Methods inherited from class adams.flow.transformer.AbstractDbDataProcessor
doExecute, getDatabaseConnection, getDefaultDatabaseConnection, initialize, wrapUp
-
Methods inherited from class adams.flow.transformer.AbstractDataProcessor
accepts, atomicMoveTipText, failedTipText, getAtomicMove, getFailed, getProcessed, getProcessing, getUseTimestampDirs, nextTimestampDir, postProcessData, prepareData, processedTipText, processingTipText, setAtomicMove, setFailed, setProcessed, setProcessing, setUseTimestampDirs, useTimestampDirsTipText
-
Methods inherited from class adams.flow.transformer.AbstractTransformer
currentInput, execute, hasInput, input, postExecute
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, 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
cleanUp, compareTo, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, 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
-
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
-
BACKUP_IDS
public static final String BACKUP_IDS
the key for storing the current ids in the backup.- See Also:
- Constant Field Values
-
BACKUP_CONTAINERS
public static final String BACKUP_CONTAINERS
the key for storing the current containers in the backup.- See Also:
- Constant Field Values
-
m_Reader
protected AbstractDataContainerReader<T extends DataContainer> m_Reader
the reader to use for processing the containers.
-
m_Containers
protected List<T extends DataContainer> m_Containers
the containers that have been read.
-
m_Import
protected boolean m_Import
whether to import the containers into the database.
-
m_Forward
protected boolean m_Forward
whether to forward the containers instead of the IDs.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractDataProcessor
-
getDefaultReader
protected abstract AbstractDataContainerReader<T> getDefaultReader()
Returns the default reader for loading the data.- Returns:
- the default reader
-
setReader
public void setReader(AbstractDataContainerReader value)
Sets the reader to use.- Parameters:
value
- the reader
-
getReader
public AbstractDataContainerReader getReader()
Returns the reader in use.- Returns:
- the reader
-
readerTipText
public String readerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setForward
public void setForward(boolean value)
Sets whether to forward the containers instead of the IDs.- Parameters:
value
- if true then the containers are forwarded
-
getForward
public boolean getForward()
Returns whether to forward the containers or the IDs.- Returns:
- true if the containers are forwarded
-
forwardTipText
public String forwardTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setImport
public void setImport(boolean value)
Sets whether to import the containers into the database.- Parameters:
value
- if true then the containers are imported
-
getImport
public boolean getImport()
Returns whether to import the containers into the database.- Returns:
- true if the containers are imported
-
importTipText
public String importTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackup
in classAbstractActor
- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupState
in classAbstractTransformer
- Returns:
- the backup
- See Also:
AbstractActor.updateVariables()
,AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreState
in classAbstractTransformer
- Parameters:
state
- the backup of the state to restore from- See Also:
AbstractActor.updateVariables()
,AbstractActor.backupState()
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractActor
-
getDataProvider
protected abstract DataProvider<T> getDataProvider()
Returns the report provider to use for writing the reports to the database.- Returns:
- the provider to use
-
setUpDatabaseConnection
protected String setUpDatabaseConnection()
Configures the database connection if necessary.- Overrides:
setUpDatabaseConnection
in classAbstractDbDataProcessor
- Returns:
- null if successful, otherwise error message
-
processData
protected boolean processData(File file)
Processes the given data.- Specified by:
processData
in classAbstractDataProcessor
- Parameters:
file
- the file/dir to process- Returns:
- true if everything went alright
- See Also:
AbstractDataProcessor.m_ProcessError
-
getDataContainerClass
protected abstract Class getDataContainerClass()
Returns the data container class in use.- Returns:
- the class
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Returns:
- java.lang.Integer.class
-
output
public Token output()
Returns the generated token.- Specified by:
output
in interfaceOutputProducer
- Overrides:
output
in classAbstractTransformer
- Returns:
- the generated token
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.- Specified by:
hasPendingOutput
in interfaceOutputProducer
- Overrides:
hasPendingOutput
in classAbstractTransformer
- Returns:
- true if there is pending output
-
-