Package adams.db
Interface SpectrumIntf
-
- All Superinterfaces:
adams.db.DatabaseConnectionProvider
,adams.db.DatabaseConnectionUser
,adams.db.DataProvider<Spectrum>
,adams.db.TableInterface
- All Known Implementing Classes:
SpectrumF
,SpectrumT
,SpectrumT
,SpectrumT
,SpectrumT
,SpectrumT
,SpectrumT
,SpectrumT
public interface SpectrumIntf extends adams.db.TableInterface, adams.db.DataProvider<Spectrum>
Interface for spectrum tables.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
MAX_NUM_SPECTRUMS_CACHED
static String
TABLE_NAME
the table names.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Integer
add(Spectrum sp)
Adds a spectrum to the database.Integer
add(Spectrum sp, boolean storeWaveNo)
Adds a spectrum to the database.boolean
bulkAdd(Spectrum[] sp, boolean storeWaveNo, int batchSize, boolean autoCommit, boolean newConnection)
Stores the spectra in the database.boolean
exists(int id)
Checks whether the container exists in the database.boolean
exists(String id)
Checks whether the container exists in the database.boolean
exists(String id, String format)
Checks whether the container exists in the database.int
getDatabaseID(String id)
Returns the database ID for given spectrum ID.int
getDatabaseID(String sample_id, String format)
Returns the database ID for given sample ID and type.SampleDataIntf
getSampleDataHandler()
Returns the corresponding SampleData handler.List<String>
getValues(String[] fields, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.List<String>
getValues(String[] fields, String where, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.List<String>
getValues(String[] fields, String tables, String where, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.boolean
init()
Initialise table & sub-tables.Spectrum
load(int auto_id)
Load a spectrum with given database ID.Spectrum
load(String id)
Load a spectrum with given ID.Spectrum
load(String sample_id, String format)
Load a spectrum with given sample ID and type.Spectrum
loadFromDB(int auto_id, String rlike, boolean raw)
Load a spectrum from DB with given auto_id.Spectrum
loadFromDB(String sample_id, String format, boolean raw)
Load a spectrum from DB with given sample_id and format.Spectrum
loadRaw(int auto_id)
Load a data container with given auto_id, without passing it through the global filter.Spectrum
loadRaw(String sample_id, String format)
Load a spectrum with given sample ID and type, without filtering through the global container filter.boolean
remove(int id, boolean keepReport)
Removes the spectrum and its sample data.boolean
remove(String sample_id, boolean keepReport)
Removes the spectrum and its sample data.boolean
remove(String sample_id, String format, boolean keepReport)
Removes the spectrum and its sample data.void
stopBulkAdd()
Interrupts a currently running bulk store, if possible.
-
-
-
Field Detail
-
TABLE_NAME
static final String TABLE_NAME
the table names.- See Also:
- Constant Field Values
-
MAX_NUM_SPECTRUMS_CACHED
static final String MAX_NUM_SPECTRUMS_CACHED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSampleDataHandler
SampleDataIntf getSampleDataHandler()
Returns the corresponding SampleData handler.- Returns:
- the corresponding handler
-
init
boolean init()
Initialise table & sub-tables.- Returns:
- success?
-
exists
boolean exists(int id)
Checks whether the container exists in the database.- Specified by:
exists
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
id
- the database ID of the data container- Returns:
- true if the container exists
-
exists
boolean exists(String id)
Checks whether the container exists in the database. UsesSampleData.DEFAULT_FORMAT
as format.- Specified by:
exists
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
id
- the ID of the data container- Returns:
- true if the container exists
- See Also:
exists(String, String)
-
exists
boolean exists(String id, String format)
Checks whether the container exists in the database.- Parameters:
id
- the ID of the data container- Returns:
- true if the container exists
-
load
Spectrum load(int auto_id)
Load a spectrum with given database ID. Get from cache if available- Specified by:
load
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
auto_id
- the database ID- Returns:
- Spectrum, or null if not found
-
load
Spectrum load(String id)
Load a spectrum with given ID. Get from cache if available UsesSampleData.DEFAULT_FORMAT
as format.- Specified by:
load
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
id
- the ID- Returns:
- Spectrum, or null if not found
- See Also:
load(String, String)
-
load
Spectrum load(String sample_id, String format)
Load a spectrum with given sample ID and type. Get from cache if available- Parameters:
sample_id
- the sample IDformat
- the format- Returns:
- Spectrum, or null if not found
-
loadRaw
Spectrum loadRaw(int auto_id)
Load a data container with given auto_id, without passing it through the global filter.- Parameters:
auto_id
- the databae ID- Returns:
- the data container, or null if not found
-
loadRaw
Spectrum loadRaw(String sample_id, String format)
Load a spectrum with given sample ID and type, without filtering through the global container filter.- Parameters:
sample_id
- the sample IDformat
- the format- Returns:
- Spectrum, or null if not found
-
loadFromDB
Spectrum loadFromDB(int auto_id, String rlike, boolean raw)
Load a spectrum from DB with given auto_id.- Parameters:
auto_id
- the databae IDrlike
- regex for chrom nameraw
- whether to return the raw spectrum or filter it through the global container filter- Returns:
- Spectrum, or null if not found
-
loadFromDB
Spectrum loadFromDB(String sample_id, String format, boolean raw)
Load a spectrum from DB with given sample_id and format.- Parameters:
sample_id
- the sample IDformat
- the formatraw
- whether to return the raw spectrum or filter it through the global container filter- Returns:
- Spectrum, or null if not found
-
getDatabaseID
int getDatabaseID(String id)
Returns the database ID for given spectrum ID. Get from cache if available UsesSampleData.DEFAULT_FORMAT
as format.- Parameters:
id
- the ID- Returns:
- Spectrum, or null if not found
- See Also:
load(String, String)
-
getDatabaseID
int getDatabaseID(String sample_id, String format)
Returns the database ID for given sample ID and type. Get from cache if available- Parameters:
sample_id
- the sample IDformat
- the format- Returns:
- the database ID,
Constants.NO_ID
-
getValues
List<String> getValues(String[] fields, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.- Parameters:
fields
- the field namescond
- the conditions for the retrieval- Returns:
- list of tab-separated values
-
getValues
List<String> getValues(String[] fields, String where, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.- Parameters:
fields
- the field nameswhere
- the where clause, can be nullcond
- the conditions for the retrieval- Returns:
- list of tab-separated values
-
getValues
List<String> getValues(String[] fields, String tables, String where, SpectrumIDConditions cond)
returns all the specified fields in the database, separated by TABs.- Parameters:
fields
- the field namestables
- the involved tableswhere
- the where clause, can be nullcond
- the conditions for the retrieval- Returns:
- list of tab-separated values
-
add
Integer add(Spectrum sp)
Adds a spectrum to the database. Returns the created auto-id, and sets in Spectrum. Wave numbers get stored.- Specified by:
add
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
sp
- spectrum Header- Returns:
- new ID, or null if fail
-
add
Integer add(Spectrum sp, boolean storeWaveNo)
Adds a spectrum to the database. Returns the created auto-id, and sets in Spectrum.- Parameters:
sp
- spectrum HeaderstoreWaveNo
- whether to store the wave numbers as well- Returns:
- new ID, or null if fail
-
bulkAdd
boolean bulkAdd(Spectrum[] sp, boolean storeWaveNo, int batchSize, boolean autoCommit, boolean newConnection)
Stores the spectra in the database.- Parameters:
sp
- the spectra to addstoreWaveNo
- whether to store the wave numbers as wellbatchSize
- 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
-
stopBulkAdd
void stopBulkAdd()
Interrupts a currently running bulk store, if possible.
-
remove
boolean remove(String sample_id, boolean keepReport)
Removes the spectrum and its sample data. UsesSampleData.DEFAULT_FORMAT
as format.- Specified by:
remove
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
sample_id
- the sample ID of the spectrumkeepReport
- if true does not delete associated report- Returns:
- true if no error
- See Also:
remove(String, String, boolean)
-
remove
boolean remove(String sample_id, String format, boolean keepReport)
Removes the spectrum and its sample data.- Parameters:
sample_id
- the sample ID of the spectrumformat
- the format of the spectrum (eg NIR)keepReport
- if true does not delete associated report- Returns:
- true if no error
-
remove
boolean remove(int id, boolean keepReport)
Removes the spectrum and its sample data.- Specified by:
remove
in interfaceadams.db.DataProvider<Spectrum>
- Parameters:
id
- the ID of the spectrum to remove from the databasekeepReport
- if true does not delete associated report- Returns:
- true if no error
-
-