IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 21, 2007, 3:52:48 PM (19 years ago)
Author:
jhoblitt
Message:

improved p4tool transactions
remove p6SumScfile.{skycell_id, tess_id}
add p6Run.{skycell_id, tess_id}
change p6tool -addsumfile to change the runs' state to stop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/stacktool.c

    r11976 r11983  
    3939static bool sumscfileMode(pxConfig *config);
    4040
    41 static bool setp6RunState(pxConfig *config, const char *p4_id, const char *state);
     41static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state);
    4242
    4343# define MODECASE(caseName, func) \
     
    104104    }
    105105
     106    psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
     107    if (!status) {
     108        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
     109        return false;
     110    }
     111    if (!skycell_id) {
     112        psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
     113        return false;
     114    }
     115
     116    psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
     117    if (!status) {
     118        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
     119        return false;
     120    }
     121    if (!tess_id) {
     122        psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
     123        return false;
     124    }
     125
    106126    psTime *registered = NULL;
    107127    {
     
    124144            workdir,
    125145            NULL,       // dvodb
    126             registered
     146            registered,
     147            skycell_id,
     148            tess_id
    127149    );
    128150    psFree(registered);
     
    223245    }
    224246
    225     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    226     if (!status) {
    227         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    228         return false;
    229     }
    230     if (!skycell_id) {
    231         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    232         return false;
    233     }
    234 
    235     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    236     if (!status) {
    237         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    238         return false;
    239     }
    240     if (!tess_id) {
    241         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    242         return false;
    243     }
    244247
    245248    // XXX need to validate the p4_id here
     
    248251    if (!p6InputScfileInsert(config->dbh,
    249252            (psS32)atoi(p6_id),
    250             (psS32)atoi(p4_id),
    251             skycell_id,
    252             tess_id
     253            (psS32)atoi(p4_id)
    253254        )) {
    254255        psError(PS_ERR_UNKNOWN, false, "database error");
     
    279280        "   USING(p6_id)\n"
    280281        " JOIN p4Scfile\n"
    281         "   ON p6InputScfile.p4_id = p4Scfile.p4_id\n"
    282         "   AND p6InputScfile.skycell_id = p4Scfile.skycell_id\n"
    283         "   AND p6InputScfile.tess_id = p4Scfile.tess_id\n"
     282        "   ON  p6InputScfile.p4_id = p4Scfile.p4_id\n"
     283        "   AND p6Run.skycell_id    = p4Scfile.skycell_id\n"
     284        "   AND p6Run.tess_id      = p4Scfile.tess_id\n"
    284285        " WHERE\n"
    285286        "   p6Run.state = 'run'\n"
     
    454455    }
    455456
    456     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    457     if (!status) {
    458         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    459         return false;
    460     }
    461     if (!skycell_id) {
    462         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    463         return false;
    464     }
    465 
    466     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    467     if (!status) {
    468         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    469         return false;
    470     }
    471     if (!tess_id) {
    472         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    473         return false;
    474     }
    475 
    476457    psString uri = psMetadataLookupStr(&status, config->args, "-uri");
    477458    if (!status) {
     
    494475    if (!status) {
    495476        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");
     477        return false;
     478    }
     479
     480    if (!psDBTransaction(config->dbh)) {
     481        psError(PS_ERR_UNKNOWN, false, "database error");
    496482        return false;
    497483    }
     
    502488    if (!p6SumScfileInsert(config->dbh,
    503489            (psS32)atoi(p6_id),
    504             skycell_id,
    505             tess_id,
    506490            uri,
    507491            bg,
    508492            bg_mean_stdev
    509493        )) {
     494        if (!psDBRollback(config->dbh)) {
     495            psError(PS_ERR_UNKNOWN, false, "database error");
     496        }
     497        psError(PS_ERR_UNKNOWN, false, "database error");
     498        return false;
     499    }
     500
     501    if (setp6RunState(config, p6_id, "stop")) {
     502        if (!psDBRollback(config->dbh)) {
     503            psError(PS_ERR_UNKNOWN, false, "database error");
     504        }
     505        psError(PS_ERR_UNKNOWN, false, "failed to change p6Run's state");
     506        return false;
     507    }
     508
     509    // point of no return
     510    if (!psDBCommit(config->dbh)) {
    510511        psError(PS_ERR_UNKNOWN, false, "database error");
    511512        return false;
Note: See TracChangeset for help on using the changeset viewer.