IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2007, 5:09:48 PM (19 years ago)
Author:
jhoblitt
Message:

rework difftool

File:
1 edited

Legend:

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

    r14108 r14250  
    236236    }
    237237
     238    psString stack_id = psMetadataLookupStr(&status, config->args, "-stack_id");
     239    if (!status) {
     240        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stack_id");
     241        return false;
     242    }
     243
    238244    psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
    239245    if (!status) {
    240246        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
    241         return false;
    242     }
    243     if (!diff_id) {
    244         psError(PS_ERR_UNKNOWN, true, "-diff_id is required");
    245         return false;
    246     }
    247 
    248     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    249     if (!status) {
    250         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    251         return false;
    252     }
    253     if (!skycell_id) {
    254         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    255         return false;
    256     }
    257 
    258     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    259     if (!status) {
    260         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    261         return false;
    262     }
    263     if (!tess_id) {
    264         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    265247        return false;
    266248    }
     
    279261    }
    280262
    281     // XXX need to validate the warp_id here
    282     // XXX instead of validiting it here we should just use forgein key
    283     // constrants
     263    // must provide either stack_id or warp_id but not BOTH
     264    if (!(stack_id || warp_id)) {
     265        psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified");
     266        return false;
     267    }
     268    if (stack_id && warp_id) {
     269        psError(PS_ERR_UNKNOWN, true, "either -stack_id or -warp_id must be specified");
     270        return false;
     271    }
     272
     273    // if a warp_id was provided we need to lookup the skycell_id and tess_id
     274    // from the warpRun
     275    psString skycell_id = NULL;
     276    psString tess_id = NULL;
     277    if (warp_id) {
     278        if (!p_psDBRunQuery(config->dbh, "SELECT * from diffRun WHERE diff_id = %" PRId64, (psS64)atoll(diff_id))) {
     279            psError(PS_ERR_UNKNOWN, false, "database error");
     280            return false;
     281        }
     282
     283        psArray *output = p_psDBFetchResult(config->dbh);
     284        if (!output) {
     285            psError(PS_ERR_UNKNOWN, false, "database error");
     286            return false;
     287        }
     288        if (!psArrayLength(output)) {
     289            psError(PS_ERR_UNKNOWN, false, "diff_id %" PRId64 " not found", (psS64)atoll(diff_id));
     290            psFree(output);
     291            return false;
     292        }
     293
     294        diffRunRow *run = diffRunObjectFromMetadata(output->data[0]);
     295        skycell_id = run->skycell_id;
     296        tess_id = run->tess_id;
     297    }
     298
    284299    if (!diffInputSkyfileInsert(config->dbh,
    285300            (psS64)atoll(diff_id),
    286             (psS64)atoll(warp_id),
     301            template,
     302            stack_id ? (psS64)atoll(stack_id) : PS_MAX_S64, // defined or NULL
     303            warp_id ? (psS64)atoll(warp_id) : PS_MAX_S64, // defined or NULL
    287304            skycell_id,
    288305            tess_id,
    289             kind,
    290             template
     306            kind
    291307        )) {
    292308        psError(PS_ERR_UNKNOWN, false, "database error");
Note: See TracChangeset for help on using the changeset viewer.