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)
    • 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 interface adams.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. Uses SampleData.DEFAULT_FORMAT as format.
        Specified by:
        exists in interface adams.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 interface adams.db.DataProvider<Spectrum>
        Parameters:
        auto_id - the database ID
        Returns:
        Spectrum, or null if not found
      • 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 ID
        format - 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 ID
        format - 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 ID
        rlike - regex for chrom name
        raw - 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 ID
        format - the format
        raw - 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 Uses SampleData.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 ID
        format - 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 names
        cond - 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 names
        where - the where clause, can be null
        cond - 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 names
        tables - the involved tables
        where - the where clause, can be null
        cond - 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 interface adams.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 Header
        storeWaveNo - 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 add
        storeWaveNo - whether to store the wave numbers as well
        batchSize - the maximum number of records in one batch
        autoCommit - 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. Uses SampleData.DEFAULT_FORMAT as format.
        Specified by:
        remove in interface adams.db.DataProvider<Spectrum>
        Parameters:
        sample_id - the sample ID of the spectrum
        keepReport - 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 spectrum
        format - 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 interface adams.db.DataProvider<Spectrum>
        Parameters:
        id - the ID of the spectrum to remove from the database
        keepReport - if true does not delete associated report
        Returns:
        true if no error