IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21308 for trunk/ippTools/src


Ignore:
Timestamp:
Feb 5, 2009, 9:35:41 AM (17 years ago)
Author:
bills
Message:

Changed the way image ids are handled. For chip and warp new tables are
added the sole purpose of which are to create the image ids before
the images are created. For diff the id is added to diffInputSkyfile

Location:
trunk/ippTools/src
Files:
6 edited

Legend:

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

    r20973 r21308  
    485485                                   path_base,
    486486                                   code,
    487                                    0,   // chip_image_id
    488487                                   0    // magic_ds_id
    489488            )) {
     
    530529    pxchipGetSearchArgs (config, where); // chipRun, chipProcessedImfile, rawExp
    531530    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
     531    PXOPT_COPY_S64(config->args, where, "-chip_imfile_id", "chipImfile.chip_imfile_id", "==");
    532532    PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
    533533    PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
     
    542542    if (where && psListLength(where->list)) {
    543543        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    544         psStringAppend(&query, " AND %s", whereClause);
     544        psStringAppend(&query, " WHERE %s", whereClause);
    545545        psFree(whereClause);
    546546    }
  • trunk/ippTools/src/chiptoolConfig.c

    r20244 r21308  
    150150    // -processedimfile
    151151    psMetadata *processedimfileArgs = psMetadataAlloc();
    152     psMetadataAddS64(processedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,         "define chip ID", 0);
     152    psMetadataAddS64(processedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,         "search by  chip ID", 0);
     153    psMetadataAddS64(processedimfileArgs, PS_LIST_TAIL, "-chip_imfile_id",  0,  "search by chip_file_id", 0);
    153154    psMetadataAddStr(processedimfileArgs,  PS_LIST_TAIL, "-class_id",           0, "search by class ID", NULL);
    154155    psMetadataAddStr(processedimfileArgs,  PS_LIST_TAIL, "-reduction",          0, "search by reduction class", NULL);
  • trunk/ippTools/src/difftool.c

    r21237 r21308  
    239239            warp2 ? warp2 : PS_MAX_S64, // defined or NULL
    240240            stack2 ? stack2 : PS_MAX_S64, // defined or NULL
    241             tess_id
     241            tess_id,
     242            0                             // diff_skyfile_id
    242243        )) {
    243244        if (!psDBRollback(config->dbh)) {
     
    532533                           good_frac,
    533534                           code,
    534                            0,       // diff_image_id
    535535                           0        // magic_ds_id
    536536          )) {
     
    568568    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diffSkyfile.diff_id", "==");
    569569    PXOPT_COPY_STR(config->args, where, "-skycell_id", "diffInputSkyfile.skycell_id", "==");
    570     PXOPT_COPY_S64(config->args, where,  "-diff_image_id", "diffSkyfile.diff_image_id", "==");
     570    PXOPT_COPY_S64(config->args, where,  "-diff_skyfile_id", "diffInputSkyfile.diff_skyfile_id", "==");
    571571    PXOPT_COPY_STR(config->args, where, "-tess_id", "diffSkyfile.tess_id", "==");
    572572    PXOPT_COPY_S16(config->args, where, "-code", "diffSkyfile.fault", "==");
     
    834834            template_warp_id,
    835835            template_stack_id,
    836             tess_id
     836            tess_id,
     837            0
    837838        )) {
    838839        if (!psDBRollback(config->dbh)) {
  • trunk/ippTools/src/difftoolConfig.c

    r21188 r21308  
    115115    psMetadataAddS64(diffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0,            "search by diff ID", 0);
    116116    psMetadataAddStr(diffskyfileArgs , PS_LIST_TAIL, "-skycell_id",  0,       "define skycell ID", NULL);
    117     psMetadataAddS64(diffskyfileArgs, PS_LIST_TAIL, "-diff_image_id", 0,      "search by diff_image_id ID", 0);
     117    psMetadataAddS64(diffskyfileArgs, PS_LIST_TAIL, "-diff_skyfile_id", 0,    "search by diff_skyfile_id ID", 0);
    118118    psMetadataAddStr(diffskyfileArgs, PS_LIST_TAIL, "-tess_id",  0,            "define tessellation ID", NULL);
    119119    psMetadataAddS64(diffskyfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "define exposure ID", 0);
  • trunk/ippTools/src/pxchip.c

    r20750 r21308  
    235235    PS_ASSERT_PTR_NON_NULL(config, false);
    236236
     237    if (!psDBTransaction(config->dbh)) {
     238        psError(PS_ERR_UNKNOWN, false, "database error");
     239        return false;
     240    }
     241
     242
    237243    // create a chipRun
    238244    if (!chipRunInsert(config->dbh,
     
    249255            end_stage)
    250256    ) {
     257        if (!psDBRollback(config->dbh)) {
     258            psError(PS_ERR_UNKNOWN, false, "database error failed to rollback transaction");
     259        }
    251260        psError(PS_ERR_UNKNOWN, false, "database error");
    252261        return 0;
    253262    }
    254263
    255     return psDBLastInsertID(config->dbh);
    256 }
    257 
     264    psS64 chip_id =  psDBLastInsertID(config->dbh);
     265
     266    // Create rows in chipImfile table for each input exposure.
     267    // This creates the chip_image_id values
     268    psString query = "INSERT INTO chipImfile "
     269                     "SELECT %" PRId64 ", class_id, 0 FROM rawImfile WHERE exp_id = %" PRId64;
     270
     271    if (!p_psDBRunQuery(config->dbh, query, chip_id, exp_id)) {
     272        psError(PS_ERR_UNKNOWN, false, "database error");
     273        // rollback
     274        if (!psDBRollback(config->dbh)) {
     275            psError(PS_ERR_UNKNOWN, false, "database error");
     276        }
     277        psError(PS_ERR_UNKNOWN, false, "database error");
     278        return 0;
     279    }
     280    if (!psDBCommit(config->dbh)) {
     281        psError(PS_ERR_UNKNOWN, false, "database error");
     282        return 0;
     283    }
     284   
     285    return chip_id;
     286}
     287
  • trunk/ippTools/src/warptool.c

    r20973 r21308  
    681681{
    682682    unsigned int nFail = 0;
     683    psMetadata *imfiles = psMetadataAlloc();
    683684    psMetadata *skycells = psMetadataConfigRead(NULL, &nFail, mapfile, false);
    684685    if (!skycells) {
     
    689690        psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing mapfile: %s", nFail, mapfile);
    690691        psFree(skycells);
     692        psFree(imfiles);
    691693        return false;
    692694    }
     
    699701            psFree(iter);
    700702            psFree(skycells);
     703            psFree(imfiles);
    701704            return false;
    702705        }
     
    710713            psFree(iter);
    711714            psFree(skycells);
    712             return false;
    713         }
     715            psFree(imfiles);
     716            return false;
     717        }
     718        psMetadataAddS64(imfiles, PS_LIST_TAIL, row->skycell_id, PS_META_REPLACE, "", row->warp_id);
    714719
    715720        if (!warpSkyCellMapInsertObject(config->dbh, row)) {
     
    726731            psFree(iter);
    727732            psFree(skycells);
     733            psFree(imfiles);
    728734            return false;
    729735        }
    730736
    731737        psFree(row);
     738    }
     739    psFree(iter);
     740
     741    // create warp_skyfile_ids for the output skyfiles
     742    psString query = "INSERT INTO warpImfile VALUES(%" PRId64 ", '%s', 0)";
     743    iter = psMetadataIteratorAlloc(imfiles, 0, NULL);
     744    while ((item = psMetadataGetAndIncrement(iter))) {
     745        psString skycell_id = item->name;
     746        psS64 warp_id = item->data.S64;
     747
     748        if (!p_psDBRunQuery(config->dbh, query, warp_id, skycell_id)) {
     749            psError(PS_ERR_UNKNOWN, false, "database error");
     750            return false;
     751        }
    732752    }
    733753    psFree(iter);
    734754    psFree(skycells);
     755    psFree(imfiles);
    735756
    736757    return true;
     
    940961                           !accept,
    941962                           code,
    942                            0,           // warp_image_id
    943963                           0            // magic_ds_id
    944964        )) {
Note: See TracChangeset for help on using the changeset viewer.