# Copyright (C) 2005  Joshua Hoblitt
#
# $Id: MetaDB.pm,v 1.1.1.1 2005-09-28 01:21:27 jhoblitt Exp $

package PS::IPP::MetaDB;

use strict;
use warnings FATAL => qw( all );

use vars qw( $VERSION ); 
$VERSION = '0.01';

use base qw( Class::DBI::mysql );

__PACKAGE__->set_db('Main', 'dbi:mysql:test', 'test', '');

#package PS::IPP::MetaDB::Image::Prepared;
#package PS::IPP::MetaDB::Image::Reduced;
#package PS::IPP::MetaDB::Image::Analyzed;
#package PS::IPP::MetaDB::Image::Combined;

=pod

=head2 Temporal Queues

These queues all describe work that I<needs> to be performed but hasn't
happened yet.

=over 4

=item * new

This table contains a list of new data waiting to be downloaded from the
summit.  The location of fetched data files is written into the C<newed> table.

Table description:

=over 4

=item * url

URL to retrieve data from

=item * exp_id

exposure ID #

=item * camera

Camera that this data was acquired from

=item * class

The 'type' of data this is

=item * class_id

A unique identifier for data of the same class in the same exposure.

=back

=cut

package PS::IPP::MetaDB::Image::New;

use base qw( PS::IPP::MetaDB );

__PACKAGE__->table("new");
__PACKAGE__->create_table(q{
    exp_id      BIGINT          NOT NULL PRIMARY KEY,
    class_id    BIGINT          NOT NULL,
    camera      VARCHAR(255),
    class       VARCHAR(255),
    url         VARCHAR(255)    NOT NULL
});
__PACKAGE__->set_up_table;

=item * raw

Phase 0.  A list of exposure IDs to extract metadata from.

=over 4

=item * exp_id

exposure ID #, keyed against the C<newed> table.

=item * class_id

Class ID #, keyed against the C<newed> table.

=back

=cut

package PS::IPP::MetaDB::Image::Raw;

use base qw( PS::IPP::MetaDB );

__PACKAGE__->table("raw");
__PACKAGE__->create_table(q{
    exp_id      BIGINT          NOT NULL PRIMARY KEY,
    class_id    BIGINT          NOT NULL 
});
__PACKAGE__->set_up_table;

=item * prepare

Phase 1: A list of exposure IDs to extra metadata from.

=over 4

=item * exp_id

exposure ID #, keyed against the C<newed> table.

=item * exp_config

Class ID #, keyed against the C<exposure_config> table.

=back

=item * reduce

Phase 2: A list of exposure components to reduce.

=over 4

=item * exp_id

exposure ID #, keyed against the C<prepared> table.

=item * class_id

class ID #, keyed against the C<prepared> table.

=item * prepared_ver

version #, keyed against the C<prepared> table.

=item * dest_ver

version # to be written into the C<reduced> table.

=back

=item * mosaic

Phase 3: A list of exposures to process.

=over 4

=item * exp_id

exposure ID #, keyed against the C<reduced> table.

=item * exp_config

Class ID #, keyed against the C<exposure_config> table.

=back

=item * combine

=over 4

=item * run_id???

=back

=back

=head2 Metadata

These tables describe data in other tables.

=over 4

=item * exposure

A list of ALL exposure ID #s.

=over 4

=item * exp_id

exposure ID #.

=item * camera

Name of the camera the generated the exposure.

=item * type

The type of exposure taken.

=item * n_components

The number of file that make of the complete exposure.

=back

=item * exposure_component

A list of the files that together make up a complete exposure.

=over 4

=item * exp_id

exposure ID #, keyed against the C<exposure> table.

=item * class_id

class ID #.

=item * class

The type of component this is

=back

=item * exposure_config

This table provides a way to configure which 'version' of components of an
'exposure' to use.

=over 4

=item * exp_config

exposure config ID #.

=item * class_id

class ID #, keyed against the C<exposure_component> table.

=item * version

version ID #, keyed against the C<exposure_component> table.

=item * n_components

=back

=item * exposure_reduced

A list of version ID #'s assigned after reducing data.  This table is used to
make sure that all components of an exposure get the same version ID assigned
to them.

=over 4

=item * exp_id

exposure ID #, keyed on the C<exposure> table.

=item * reduced_version

Version ID # used.

=back

=back

=head2 File Storage

These tables describe data actually stored on disk.

=over 4

=item * newed

Note that there is only one 'version' of the original data.

=over 4

=item * exp_id

exposure ID #, keyed on the C<exposure_component> table.

=item * class_id

class ID #, keyed on the C<exposure_componet> table.

=item * url

url to the storage location of the file.

=back

=cut

package PS::IPP::MetaDB::Image::Newed;

use base qw( PS::IPP::MetaDB );

__PACKAGE__->table("newed");
__PACKAGE__->create_table(q{
    exp_id      BIGINT          NOT NULL PRIMARY KEY,
    class_id    BIGINT          NOT NULL,
    url         VARCHAR(255)    NOT NULL
});
__PACKAGE__->set_up_table;

=item * prepared

Data that has been through Phase: 0.

=over 4

=item * exp_id

exposure ID #, keyed on the C<exposure_component> table.

=item * class_id

class ID #, keyed on the C<exposure_componet> table.

=item * version

version ID #

=item * recipe

algorithm ID #

=item * url

url to the storage location of the file.

=back

=item * reduced

Data that's been through Phase: 2.

=over 4

=item * exp_id

exposure ID #, keyed on the C<exposure_component> table.

=item * class_id

class ID #, keyed on the C<exposure_componet> table.

=item * version

version ID #

=item * recipe

algorithm ID #

=item * url

url to the storage location of the file.

=back

=item * mosaiced

???

=item * combined

???

=back

=cut

1;

__END__
