IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2007, 2:16:55 PM (19 years ago)
Author:
jhoblitt
Message:

implement most of p5tool functionality

File:
1 edited

Legend:

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

    r11787 r11789  
    4040
    4141static bool setp5RunState(pxConfig *config, const char *p4_id, const char *state);
    42 static bool isValidMode(pxConfig *config, const char *mode);
    4342
    4443# define MODECASE(caseName, func) \
     
    9089    // required options
    9190    bool status = false;
    92     psString mode = psMetadataLookupStr(&status, config->args, "-mode");
    93     if (!status) {
    94         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -survey_mode");
    95         return false;
    96     }
    97     if (!mode) {
    98         psError(PS_ERR_UNKNOWN, true, "-mode is required");
    99         return false;
    100     }
    101     // check mode
    102     if (mode && !isValidMode(config, mode)) {
    103         psError(PS_ERR_UNKNOWN, false, "invalud mode");
    104         return false;
    105     }
    106 
    10791    psString workdir = psMetadataLookupStr(&status, config->args, "-workdir");
    10892    if (!status) {
     
    130114    }
    131115
    132     p4RunRow *p4Run = p4RunRowAlloc(
     116    p5RunRow *run = p5RunRowAlloc(
    133117            0,          // ID
    134             mode,
    135118            "reg",      // state
    136119            workdir,
     
    138121    );
    139122    psFree(registered);
    140     if (!p4Run) {
    141         psError(PS_ERR_UNKNOWN, false, "failed to alloc p4Run object");
     123    if (!run) {
     124        psError(PS_ERR_UNKNOWN, false, "failed to alloc p5Run object");
    142125        return true;
    143126    }
    144     if (!p4RunInsertObject(config->dbh, p4Run)) {
     127    if (!p5RunInsertObject(config->dbh, run)) {
    145128        psError(PS_ERR_UNKNOWN, false, "database error");
    146         psFree(p4Run);
     129        psFree(run);
    147130        return true;
    148131    }
     
    154137        if (!status) {
    155138            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    156             psFree(p4Run);
    157             return false;
    158         }
    159     }
    160 
    161     if (!p4RunPrintObject(stdout, p4Run, !simple)) {
     139            psFree(run);
     140            return false;
     141        }
     142    }
     143
     144    if (!p5RunPrintObject(stdout, run, !simple)) {
    162145            psError(PS_ERR_UNKNOWN, false, "failed to print object");
    163             psFree(p4Run);
    164             return false;
    165     }
    166 
    167     psFree(p4Run);
     146            psFree(run);
     147            return false;
     148    }
     149
     150    psFree(run);
    168151
    169152    return true;
     
    176159
    177160    bool status = false;
    178     psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
    179     if (!status) {
    180         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4t_id");
    181         return false;
    182     }
    183     if (!p4_id) {
    184         psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
     161    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
     162    if (!status) {
     163        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
     164        return false;
     165    }
     166    if (!p5_id) {
     167        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
    185168        return false;
    186169    }
     
    198181    if (state) {
    199182        // set detRun.state to state
    200         return setp5RunState(config, p4_id, state);
     183        return setp5RunState(config, p5_id, state);
    201184    }
    202185
     
    210193
    211194    bool status = false;
     195    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
     196    if (!status) {
     197        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
     198        return false;
     199    }
     200    if (!p5_id) {
     201        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
     202        return false;
     203    }
     204
    212205    psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
    213206    if (!status) {
     
    215208        return false;
    216209    }
    217     if (!p4_id) {
    218         psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
    219         return false;
    220     }
    221 
     210    if (!p5_id) {
     211        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
     212        return false;
     213    }
     214
     215    psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
     216    if (!status) {
     217        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
     218        return false;
     219    }
     220    if (!skycell_id) {
     221        psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
     222        return false;
     223    }
     224
     225    psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
     226    if (!status) {
     227        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
     228        return false;
     229    }
     230    if (!tess_id) {
     231        psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
     232        return false;
     233    }
    222234    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
    223235    if (!status) {
     
    237249    }
    238250
     251    psString kind = psMetadataLookupStr(&status, config->args, "-kind");
     252    if (!status) {
     253        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -kind");
     254        return false;
     255    }
     256
    239257    // defaults to false
    240     bool magiced = psMetadataLookupBool(&status, config->args, "-p3_version");
    241     if (!status) {
    242         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version");
     258    bool template = psMetadataLookupBool(&status, config->args, "-template");
     259    if (!status) {
     260        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -template");
    243261        return false;
    244262    }
     
    247265    // XXX instead of validiting it here we should just use forgein key
    248266    // constrants
    249     if (!p4InputExpInsert(config->dbh,
     267    if (!p5InputScfileInsert(config->dbh,
     268            (psS32)atoi(p5_id),
    250269            (psS32)atoi(p4_id),
     270            skycell_id,
     271            tess_id,
    251272            exp_tag,
    252273            p3_version,
    253             magiced
     274            kind,
     275            template
    254276        )) {
    255277        psError(PS_ERR_UNKNOWN, false, "database error");
     
    275297    psString query = psStringCopy(
    276298        "SELECT\n"
    277         "   p3ProcessedExp.*\n"
    278         " FROM p4Run\n"
    279         " JOIN p4InputExp\n"
    280         "   USING(p4_id)\n"
    281         " JOIN p3ProcessedExp\n"
    282         "   ON p4InputExp.exp_tag = p3ProcessedExp.exp_tag\n"
    283         "   AND p4InputExp.p3_version = p3ProcessedExp.p3_version\n"
     299        "   p4Scfile.*\n"
     300        " FROM p5Run\n"
     301        " JOIN p5InputScfile\n"
     302        "   USING(p5_id)\n"
     303        " JOIN p4Scfile\n"
     304        "   ON p5InputScile.p4_id      = p4Scfile.p4_id\n"
     305        "   ON p5InputScile.skycell_id = p4Scfile.skycell_id\n"
     306        "   ON p5InputScile.tess_id    = p4Scfile.tess_id\n"
     307        "   ON p5InputScile.exp_tag    = p4Scfile.exp_tag\n"
     308        "   ON p5InputScile.p3_version = p4Scfile.p3_versiong\n"
    284309        " WHERE\n"
    285         "   p4Run.state = 'run'\n"
    286         "   AND p3ProcessedExp.fault = 0\n"
     310        "   p5Run.state = 'run'\n"
    287311    );
    288312
    289313    if (config->where) {
    290         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputExp");
     314        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5InputScfile");
    291315        psStringAppend(&query, " AND %s", whereClause);
    292316        psFree(whereClause);
     
    322346    }
    323347    if (!psArrayLength(output)) {
    324         psError(PS_ERR_UNKNOWN, false, "no pending rawImfile rows found");
     348        psError(PS_ERR_UNKNOWN, false, "no p5InputScfile rows found");
    325349        psFree(output);
    326350        return true;
     
    339363    if (psArrayLength(output)) {
    340364        // negative simple so the default is true
    341         if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) {
     365        if (!ippdbPrintMetadatas(stdout, output, "p5InputScfile", !simple)) {
    342366            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    343367            psFree(output);
     
    366390    psString query = psStringCopy(
    367391        "SELECT\n"
    368         "   p3ProcessedExp.*\n"
    369         " FROM p4Run\n"
    370         " JOIN p4InputExp\n"
    371         "   USING(p4_id)\n"
    372         " JOIN p3ProcessedExp\n"
    373         "   ON p4InputExp.exp_tag = p3ProcessedExp.exp_tag\n"
    374         "   AND p4InputExp.p3_version = p3ProcessedExp.p3_version\n"
    375         " LEFT JOIN p4SkyCellMap\n"
    376         "   ON p4InputExp.p4_id = p4SkyCellMap.p4_id\n"
    377         "   AND p4InputExp.exp_tag = p4SkyCellMap.exp_tag\n"
    378         "   AND p4InputExp.p3_version = p4SkyCellMap.p3_version\n"
     392        "   p4Scfile.*\n"
     393        " FROM p5Run\n"
     394        " JOIN p5InputScfile\n"
     395        "   USING(p5_id)\n"
     396        " JOIN p4Scfile\n"
     397        "   ON p5InputScile.p4_id      = p4Scfile.p4_id\n"
     398        "   ON p5InputScile.skycell_id = p4Scfile.skycell_id\n"
     399        "   ON p5InputScile.tess_id    = p4Scfile.tess_id\n"
     400        "   ON p5InputScile.exp_tag    = p4Scfile.exp_tag\n"
     401        "   ON p5InputScile.p3_version = p4Scfile.p3_versiong\n"
     402        " LEFT JOIN p5DiffScfile\n"
     403        "   USING(p5_id, skycell_id, tess_id, exp_tag, p3_version)\n"
    379404        " WHERE\n"
    380         "   p4Run.state = 'run'\n"
    381         "   AND p3ProcessedExp.fault = 0\n"
    382         "   AND p4SkyCellMap.p4_id IS NULL\n"
    383         "   AND p4SkyCellMap.exp_tag IS NULL\n"
    384         "   AND p4SkyCellMap.p3_version IS NULL\n"
     405        "   p5Run.state = 'run'\n"
     406        "   AND p4DiffScfile.p5_id IS NULL\n"
     407        "   AND p4DiffScfile.skycell_id IS NULL\n"
     408        "   AND p4DiffScfile.tess_id IS NULL\n"
     409        "   AND p4DiffScfile.exp_tag IS NULL\n"
     410        "   AND p4DiffScfile.p3_version IS NULL\n"
    385411    );
    386412
    387413    if (config->where) {
    388         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputExp");
     414        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5Scfile");
    389415        psStringAppend(&query, " AND %s", whereClause);
    390416        psFree(whereClause);
     
    420446    }
    421447    if (!psArrayLength(output)) {
    422         psError(PS_ERR_UNKNOWN, false, "no pending rawImfile rows found");
     448        psError(PS_ERR_UNKNOWN, false, "no p5Scfile rows found");
    423449        psFree(output);
    424450        return true;
     
    437463    if (psArrayLength(output)) {
    438464        // negative simple so the default is true
    439         if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) {
     465        if (!ippdbPrintMetadatas(stdout, output, "p5Scfile", !simple)) {
    440466            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    441467            psFree(output);
     
    455481
    456482    bool status = false;
    457     psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
    458     if (!status) {
    459         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id");
    460         return false;
    461     }
    462     if (!p4_id) {
    463         psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
     483    psString p5_id = psMetadataLookupStr(&status, config->args, "-p5_id");
     484    if (!status) {
     485        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p5_id");
     486        return false;
     487    }
     488    if (!p5_id) {
     489        psError(PS_ERR_UNKNOWN, true, "-p5_id is required");
    464490        return false;
    465491    }
     
    527553
    528554    // XXX need to validate that this coresponds to an p4InputImfile
    529     if (!p4ScfileInsert(config->dbh,
    530             (psS32)atoi(p4_id),
     555    if (!p5DiffScfileInsert(config->dbh,
     556            (psS32)atoi(p5_id),
    531557            skycell_id,
    532558            tess_id,
     
    544570}
    545571
     572
    546573static bool diffscfileMode(pxConfig *config)
    547574{
     
    558585    psString query = psStringCopy(
    559586        "SELECT\n"
    560         "   p4Scfile.*\n"
    561         " FROM p4Run\n"
    562         " JOIN p4Scfile\n"
    563         "   USING(p4_id)\n"
     587        "   p5DiffScfile.*\n"
     588        " FROM p5Run\n"
     589        " JOIN p5Scfile\n"
     590        "   USING(p5_id)\n"
    564591        " WHERE\n"
    565         "   p4Run.state = 'run'\n"
     592        "   p5Run.state = 'run'\n"
    566593    );
    567594
    568595    if (config->where) {
    569         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4Scfile");
     596        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p5DiffScfile");
    570597        psStringAppend(&query, " AND %s", whereClause);
    571598        psFree(whereClause);
     
    601628    }
    602629    if (!psArrayLength(output)) {
    603         psError(PS_ERR_UNKNOWN, false, "no p4Scfile rows found");
     630        psError(PS_ERR_UNKNOWN, false, "no p5DiffScfile rows found");
    604631        psFree(output);
    605632        return true;
     
    618645    if (psArrayLength(output)) {
    619646        // negative simple so the default is true
    620         if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) {
     647        if (!ippdbPrintMetadatas(stdout, output, "p5DiffScfile", !simple)) {
    621648            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    622649            psFree(output);
     
    656683    return true;
    657684}
    658 
    659 static bool isValidMode(pxConfig *config, const char *mode)
    660 {
    661     PS_ASSERT_PTR_NON_NULL(config, false);
    662     PS_ASSERT_PTR_NON_NULL(mode, false);
    663 
    664     // check that state is a valid string value
    665     if (!(
    666             (strncmp(mode, "warp", 5) == 0)
    667             || (strncmp(mode, "diff", 5) == 0)
    668             || (strncmp(mode, "stack", 6) == 0)
    669             || (strncmp(mode, "magic", 6) == 0)
    670         )
    671     ) {
    672         psError(PS_ERR_UNKNOWN, false,
    673                 "invalid detRun mode: %s", mode);
    674         return false;
    675     }
    676 
    677     return true;
    678 }
Note: See TracChangeset for help on using the changeset viewer.