Package adams.db
Class ReportTableByID<R extends Report & IDHandler,F extends AbstractField>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.generic.SQL
-
- adams.db.AbstractTable
-
- adams.db.AbstractIndexedTable
-
- adams.db.ReportTableByID<R,F>
-
- Type Parameters:
R
- the type of reports to handleF
- the type of fields to handle
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,DatabaseConnectionProvider
,DatabaseConnectionUser
,FieldProvider<F>
,ReportProvider<R,String>
,ReportProviderByID<R>
,SQLIntf
,TableInterface
,DatabaseConnectionChangeListener
,Serializable
public abstract class ReportTableByID<R extends Report & IDHandler,F extends AbstractField> extends AbstractIndexedTable implements FieldProvider<F>, ReportProviderByID<R>
Abstract ancestor for classes that provide access to reports stored in tables.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.db.AbstractIndexedTable
m_init
-
Fields inherited from class adams.db.AbstractTable
FILENAME, m_AnsiQuotes, m_Properties, m_TableName
-
Fields inherited from class adams.db.generic.SQL
m_DatabaseConnection, m_Debug, m_TableManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.db.SQLIntf
FAKE_TABLE_NAME
-
-
Constructor Summary
Constructors Constructor Description ReportTableByID(AbstractDatabaseConnection dbcon, String tableName)
Initializes the table class with the given table name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Field
createField(String name, String type)
Creates a new Field object.protected abstract boolean
doStore(String id, R report)
Stores the report.List<F>
getFields()
Returns all available fields.protected Object
parse(AbstractField field, String s)
Parses the given string according to the given field's type.boolean
remove(String id)
Removes the quantitation report from the database.boolean
remove(String id, AbstractField field)
Removes the report field from the database.boolean
remove(R report)
Removes the report from the database.boolean
store(String id, R report)
Stores the report.boolean
store(String id, R report, boolean removeExisting, boolean merge, Field[] overwrite)
Stores the report.-
Methods inherited from class adams.db.AbstractIndexedTable
columnsMatch, columnsMatchTest, create, getAllColumns, getColumnMapping, getIndices, getTables, init, initTables, isThere, postCreate, select, select, selectDistinct, selectDistinct, truncate, update
-
Methods inherited from class adams.db.AbstractTable
columnExists, databaseConnectionStateChanged, getProperties, getTableName, isEnabled, quoteName, tableExists, toString, useAnsiQuotes
-
Methods inherited from class adams.db.generic.SQL
columnExists, doSelect, drop, execute, executeGeneratedKeys, getDatabaseConnection, getDebug, getMaxColumnNameLength, getResultSet, getSimpleResultSet, prepareStatement, prepareStatement, prepareStatement, select, selectDistinct, selectDouble, selectInt, selectLong, selectString, selectStrings, setDebug, singleton, tableExists, truncate, update, updatePrefix, updateTableName
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.db.DatabaseConnectionProvider
getDatabaseConnection
-
Methods inherited from interface adams.db.FieldProvider
getFields
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
-
-
-
Constructor Detail
-
ReportTableByID
public ReportTableByID(AbstractDatabaseConnection dbcon, String tableName)
Initializes the table class with the given table name.- Parameters:
dbcon
- the database context this table is used intableName
- the name of the table
-
-
Method Detail
-
createField
protected Field createField(String name, String type) throws Exception
Creates a new Field object.- Parameters:
name
- the name of the fieldtype
- the type of the field- Returns:
- the generated field
- Throws:
Exception
- if the field type is not handled
-
parse
protected Object parse(AbstractField field, String s)
Parses the given string according to the given field's type.- Parameters:
field
- the field that specifies the types
- the value to parse- Returns:
- the parsed value
-
getFields
public List<F> getFields()
Returns all available fields.- Specified by:
getFields
in interfaceFieldProvider<R extends Report & IDHandler>
- Returns:
- the list of fields
-
remove
public boolean remove(R report)
Removes the report from the database.- Parameters:
report
- the report to delete (and obtain the parent ID from)- Returns:
- true if successfully removed
-
remove
public boolean remove(String id)
Removes the quantitation report from the database.- Specified by:
remove
in interfaceReportProvider<R extends Report & IDHandler,F extends AbstractField>
- Specified by:
remove
in interfaceReportProviderByID<R extends Report & IDHandler>
- Parameters:
id
- ID of chromatogram- Returns:
- true if successfully removed
-
remove
public boolean remove(String id, AbstractField field)
Removes the report field from the database.- Specified by:
remove
in interfaceReportProviderByID<R extends Report & IDHandler>
- Parameters:
id
- the ID of the parent data containerfield
- the field to remove- Returns:
- true if successfully removed
-
store
public boolean store(String id, R report)
Stores the report. Always removes an already existing report first.- Specified by:
store
in interfaceReportProvider<R extends Report & IDHandler,F extends AbstractField>
- Specified by:
store
in interfaceReportProviderByID<R extends Report & IDHandler>
- Parameters:
id
- the id of the reportreport
- the report- Returns:
- true if successfully inserted
-
store
public boolean store(String id, R report, boolean removeExisting, boolean merge, Field[] overwrite)
Stores the report. Report can be merged with already existing one or the existing one can be removed from the database first.- Specified by:
store
in interfaceReportProvider<R extends Report & IDHandler,F extends AbstractField>
- Specified by:
store
in interfaceReportProviderByID<R extends Report & IDHandler>
- Parameters:
id
- the id of the reportreport
- the reportremoveExisting
- whether to remove existing an already existing report before storing it (has precedence over "merge")merge
- whether to merge the existing and the currentoverwrite
- fields to overwrite if in "merge" mode- Returns:
- true if successfully inserted/updated
-
-