Changeset 5185
- Timestamp:
- Sep 29, 2005, 11:20:25 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-MetaDB/lib/PS/IPP/MetaDB.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-MetaDB/lib/PS/IPP/MetaDB.pm
r5172 r5185 1 1 # Copyright (C) 2005 Joshua Hoblitt 2 2 # 3 # $Id: MetaDB.pm,v 1. 3 2005-09-28 21:45:08jhoblitt Exp $3 # $Id: MetaDB.pm,v 1.4 2005-09-29 21:20:25 jhoblitt Exp $ 4 4 5 5 package PS::IPP::MetaDB; … … 15 15 use Carp qw( croak ); 16 16 17 __PACKAGE__->set_db('Main', 'dbi:mysql:test', 'test', ''); 17 sub import { 18 my $class = shift; 19 20 $class->init( @_ ) if @_; 21 } 22 23 my @child_inits; 24 25 sub init { 26 my $class = shift; 27 my %p = @_; 28 29 croak "dsn is required" unless exists $p{dsn}; 30 31 $class->set_db('Main', $p{dsn}, $p{user}, $p{passwd}); 32 33 foreach my $init (@child_inits) { 34 &$init; 35 } 36 } 37 38 sub register_init { 39 my $class = shift; 40 push @child_inits, shift; 41 } 18 42 19 43 # lifted from Class::DBI docs (modified) … … 36 60 } 37 61 38 39 sub new2newed { 62 sub add_new { 40 63 my $class = shift; 41 64 my %p = @_; 42 65 43 $class->do_transaction(sub { $class->_new2newed(%p) }); 44 } 45 46 sub _new2newed { 47 my $class = shift; 48 my %p = @_; 49 50 "${class}::Image::New"->search( 51 exp_id => $p{exp_id}, 52 class_id => $p{class_id}, 53 )->delete_all; 54 55 "${class}::Image::Newed"->create({ 56 exp_id => $p{exp_id}, 57 class_id => $p{class_id}, 58 url => $p{url}, 59 }); 60 } 61 62 63 #package PS::IPP::MetaDB::Image::Prepared; 64 #package PS::IPP::MetaDB::Image::Reduced; 65 #package PS::IPP::MetaDB::Image::Analyzed; 66 #package PS::IPP::MetaDB::Image::Combined; 67 68 =pod 69 70 =head2 Temporal Queues 71 72 These queues all describe work that I<needs> to be performed but hasn't 73 happened yet. 74 75 =over 4 76 77 =item * new 78 79 This table contains a list of new data waiting to be downloaded from the 80 summit. The location of fetched data files is written into the C<newed> table. 81 82 Table description: 83 84 =over 4 85 86 =item * url 87 88 URL to retrieve data from 89 90 =item * exp_id 91 92 exposure ID # 93 94 =item * camera 95 96 Camera that this data was acquired from 97 98 =item * class 99 100 The 'type' of data this is 101 102 =item * class_id 103 104 A unique identifier for data of the same class in the same exposure. 105 106 =back 107 108 =cut 109 110 package PS::IPP::MetaDB::Image::New; 111 112 use base qw( PS::IPP::MetaDB ); 113 114 __PACKAGE__->table("new"); 115 __PACKAGE__->create_table(q{ 116 exp_id BIGINT NOT NULL PRIMARY KEY, 117 class_id BIGINT NOT NULL, 118 camera VARCHAR(255), 119 class VARCHAR(255), 120 url VARCHAR(255) NOT NULL 121 }); 122 __PACKAGE__->set_up_table; 123 124 sub add_new { 125 my $class = shift; 126 my %p = @_; 127 128 $class->create({ 66 PS::IPP::MetaDB::Image::New->create({ 129 67 exp_id => $p{exp_id}, 130 68 class_id => $p{class_id}, … … 140 78 141 79 if (exists $p{exp_id}) { 142 $class->search( $p{exp_id}, { order_by => 'class_id' } ); 80 PS::IPP::MetaDB::Image::New->search( 81 $p{exp_id}, 82 { order_by => 'class_id' }, 83 ); 143 84 } else { 144 $class->retrieve_all;85 PS::IPP::MetaDB::Image::New->retrieve_all; 145 86 } 146 87 } 147 88 89 sub new2newed { 90 my $class = shift; 91 my %p = @_; 92 93 $class->do_transaction(sub { $class->_new2newed(%p) }); 94 } 95 96 sub _new2newed { 97 my $class = shift; 98 my %p = @_; 99 100 $class->search( 101 exp_id => $p{exp_id}, 102 class_id => $p{class_id}, 103 )->delete_all; 104 105 $class->create({ 106 exp_id => $p{exp_id}, 107 class_id => $p{class_id}, 108 url => $p{url}, 109 }); 110 } 111 112 113 #package PS::IPP::MetaDB::Image::Prepared; 114 #package PS::IPP::MetaDB::Image::Reduced; 115 #package PS::IPP::MetaDB::Image::Analyzed; 116 #package PS::IPP::MetaDB::Image::Combined; 117 118 =pod 119 120 =head2 Temporal Queues 121 122 These queues all describe work that I<needs> to be performed but hasn't 123 happened yet. 124 125 =over 4 126 127 =item * new 128 129 This table contains a list of new data waiting to be downloaded from the 130 summit. The location of fetched data files is written into the C<newed> table. 131 132 Table description: 133 134 =over 4 135 136 =item * url 137 138 URL to retrieve data from 139 140 =item * exp_id 141 142 exposure ID # 143 144 =item * camera 145 146 Camera that this data was acquired from 147 148 =item * class 149 150 The 'type' of data this is 151 152 =item * class_id 153 154 A unique identifier for data of the same class in the same exposure. 155 156 =back 157 158 =cut 159 160 package PS::IPP::MetaDB::Image::New; 161 162 use base qw( PS::IPP::MetaDB ); 163 164 __PACKAGE__->register_init(\&init); 165 166 sub init 167 { 168 __PACKAGE__->table("new"); 169 __PACKAGE__->create_table(q{ 170 exp_id BIGINT NOT NULL PRIMARY KEY, 171 class_id BIGINT NOT NULL, 172 camera VARCHAR(255), 173 class VARCHAR(255), 174 url VARCHAR(255) NOT NULL 175 }); 176 __PACKAGE__->set_up_table; 177 } 178 148 179 =item * raw 149 180 … … 168 199 use base qw( PS::IPP::MetaDB ); 169 200 170 __PACKAGE__->table("raw"); 171 __PACKAGE__->create_table(q{ 172 exp_id BIGINT NOT NULL PRIMARY KEY, 173 class_id BIGINT NOT NULL 174 }); 175 __PACKAGE__->set_up_table; 201 __PACKAGE__->register_init(\&init); 202 203 sub init 204 { 205 __PACKAGE__->table("raw"); 206 __PACKAGE__->create_table(q{ 207 exp_id BIGINT NOT NULL PRIMARY KEY, 208 class_id BIGINT NOT NULL 209 }); 210 __PACKAGE__->set_up_table; 211 } 176 212 177 213 =item * prepare … … 366 402 use base qw( PS::IPP::MetaDB ); 367 403 368 __PACKAGE__->table("newed"); 369 __PACKAGE__->create_table(q{ 370 exp_id BIGINT NOT NULL PRIMARY KEY, 371 class_id BIGINT NOT NULL, 372 url VARCHAR(255) NOT NULL 373 }); 374 __PACKAGE__->set_up_table; 404 __PACKAGE__->register_init(\&init); 405 406 sub init 407 { 408 __PACKAGE__->table("newed"); 409 __PACKAGE__->create_table(q{ 410 exp_id BIGINT NOT NULL PRIMARY KEY, 411 class_id BIGINT NOT NULL, 412 url VARCHAR(255) NOT NULL 413 }); 414 __PACKAGE__->set_up_table; 415 } 375 416 376 417 =item * prepared
Note:
See TracChangeset
for help on using the changeset viewer.
