IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 26, 2008, 3:39:54 PM (18 years ago)
Author:
jhoblitt
Message:

consitently handle *_id fields as numeric values instead of converting back of forth between ints and strings

File:
1 edited

Legend:

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

    r18093 r18336  
    103103    PS_ASSERT_PTR_NON_NULL(config, NULL);
    104104
    105     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    106 
    107105    psMetadata *where = psMetadataAlloc();
    108     // convert exp_id into a psS64
    109     if (exp_id) {
    110         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
    111             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    112             psFree(where);
    113             return false;
    114         }
    115     }
    116 
     106    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    117107    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
    118108    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     
    259249
    260250    psMetadata *where = psMetadataAlloc();
    261     PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false);
    262     // convert fake_id into a psS64
    263     if (fake_id) {
    264         if (!psMetadataAddS64(where, PS_LIST_TAIL, "fake_id", 0, "==", (psS64)atoll(fake_id))) {
    265             psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id");
    266             psFree(where);
    267             return false;
    268         }
    269     }
    270 
    271     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    272     // convert exp_id into a psS64
    273     if (exp_id) {
    274         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
    275             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    276             psFree(where);
    277             return false;
    278         }
    279     }
    280 
     251    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     252    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    281253    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
    282254    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     
    406378    }
    407379
    408     if (!convertIdToStr(output)) {
    409         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    410         psFree(output);
    411         return false;
    412     }
    413 
    414380    // negate simple so the default is true
    415381    if (!ippdbPrintMetadatas(stdout, output, "fakePendingExp", !simple)) {
     
    433399
    434400    psMetadata *where = psMetadataAlloc();
    435     PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false);
    436     // convert fake_id into a psS64
    437     if (fake_id) {
    438         if (!psMetadataAddS64(where, PS_LIST_TAIL, "fakeRun.fake_id", 0, "==", (psS64)atoll(fake_id))) {
    439             psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id");
    440             psFree(where);
    441             return false;
    442         }
    443     }
    444 
    445     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    446     // convert exp_id into a psS64
    447     if (exp_id) {
    448         if (!psMetadataAddS64(where, PS_LIST_TAIL, "rawExp.exp_id", 0, "==", (psS64)atoll(exp_id))) {
    449             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    450             psFree(where);
    451             return false;
    452         }
    453     }
    454 
     401    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     402    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    455403    PXOPT_COPY_STR(config->args, where, "-class_id", "rawImfile.class_id", "==");
    456404    PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.telescope", "==");
     
    495443    }
    496444
    497     if (!convertIdToStr(output)) {
    498         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    499         psFree(output);
    500         return false;
    501     }
    502 
    503445    // negative simple so the default is true
    504446    if (!ippdbPrintMetadatas(stdout, output, "fakePendingImfile", !simple)) {
     
    519461
    520462    // fake_id, ext_tag, class_id are required
    521     PXOPT_LOOKUP_STR(fake_id, config->args,     "-fake_id", true, false);
    522     PXOPT_LOOKUP_STR(exp_id, config->args,      "-exp_id", true, false);
     463    PXOPT_LOOKUP_S64(fake_id, config->args,     "-fake_id", true, false);
     464    PXOPT_LOOKUP_S64(exp_id, config->args,      "-exp_id", true, false);
    523465    PXOPT_LOOKUP_STR(class_id, config->args,    "-class_id", true, false);
    524466
     
    539481
    540482    if (!fakeProcessedImfileInsert(config->dbh,
    541                                    (psS64)atoll(fake_id),
    542                                    (psS64)atoll(exp_id),
     483                                   fake_id,
     484                                   exp_id,
    543485                                   class_id,
    544486                                   uri,
     
    589531
    590532    psMetadata *where = psMetadataAlloc();
    591     PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false);
    592     // convert fake_id into a psS64
    593     if (fake_id) {
    594         if (!psMetadataAddS64(where, PS_LIST_TAIL, "fakeRun.fake_id", 0, "==", (psS64)atoll(fake_id))) {
    595             psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id");
    596             psFree(where);
    597             return false;
    598         }
    599     }
    600 
    601     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    602     // convert exp_id into a psS64
    603     if (exp_id) {
    604         if (!psMetadataAddS64(where, PS_LIST_TAIL, "rawExp.exp_id", 0, "==", (psS64)atoll(exp_id))) {
    605             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    606             psFree(where);
    607             return false;
    608         }
    609     }
    610 
     533    PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "==");
     534    PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
    611535    PXOPT_COPY_STR(config->args, where, "-class_id", "rawImfile.class_id", "==");
    612536    PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.telescope", "==");
     
    659583    }
    660584
    661     if (!convertIdToStr(output)) {
    662         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    663         psFree(output);
    664         return false;
    665     }
    666 
    667585    // negative simple so the default is true
    668586    if (!ippdbPrintMetadatas(stdout, output, "fakeProcessedImfile", !simple)) {
     
    682600
    683601    psMetadata *where = psMetadataAlloc();
    684     PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false);
    685     // convert fake_id into a psS64
    686     if (fake_id) {
    687         if (!psMetadataAddS64(where, PS_LIST_TAIL, "fake_id", 0, "==", (psS64)atoll(fake_id))) {
    688             psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id");
    689             psFree(where);
    690             return false;
    691         }
    692     }
    693 
    694     PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
    695     // convert exp_id into a psS64
    696     if (exp_id) {
    697         if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
    698             psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    699             psFree(where);
    700             return false;
    701         }
    702     }
    703 
     602    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     603    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    704604    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
    705605    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     
    778678
    779679    psMetadata *where = psMetadataAlloc();
    780     PXOPT_LOOKUP_STR(fake_id, config->args, "-fake_id", false, false);
    781     // convert fake_id into a psS64
    782     if (fake_id) {
    783         if (!psMetadataAddS64(where, PS_LIST_TAIL, "fake_id", 0, "==", (psS64)atoll(fake_id))) {
    784             psError(PS_ERR_UNKNOWN, false, "failed to add item fake_id");
    785             psFree(where);
    786             return false;
    787         }
    788     }
     680    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
    789681    PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    790682
     
    866758    }
    867759
    868     if (!convertIdToStr(output)) {
    869         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    870         psFree(output);
    871         return false;
    872     }
    873 
    874760    // negative simple so the default is true
    875761    if (!ippdbPrintMetadatas(stdout, output, "fakeMask", !simple)) {
     
    937823        psFree(output);
    938824        return true;
    939     }
    940 
    941     if (!convertIdToStr(output)) {
    942         psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
    943         psFree(output);
    944         return false;
    945825    }
    946826
Note: See TracChangeset for help on using the changeset viewer.