Package adams.db
Class SampleDataF
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.AbstractTableFacade
-
- adams.db.SampleDataF
-
- All Implemented Interfaces:
adams.core.logging.LoggingSupporter,adams.core.SizeOfHandler,adams.db.BulkReportUpdater<SampleData>,adams.db.DatabaseConnectionProvider,adams.db.DatabaseConnectionUser,adams.db.FieldProvider<adams.data.report.Field>,adams.db.InstrumentProvider,adams.db.ReportProvider<SampleData,String>,adams.db.ReportProviderByID<SampleData>,SampleDataIntf,adams.db.TableInterface,Serializable
public class SampleDataF extends adams.db.AbstractTableFacade implements SampleDataIntf
Facade for sample data.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected SampleDataIntfm_DBthe backend.protected static adams.db.FacadeManager<SampleDataF>m_TableManagerthe facade manager.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.db.SampleDataIntf
TABLE_NAME
-
-
Constructor Summary
Constructors Constructor Description SampleDataF(adams.db.AbstractDatabaseConnection dbcon, String tableName)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbulkStore(SampleData[] records, adams.data.report.DataType[] types, String skipFields, int batchSize, boolean autoCommit, boolean newConnection)Stores the records.booleanexists(String id)Checks whether the report exists in the database.List<Integer>getDBIDs(adams.db.AbstractConditions conditions)Return a list of database IDs of data containers that match the defined conditions.List<adams.data.report.Field>getFields()Returns all available fields.List<adams.data.report.Field>getFields(adams.data.report.DataType dtype)Returns all available fields.List<String>getIDs(adams.db.AbstractConditions cond)Return a list of IDs of spectra that match the defined conditions.List<String>getIDs(String[] columns, adams.db.AbstractConditions cond)Return a list of IDs of spectra that match the defined conditions.List<String>getInstruments()Returns all the various instruments.List<String>getOrphanedIDs(OrphanedSampleDataConditions conditions)Returns a list of sample IDs of of sample data without associated spectra.static SampleDataFgetSingleton(adams.db.AbstractDatabaseConnection dbcon)Returns the singleton of the facade.SpectrumIntfgetSpectrumHandler()Returns the corresponding Spectrum handler.booleaninit()Initialise table & sub-tables.SampleDataload(String id)Get params.booleanremove(String id)Removes the report from the database.booleanremove(String id, adams.data.report.AbstractField field)Removes the report field from the database.voidstopBulkStore()Interrupts a currently running bulk store, if possible.booleanstore(String id, SampleData report)Stores the report.booleanstore(String id, SampleData report, boolean removeExisting, boolean merge, adams.data.report.Field[] overwrite)Stores the report.-
Methods inherited from class adams.db.AbstractTableFacade
getDatabaseConnection, getDebug, getTableName, reload, setDebug, updatePrefix
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_TableManager
protected static adams.db.FacadeManager<SampleDataF> m_TableManager
the facade manager.
-
m_DB
protected SampleDataIntf m_DB
the backend.
-
-
Constructor Detail
-
SampleDataF
public SampleDataF(adams.db.AbstractDatabaseConnection dbcon, String tableName)Constructor.- Parameters:
dbcon- the database context to usetableName- the name of the table
-
-
Method Detail
-
getSpectrumHandler
public SpectrumIntf getSpectrumHandler()
Returns the corresponding Spectrum handler.- Specified by:
getSpectrumHandlerin interfaceSampleDataIntf- Returns:
- the corresponding handler
-
init
public boolean init()
Initialise table & sub-tables.- Specified by:
initin interfaceSampleDataIntf- Returns:
- success?
-
getFields
public List<adams.data.report.Field> getFields()
Returns all available fields.- Specified by:
getFieldsin interfaceadams.db.FieldProvider<adams.data.report.Field>- Returns:
- the list of fields
-
getFields
public List<adams.data.report.Field> getFields(adams.data.report.DataType dtype)
Returns all available fields.- Specified by:
getFieldsin interfaceadams.db.FieldProvider<adams.data.report.Field>- Specified by:
getFieldsin interfaceSampleDataIntf- Parameters:
dtype- the type to limit the search to, use "null" for all- Returns:
- the list of fields
-
exists
public boolean exists(String id)
Checks whether the report exists in the database.- Specified by:
existsin interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
existsin interfaceadams.db.ReportProviderByID<SampleData>- Specified by:
existsin interfaceSampleDataIntf- Parameters:
id- the ID of parent data container- Returns:
- true if the report exists
-
remove
public boolean remove(String id)
Removes the report from the database.- Specified by:
removein interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
removein interfaceadams.db.ReportProviderByID<SampleData>- Parameters:
id- the ID of the parent data container- Returns:
- true if successfully removed
-
remove
public boolean remove(String id, adams.data.report.AbstractField field)
Removes the report field from the database.- Specified by:
removein interfaceadams.db.ReportProviderByID<SampleData>- Parameters:
id- the ID of the parent data containerfield- the field to remove- Returns:
- true if successfully removed
-
store
public boolean store(String id, SampleData report)
Stores the report. Removes a previously existing report.- Specified by:
storein interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
storein interfaceadams.db.ReportProviderByID<SampleData>- Parameters:
id- the id of the reportreport- the report- Returns:
- true if successfully inserted/updated
-
store
public boolean store(String id, SampleData report, boolean removeExisting, boolean merge, adams.data.report.Field[] overwrite)
Stores the report. Either updates or inserts the fields.- Specified by:
storein interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
storein interfaceadams.db.ReportProviderByID<SampleData>- 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
-
load
public SampleData load(String id)
Get params.- Specified by:
loadin interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
loadin interfaceadams.db.ReportProviderByID<SampleData>- Specified by:
loadin interfaceSampleDataIntf- Parameters:
id- sample ID of spectrum- Returns:
- the hashtable
-
getIDs
public List<String> getIDs(adams.db.AbstractConditions cond)
Return a list of IDs of spectra that match the defined conditions. Since the alphanumeric IDs can be of numeric nature as well, we're returning them surrounded with double quotes to avoid them being interpreted as database IDs.- Specified by:
getIDsin interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
getIDsin interfaceadams.db.ReportProviderByID<SampleData>- Specified by:
getIDsin interfaceSampleDataIntf- Parameters:
cond- the conditions that the spectra must meet- Returns:
- list of spectrum ids
-
getIDs
public List<String> getIDs(String[] columns, adams.db.AbstractConditions cond)
Return a list of IDs of spectra that match the defined conditions. Since the alphanumeric IDs can be of numeric nature as well, we're returning them surrounded with double quotes to avoid them being interpreted as database IDs. If several columns are specified, then the result contains them tab-separated.- Specified by:
getIDsin interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
getIDsin interfaceadams.db.ReportProviderByID<SampleData>- Specified by:
getIDsin interfaceSampleDataIntf- Parameters:
columns- the columns to retrieve ("sp." for spectrum table, "sd." for sampledata table)cond- the conditions that the spectra must meet- Returns:
- list of spectrum ids
-
getDBIDs
public List<Integer> getDBIDs(adams.db.AbstractConditions conditions)
Return a list of database IDs of data containers that match the defined conditions.- Specified by:
getDBIDsin interfaceadams.db.ReportProvider<SampleData,String>- Specified by:
getDBIDsin interfaceadams.db.ReportProviderByID<SampleData>- Specified by:
getDBIDsin interfaceSampleDataIntf- Parameters:
conditions- the conditions that the conatiners must meet- Returns:
- list of database IDs
-
getOrphanedIDs
public List<String> getOrphanedIDs(OrphanedSampleDataConditions conditions)
Returns a list of sample IDs of of sample data without associated spectra.- Specified by:
getOrphanedIDsin interfaceSampleDataIntf- Parameters:
conditions- the conditions that the sampledata must meet- Returns:
- list of sample IDs
-
getInstruments
public List<String> getInstruments()
Returns all the various instruments.- Specified by:
getInstrumentsin interfaceadams.db.InstrumentProvider- Specified by:
getInstrumentsin interfaceSampleDataIntf- Returns:
- the instruments
-
bulkStore
public boolean bulkStore(SampleData[] records, adams.data.report.DataType[] types, String skipFields, int batchSize, boolean autoCommit, boolean newConnection)
Stores the records. Removes any previously existing reference values.- Specified by:
bulkStorein interfaceadams.db.BulkReportUpdater<SampleData>- Parameters:
records- the reporttypes- the data types to importskipFields- the fields to skip (regular expression), null to accept allbatchSize- the maximum number of records in one batchautoCommit- whether to use auto-commit or not (turning off may impact other transactions!)newConnection- uses a separate database connection just for this connection (then no auto-commit doesn't affect the rest)- Returns:
- true if successfully inserted/updated
-
stopBulkStore
public void stopBulkStore()
Interrupts a currently running bulk store, if possible.- Specified by:
stopBulkStorein interfaceadams.db.BulkReportUpdater<SampleData>
-
getSingleton
public static SampleDataF getSingleton(adams.db.AbstractDatabaseConnection dbcon)
Returns the singleton of the facade.- Parameters:
dbcon- the database connection to get the singleton for- Returns:
- the singleton
-
-