Changeset 11866
- Timestamp:
- Feb 16, 2007, 4:42:08 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
-
pxtables.c (modified) (2 diffs)
-
stacktool.c (modified) (17 diffs)
-
stacktoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxtables.c
r11784 r11866 86 86 CREATE_TABLE(p5InputScfileCreateTable); 87 87 CREATE_TABLE(p5DiffScfileCreateTable); 88 CREATE_TABLE(p6RunCreateTable); 89 CREATE_TABLE(p6InputScfileCreateTable); 90 CREATE_TABLE(p6SumScfileCreateTable); 88 91 89 92 return true; … … 159 162 DROP_TABLE(p5InputScfileDropTable); 160 163 DROP_TABLE(p5DiffScfileDropTable); 164 DROP_TABLE(p6RunDropTable); 165 DROP_TABLE(p6InputScfileDropTable); 166 DROP_TABLE(p6SumScfileDropTable); 161 167 162 168 return status; -
trunk/ippTools/src/stacktool.c
r11851 r11866 94 94 // required options 95 95 bool status = false; 96 psString mode = psMetadataLookupStr(&status, config->args, "-mode");97 if (!status) {98 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -survey_mode");99 return false;100 }101 if (!mode) {102 psError(PS_ERR_UNKNOWN, true, "-mode is required");103 return false;104 }105 106 96 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir"); 107 97 if (!status) { … … 129 119 } 130 120 131 p 4RunRow *p4Run = p4RunRowAlloc(121 p6RunRow *run = p6RunRowAlloc( 132 122 0, // ID 133 mode,134 123 "reg", // state 135 124 workdir, … … 137 126 ); 138 127 psFree(registered); 139 if (! p4Run) {140 psError(PS_ERR_UNKNOWN, false, "failed to alloc p 4Run object");128 if (!run) { 129 psError(PS_ERR_UNKNOWN, false, "failed to alloc p6Run object"); 141 130 return true; 142 131 } 143 if (!p 4RunInsertObject(config->dbh, p4Run)) {132 if (!p6RunInsertObject(config->dbh, run)) { 144 133 psError(PS_ERR_UNKNOWN, false, "database error"); 145 psFree( p4Run);134 psFree(run); 146 135 return true; 147 136 } 148 137 149 138 // get the assigned p4_id 150 p4Run->p4_id = psDBLastInsertID(config->dbh);139 run->p6_id = psDBLastInsertID(config->dbh); 151 140 152 141 bool simple = false; … … 156 145 if (!status) { 157 146 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 158 psFree( p4Run);159 return false; 160 } 161 } 162 163 if (!p 4RunPrintObject(stdout, p4Run, !simple)) {147 psFree(run); 148 return false; 149 } 150 } 151 152 if (!p6RunPrintObject(stdout, run, !simple)) { 164 153 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 165 psFree( p4Run);166 return false; 167 } 168 169 psFree( p4Run);154 psFree(run); 155 return false; 156 } 157 158 psFree(run); 170 159 171 160 return true; … … 178 167 179 168 bool status = false; 169 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id"); 170 if (!status) { 171 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id"); 172 return false; 173 } 174 if (!p6_id) { 175 psError(PS_ERR_UNKNOWN, true, "-p6_id is required"); 176 return false; 177 } 178 179 psString state = psMetadataLookupStr(&status, config->args, "-state"); 180 if (!status) { 181 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 182 return false; 183 } 184 if (!state) { 185 psError(PS_ERR_UNKNOWN, true, "-state is required"); 186 return false; 187 } 188 189 if (state) { 190 // set detRun.state to state 191 return setp6RunState(config, p6_id, state); 192 } 193 194 return true; 195 } 196 197 198 static bool addinputscfileMode(pxConfig *config) 199 { 200 PS_ASSERT_PTR_NON_NULL(config, false); 201 202 bool status = false; 203 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id"); 204 if (!status) { 205 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id"); 206 return false; 207 } 208 if (!p6_id) { 209 psError(PS_ERR_UNKNOWN, true, "-p6_id is required"); 210 return false; 211 212 } 213 180 214 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id"); 181 215 if (!status) { 182 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4 t_id");216 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id"); 183 217 return false; 184 218 } … … 188 222 } 189 223 190 psString state = psMetadataLookupStr(&status, config->args, "-state"); 191 if (!status) { 192 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 193 return false; 194 } 195 if (!state) { 196 psError(PS_ERR_UNKNOWN, true, "-state is required"); 197 return false; 198 } 199 200 if (state) { 201 // set detRun.state to state 202 return setp6RunState(config, p4_id, state); 203 } 204 205 return true; 206 } 207 208 209 static bool addinputscfileMode(pxConfig *config) 210 { 211 PS_ASSERT_PTR_NON_NULL(config, false); 212 213 bool status = false; 214 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id"); 215 if (!status) { 216 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id"); 217 return false; 218 } 219 if (!p4_id) { 220 psError(PS_ERR_UNKNOWN, true, "-p4_id is required"); 221 return false; 222 } 223 224 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 225 if (!status) { 226 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 227 return false; 228 } 229 if (!exp_tag) { 230 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 231 return false; 232 } 233 234 // defaults to 0 235 psS32 p3_version = psMetadataLookupS32(&status, config->args, "-p3_version"); 236 if (!status) { 237 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version"); 238 return false; 239 } 240 241 // defaults to false 242 bool magiced = psMetadataLookupBool(&status, config->args, "-p3_version"); 243 if (!status) { 244 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version"); 224 psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id"); 225 if (!status) { 226 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id"); 227 return false; 228 } 229 if (!skycell_id) { 230 psError(PS_ERR_UNKNOWN, true, "-skycell_id is required"); 231 return false; 232 } 233 234 psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id"); 235 if (!status) { 236 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id"); 237 return false; 238 } 239 if (!tess_id) { 240 psError(PS_ERR_UNKNOWN, true, "-tess_id is required"); 245 241 return false; 246 242 } … … 249 245 // XXX instead of validiting it here we should just use forgein key 250 246 // constrants 251 if (!p4InputExpInsert(config->dbh, 247 if (!p6InputScfileInsert(config->dbh, 248 (psS32)atoi(p6_id), 252 249 (psS32)atoi(p4_id), 253 exp_tag, 254 p3_version, 255 magiced 250 skycell_id, 251 tess_id 256 252 )) { 257 253 psError(PS_ERR_UNKNOWN, false, "database error"); … … 277 273 psString query = psStringCopy( 278 274 "SELECT\n" 279 " rawImfile.*\n" 280 " FROM p4Run\n" 281 " JOIN p4InputExp\n" 282 " USING(p4_id)\n" 283 " JOIN rawImfile\n -- is there any reason not to refer back to rawimfiles?" 284 " ON p4InputExp.exp_tag = rawImfile.exp_tag\n" 275 " p4Scfile.*\n" 276 " FROM p6Run\n" 277 " JOIN p6InputScfile\n" 278 " USING(p6_id)\n" 279 " JOIN p4Scfile\n" 280 " ON p6InputScfile.p4_id = p4Scfile.p4_id\n" 281 " AND p6InputScfile.skycell_id = p4Scfile.skycell_id\n" 282 " AND p6InputScfile.tess_id = p4Scfile.tess_id\n" 285 283 " WHERE\n" 286 " p 4Run.state = 'run'\n"284 " p6Run.state = 'run'\n" 287 285 ); 288 286 if (config->where) { 289 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p 4InputExp");287 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6InputScfile"); 290 288 psStringAppend(&query, " AND %s", whereClause); 291 289 psFree(whereClause); … … 321 319 } 322 320 if (!psArrayLength(output)) { 323 psError(PS_ERR_UNKNOWN, false, "no p ending rawImfile rows found");321 psError(PS_ERR_UNKNOWN, false, "no p6InputScfile rows found"); 324 322 psFree(output); 325 323 return true; … … 338 336 if (psArrayLength(output)) { 339 337 // negative simple so the default is true 340 if (!ippdbPrintMetadatas(stdout, output, "p 4InputImfile", !simple)) {338 if (!ippdbPrintMetadatas(stdout, output, "p6InputScfile", !simple)) { 341 339 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 342 340 psFree(output); … … 365 363 psString query = psStringCopy( 366 364 "SELECT\n" 367 " p3ProcessedExp.*\n" 368 " FROM p4Run\n" 369 " JOIN p4InputExp\n" 370 " USING(p4_id)\n" 371 " JOIN p3ProcessedExp\n" 372 " ON p4InputExp.exp_tag = p3ProcessedExp.exp_tag\n" 373 " AND p4InputExp.p3_version = p3ProcessedExp.p3_version\n" 374 " LEFT JOIN p4SkyCellMap\n" 375 " ON p4InputExp.p4_id = p4SkyCellMap.p4_id\n" 376 " AND p4InputExp.exp_tag = p4SkyCellMap.exp_tag\n" 377 " AND p4InputExp.p3_version = p4SkyCellMap.p3_version\n" 365 " p6Run.p6_id\n" 366 " FROM p6Run\n" 367 " LEFT JOIN p4SumScfile\n" 368 " USING(p6_id)\n" 378 369 " WHERE\n" 379 " p4Run.state = 'run'\n" 380 " AND p3ProcessedExp.fault = 0\n" 381 " AND p4SkyCellMap.p4_id IS NULL\n" 382 " AND p4SkyCellMap.exp_tag IS NULL\n" 383 " AND p4SkyCellMap.p3_version IS NULL\n" 370 " p6Run.state = 'run'\n" 371 " AND p6SumScfile.p6_id IS NULL\n" 384 372 ); 385 373 386 374 if (config->where) { 387 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p 4InputExp");375 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumScfile"); 388 376 psStringAppend(&query, " AND %s", whereClause); 389 377 psFree(whereClause); … … 419 407 } 420 408 if (!psArrayLength(output)) { 421 psError(PS_ERR_UNKNOWN, false, "no p ending rawImfile rows found");409 psError(PS_ERR_UNKNOWN, false, "no p6SumScfile rows found"); 422 410 psFree(output); 423 411 return true; … … 436 424 if (psArrayLength(output)) { 437 425 // negative simple so the default is true 438 if (!ippdbPrintMetadatas(stdout, output, "p 4InputExp", !simple)) {426 if (!ippdbPrintMetadatas(stdout, output, "p6SumScfile", !simple)) { 439 427 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 440 428 psFree(output); … … 454 442 455 443 bool status = false; 456 psString mapfile = psMetadataLookupStr(&status, config->args, "-mapfile"); 457 if (!status) { 458 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mapfile"); 459 return false; 460 } 461 if (!mapfile) { 462 psError(PS_ERR_UNKNOWN, true, "-mapfile is required"); 463 return false; 464 } 465 466 if (!psDBTransaction(config->dbh)) { 467 psError(PS_ERR_UNKNOWN, false, "database error"); 468 return false; 469 } 470 471 // point of no return 472 if (!psDBCommit(config->dbh)) { 444 psString p6_id = psMetadataLookupStr(&status, config->args, "-p6_id"); 445 if (!status) { 446 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p6_id"); 447 return false; 448 } 449 if (!p6_id) { 450 psError(PS_ERR_UNKNOWN, true, "-p6_id is required"); 451 return false; 452 453 } 454 455 psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id"); 456 if (!status) { 457 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id"); 458 return false; 459 } 460 if (!skycell_id) { 461 psError(PS_ERR_UNKNOWN, true, "-skycell_id is required"); 462 return false; 463 } 464 465 psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id"); 466 if (!status) { 467 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id"); 468 return false; 469 } 470 if (!tess_id) { 471 psError(PS_ERR_UNKNOWN, true, "-tess_id is required"); 472 return false; 473 } 474 475 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 476 if (!status) { 477 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 478 return false; 479 } 480 if (!uri) { 481 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 482 return false; 483 } 484 485 // optional 486 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 487 if (!status) { 488 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 489 return false; 490 } 491 492 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 493 if (!status) { 494 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 495 return false; 496 } 497 498 // XXX need to validate the p6_id here 499 // XXX instead of validiting it here we should just use forgein key 500 // constrants 501 if (!p6SumScfileInsert(config->dbh, 502 (psS32)atoi(p6_id), 503 skycell_id, 504 tess_id, 505 uri, 506 bg, 507 bg_mean_stdev 508 )) { 473 509 psError(PS_ERR_UNKNOWN, false, "database error"); 474 510 return false; … … 493 529 psString query = psStringCopy( 494 530 "SELECT\n" 495 " p 4Scfile.*\n"496 " FROM p 4Run\n"497 " JOIN p 4Scfile\n"498 " USING(p 4_id)\n"531 " p6SumScfile.*\n" 532 " FROM p6Run\n" 533 " JOIN p6SumScfile\n" 534 " USING(p6_id)\n" 499 535 " WHERE\n" 500 " p 4Run.state = 'run'\n"536 " p6Run.state = 'run'\n" 501 537 ); 502 538 503 539 if (config->where) { 504 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p 4Scfile");540 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p6SumScfile"); 505 541 psStringAppend(&query, " AND %s", whereClause); 506 542 psFree(whereClause); … … 552 588 553 589 if (psArrayLength(output)) { 554 // negative simple so the default is true 555 if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) { 590 if (!ippdbPrintMetadatas(stdout, output, "p6SumScfile", !simple)) { 556 591 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 557 592 psFree(output); … … 583 618 } 584 619 585 char *query = "UPDATE p 4Run SET state = '%s' WHERE p4_id = '%s'";620 char *query = "UPDATE p6Run SET state = '%s' WHERE p6_id = '%s'"; 586 621 if (!p_psDBRunQuery(config->dbh, query, state, p6_id)) { 587 622 psError(PS_ERR_UNKNOWN, false, -
trunk/ippTools/src/stacktoolConfig.c
r11851 r11866 48 48 // -definerun 49 49 psMetadata *definerunArgs = psMetadataAlloc(); 50 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-mode", 0,51 "define mode (required)", NULL);52 50 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-workdir", 0, 53 51 "define workdir (required)", NULL); … … 113 111 // -addsumscfile 114 112 psMetadata *addsumscfileArgs = psMetadataAlloc(); 115 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-p 4_id", 0,113 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-p6_id", 0, 116 114 "define p4 ID (required)", NULL); 117 115 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-skycell_id", 0,
Note:
See TracChangeset
for help on using the changeset viewer.
