IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 28, 2010, 3:09:59 PM (16 years ago)
Author:
watersc1
Message:

JPEG work should be done. Transitioning to try to pick up stackAssociation concept in this branch as well.

Location:
branches/czw_branch/20100519
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100519

  • branches/czw_branch/20100519/ippTools/src

    • Property svn:ignore
      •  

        old new  
        2020flatcorr
        2121guidetool
         22labeltool
        2223magicdstool
        2324magictool
         
        3738stamp-h1
        3839warptool
         40
  • branches/czw_branch/20100519/ippTools/src/stacktool.c

    r28043 r28164  
    4040static bool sumskyfileMode(pxConfig *config);
    4141static bool revertsumskyfileMode(pxConfig *config);
     42static bool tosummaryMode(pxConfig *config);
     43static bool addsummaryMode(pxConfig *config);
    4244static bool pendingcleanuprunMode(pxConfig *config);
    4345static bool pendingcleanupskyfileMode(pxConfig *config);
     
    7678        MODECASE(STACKTOOL_MODE_SUMSKYFILE,            sumskyfileMode);
    7779        MODECASE(STACKTOOL_MODE_REVERTSUMSKYFILE,      revertsumskyfileMode);
     80        MODECASE(STACKTOOL_MODE_TOSUMMARY,             tosummaryMode);
     81        MODECASE(STACKTOOL_MODE_ADDSUMMARY,            addsummaryMode);
    7882        MODECASE(STACKTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    7983        MODECASE(STACKTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
     
    11251129}
    11261130#endif
     1131static bool tosummaryMode(pxConfig *config) {
     1132  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1133 
     1134  psMetadata *where = psMetadataAlloc();
     1135  PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackSumSkyfile.warp_id", "==");
     1136  PXOPT_COPY_STR(config->args, where, "-tess_id",    "stackSumSkyfile.tess_id", "==");
     1137  PXOPT_COPY_STR(config->args, where, "-state",      "stackRun.state", "==");
     1138  PXOPT_COPY_STR(config->args, where, "-filter",    "stackRun.filter", "LIKE");
     1139  pxAddLabelSearchArgs (config, where, "-label",   "stackRun.label", "LIKE");
     1140  pxAddLabelSearchArgs (config, where, "-data_group",   "stackRun.data_group", "LIKE");
     1141 
     1142  PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     1143
     1144  PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1145  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1146 
     1147  // find all rawImfiles matching the default query
     1148  psString query = pxDataGet("stacktool_tosummary.sql");
     1149  if (!query) {
     1150    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1151    return false;
     1152  }
     1153
     1154  // generate where strings for arguments that require extra processing
     1155  // beyond PXOPT_COPY*
     1156  if (psListLength(where->list)) {
     1157    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1158    psStringAppend(&query, " WHERE %s", whereClause);
     1159    psFree(whereClause);
     1160  } else if (!all) {
     1161    psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     1162    return false;
     1163  }
     1164 
     1165  psFree(where);
     1166
     1167  // treat limit == 0 as "no limit"
     1168  if (limit) {
     1169    psString limitString = psDBGenerateLimitSQL(limit);
     1170    psStringAppend(&query, " %s", limitString);
     1171    psFree(limitString);
     1172  }
     1173 
     1174  if (!p_psDBRunQuery(config->dbh, query)) {
     1175    psError(PS_ERR_UNKNOWN, false, "database error");
     1176    psFree(query);
     1177    return false;
     1178  }
     1179  psFree(query);
     1180
     1181  psArray *output = p_psDBFetchResult(config->dbh);
     1182  if (!output) {
     1183    psErrorCode err = psErrorCodeLast();
     1184    switch (err) {
     1185    case PS_ERR_DB_CLIENT:
     1186      psError(PXTOOLS_ERR_SYS, false, "database error");
     1187    case PS_ERR_DB_SERVER:
     1188      psError(PXTOOLS_ERR_PROG, false, "database error");
     1189    default:
     1190      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1191    }
     1192   
     1193    return false;
     1194  }
     1195  if (!psArrayLength(output)) {
     1196    psTrace("stacktool", PS_LOG_INFO, "no rows found");
     1197    psFree(output);
     1198    return true;
     1199  }
     1200 
     1201  if (psArrayLength(output)) {
     1202    // negative simple so the default is true
     1203    if (!ippdbPrintMetadatas(stdout, output, "stackRun", !simple)) {
     1204      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1205      psFree(output);
     1206      return false;
     1207    }
     1208  }
     1209 
     1210  psFree(output);
     1211  return(true);
     1212}
     1213static bool addsummaryMode(pxConfig *config) {
     1214  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1215
     1216  PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", true, false);
     1217  PXOPT_LOOKUP_STR(tangent_plane, config->args, "-tangent_plane", true, false);
     1218  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
     1219
     1220  psString query = pxDataGet("stacktool_addsummary.sql");
     1221  if (!query) {
     1222    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1223    return(false);
     1224  }
     1225  if (!p_psDBRunQueryF(config->dbh, query, stack_id, tangent_plane, path_base)) {
     1226    psError(PS_ERR_UNKNOWN, false, "database error");
     1227    psFree(query);
     1228    return(false);
     1229  }
     1230  psS64 numUpdated = psDBAffectedRows(config->dbh);
     1231 
     1232  if (numUpdated != 1) {
     1233    psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     1234    psFree(query);
     1235    return false;
     1236  }
     1237 
     1238  psFree(query);
     1239
     1240  // Print anything here?
     1241 
     1242  return(true);
     1243}
    11271244
    11281245static bool pendingcleanuprunMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.