Changeset 28850
- Timestamp:
- Aug 5, 2010, 12:57:46 PM (16 years ago)
- Location:
- trunk/ippToPsps/perl
- Files:
-
- 2 edited
-
ippToPsps/IppToPspsDb.pm (modified) (7 diffs)
-
ippToPsps_run.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm
r28813 r28850 56 56 # 57 57 ######################################################################################## 58 sub update Db{59 my ($self, $batchId, $expId, $processed, $published, $totalDetections ) = @_;58 sub updateBatch { 59 my ($self, $batchId, $expId, $processed, $published, $totalDetections, $minObjId, $maxObjId) = @_; 60 60 61 61 if (!$totalDetections) {$totalDetections = -1;} … … 63 63 my $query = $self->{_db}->prepare(<<SQL); 64 64 UPDATE batches 65 SET processed = $processed, on_datastore = $published, total_detections = $totalDetections 65 SET 66 processed = $processed, 67 on_datastore = $published, 68 total_detections = $totalDetections, 69 min_obj_id = $minObjId, 70 max_obj_id = $maxObjId 66 71 WHERE batch_id = $batchId 67 72 AND exp_id = $expId; … … 100 105 # 101 106 ######################################################################################## 102 sub getNewBatchId{103 my ($self, $expId, $surveyType, $batchType ) = @_;107 sub createNewBatch { 108 my ($self, $expId, $surveyType, $batchType, $dvoDb, $datastoreProduct) = @_; 104 109 105 110 my $query = $self->{_db}->prepare(<<SQL); … … 118 123 $query = $self->{_db}->prepare(<<SQL); 119 124 INSERT INTO batches 120 (batch_id, exp_id, survey_id, batch_type )125 (batch_id, exp_id, survey_id, batch_type, dvo_db, datastore_product) 121 126 VALUES 122 ($batchId, $expId, '$surveyType', '$batchType'); 123 127 ($batchId, $expId, '$surveyType', '$batchType', '$dvoDb', '$datastoreProduct'); 124 128 SQL 125 129 … … 140 144 141 145 my $currentRevision = -1; 142 my $latestRevision = 5;146 my $latestRevision = 6; 143 147 144 148 while ($currentRevision != $latestRevision) { 145 149 146 150 $currentRevision = $self->getRevision(); 147 if ($self->{_verbose}) {print "* Current revision = $currentRevision\n";}151 if ($self->{_verbose}) {print "* Current database revision = $currentRevision\n";} 148 152 149 153 if ($currentRevision == 0) {$self->createRevision_1();} … … 152 156 elsif ($currentRevision == 3) {$self->createRevision_4();} 153 157 elsif ($currentRevision == 4) {$self->createRevision_5();} 158 elsif ($currentRevision == 5) {$self->createRevision_6();} 154 159 } 155 160 } … … 271 276 ####################################################################################### 272 277 # 278 # Create revision 6 of the database 279 # 280 ####################################################################################### 281 sub createRevision_6 { 282 my ($self) = @_; 283 284 print "* Creating revision 6 of '$self->{_dbName}'\n"; 285 286 my $query = $self->{_db}->prepare(<<SQL); 287 ALTER TABLE batches 288 ADD COLUMN dvo_db VARCHAR(50) DEFAULT "UNKNOWN", 289 ADD COLUMN datastore_product VARCHAR(50) DEFAULT "UNKNOWN", 290 ADD COLUMN min_obj_id BIGINT DEFAULT 0, 291 ADD COLUMN max_obj_id BIGINT DEFAULT 0 292 SQL 293 $query->execute; 294 295 $self->setRevision(6); 296 } 297 298 ####################################################################################### 299 # 273 300 # Sets current revision of ippToPsps database 274 301 # -
trunk/ippToPsps/perl/ippToPsps_run.pl
r28849 r28850 103 103 $fullDvoPath = $dvoPath . "/" . $dvoDb; 104 104 105 # determine PSPS batch 'type' 106 my $pspsBatchType; 107 if ($batchType eq 'init') {$pspsBatchType = "IN";} 108 elsif ($batchType eq 'det') {$pspsBatchType = "P2";} 109 elsif ($batchType eq 'stack') {$pspsBatchType = "ST";} 110 elsif ($batchType eq 'diff') {$pspsBatchType = "OB";} 111 else {$pspsBatchType = "UNKNOWN";} 112 105 113 my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps); 106 114 my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps); … … 181 189 if (!$surveyType) {next;} 182 190 183 $batchId = $ippToPspsDb-> getNewBatchId($expId, $surveyType, $batchType);191 $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastoreProduct) ? $datastoreProduct : "NONE"); 184 192 185 193 # TODO quit here if no sensible batch ID … … 208 216 } 209 217 210 $ippToPspsDb->update Db($batchId, $expId, 1, $published, $totalDetections);218 $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId); 211 219 } 212 220 … … 361 369 my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec; 362 370 363 # determine batch 'type'364 my $type;365 if ($batchType eq 'init') {$type = "IN";}366 elsif ($batchType eq 'det') {$type = "P2";}367 elsif ($batchType eq 'stack') {$type = "ST";}368 elsif ($batchType eq 'diff') {$type = "OB";}369 else {$type = "UNKNOWN";}370 371 371 # create XML file 372 372 my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2); … … 403 403 $writer->startTag('manifest', 404 404 "name" => "$batch", 405 "type" => $ type,405 "type" => $pspsBatchType, 406 406 "survey" => $pspsSurvey, 407 407 "timestamp" => "$timeStamp", … … 413 413 $writer->startTag('manifest', 414 414 "name" => "$batch", 415 "type" => $ type,415 "type" => $pspsBatchType, 416 416 "timestamp" => "$timeStamp"); 417 417 }
Note:
See TracChangeset
for help on using the changeset viewer.
