IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28850


Ignore:
Timestamp:
Aug 5, 2010, 12:57:46 PM (16 years ago)
Author:
rhenders
Message:

DVO db, datastore product and min and max object IDs are now stored in the database; batch type in Db is now PSPS-stype batch type (eg 'P2'); survey ID is now IPP's (eg SAS)

Location:
trunk/ippToPsps/perl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/perl/ippToPsps/IppToPspsDb.pm

    r28813 r28850  
    5656#
    5757########################################################################################
    58 sub updateDb {
    59     my ($self, $batchId, $expId, $processed, $published, $totalDetections) = @_;
     58sub updateBatch {
     59    my ($self, $batchId, $expId, $processed, $published, $totalDetections, $minObjId, $maxObjId) = @_;
    6060
    6161if (!$totalDetections) {$totalDetections = -1;}
     
    6363    my $query = $self->{_db}->prepare(<<SQL);
    6464    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
    6671        WHERE batch_id = $batchId
    6772        AND exp_id = $expId;
     
    100105#
    101106########################################################################################
    102 sub getNewBatchId {
    103     my ($self, $expId, $surveyType, $batchType) = @_;
     107sub createNewBatch {
     108    my ($self, $expId, $surveyType, $batchType, $dvoDb, $datastoreProduct) = @_;
    104109
    105110    my $query = $self->{_db}->prepare(<<SQL);
     
    118123    $query = $self->{_db}->prepare(<<SQL);
    119124    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)
    121126        VALUES
    122         ($batchId, $expId, '$surveyType', '$batchType');
    123 
     127        ($batchId, $expId, '$surveyType', '$batchType', '$dvoDb', '$datastoreProduct');
    124128SQL
    125129
     
    140144
    141145    my $currentRevision = -1;
    142     my $latestRevision = 5;
     146    my $latestRevision = 6;
    143147
    144148    while ($currentRevision != $latestRevision) {
    145149
    146150        $currentRevision = $self->getRevision();
    147         if ($self->{_verbose}) {print "* Current revision = $currentRevision\n";}
     151        if ($self->{_verbose}) {print "* Current database revision = $currentRevision\n";}
    148152
    149153        if ($currentRevision == 0) {$self->createRevision_1();}
     
    152156        elsif ($currentRevision == 3) {$self->createRevision_4();}
    153157        elsif ($currentRevision == 4) {$self->createRevision_5();}
     158        elsif ($currentRevision == 5) {$self->createRevision_6();}
    154159    }
    155160}
     
    271276#######################################################################################
    272277#
     278# Create revision 6 of the database
     279#
     280#######################################################################################
     281sub 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
     292SQL
     293    $query->execute;
     294
     295    $self->setRevision(6);
     296}
     297
     298#######################################################################################
     299#
    273300# Sets current revision of ippToPsps database
    274301#
  • trunk/ippToPsps/perl/ippToPsps_run.pl

    r28849 r28850  
    103103$fullDvoPath = $dvoPath . "/" . $dvoDb;
    104104
     105# determine PSPS batch 'type'
     106my $pspsBatchType;
     107if ($batchType eq 'init') {$pspsBatchType = "IN";}
     108elsif ($batchType eq 'det') {$pspsBatchType = "P2";}
     109elsif ($batchType eq 'stack') {$pspsBatchType = "ST";}
     110elsif ($batchType eq 'diff') {$pspsBatchType = "OB";}
     111else {$pspsBatchType = "UNKNOWN";}
     112
    105113my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps);
    106114my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
     
    181189        if (!$surveyType) {next;}
    182190
    183         $batchId = $ippToPspsDb->getNewBatchId($expId, $surveyType, $batchType);
     191        $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastoreProduct) ? $datastoreProduct : "NONE");
    184192
    185193        # TODO quit here if no sensible batch ID
     
    208216            }
    209217
    210             $ippToPspsDb->updateDb($batchId, $expId, 1, $published, $totalDetections);
     218            $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId);
    211219        }
    212220
     
    361369    my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec;
    362370
    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 
    371371    # create XML file
    372372    my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);
     
    403403                $writer->startTag('manifest',
    404404                        "name" => "$batch",
    405                         "type" => $type,
     405                        "type" => $pspsBatchType,
    406406                        "survey" => $pspsSurvey,
    407407                        "timestamp" => "$timeStamp",
     
    413413                $writer->startTag('manifest',
    414414                        "name" => "$batch",
    415                         "type" => $type,
     415                        "type" => $pspsBatchType,
    416416                        "timestamp" => "$timeStamp");
    417417            }
Note: See TracChangeset for help on using the changeset viewer.