Index: /trunk/PS-IPP-MetaDB/lib/PS/IPP/MetaDB.pm
===================================================================
--- /trunk/PS-IPP-MetaDB/lib/PS/IPP/MetaDB.pm	(revision 6097)
+++ /trunk/PS-IPP-MetaDB/lib/PS/IPP/MetaDB.pm	(revision 6098)
@@ -1,5 +1,5 @@
 # Copyright (C) 2005  Joshua Hoblitt
 #
-# $Id: MetaDB.pm,v 1.13 2005-10-15 00:09:37 jhoblitt Exp $
+# $Id: MetaDB.pm,v 1.14 2006-01-21 02:39:05 jhoblitt Exp $
 
 package PS::IPP::MetaDB;
@@ -60,9 +60,9 @@
 }
 
-sub add_new {
+sub add_fetch {
     my $class = shift;
     my %p = @_;
 
-    PS::IPP::MetaDB::Image::New->create({
+    PS::IPP::MetaDB::Image::Fetch->create({
         exp_id      => $p{exp_id},
         class       => $p{class},
@@ -77,10 +77,10 @@
 }
 
-sub new_fields
+sub fetch_fields
 {
-    return PS::IPP::MetaDB::Image::New->fields;
-}
-
-sub find_new {
+    return PS::IPP::MetaDB::Image::Raw->fields;
+}
+
+sub find_fetch {
     my $class = shift;
     my %p = @_;
@@ -88,13 +88,13 @@
     my @rows;
     if (exists $p{exp_id}) {
-        @rows = PS::IPP::MetaDB::Image::New->search(
+        @rows = PS::IPP::MetaDB::Image::Fetch ->search(
             exp_id => $p{exp_id},
             { order_by => 'class_id' },
         );
     } else {
-        @rows = PS::IPP::MetaDB::Image::New->retrieve_all;
+        @rows = PS::IPP::MetaDB::Image::Fetch->retrieve_all;
     }
 
-    my @fields = new_fields();
+    my @fields = fetch_fields();
     my @result;
     foreach my $obj (@rows) {
@@ -107,16 +107,16 @@
 }
 
-sub new2newed {
+sub fetch2raw {
     my $class = shift;
     my %p = @_;
 
-    $class->do_transaction(sub { $class->_new2newed(%p) });
-}
-
-sub _new2newed {
+    $class->do_transaction(sub { $class->_fetch2raw(%p) });
+}
+
+sub _fetch2raw {
     my $class = shift;
     my %p = @_;
 
-    my $new = PS::IPP::MetaDB::Image::New->search(
+    my $fetch = PS::IPP::MetaDB::Image::fetch->search(
         exp_id      => $p{exp_id},
         class       => $p{class},
@@ -125,21 +125,21 @@
 
     PS::IPP::MetaDB::Image::NotifyReceived->create({
-        file_id => $new->file_id,
-    });
-
-    PS::IPP::MetaDB::Image::Newed->create({
-        exp_id      => $new->exp_id,
-        class       => $new->class,
-        class_id    => $new->class_id,
-        camera      => $new->camera,
+        file_id => $fetch->file_id,
+    });
+
+    PS::IPP::MetaDB::Image::Raw->create({
+        exp_id      => $fetch->exp_id,
+        class       => $fetch->class,
+        class_id    => $fetch->class_id,
+        camera      => $fetch->camera,
         # stamp should auto-update
-        file_id     => $new->file_id,
-        size        => $new->size,
-        md5         => $new->md5,
+        file_id     => $fetch->file_id,
+        size        => $fetch->size,
+        md5         => $fetch->md5,
         # new storage url
         url         => $p{url},
     });
 
-    $new->delete;
+    $fetch->delete;
 }
 
@@ -159,8 +159,8 @@
 =over 4
 
-=item * image_new
+=item * image_fetch
 
 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.
+summit.  The location of fetched data files is written into the C<raw> table.
 
 Table description:
@@ -208,5 +208,5 @@
 =cut
 
-package PS::IPP::MetaDB::Image::New;
+package PS::IPP::MetaDB::Image::Fetch;
 
 use base qw( PS::IPP::MetaDB );
@@ -216,5 +216,5 @@
 sub init
 {
-    __PACKAGE__->table("image_new");
+    __PACKAGE__->table("image_fetch");
     __PACKAGE__->create_table(q{
         exp_id      BIGINT          NOT NULL PRIMARY KEY,
@@ -238,4 +238,6 @@
 =item * notify_received
 
+XXX no longer needed?
+
 This is a queue of pending file received notifications that need to be send to
 OTIS.  Once a notification is successfully sent to OTIS the entry is removed
@@ -267,5 +269,5 @@
 }
 
-=item * metadata_new
+=item * metadata_fetch
 
 This table contains a list of new metadata waiting to be downloaded from the
@@ -300,5 +302,5 @@
 =cut
 
-package PS::IPP::MetaDB::Metadata::New;
+package PS::IPP::MetaDB::Metadata::Fetch;
 
 use base qw( PS::IPP::MetaDB );
@@ -308,5 +310,5 @@
 sub init
 {
-    __PACKAGE__->table("metadata_new");
+    __PACKAGE__->table("metadata_fetch");
     __PACKAGE__->create_table(q{
         stamp       DATETIME,
@@ -319,17 +321,199 @@
 }
 
-=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 * exposure_prepare
+
+Phase 1: A list of exposure IDs to extra metadata from.
+
+=over 4
+
+=item * exp_id
+
+exposure ID #, keyed against the C<raw> table.
+
+=back
+
+=cut
+
+package PS::IPP::MetaDB::Exposure::Prepare;
+
+use base qw( PS::IPP::MetaDB );
+
+__PACKAGE__->register_init(\&init);
+
+sub init
+{
+    __PACKAGE__->table("exposure_prepare");
+    __PACKAGE__->create_table(q{
+        exp_id      BIGINT          NOT NULL PRIMARY KEY,
+    });
+    __PACKAGE__->set_up_table;
+}
+
+=item * image_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<newed> table.
+class ID #, keyed against the C<prepared> table.
+
+=item * prepare_version
+
+version #, keyed against the C<prepared> table.
+
+=back
+
+=item * exposure_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 * raw 
+
+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
+
+The 'type' of data this is.
+
+=item * class_id
+
+class ID #, keyed on the C<exposure_componet> table.
+
+=item * url
+
+url to the storage location of the file.
 
 =back
@@ -346,211 +530,4 @@
 {
     __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
-
-The 'type' of data this is.
-
-=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__->register_init(\&init);
-
-sub init
-{
-    __PACKAGE__->table("newed");
     __PACKAGE__->create_table(q{
         exp_id      BIGINT          NOT NULL PRIMARY KEY,
@@ -582,11 +559,8 @@
 class ID #, keyed on the C<exposure_componet> table.
 
-=item * version
-
-version ID #
-
-=item * recipe
-
-algorithm ID #
+=item * prepare_version
+
+prepare step version ID #
+
 
 =item * url
@@ -610,11 +584,11 @@
 class ID #, keyed on the C<exposure_componet> table.
 
-=item * version
-
-version ID #
-
-=item * recipe
-
-algorithm ID #
+=item * prepare_version
+
+prepare step version ID #
+
+=item * reduce_version
+
+reduce step version ID #
 
 =item * url
