Changeset 25149 for branches/czw_branch/cleanup/ippTools/src/pstamptool.c
- Timestamp:
- Aug 20, 2009, 11:48:09 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup/ippTools/src/pstamptool.c
r25051 r25149 315 315 PS_ASSERT_PTR_NON_NULL(config, false); 316 316 317 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 317 psMetadata *where = psMetadataAlloc(); 318 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 319 PXOPT_COPY_STR(config->args, where, "-name", "name", "=="); 320 318 321 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 319 322 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 320 323 321 psString query = NULL; 322 psStringAppend(&query, "SELECT * from pstampRequest WHERE req_id = %" PRId64, req_id); 324 if (!psListLength(where->list)) { 325 psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied"); 326 return false; 327 } 328 329 psString query = psStringCopy("SELECT * from pstampRequest"); 330 331 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 332 psStringAppend(&query, " WHERE %s", whereClause); 333 psFree(whereClause); 334 psFree(where); 323 335 324 336 // treat limit == 0 as "no limit" … … 342 354 } 343 355 if (!psArrayLength(output)) { 344 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 345 psFree(output); 346 return true; 356 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 357 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 358 psError(PXTOOLS_ERR_DATA, true, "request not found"); 359 psFree(output); 360 // we return false so that the caller can determine that a request does not exist 361 return false; 347 362 } 348 363 … … 496 511 { 497 512 bool stampJob = false; 498 char *query = NULL;499 513 500 514 PS_ASSERT_PTR_NON_NULL(config, false); … … 503 517 PXOPT_LOOKUP_STR(rownum, config->args, "-rownum", true, false); 504 518 PXOPT_LOOKUP_STR(job_type, config->args, "-job_type", false, false); 505 PXOPT_LOOKUP_STR(outputBase, config->args, "-outputBase", true, false);519 PXOPT_LOOKUP_STR(outputBase, config->args, "-outputBase", false, false); 506 520 PXOPT_LOOKUP_STR(stateString, config->args, "-state", false, false); 507 PXOPT_LOOKUP_S TR(fault, config->args, "-fault", false, false);521 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 508 522 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 509 523 524 // unless the job is being inserted with stop state require outputBase 525 if (strcmp(stateString, "stop") && !outputBase) { 526 psError(PS_ERR_UNKNOWN, true, "-outputBase is required"); 527 return false; 528 } 529 510 530 // default value for job_type is defined in pstamptoolConfig.c 511 if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query") ) {531 if (!strcmp(job_type, "get_image") || !strcmp(job_type, "detect_query") || !strcmp(job_type, "none")) { 512 532 stampJob = false; 513 533 } else if (!strcmp(job_type, "stamp")) { … … 517 537 return false; 518 538 } 519 if (stampJob) { 520 query = pxDataGet("pstamptool_addjob_stampjob.sql"); 521 } else { 522 query = pxDataGet("pstamptool_addjob_otherjob.sql"); 523 } 524 if (!query) { 525 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 526 return false; 527 } 528 529 if (!p_psDBRunQueryF(config->dbh, query, req_id, rownum, stateString, job_type, exp_id, outputBase, fault)) { 539 if (!pstampJobInsert(config->dbh, 540 0, // job_id 541 req_id, 542 rownum, 543 stateString, 544 job_type, 545 fault, 546 exp_id, 547 outputBase 548 )) { 530 549 psError(PS_ERR_UNKNOWN, false, "database error"); 531 550 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
