IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2010, 12:00:46 PM (16 years ago)
Author:
watersc1
Message:

Final changes before trunk->branch merge.

Then, simtest to see if it all works correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100519/ippTools/src/stacktool.c

    r28164 r28245  
    106106    exit(exit_status);
    107107}
     108//stackAssociationRow *association = pxStackAssociationDefine(data_group,tess_id,filter,skycell_id);
     109stackAssociationRow *pxStackAssociationDefine(pxConfig *config, psS64 stack_id) {
     110  psString select = pxDataGet("stacktool_associationdefine_select.sql");
     111  if (!select) {
     112    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     113    return false;
     114  }
     115
     116  psString idString = NULL;
     117  psStringAppend(&idString, "%" PRId64, stack_id);
     118  psStringSubstitute(&select,idString, "@STACK_ID@");
     119  psFree(idString);
     120
     121  if (!p_psDBRunQuery(config->dbh, select)) {
     122    psError(PS_ERR_UNKNOWN,false, "database error");
     123    psFree(select);
     124    return(NULL);
     125  }
     126  psFree(select);
     127  psArray *output = p_psDBFetchResult(config->dbh);
     128  if (!output) {
     129    psErrorCode err = psErrorCodeLast();
     130    switch (err) {
     131    case PS_ERR_DB_CLIENT:
     132      psError(PXTOOLS_ERR_SYS, false, "database error");
     133    case PS_ERR_DB_SERVER:
     134      psError(PXTOOLS_ERR_PROG, false, "database error");
     135    default:
     136      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     137    }
     138    return(NULL);
     139  }
     140  if (psArrayLength(output) != 1) {
     141    psWarning("stacktool: incorrect number of rows found");
     142    psFree(output);
     143    return(NULL);
     144  }
     145  psMetadata *outrow = NULL;
     146  for (long i = 0; i < output->n; i++) {
     147    psMetadata *row = output->data[i];
     148    if (!psMetadataCopy(row,outrow)) {
     149      psError(PS_ERR_UNKNOWN, false, "Failed to copy row to return");
     150      return(NULL);
     151    }
     152  }
     153  psFree(output);
     154  stackAssociationRow *sassRow = stackAssociationObjectFromMetadata(outrow);
     155  psFree(outrow);
     156  return(sassRow);
     157}
     158     
     159     
     160 
     161                                             
    108162
    109163
     
    399453        psFree(run);
    400454
     455        //CZW Add an association entry here.
     456        // Define the requested association, and insert it if it doesn't already exist
     457        stackAssociationRow *association = pxStackAssociationDefine(config,stack_id);
     458        psS64 sass_id;
     459        if (!association->sass_id) {
     460          psTrace("stacktool.association",2,"No required Association found. Adding.");
     461
     462          if (!stackAssociationInsertObject(config->dbh,association)) {
     463            if (!psDBRollback(config->dbh)) {
     464              psError(PS_ERR_UNKNOWN, false, "database error");
     465            }
     466            psError(PS_ERR_UNKNOWN, false, "database error");
     467            psFree(output);
     468            psFree(run);
     469            psFree(insert);
     470            psFree(list);
     471            psFree(association);
     472            if (!psDBRollback(config->dbh)) {
     473              psError(PS_ERR_UNKNOWN, false, "database error");
     474            }
     475            return(false);
     476          }
     477          sass_id = psDBLastInsertID(config->dbh);
     478          association->sass_id = sass_id;
     479        }
     480        // Insert the map entry for this row.
     481        stackAssociationMapRow *maprow = stackAssociationMapRowAlloc(sass_id,stack_id);
     482        if (!stackAssociationMapInsertObject(config->dbh,maprow)) {
     483          if (!psDBRollback(config->dbh)) {
     484            psError(PS_ERR_UNKNOWN, false, "database error");
     485          }
     486          psError(PS_ERR_UNKNOWN, false, "database error");
     487          psFree(output);
     488          psFree(run);
     489          psFree(insert);
     490          psFree(list);
     491          psFree(association);
     492          if (!psDBRollback(config->dbh)) {
     493            psError(PS_ERR_UNKNOWN, false, "database error");
     494          }
     495          return(false);
     496        }
     497       
     498       
    401499        // Create a suitable insertion query for this run
    402500        psString thisInsert = psStringCopy(insert);
     
    556654    run->stack_id = psDBLastInsertID(config->dbh);
    557655
     656    //CZW Add an association entry here.
     657   
    558658    // insert the stackInputSkyfile rows
    559659    psListIterator *iter = psListIteratorAlloc(warp_ids->data.list, 0, false);
     
    607707#endif
    608708    psMetadata *where = psMetadataAlloc();
    609     PXOPT_COPY_S64(config->args, where, "-stack_id",  "stack_id",   "==");
    610     PXOPT_COPY_STR(config->args, where, "-label",     "label",     "==");
    611     PXOPT_COPY_STR(config->args, where, "-state",     "state",     "==");
     709    PXOPT_COPY_S64(config->args, where, "-stack_id",  "stackRun.stack_id",   "==");
     710    PXOPT_COPY_STR(config->args, where, "-label",     "stackRun.label",     "==");
     711    PXOPT_COPY_STR(config->args, where, "-state",     "stackRun.state",     "==");
     712    PXOPT_COPY_STR(config->args, where, "-sass_id",   "stackAssociationMap.sass_id",  "==");
    612713    if (!psListLength(where->list)) {
    613714        psFree(where);
     
    616717    }
    617718
     719    //CZW join against stackAssociationMap
    618720    psString query = psStringCopy("UPDATE stackRun");
    619721
     
    9611063    psMetadata *where = psMetadataAlloc();
    9621064    PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "==");
     1065    PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociationMap.sass_id", "==");
    9631066    PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "==");
    9641067    PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "==");
     
    11341237  psMetadata *where = psMetadataAlloc();
    11351238  PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackSumSkyfile.warp_id", "==");
     1239  PXOPT_COPY_S64(config->args, where, "-sass_id",     "stackAssociationMap.sass_id", "==");
    11361240  PXOPT_COPY_STR(config->args, where, "-tess_id",    "stackSumSkyfile.tess_id", "==");
    11371241  PXOPT_COPY_STR(config->args, where, "-state",      "stackRun.state", "==");
     
    12151319
    12161320  PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", true, false);
    1217   PXOPT_LOOKUP_STR(tangent_plane, config->args, "-tangent_plane", true, false);
     1321  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
    12181322  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    12191323
     
    12231327    return(false);
    12241328  }
    1225   if (!p_psDBRunQueryF(config->dbh, query, stack_id, tangent_plane, path_base)) {
     1329  if (!p_psDBRunQueryF(config->dbh, query, stack_id, projection_cell, path_base)) {
    12261330    psError(PS_ERR_UNKNOWN, false, "database error");
    12271331    psFree(query);
     
    12511355
    12521356    psMetadata *where = psMetadataAlloc();
     1357    PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "==");
     1358    PXOPT_COPY_S64(config->args, where, "-sass_id", "stackAssociationMap.sass_id", "==");
     1359   
    12531360    pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "==");
    12541361
     
    13771484    psMetadata *where = psMetadataAlloc();
    13781485    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1486    PXOPT_COPY_STR(config->args, where, "-sass_id", "sass_id", "==");
    13791487
    13801488    psString query = pxDataGet("stacktool_donecleanup.sql");
     
    14461554}
    14471555
     1556//CZW I have not added sass information to the export/import run modes yet.
    14481557bool exportrunMode(pxConfig *config)
    14491558{
Note: See TracChangeset for help on using the changeset viewer.