Changeset 14061 for trunk/ippdb/src
- Timestamp:
- Jul 6, 2007, 4:55:04 PM (19 years ago)
- Location:
- trunk/ippdb/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippdb/src/ippdb.c
r13937 r14061 31 31 #include "ippdb.h" 32 32 33 #define EXPTAGCOUNTER_TABLE_NAME "expTagCounter"34 33 #define SUMMITEXP_TABLE_NAME "summitExp" 35 34 #define SUMMITIMFILE_TABLE_NAME "summitImfile" … … 43 42 #define RAWIMFILE_TABLE_NAME "rawImfile" 44 43 #define GUIDEPENDINGEXP_TABLE_NAME "guidePendingExp" 45 #define CHIP PENDINGEXP_TABLE_NAME "chipPendingExp"46 #define CHIP PENDINGIMFILE_TABLE_NAME "chipPendingImfile"47 #define CHIPPROCESSED EXP_TABLE_NAME "chipProcessedExp"44 #define CHIPRUN_TABLE_NAME "chipRun" 45 #define CHIPINPUTIMFILE_TABLE_NAME "chipInputImfile" 46 #define CHIPPROCESSEDIMFILE_TABLE_NAME "chipProcessedImfile" 48 47 #define CHIPMASK_TABLE_NAME "chipMask" 49 #define CHIPPROCESSEDIMFILE_TABLE_NAME "chipProcessedImfile" 50 #define CAMPENDINGEXP_TABLE_NAME "camPendingExp" 48 #define CAMRUN_TABLE_NAME "camRun" 51 49 #define CAMPROCESSEDEXP_TABLE_NAME "camProcessedExp" 52 50 #define CAMMASK_TABLE_NAME "camMask" … … 248 246 } 249 247 250 static void expTagCounterRowFree(expTagCounterRow *object);251 252 expTagCounterRow *expTagCounterRowAlloc(psU64 counter)253 {254 expTagCounterRow *_object;255 256 _object = psAlloc(sizeof(expTagCounterRow));257 psMemSetDeallocator(_object, (psFreeFunc)expTagCounterRowFree);258 259 _object->counter = counter;260 261 return _object;262 }263 264 static void expTagCounterRowFree(expTagCounterRow *object)265 {266 }267 268 bool expTagCounterCreateTable(psDB *dbh)269 {270 psMetadata *md = psMetadataAlloc();271 if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, 0)) {272 psError(PS_ERR_UNKNOWN, false, "failed to add item counter");273 psFree(md);274 return false;275 }276 277 bool status = psDBCreateTable(dbh, EXPTAGCOUNTER_TABLE_NAME, md);278 279 psFree(md);280 281 return status;282 }283 284 bool expTagCounterDropTable(psDB *dbh)285 {286 return psDBDropTable(dbh, EXPTAGCOUNTER_TABLE_NAME);287 }288 289 bool expTagCounterInsert(psDB * dbh, psU64 counter)290 {291 psMetadata *md = psMetadataAlloc();292 if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, counter)) {293 psError(PS_ERR_UNKNOWN, false, "failed to add item counter");294 psFree(md);295 return false;296 }297 298 bool status = psDBInsertOneRow(dbh, EXPTAGCOUNTER_TABLE_NAME, md);299 psFree(md);300 301 return status;302 }303 304 long long expTagCounterDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)305 {306 long long deleted = 0;307 308 long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);309 if (count < 0) {310 psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");311 return count;312 313 deleted += count;314 }315 316 return deleted;317 }318 bool expTagCounterInsertObject(psDB *dbh, expTagCounterRow *object)319 {320 return expTagCounterInsert(dbh, object->counter);321 }322 323 bool expTagCounterInsertObjects(psDB *dbh, psArray *objects)324 {325 for (long i = 0; i < psArrayLength(objects); i++) {326 if (!expTagCounterInsertObject(dbh, objects->data[i])) {327 return false;328 }329 }330 331 return true;332 }333 334 bool expTagCounterInsertFits(psDB *dbh, const psFits *fits)335 {336 psArray *rowSet;337 338 // move to (the first?) extension named EXPTAGCOUNTER_TABLE_NAME339 if (!psFitsMoveExtName(fits, EXPTAGCOUNTER_TABLE_NAME)) {340 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", EXPTAGCOUNTER_TABLE_NAME);341 return false;342 }343 344 // check HDU type345 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) {346 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");347 return false;348 }349 350 // read fits table351 rowSet = psFitsReadTable(fits);352 if (!rowSet) {353 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");354 psFree(rowSet);355 return false;356 }357 358 if (!psDBInsertRows(dbh, EXPTAGCOUNTER_TABLE_NAME, rowSet)) {359 psError(PS_ERR_UNKNOWN, false, "databse insert failed");360 psFree(rowSet);361 return false;362 }363 364 psFree(rowSet);365 366 return true;367 }368 369 bool expTagCounterSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)370 {371 psArray *rowSet;372 373 rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);374 if (!rowSet) {375 return false;376 }377 378 // output to fits379 if (!psFitsWriteTable(fits, NULL, rowSet, EXPTAGCOUNTER_TABLE_NAME)) {380 psError(PS_ERR_UNKNOWN, false, "FITS table write failed");381 psFree(rowSet);382 return false;383 }384 385 psFree(rowSet);386 387 return true;388 }389 390 psMetadata *expTagCounterMetadataFromObject(const expTagCounterRow *object)391 {392 psMetadata *md = psMetadataAlloc();393 if (!psMetadataAdd(md, PS_LIST_TAIL, "counter", PS_DATA_U64, NULL, object->counter)) {394 psError(PS_ERR_UNKNOWN, false, "failed to add item counter");395 psFree(md);396 return false;397 }398 399 400 return md;401 }402 403 expTagCounterRow *expTagCounterObjectFromMetadata(psMetadata *md)404 {405 406 bool status = false;407 psU64 counter = psMetadataLookupU64(&status, md, "counter");408 if (!status) {409 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item counter");410 return false;411 }412 413 return expTagCounterRowAlloc(counter);414 }415 psArray *expTagCounterSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)416 {417 psArray *rowSet;418 psArray *returnSet;419 psU64 i;420 421 rowSet = psDBSelectRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);422 if (!rowSet) {423 return NULL;424 }425 426 // convert psMetadata rows to row objects427 428 returnSet = psArrayAllocEmpty(rowSet->n);429 430 for (i = 0; i < rowSet->n; i++) {431 expTagCounterRow *object = expTagCounterObjectFromMetadata(rowSet->data[i]);432 psArrayAdd(returnSet, 0, object);433 psFree(object);434 }435 436 psFree(rowSet);437 438 return returnSet;439 }440 bool expTagCounterDeleteObject(psDB *dbh, const expTagCounterRow *object)441 {442 psMetadata *where = expTagCounterMetadataFromObject(object);443 long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, 0);444 psFree(where);445 if (count < 0) {446 psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");447 return false;448 }449 if (count > 1) {450 // XXX should this be a psAbort() instead? It is possible that451 // having an object match multiple rows was by design.452 psError(PS_ERR_UNKNOWN, true, "expTagCounterRow object matched more then one row. Check your database schema");453 return false;454 }455 456 return true;457 }458 long long expTagCounterDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)459 {460 long long deleted = 0;461 462 for (long long i = 0; i < objects->n; i++) {463 expTagCounterRow *object = objects->data[i];464 psMetadata *where = expTagCounterMetadataFromObject(object);465 long long count = psDBDeleteRows(dbh, EXPTAGCOUNTER_TABLE_NAME, where, limit);466 psFree(where);467 if (count < 0) {468 psError(PS_ERR_UNKNOWN, true, "failed to delete row from expTagCounter");469 return count;470 }471 472 deleted += count;473 }474 475 return deleted;476 }477 bool expTagCounterPrintObjects(FILE *stream, psArray *objects, bool mdcf)478 {479 PS_ASSERT_PTR_NON_NULL(objects, false);480 481 psMetadata *output = psMetadataAlloc();482 for (long i = 0; i < psArrayLength(objects); i++) {483 psMetadata *md = expTagCounterMetadataFromObject(objects->data[i]);484 if (!psMetadataAddMetadata(485 output,486 PS_LIST_TAIL,487 EXPTAGCOUNTER_TABLE_NAME,488 PS_META_DUPLICATE_OK,489 NULL,490 md491 )) {492 psError(PS_ERR_UNKNOWN, false, "failed to add metadata");493 psFree(md);494 psFree(output);495 return false;496 }497 psFree(md);498 }499 500 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {501 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");502 psFree(output);503 }504 psFree(output);505 506 return true;507 }508 bool expTagCounterPrintObject(FILE *stream, expTagCounterRow *object, bool mdcf)509 {510 PS_ASSERT_PTR_NON_NULL(object, false);511 512 psMetadata *md = expTagCounterMetadataFromObject(object);513 514 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {515 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");516 psFree(md);517 }518 519 psFree(md);520 521 return true;522 }523 248 static void summitExpRowFree(summitExpRow *object); 524 249 525 summitExpRow *summitExpRowAlloc(const char *exp_ id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, const char *uri, psS32 imfiles)250 summitExpRow *summitExpRowAlloc(const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, const char *uri, psS32 imfiles) 526 251 { 527 252 summitExpRow *_object; … … 530 255 psMemSetDeallocator(_object, (psFreeFunc)summitExpRowFree); 531 256 532 _object->exp_ id = psStringCopy(exp_id);257 _object->exp_name = psStringCopy(exp_name); 533 258 _object->camera = psStringCopy(camera); 534 259 _object->telescope = psStringCopy(telescope); … … 543 268 static void summitExpRowFree(summitExpRow *object) 544 269 { 545 psFree(object->exp_ id);270 psFree(object->exp_name); 546 271 psFree(object->camera); 547 272 psFree(object->telescope); … … 554 279 { 555 280 psMetadata *md = psMetadataAlloc(); 556 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {557 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");281 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 282 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 558 283 psFree(md); 559 284 return false; … … 602 327 } 603 328 604 bool summitExpInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, const char *uri, psS32 imfiles)329 bool summitExpInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, const char *uri, psS32 imfiles) 605 330 { 606 331 psMetadata *md = psMetadataAlloc(); 607 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {608 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");332 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 333 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 609 334 psFree(md); 610 335 return false; … … 663 388 bool summitExpInsertObject(psDB *dbh, summitExpRow *object) 664 389 { 665 return summitExpInsert(dbh, object->exp_ id, object->camera, object->telescope, object->dateobs, object->exp_type, object->uri, object->imfiles);390 return summitExpInsert(dbh, object->exp_name, object->camera, object->telescope, object->dateobs, object->exp_type, object->uri, object->imfiles); 666 391 } 667 392 … … 736 461 { 737 462 psMetadata *md = psMetadataAlloc(); 738 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {739 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");463 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 464 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 740 465 psFree(md); 741 466 return false; … … 780 505 781 506 bool status = false; 782 char* exp_ id = psMetadataLookupPtr(&status, md, "exp_id");783 if (!status) { 784 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ id");507 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 508 if (!status) { 509 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 785 510 return false; 786 511 } … … 816 541 } 817 542 818 return summitExpRowAlloc(exp_ id, camera, telescope, dateobs, exp_type, uri, imfiles);543 return summitExpRowAlloc(exp_name, camera, telescope, dateobs, exp_type, uri, imfiles); 819 544 } 820 545 psArray *summitExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 928 653 static void summitImfileRowFree(summitImfileRow *object); 929 654 930 summitImfileRow *summitImfileRowAlloc(const char *exp_ id, const char *camera, const char *telescope, const char *file_id, psS32 bytes, const char *md5sum, const char *class, const char *class_id, const char *uri)655 summitImfileRow *summitImfileRowAlloc(const char *exp_name, const char *camera, const char *telescope, const char *file_id, psS32 bytes, const char *md5sum, const char *class, const char *class_id, const char *uri) 931 656 { 932 657 summitImfileRow *_object; … … 935 660 psMemSetDeallocator(_object, (psFreeFunc)summitImfileRowFree); 936 661 937 _object->exp_ id = psStringCopy(exp_id);662 _object->exp_name = psStringCopy(exp_name); 938 663 _object->camera = psStringCopy(camera); 939 664 _object->telescope = psStringCopy(telescope); … … 950 675 static void summitImfileRowFree(summitImfileRow *object) 951 676 { 952 psFree(object->exp_ id);677 psFree(object->exp_name); 953 678 psFree(object->camera); 954 679 psFree(object->telescope); … … 963 688 { 964 689 psMetadata *md = psMetadataAlloc(); 965 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {966 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");690 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 691 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 967 692 psFree(md); 968 693 return false; … … 1021 746 } 1022 747 1023 bool summitImfileInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope, const char *file_id, psS32 bytes, const char *md5sum, const char *class, const char *class_id, const char *uri)748 bool summitImfileInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope, const char *file_id, psS32 bytes, const char *md5sum, const char *class, const char *class_id, const char *uri) 1024 749 { 1025 750 psMetadata *md = psMetadataAlloc(); 1026 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {1027 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");751 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 752 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1028 753 psFree(md); 1029 754 return false; … … 1092 817 bool summitImfileInsertObject(psDB *dbh, summitImfileRow *object) 1093 818 { 1094 return summitImfileInsert(dbh, object->exp_ id, object->camera, object->telescope, object->file_id, object->bytes, object->md5sum, object->class, object->class_id, object->uri);819 return summitImfileInsert(dbh, object->exp_name, object->camera, object->telescope, object->file_id, object->bytes, object->md5sum, object->class, object->class_id, object->uri); 1095 820 } 1096 821 … … 1165 890 { 1166 891 psMetadata *md = psMetadataAlloc(); 1167 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {1168 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");892 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 893 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1169 894 psFree(md); 1170 895 return false; … … 1219 944 1220 945 bool status = false; 1221 char* exp_ id = psMetadataLookupPtr(&status, md, "exp_id");1222 if (!status) { 1223 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ id");946 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 947 if (!status) { 948 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 1224 949 return false; 1225 950 } … … 1265 990 } 1266 991 1267 return summitImfileRowAlloc(exp_ id, camera, telescope, file_id, bytes, md5sum, class, class_id, uri);992 return summitImfileRowAlloc(exp_name, camera, telescope, file_id, bytes, md5sum, class, class_id, uri); 1268 993 } 1269 994 psArray *summitImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 1377 1102 static void pzPendingExpRowFree(pzPendingExpRow *object); 1378 1103 1379 pzPendingExpRow *pzPendingExpRowAlloc(const char *exp_ id, const char *camera, const char *telescope)1104 pzPendingExpRow *pzPendingExpRowAlloc(const char *exp_name, const char *camera, const char *telescope) 1380 1105 { 1381 1106 pzPendingExpRow *_object; … … 1384 1109 psMemSetDeallocator(_object, (psFreeFunc)pzPendingExpRowFree); 1385 1110 1386 _object->exp_ id = psStringCopy(exp_id);1111 _object->exp_name = psStringCopy(exp_name); 1387 1112 _object->camera = psStringCopy(camera); 1388 1113 _object->telescope = psStringCopy(telescope); … … 1393 1118 static void pzPendingExpRowFree(pzPendingExpRow *object) 1394 1119 { 1395 psFree(object->exp_ id);1120 psFree(object->exp_name); 1396 1121 psFree(object->camera); 1397 1122 psFree(object->telescope); … … 1401 1126 { 1402 1127 psMetadata *md = psMetadataAlloc(); 1403 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {1404 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1128 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 1129 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1405 1130 psFree(md); 1406 1131 return false; … … 1429 1154 } 1430 1155 1431 bool pzPendingExpInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope)1156 bool pzPendingExpInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope) 1432 1157 { 1433 1158 psMetadata *md = psMetadataAlloc(); 1434 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {1435 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1159 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 1160 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1436 1161 psFree(md); 1437 1162 return false; … … 1470 1195 bool pzPendingExpInsertObject(psDB *dbh, pzPendingExpRow *object) 1471 1196 { 1472 return pzPendingExpInsert(dbh, object->exp_ id, object->camera, object->telescope);1197 return pzPendingExpInsert(dbh, object->exp_name, object->camera, object->telescope); 1473 1198 } 1474 1199 … … 1543 1268 { 1544 1269 psMetadata *md = psMetadataAlloc(); 1545 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {1546 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1270 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 1271 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1547 1272 psFree(md); 1548 1273 return false; … … 1567 1292 1568 1293 bool status = false; 1569 char* exp_ id = psMetadataLookupPtr(&status, md, "exp_id");1570 if (!status) { 1571 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ id");1294 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 1295 if (!status) { 1296 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 1572 1297 return false; 1573 1298 } … … 1583 1308 } 1584 1309 1585 return pzPendingExpRowAlloc(exp_ id, camera, telescope);1310 return pzPendingExpRowAlloc(exp_name, camera, telescope); 1586 1311 } 1587 1312 psArray *pzPendingExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 1695 1420 static void pzPendingImfileRowFree(pzPendingImfileRow *object); 1696 1421 1697 pzPendingImfileRow *pzPendingImfileRowAlloc(const char *exp_ id, const char *camera, const char *telescope, const char *class, const char *class_id, const char *exp_tag)1422 pzPendingImfileRow *pzPendingImfileRowAlloc(const char *exp_name, const char *camera, const char *telescope, const char *class, const char *class_id, psS64 exp_id) 1698 1423 { 1699 1424 pzPendingImfileRow *_object; … … 1702 1427 psMemSetDeallocator(_object, (psFreeFunc)pzPendingImfileRowFree); 1703 1428 1704 _object->exp_ id = psStringCopy(exp_id);1429 _object->exp_name = psStringCopy(exp_name); 1705 1430 _object->camera = psStringCopy(camera); 1706 1431 _object->telescope = psStringCopy(telescope); 1707 1432 _object->class = psStringCopy(class); 1708 1433 _object->class_id = psStringCopy(class_id); 1709 _object->exp_ tag = psStringCopy(exp_tag);1434 _object->exp_id = exp_id; 1710 1435 1711 1436 return _object; … … 1714 1439 static void pzPendingImfileRowFree(pzPendingImfileRow *object) 1715 1440 { 1716 psFree(object->exp_ id);1441 psFree(object->exp_name); 1717 1442 psFree(object->camera); 1718 1443 psFree(object->telescope); 1719 1444 psFree(object->class); 1720 1445 psFree(object->class_id); 1721 psFree(object->exp_tag);1722 1446 } 1723 1447 … … 1725 1449 { 1726 1450 psMetadata *md = psMetadataAlloc(); 1727 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {1728 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1451 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 1452 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1729 1453 psFree(md); 1730 1454 return false; … … 1750 1474 return false; 1751 1475 } 1752 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Unique Key", "64")) {1753 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");1476 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Unique Key", 64)) { 1477 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 1754 1478 psFree(md); 1755 1479 return false; … … 1768 1492 } 1769 1493 1770 bool pzPendingImfileInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope, const char *class, const char *class_id, const char *exp_tag)1494 bool pzPendingImfileInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope, const char *class, const char *class_id, psS64 exp_id) 1771 1495 { 1772 1496 psMetadata *md = psMetadataAlloc(); 1773 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {1774 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1497 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 1498 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1775 1499 psFree(md); 1776 1500 return false; … … 1796 1520 return false; 1797 1521 } 1798 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {1799 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");1522 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 1523 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 1800 1524 psFree(md); 1801 1525 return false; … … 1824 1548 bool pzPendingImfileInsertObject(psDB *dbh, pzPendingImfileRow *object) 1825 1549 { 1826 return pzPendingImfileInsert(dbh, object->exp_ id, object->camera, object->telescope, object->class, object->class_id, object->exp_tag);1550 return pzPendingImfileInsert(dbh, object->exp_name, object->camera, object->telescope, object->class, object->class_id, object->exp_id); 1827 1551 } 1828 1552 … … 1897 1621 { 1898 1622 psMetadata *md = psMetadataAlloc(); 1899 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {1900 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1623 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 1624 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 1901 1625 psFree(md); 1902 1626 return false; … … 1922 1646 return false; 1923 1647 } 1924 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {1925 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");1648 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 1649 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 1926 1650 psFree(md); 1927 1651 return false; … … 1936 1660 1937 1661 bool status = false; 1938 char* exp_id = psMetadataLookupPtr(&status, md, "exp_id"); 1662 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 1663 if (!status) { 1664 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 1665 return false; 1666 } 1667 char* camera = psMetadataLookupPtr(&status, md, "camera"); 1668 if (!status) { 1669 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 1670 return false; 1671 } 1672 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 1673 if (!status) { 1674 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 1675 return false; 1676 } 1677 char* class = psMetadataLookupPtr(&status, md, "class"); 1678 if (!status) { 1679 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class"); 1680 return false; 1681 } 1682 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 1683 if (!status) { 1684 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 1685 return false; 1686 } 1687 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 1939 1688 if (!status) { 1940 1689 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 1941 1690 return false; 1942 1691 } 1943 char* camera = psMetadataLookupPtr(&status, md, "camera"); 1944 if (!status) { 1945 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 1946 return false; 1947 } 1948 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 1949 if (!status) { 1950 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 1951 return false; 1952 } 1953 char* class = psMetadataLookupPtr(&status, md, "class"); 1954 if (!status) { 1955 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class"); 1956 return false; 1957 } 1958 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 1959 if (!status) { 1960 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 1961 return false; 1962 } 1963 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 1964 if (!status) { 1965 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 1966 return false; 1967 } 1968 1969 return pzPendingImfileRowAlloc(exp_id, camera, telescope, class, class_id, exp_tag); 1692 1693 return pzPendingImfileRowAlloc(exp_name, camera, telescope, class, class_id, exp_id); 1970 1694 } 1971 1695 psArray *pzPendingImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 2079 1803 static void pzDoneExpRowFree(pzDoneExpRow *object); 2080 1804 2081 pzDoneExpRow *pzDoneExpRowAlloc(const char *exp_ id, const char *camera, const char *telescope)1805 pzDoneExpRow *pzDoneExpRowAlloc(const char *exp_name, const char *camera, const char *telescope) 2082 1806 { 2083 1807 pzDoneExpRow *_object; … … 2086 1810 psMemSetDeallocator(_object, (psFreeFunc)pzDoneExpRowFree); 2087 1811 2088 _object->exp_ id = psStringCopy(exp_id);1812 _object->exp_name = psStringCopy(exp_name); 2089 1813 _object->camera = psStringCopy(camera); 2090 1814 _object->telescope = psStringCopy(telescope); … … 2095 1819 static void pzDoneExpRowFree(pzDoneExpRow *object) 2096 1820 { 2097 psFree(object->exp_ id);1821 psFree(object->exp_name); 2098 1822 psFree(object->camera); 2099 1823 psFree(object->telescope); … … 2103 1827 { 2104 1828 psMetadata *md = psMetadataAlloc(); 2105 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {2106 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1829 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 1830 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2107 1831 psFree(md); 2108 1832 return false; … … 2131 1855 } 2132 1856 2133 bool pzDoneExpInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope)1857 bool pzDoneExpInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope) 2134 1858 { 2135 1859 psMetadata *md = psMetadataAlloc(); 2136 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {2137 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1860 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 1861 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2138 1862 psFree(md); 2139 1863 return false; … … 2172 1896 bool pzDoneExpInsertObject(psDB *dbh, pzDoneExpRow *object) 2173 1897 { 2174 return pzDoneExpInsert(dbh, object->exp_ id, object->camera, object->telescope);1898 return pzDoneExpInsert(dbh, object->exp_name, object->camera, object->telescope); 2175 1899 } 2176 1900 … … 2245 1969 { 2246 1970 psMetadata *md = psMetadataAlloc(); 2247 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {2248 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");1971 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 1972 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2249 1973 psFree(md); 2250 1974 return false; … … 2269 1993 2270 1994 bool status = false; 2271 char* exp_ id = psMetadataLookupPtr(&status, md, "exp_id");2272 if (!status) { 2273 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ id");1995 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 1996 if (!status) { 1997 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 2274 1998 return false; 2275 1999 } … … 2285 2009 } 2286 2010 2287 return pzDoneExpRowAlloc(exp_ id, camera, telescope);2011 return pzDoneExpRowAlloc(exp_name, camera, telescope); 2288 2012 } 2289 2013 psArray *pzDoneExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 2397 2121 static void pzDoneImfileRowFree(pzDoneImfileRow *object); 2398 2122 2399 pzDoneImfileRow *pzDoneImfileRowAlloc(const char *exp_ id, const char *camera, const char *telescope, const char *class, const char *class_id, const char *exp_tag, const char *uri)2123 pzDoneImfileRow *pzDoneImfileRowAlloc(const char *exp_name, const char *camera, const char *telescope, const char *class, const char *class_id, psS64 exp_id, const char *uri) 2400 2124 { 2401 2125 pzDoneImfileRow *_object; … … 2404 2128 psMemSetDeallocator(_object, (psFreeFunc)pzDoneImfileRowFree); 2405 2129 2406 _object->exp_ id = psStringCopy(exp_id);2130 _object->exp_name = psStringCopy(exp_name); 2407 2131 _object->camera = psStringCopy(camera); 2408 2132 _object->telescope = psStringCopy(telescope); 2409 2133 _object->class = psStringCopy(class); 2410 2134 _object->class_id = psStringCopy(class_id); 2411 _object->exp_ tag = psStringCopy(exp_tag);2135 _object->exp_id = exp_id; 2412 2136 _object->uri = psStringCopy(uri); 2413 2137 … … 2417 2141 static void pzDoneImfileRowFree(pzDoneImfileRow *object) 2418 2142 { 2419 psFree(object->exp_ id);2143 psFree(object->exp_name); 2420 2144 psFree(object->camera); 2421 2145 psFree(object->telescope); 2422 2146 psFree(object->class); 2423 2147 psFree(object->class_id); 2424 psFree(object->exp_tag);2425 2148 psFree(object->uri); 2426 2149 } … … 2429 2152 { 2430 2153 psMetadata *md = psMetadataAlloc(); 2431 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, "Primary Key", "64")) {2432 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");2154 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, "Primary Key", "64")) { 2155 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2433 2156 psFree(md); 2434 2157 return false; … … 2454 2177 return false; 2455 2178 } 2456 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Unique Key", "64")) {2457 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");2179 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Unique Key", 64)) { 2180 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2458 2181 psFree(md); 2459 2182 return false; … … 2477 2200 } 2478 2201 2479 bool pzDoneImfileInsert(psDB * dbh, const char *exp_ id, const char *camera, const char *telescope, const char *class, const char *class_id, const char *exp_tag, const char *uri)2202 bool pzDoneImfileInsert(psDB * dbh, const char *exp_name, const char *camera, const char *telescope, const char *class, const char *class_id, psS64 exp_id, const char *uri) 2480 2203 { 2481 2204 psMetadata *md = psMetadataAlloc(); 2482 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, exp_id)) {2483 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");2205 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 2206 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2484 2207 psFree(md); 2485 2208 return false; … … 2505 2228 return false; 2506 2229 } 2507 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {2508 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");2230 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 2231 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2509 2232 psFree(md); 2510 2233 return false; … … 2538 2261 bool pzDoneImfileInsertObject(psDB *dbh, pzDoneImfileRow *object) 2539 2262 { 2540 return pzDoneImfileInsert(dbh, object->exp_ id, object->camera, object->telescope, object->class, object->class_id, object->exp_tag, object->uri);2263 return pzDoneImfileInsert(dbh, object->exp_name, object->camera, object->telescope, object->class, object->class_id, object->exp_id, object->uri); 2541 2264 } 2542 2265 … … 2611 2334 { 2612 2335 psMetadata *md = psMetadataAlloc(); 2613 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ id", PS_DATA_STRING, NULL, object->exp_id)) {2614 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ id");2336 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 2337 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 2615 2338 psFree(md); 2616 2339 return false; … … 2636 2359 return false; 2637 2360 } 2638 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {2639 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");2361 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 2362 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2640 2363 psFree(md); 2641 2364 return false; … … 2655 2378 2656 2379 bool status = false; 2657 char* exp_id = psMetadataLookupPtr(&status, md, "exp_id"); 2380 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 2381 if (!status) { 2382 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 2383 return false; 2384 } 2385 char* camera = psMetadataLookupPtr(&status, md, "camera"); 2386 if (!status) { 2387 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 2388 return false; 2389 } 2390 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 2391 if (!status) { 2392 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 2393 return false; 2394 } 2395 char* class = psMetadataLookupPtr(&status, md, "class"); 2396 if (!status) { 2397 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class"); 2398 return false; 2399 } 2400 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 2401 if (!status) { 2402 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 2403 return false; 2404 } 2405 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 2658 2406 if (!status) { 2659 2407 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 2660 2408 return false; 2661 2409 } 2662 char* camera = psMetadataLookupPtr(&status, md, "camera");2663 if (!status) {2664 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera");2665 return false;2666 }2667 char* telescope = psMetadataLookupPtr(&status, md, "telescope");2668 if (!status) {2669 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope");2670 return false;2671 }2672 char* class = psMetadataLookupPtr(&status, md, "class");2673 if (!status) {2674 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class");2675 return false;2676 }2677 char* class_id = psMetadataLookupPtr(&status, md, "class_id");2678 if (!status) {2679 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id");2680 return false;2681 }2682 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");2683 if (!status) {2684 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag");2685 return false;2686 }2687 2410 char* uri = psMetadataLookupPtr(&status, md, "uri"); 2688 2411 if (!status) { … … 2691 2414 } 2692 2415 2693 return pzDoneImfileRowAlloc(exp_ id, camera, telescope, class, class_id, exp_tag, uri);2416 return pzDoneImfileRowAlloc(exp_name, camera, telescope, class, class_id, exp_id, uri); 2694 2417 } 2695 2418 psArray *pzDoneImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 2803 2526 static void newExpRowFree(newExpRow *object); 2804 2527 2805 newExpRow *newExpRowAlloc( const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psS32 imfiles, const char *workdir)2528 newExpRow *newExpRowAlloc(psS64 exp_id, const char *tmp_exp_name, const char *tmp_camera, const char *tmp_telescope, const char *state, const char *workdir, const char *workdir_state) 2806 2529 { 2807 2530 newExpRow *_object; … … 2810 2533 psMemSetDeallocator(_object, (psFreeFunc)newExpRowFree); 2811 2534 2812 _object->exp_ tag = psStringCopy(exp_tag);2813 _object-> exp_id = psStringCopy(exp_id);2814 _object-> camera = psStringCopy(camera);2815 _object->t elescope = psStringCopy(telescope);2816 _object-> imfiles = imfiles;2535 _object->exp_id = exp_id; 2536 _object->tmp_exp_name = psStringCopy(tmp_exp_name); 2537 _object->tmp_camera = psStringCopy(tmp_camera); 2538 _object->tmp_telescope = psStringCopy(tmp_telescope); 2539 _object->state = psStringCopy(state); 2817 2540 _object->workdir = psStringCopy(workdir); 2541 _object->workdir_state = psStringCopy(workdir_state); 2818 2542 2819 2543 return _object; … … 2822 2546 static void newExpRowFree(newExpRow *object) 2823 2547 { 2824 psFree(object-> exp_tag);2825 psFree(object-> exp_id);2826 psFree(object-> camera);2827 psFree(object-> telescope);2548 psFree(object->tmp_exp_name); 2549 psFree(object->tmp_camera); 2550 psFree(object->tmp_telescope); 2551 psFree(object->state); 2828 2552 psFree(object->workdir); 2553 psFree(object->workdir_state); 2829 2554 } 2830 2555 … … 2832 2557 { 2833 2558 psMetadata *md = psMetadataAlloc(); 2834 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 2835 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2836 psFree(md); 2837 return false; 2838 } 2839 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, "Key", "64")) { 2559 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key AUTO_INCREMENT", 0)) { 2840 2560 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2841 2561 psFree(md); 2842 2562 return false; 2843 2563 } 2844 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, "Key", "64")) { 2845 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 2846 psFree(md); 2847 return false; 2848 } 2849 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, "Key", "64")) { 2850 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 2851 psFree(md); 2852 return false; 2853 } 2854 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, 0)) { 2855 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles"); 2564 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_exp_name", PS_DATA_STRING, "Key", "64")) { 2565 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_exp_name"); 2566 psFree(md); 2567 return false; 2568 } 2569 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_camera", PS_DATA_STRING, "Key", "64")) { 2570 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_camera"); 2571 psFree(md); 2572 return false; 2573 } 2574 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_telescope", PS_DATA_STRING, "Key", "64")) { 2575 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_telescope"); 2576 psFree(md); 2577 return false; 2578 } 2579 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "Key", "64")) { 2580 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 2856 2581 psFree(md); 2857 2582 return false; … … 2862 2587 return false; 2863 2588 } 2589 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, "key", "64")) { 2590 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 2591 psFree(md); 2592 return false; 2593 } 2864 2594 2865 2595 bool status = psDBCreateTable(dbh, NEWEXP_TABLE_NAME, md); … … 2875 2605 } 2876 2606 2877 bool newExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psS32 imfiles, const char *workdir)2607 bool newExpInsert(psDB * dbh, psS64 exp_id, const char *tmp_exp_name, const char *tmp_camera, const char *tmp_telescope, const char *state, const char *workdir, const char *workdir_state) 2878 2608 { 2879 2609 psMetadata *md = psMetadataAlloc(); 2880 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 2881 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 2882 psFree(md); 2883 return false; 2884 } 2885 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, NULL, exp_id)) { 2610 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 2886 2611 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2887 2612 psFree(md); 2888 2613 return false; 2889 2614 } 2890 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, camera)) { 2891 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 2892 psFree(md); 2893 return false; 2894 } 2895 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) { 2896 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 2897 psFree(md); 2898 return false; 2899 } 2900 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, imfiles)) { 2901 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles"); 2615 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_exp_name", PS_DATA_STRING, NULL, tmp_exp_name)) { 2616 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_exp_name"); 2617 psFree(md); 2618 return false; 2619 } 2620 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_camera", PS_DATA_STRING, NULL, tmp_camera)) { 2621 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_camera"); 2622 psFree(md); 2623 return false; 2624 } 2625 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_telescope", PS_DATA_STRING, NULL, tmp_telescope)) { 2626 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_telescope"); 2627 psFree(md); 2628 return false; 2629 } 2630 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 2631 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 2902 2632 psFree(md); 2903 2633 return false; … … 2905 2635 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) { 2906 2636 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 2637 psFree(md); 2638 return false; 2639 } 2640 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, workdir_state)) { 2641 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 2907 2642 psFree(md); 2908 2643 return false; … … 2931 2666 bool newExpInsertObject(psDB *dbh, newExpRow *object) 2932 2667 { 2933 return newExpInsert(dbh, object->exp_ tag, object->exp_id, object->camera, object->telescope, object->imfiles, object->workdir);2668 return newExpInsert(dbh, object->exp_id, object->tmp_exp_name, object->tmp_camera, object->tmp_telescope, object->state, object->workdir, object->workdir_state); 2934 2669 } 2935 2670 … … 3004 2739 { 3005 2740 psMetadata *md = psMetadataAlloc(); 3006 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 3007 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3008 psFree(md); 3009 return false; 3010 } 3011 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, NULL, object->exp_id)) { 2741 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 3012 2742 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 3013 2743 psFree(md); 3014 2744 return false; 3015 2745 } 3016 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, object->camera)) { 3017 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 3018 psFree(md); 3019 return false; 3020 } 3021 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, object->telescope)) { 3022 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 3023 psFree(md); 3024 return false; 3025 } 3026 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, object->imfiles)) { 3027 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles"); 2746 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_exp_name", PS_DATA_STRING, NULL, object->tmp_exp_name)) { 2747 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_exp_name"); 2748 psFree(md); 2749 return false; 2750 } 2751 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_camera", PS_DATA_STRING, NULL, object->tmp_camera)) { 2752 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_camera"); 2753 psFree(md); 2754 return false; 2755 } 2756 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_telescope", PS_DATA_STRING, NULL, object->tmp_telescope)) { 2757 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_telescope"); 2758 psFree(md); 2759 return false; 2760 } 2761 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 2762 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 3028 2763 psFree(md); 3029 2764 return false; … … 3034 2769 return false; 3035 2770 } 2771 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, object->workdir_state)) { 2772 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 2773 psFree(md); 2774 return false; 2775 } 3036 2776 3037 2777 … … 3043 2783 3044 2784 bool status = false; 3045 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 3046 if (!status) { 3047 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 3048 return false; 3049 } 3050 char* exp_id = psMetadataLookupPtr(&status, md, "exp_id"); 2785 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 3051 2786 if (!status) { 3052 2787 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 3053 2788 return false; 3054 2789 } 3055 char* camera = psMetadataLookupPtr(&status, md, "camera"); 3056 if (!status) { 3057 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 3058 return false; 3059 } 3060 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 3061 if (!status) { 3062 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 3063 return false; 3064 } 3065 psS32 imfiles = psMetadataLookupS32(&status, md, "imfiles"); 3066 if (!status) { 3067 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item imfiles"); 2790 char* tmp_exp_name = psMetadataLookupPtr(&status, md, "tmp_exp_name"); 2791 if (!status) { 2792 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tmp_exp_name"); 2793 return false; 2794 } 2795 char* tmp_camera = psMetadataLookupPtr(&status, md, "tmp_camera"); 2796 if (!status) { 2797 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tmp_camera"); 2798 return false; 2799 } 2800 char* tmp_telescope = psMetadataLookupPtr(&status, md, "tmp_telescope"); 2801 if (!status) { 2802 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tmp_telescope"); 2803 return false; 2804 } 2805 char* state = psMetadataLookupPtr(&status, md, "state"); 2806 if (!status) { 2807 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 3068 2808 return false; 3069 2809 } … … 3073 2813 return false; 3074 2814 } 3075 3076 return newExpRowAlloc(exp_tag, exp_id, camera, telescope, imfiles, workdir); 2815 char* workdir_state = psMetadataLookupPtr(&status, md, "workdir_state"); 2816 if (!status) { 2817 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir_state"); 2818 return false; 2819 } 2820 2821 return newExpRowAlloc(exp_id, tmp_exp_name, tmp_camera, tmp_telescope, state, workdir, workdir_state); 3077 2822 } 3078 2823 psArray *newExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 3186 2931 static void newImfileRowFree(newImfileRow *object); 3187 2932 3188 newImfileRow *newImfileRowAlloc( const char *exp_tag, const char *class, const char *class_id, const char *uri)2933 newImfileRow *newImfileRowAlloc(psS64 exp_id, const char *tmp_class_id, const char *uri) 3189 2934 { 3190 2935 newImfileRow *_object; … … 3193 2938 psMemSetDeallocator(_object, (psFreeFunc)newImfileRowFree); 3194 2939 3195 _object->exp_tag = psStringCopy(exp_tag); 3196 _object->class = psStringCopy(class); 3197 _object->class_id = psStringCopy(class_id); 2940 _object->exp_id = exp_id; 2941 _object->tmp_class_id = psStringCopy(tmp_class_id); 3198 2942 _object->uri = psStringCopy(uri); 3199 2943 … … 3203 2947 static void newImfileRowFree(newImfileRow *object) 3204 2948 { 3205 psFree(object->exp_tag); 3206 psFree(object->class); 3207 psFree(object->class_id); 2949 psFree(object->tmp_class_id); 3208 2950 psFree(object->uri); 3209 2951 } … … 3212 2954 { 3213 2955 psMetadata *md = psMetadataAlloc(); 3214 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 3215 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3216 psFree(md); 3217 return false; 3218 } 3219 if (!psMetadataAdd(md, PS_LIST_TAIL, "class", PS_DATA_STRING, "Primary Key", "64")) { 3220 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 3221 psFree(md); 3222 return false; 3223 } 3224 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, "Primary Key", "64")) { 3225 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 2956 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key fkey(exp_id) ref newExp(exp_id)", 64)) { 2957 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2958 psFree(md); 2959 return false; 2960 } 2961 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, "Primary Key", "64")) { 2962 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 3226 2963 psFree(md); 3227 2964 return false; … … 3245 2982 } 3246 2983 3247 bool newImfileInsert(psDB * dbh, const char *exp_tag, const char *class, const char *class_id, const char *uri)2984 bool newImfileInsert(psDB * dbh, psS64 exp_id, const char *tmp_class_id, const char *uri) 3248 2985 { 3249 2986 psMetadata *md = psMetadataAlloc(); 3250 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 3251 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3252 psFree(md); 3253 return false; 3254 } 3255 if (!psMetadataAdd(md, PS_LIST_TAIL, "class", PS_DATA_STRING, NULL, class)) { 3256 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 3257 psFree(md); 3258 return false; 3259 } 3260 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 3261 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 2987 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 2988 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 2989 psFree(md); 2990 return false; 2991 } 2992 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, NULL, tmp_class_id)) { 2993 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 3262 2994 psFree(md); 3263 2995 return false; … … 3291 3023 bool newImfileInsertObject(psDB *dbh, newImfileRow *object) 3292 3024 { 3293 return newImfileInsert(dbh, object->exp_ tag, object->class, object->class_id, object->uri);3025 return newImfileInsert(dbh, object->exp_id, object->tmp_class_id, object->uri); 3294 3026 } 3295 3027 … … 3364 3096 { 3365 3097 psMetadata *md = psMetadataAlloc(); 3366 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 3367 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3368 psFree(md); 3369 return false; 3370 } 3371 if (!psMetadataAdd(md, PS_LIST_TAIL, "class", PS_DATA_STRING, NULL, object->class)) { 3372 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 3373 psFree(md); 3374 return false; 3375 } 3376 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 3377 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 3098 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 3099 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 3100 psFree(md); 3101 return false; 3102 } 3103 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, NULL, object->tmp_class_id)) { 3104 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 3378 3105 psFree(md); 3379 3106 return false; … … 3393 3120 3394 3121 bool status = false; 3395 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 3396 if (!status) { 3397 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 3398 return false; 3399 } 3400 char* class = psMetadataLookupPtr(&status, md, "class"); 3401 if (!status) { 3402 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class"); 3403 return false; 3404 } 3405 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 3406 if (!status) { 3407 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item class_id"); 3122 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 3123 if (!status) { 3124 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 3125 return false; 3126 } 3127 char* tmp_class_id = psMetadataLookupPtr(&status, md, "tmp_class_id"); 3128 if (!status) { 3129 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tmp_class_id"); 3408 3130 return false; 3409 3131 } … … 3414 3136 } 3415 3137 3416 return newImfileRowAlloc(exp_ tag, class,class_id, uri);3138 return newImfileRowAlloc(exp_id, tmp_class_id, uri); 3417 3139 } 3418 3140 psArray *newImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 3526 3248 static void rawExpRowFree(rawExpRow *object); 3527 3249 3528 rawExpRow *rawExpRowAlloc( const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles, const char *filelevel, const char *workdir, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psF32 solang, psS16 fault)3250 rawExpRow *rawExpRowAlloc(psS64 exp_id, const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *exp_tag, const char *exp_type, const char *filelevel, const char *workdir, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psF32 solang, psS16 fault) 3529 3251 { 3530 3252 rawExpRow *_object; … … 3533 3255 psMemSetDeallocator(_object, (psFreeFunc)rawExpRowFree); 3534 3256 3535 _object->exp_ tag = psStringCopy(exp_tag);3536 _object->exp_ id = psStringCopy(exp_id);3257 _object->exp_id = exp_id; 3258 _object->exp_name = psStringCopy(exp_name); 3537 3259 _object->camera = psStringCopy(camera); 3538 3260 _object->telescope = psStringCopy(telescope); 3539 3261 _object->dateobs = psTimeCopy(dateobs); 3262 _object->exp_tag = psStringCopy(exp_tag); 3540 3263 _object->exp_type = psStringCopy(exp_type); 3541 _object->imfiles = imfiles;3542 3264 _object->filelevel = psStringCopy(filelevel); 3543 3265 _object->workdir = psStringCopy(workdir); … … 3569 3291 static void rawExpRowFree(rawExpRow *object) 3570 3292 { 3571 psFree(object->exp_tag); 3572 psFree(object->exp_id); 3293 psFree(object->exp_name); 3573 3294 psFree(object->camera); 3574 3295 psFree(object->telescope); 3575 3296 psFree(object->dateobs); 3297 psFree(object->exp_tag); 3576 3298 psFree(object->exp_type); 3577 3299 psFree(object->filelevel); … … 3584 3306 { 3585 3307 psMetadata *md = psMetadataAlloc(); 3586 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 3587 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3588 psFree(md); 3589 return false; 3590 } 3591 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, "Key", "64")) { 3308 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key fkey(exp_id) ref newExp(exp_id)", 64)) { 3592 3309 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 3310 psFree(md); 3311 return false; 3312 } 3313 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, "64")) { 3314 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 3593 3315 psFree(md); 3594 3316 return false; … … 3609 3331 return false; 3610 3332 } 3333 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, "255")) { 3334 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 3335 psFree(md); 3336 return false; 3337 } 3611 3338 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, "64")) { 3612 3339 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); … … 3614 3341 return false; 3615 3342 } 3616 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, 0)) {3617 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");3618 psFree(md);3619 return false;3620 }3621 3343 if (!psMetadataAdd(md, PS_LIST_TAIL, "filelevel", PS_DATA_STRING, NULL, "64")) { 3622 3344 psError(PS_ERR_UNKNOWN, false, "failed to add item filelevel"); … … 3747 3469 } 3748 3470 3749 bool rawExpInsert(psDB * dbh, const char *exp_tag, const char *exp_id, const char *camera, const char *telescope, psTime* dateobs, const char *exp_type, psS32 imfiles, const char *filelevel, const char *workdir, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psF32 solang, psS16 fault)3471 bool rawExpInsert(psDB * dbh, psS64 exp_id, const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *exp_tag, const char *exp_type, const char *filelevel, const char *workdir, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psF32 solang, psS16 fault) 3750 3472 { 3751 3473 psMetadata *md = psMetadataAlloc(); 3474 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 3475 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 3476 psFree(md); 3477 return false; 3478 } 3479 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 3480 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 3481 psFree(md); 3482 return false; 3483 } 3484 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, camera)) { 3485 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 3486 psFree(md); 3487 return false; 3488 } 3489 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) { 3490 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 3491 psFree(md); 3492 return false; 3493 } 3494 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, dateobs)) { 3495 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 3496 psFree(md); 3497 return false; 3498 } 3752 3499 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 3753 3500 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); … … 3755 3502 return false; 3756 3503 } 3757 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, NULL, exp_id)) {3758 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");3759 psFree(md);3760 return false;3761 }3762 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, camera)) {3763 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");3764 psFree(md);3765 return false;3766 }3767 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) {3768 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope");3769 psFree(md);3770 return false;3771 }3772 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, dateobs)) {3773 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs");3774 psFree(md);3775 return false;3776 }3777 3504 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, exp_type)) { 3778 3505 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); 3779 psFree(md);3780 return false;3781 }3782 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, imfiles)) {3783 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");3784 3506 psFree(md); 3785 3507 return false; … … 3923 3645 bool rawExpInsertObject(psDB *dbh, rawExpRow *object) 3924 3646 { 3925 return rawExpInsert(dbh, object->exp_ tag, object->exp_id, object->camera, object->telescope, object->dateobs, object->exp_type, object->imfiles, object->filelevel, object->workdir, object->filter, object->airmass, object->ra, object->decl, object->exp_time, object->sat_pixel_frac, object->bg, object->bg_stdev, object->bg_mean_stdev, object->alt, object->az, object->ccd_temp, object->posang, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->object, object->solang, object->fault);3647 return rawExpInsert(dbh, object->exp_id, object->exp_name, object->camera, object->telescope, object->dateobs, object->exp_tag, object->exp_type, object->filelevel, object->workdir, object->filter, object->airmass, object->ra, object->decl, object->exp_time, object->sat_pixel_frac, object->bg, object->bg_stdev, object->bg_mean_stdev, object->alt, object->az, object->ccd_temp, object->posang, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->object, object->solang, object->fault); 3926 3648 } 3927 3649 … … 3996 3718 { 3997 3719 psMetadata *md = psMetadataAlloc(); 3720 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 3721 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 3722 psFree(md); 3723 return false; 3724 } 3725 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 3726 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 3727 psFree(md); 3728 return false; 3729 } 3730 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, object->camera)) { 3731 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 3732 psFree(md); 3733 return false; 3734 } 3735 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, object->telescope)) { 3736 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 3737 psFree(md); 3738 return false; 3739 } 3740 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, object->dateobs)) { 3741 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 3742 psFree(md); 3743 return false; 3744 } 3998 3745 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 3999 3746 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); … … 4001 3748 return false; 4002 3749 } 4003 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_STRING, NULL, object->exp_id)) {4004 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");4005 psFree(md);4006 return false;4007 }4008 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, object->camera)) {4009 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");4010 psFree(md);4011 return false;4012 }4013 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, object->telescope)) {4014 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope");4015 psFree(md);4016 return false;4017 }4018 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, object->dateobs)) {4019 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs");4020 psFree(md);4021 return false;4022 }4023 3750 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, object->exp_type)) { 4024 3751 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); … … 4026 3753 return false; 4027 3754 } 4028 if (!psMetadataAdd(md, PS_LIST_TAIL, "imfiles", PS_DATA_S32, NULL, object->imfiles)) {4029 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");4030 psFree(md);4031 return false;4032 }4033 3755 if (!psMetadataAdd(md, PS_LIST_TAIL, "filelevel", PS_DATA_STRING, NULL, object->filelevel)) { 4034 3756 psError(PS_ERR_UNKNOWN, false, "failed to add item filelevel"); … … 4155 3877 4156 3878 bool status = false; 3879 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 3880 if (!status) { 3881 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 3882 return false; 3883 } 3884 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 3885 if (!status) { 3886 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 3887 return false; 3888 } 3889 char* camera = psMetadataLookupPtr(&status, md, "camera"); 3890 if (!status) { 3891 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 3892 return false; 3893 } 3894 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 3895 if (!status) { 3896 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 3897 return false; 3898 } 3899 psTime* dateobs = psMetadataLookupPtr(&status, md, "dateobs"); 3900 if (!status) { 3901 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dateobs"); 3902 return false; 3903 } 4157 3904 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 4158 3905 if (!status) { … … 4160 3907 return false; 4161 3908 } 4162 char* exp_id = psMetadataLookupPtr(&status, md, "exp_id");4163 if (!status) {4164 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id");4165 return false;4166 }4167 char* camera = psMetadataLookupPtr(&status, md, "camera");4168 if (!status) {4169 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera");4170 return false;4171 }4172 char* telescope = psMetadataLookupPtr(&status, md, "telescope");4173 if (!status) {4174 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope");4175 return false;4176 }4177 psTime* dateobs = psMetadataLookupPtr(&status, md, "dateobs");4178 if (!status) {4179 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dateobs");4180 return false;4181 }4182 3909 char* exp_type = psMetadataLookupPtr(&status, md, "exp_type"); 4183 3910 if (!status) { … … 4185 3912 return false; 4186 3913 } 4187 psS32 imfiles = psMetadataLookupS32(&status, md, "imfiles");4188 if (!status) {4189 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item imfiles");4190 return false;4191 }4192 3914 char* filelevel = psMetadataLookupPtr(&status, md, "filelevel"); 4193 3915 if (!status) { … … 4306 4028 } 4307 4029 4308 return rawExpRowAlloc(exp_ tag, exp_id, camera, telescope, dateobs, exp_type, imfiles, filelevel, workdir, filter, airmass, ra, decl, exp_time, sat_pixel_frac, bg, bg_stdev, bg_mean_stdev, alt, az, ccd_temp, posang, user_1, user_2, user_3, user_4, user_5, object, solang, fault);4030 return rawExpRowAlloc(exp_id, exp_name, camera, telescope, dateobs, exp_tag, exp_type, filelevel, workdir, filter, airmass, ra, decl, exp_time, sat_pixel_frac, bg, bg_stdev, bg_mean_stdev, alt, az, ccd_temp, posang, user_1, user_2, user_3, user_4, user_5, object, solang, fault); 4309 4031 } 4310 4032 psArray *rawExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 4418 4140 static void rawImfileRowFree(rawImfileRow *object); 4419 4141 4420 rawImfileRow *rawImfileRowAlloc( const char *exp_tag, const char *class_id, const char *uri, const char *exp_type, const char *filelevel, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psTime* dateobs, psS16 fault)4142 rawImfileRow *rawImfileRowAlloc(psS64 exp_id, const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *tmp_class_id, const char *class_id, const char *uri, const char *exp_type, const char *filelevel, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psS16 fault) 4421 4143 { 4422 4144 rawImfileRow *_object; … … 4425 4147 psMemSetDeallocator(_object, (psFreeFunc)rawImfileRowFree); 4426 4148 4427 _object->exp_tag = psStringCopy(exp_tag); 4149 _object->exp_id = exp_id; 4150 _object->exp_name = psStringCopy(exp_name); 4151 _object->camera = psStringCopy(camera); 4152 _object->telescope = psStringCopy(telescope); 4153 _object->dateobs = psTimeCopy(dateobs); 4154 _object->tmp_class_id = psStringCopy(tmp_class_id); 4428 4155 _object->class_id = psStringCopy(class_id); 4429 4156 _object->uri = psStringCopy(uri); … … 4449 4176 _object->user_5 = user_5; 4450 4177 _object->object = psStringCopy(object); 4451 _object->dateobs = psTimeCopy(dateobs);4452 4178 _object->fault = fault; 4453 4179 … … 4457 4183 static void rawImfileRowFree(rawImfileRow *object) 4458 4184 { 4459 psFree(object->exp_tag); 4185 psFree(object->exp_name); 4186 psFree(object->camera); 4187 psFree(object->telescope); 4188 psFree(object->dateobs); 4189 psFree(object->tmp_class_id); 4460 4190 psFree(object->class_id); 4461 4191 psFree(object->uri); … … 4464 4194 psFree(object->filter); 4465 4195 psFree(object->object); 4466 psFree(object->dateobs);4467 4196 } 4468 4197 … … 4470 4199 { 4471 4200 psMetadata *md = psMetadataAlloc(); 4472 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 4473 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 4201 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key fkey(exp_id, tmp_class_id) ref newImfile(exp_id, tmp_class_id)", 64)) { 4202 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 4203 psFree(md); 4204 return false; 4205 } 4206 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, "64")) { 4207 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 4208 psFree(md); 4209 return false; 4210 } 4211 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, "64")) { 4212 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 4213 psFree(md); 4214 return false; 4215 } 4216 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, "64")) { 4217 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 4218 psFree(md); 4219 return false; 4220 } 4221 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, NULL)) { 4222 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 4223 psFree(md); 4224 return false; 4225 } 4226 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, "Key", "64")) { 4227 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 4474 4228 psFree(md); 4475 4229 return false; … … 4590 4344 return false; 4591 4345 } 4592 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, NULL)) {4593 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs");4594 psFree(md);4595 return false;4596 }4597 4346 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, "Key NOT NULL", 0)) { 4598 4347 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); … … 4613 4362 } 4614 4363 4615 bool rawImfileInsert(psDB * dbh, const char *exp_tag, const char *class_id, const char *uri, const char *exp_type, const char *filelevel, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psTime* dateobs, psS16 fault)4364 bool rawImfileInsert(psDB * dbh, psS64 exp_id, const char *exp_name, const char *camera, const char *telescope, psTime* dateobs, const char *tmp_class_id, const char *class_id, const char *uri, const char *exp_type, const char *filelevel, const char *filter, psF32 airmass, psF64 ra, psF64 decl, psF32 exp_time, psF32 sat_pixel_frac, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 alt, psF64 az, psF32 ccd_temp, psF64 posang, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *object, psS16 fault) 4616 4365 { 4617 4366 psMetadata *md = psMetadataAlloc(); 4618 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 4619 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 4367 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 4368 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 4369 psFree(md); 4370 return false; 4371 } 4372 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, exp_name)) { 4373 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 4374 psFree(md); 4375 return false; 4376 } 4377 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, camera)) { 4378 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 4379 psFree(md); 4380 return false; 4381 } 4382 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) { 4383 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 4384 psFree(md); 4385 return false; 4386 } 4387 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, dateobs)) { 4388 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 4389 psFree(md); 4390 return false; 4391 } 4392 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, NULL, tmp_class_id)) { 4393 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 4620 4394 psFree(md); 4621 4395 return false; … … 4733 4507 if (!psMetadataAdd(md, PS_LIST_TAIL, "object", PS_DATA_STRING, NULL, object)) { 4734 4508 psError(PS_ERR_UNKNOWN, false, "failed to add item object"); 4735 psFree(md);4736 return false;4737 }4738 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, dateobs)) {4739 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs");4740 4509 psFree(md); 4741 4510 return false; … … 4769 4538 bool rawImfileInsertObject(psDB *dbh, rawImfileRow *object) 4770 4539 { 4771 return rawImfileInsert(dbh, object->exp_ tag, object->class_id, object->uri, object->exp_type, object->filelevel, object->filter, object->airmass, object->ra, object->decl, object->exp_time, object->sat_pixel_frac, object->bg, object->bg_stdev, object->bg_mean_stdev, object->alt, object->az, object->ccd_temp, object->posang, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->object, object->dateobs, object->fault);4540 return rawImfileInsert(dbh, object->exp_id, object->exp_name, object->camera, object->telescope, object->dateobs, object->tmp_class_id, object->class_id, object->uri, object->exp_type, object->filelevel, object->filter, object->airmass, object->ra, object->decl, object->exp_time, object->sat_pixel_frac, object->bg, object->bg_stdev, object->bg_mean_stdev, object->alt, object->az, object->ccd_temp, object->posang, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->object, object->fault); 4772 4541 } 4773 4542 … … 4842 4611 { 4843 4612 psMetadata *md = psMetadataAlloc(); 4844 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 4845 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 4613 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 4614 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 4615 psFree(md); 4616 return false; 4617 } 4618 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_name", PS_DATA_STRING, NULL, object->exp_name)) { 4619 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_name"); 4620 psFree(md); 4621 return false; 4622 } 4623 if (!psMetadataAdd(md, PS_LIST_TAIL, "camera", PS_DATA_STRING, NULL, object->camera)) { 4624 psError(PS_ERR_UNKNOWN, false, "failed to add item camera"); 4625 psFree(md); 4626 return false; 4627 } 4628 if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, object->telescope)) { 4629 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 4630 psFree(md); 4631 return false; 4632 } 4633 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, object->dateobs)) { 4634 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 4635 psFree(md); 4636 return false; 4637 } 4638 if (!psMetadataAdd(md, PS_LIST_TAIL, "tmp_class_id", PS_DATA_STRING, NULL, object->tmp_class_id)) { 4639 psError(PS_ERR_UNKNOWN, false, "failed to add item tmp_class_id"); 4846 4640 psFree(md); 4847 4641 return false; … … 4962 4756 return false; 4963 4757 } 4964 if (!psMetadataAdd(md, PS_LIST_TAIL, "dateobs", PS_DATA_TIME, NULL, object->dateobs)) {4965 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs");4966 psFree(md);4967 return false;4968 }4969 4758 if (!psMetadataAdd(md, PS_LIST_TAIL, "fault", PS_DATA_S16, NULL, object->fault)) { 4970 4759 psError(PS_ERR_UNKNOWN, false, "failed to add item fault"); … … 4981 4770 4982 4771 bool status = false; 4983 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 4984 if (!status) { 4985 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 4772 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 4773 if (!status) { 4774 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 4775 return false; 4776 } 4777 char* exp_name = psMetadataLookupPtr(&status, md, "exp_name"); 4778 if (!status) { 4779 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_name"); 4780 return false; 4781 } 4782 char* camera = psMetadataLookupPtr(&status, md, "camera"); 4783 if (!status) { 4784 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item camera"); 4785 return false; 4786 } 4787 char* telescope = psMetadataLookupPtr(&status, md, "telescope"); 4788 if (!status) { 4789 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item telescope"); 4790 return false; 4791 } 4792 psTime* dateobs = psMetadataLookupPtr(&status, md, "dateobs"); 4793 if (!status) { 4794 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dateobs"); 4795 return false; 4796 } 4797 char* tmp_class_id = psMetadataLookupPtr(&status, md, "tmp_class_id"); 4798 if (!status) { 4799 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item tmp_class_id"); 4986 4800 return false; 4987 4801 } … … 5101 4915 return false; 5102 4916 } 5103 psTime* dateobs = psMetadataLookupPtr(&status, md, "dateobs");5104 if (!status) {5105 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dateobs");5106 return false;5107 }5108 4917 psS16 fault = psMetadataLookupS16(&status, md, "fault"); 5109 4918 if (!status) { … … 5112 4921 } 5113 4922 5114 return rawImfileRowAlloc(exp_ tag, class_id, uri, exp_type, filelevel, filter, airmass, ra, decl, exp_time, sat_pixel_frac, bg, bg_stdev, bg_mean_stdev, alt, az, ccd_temp, posang, user_1, user_2, user_3, user_4, user_5, object, dateobs, fault);4923 return rawImfileRowAlloc(exp_id, exp_name, camera, telescope, dateobs, tmp_class_id, class_id, uri, exp_type, filelevel, filter, airmass, ra, decl, exp_time, sat_pixel_frac, bg, bg_stdev, bg_mean_stdev, alt, az, ccd_temp, posang, user_1, user_2, user_3, user_4, user_5, object, fault); 5115 4924 } 5116 4925 psArray *rawImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 5224 5033 static void guidePendingExpRowFree(guidePendingExpRow *object); 5225 5034 5226 guidePendingExpRow *guidePendingExpRowAlloc(psS64 guide_id, const char *exp_tag, const char *recipe)5035 guidePendingExpRow *guidePendingExpRowAlloc(psS64 guide_id, psS64 exp_id, const char *recipe) 5227 5036 { 5228 5037 guidePendingExpRow *_object; … … 5232 5041 5233 5042 _object->guide_id = guide_id; 5234 _object->exp_ tag = psStringCopy(exp_tag);5043 _object->exp_id = exp_id; 5235 5044 _object->recipe = psStringCopy(recipe); 5236 5045 … … 5240 5049 static void guidePendingExpRowFree(guidePendingExpRow *object) 5241 5050 { 5242 psFree(object->exp_tag);5243 5051 psFree(object->recipe); 5244 5052 } … … 5252 5060 return false; 5253 5061 } 5254 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Key", "64")) {5255 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");5062 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Key", 64)) { 5063 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5256 5064 psFree(md); 5257 5065 return false; … … 5275 5083 } 5276 5084 5277 bool guidePendingExpInsert(psDB * dbh, psS64 guide_id, const char *exp_tag, const char *recipe)5085 bool guidePendingExpInsert(psDB * dbh, psS64 guide_id, psS64 exp_id, const char *recipe) 5278 5086 { 5279 5087 psMetadata *md = psMetadataAlloc(); … … 5283 5091 return false; 5284 5092 } 5285 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {5286 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");5093 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 5094 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5287 5095 psFree(md); 5288 5096 return false; … … 5316 5124 bool guidePendingExpInsertObject(psDB *dbh, guidePendingExpRow *object) 5317 5125 { 5318 return guidePendingExpInsert(dbh, object->guide_id, object->exp_ tag, object->recipe);5126 return guidePendingExpInsert(dbh, object->guide_id, object->exp_id, object->recipe); 5319 5127 } 5320 5128 … … 5394 5202 return false; 5395 5203 } 5396 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {5397 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");5204 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 5205 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5398 5206 psFree(md); 5399 5207 return false; … … 5418 5226 return false; 5419 5227 } 5420 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");5421 if (!status) { 5422 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");5228 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 5229 if (!status) { 5230 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 5423 5231 return false; 5424 5232 } … … 5429 5237 } 5430 5238 5431 return guidePendingExpRowAlloc(guide_id, exp_ tag, recipe);5239 return guidePendingExpRowAlloc(guide_id, exp_id, recipe); 5432 5240 } 5433 5241 psArray *guidePendingExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 5539 5347 return true; 5540 5348 } 5541 static void chip PendingExpRowFree(chipPendingExpRow *object);5542 5543 chip PendingExpRow *chipPendingExpRowAlloc(psS64 chip_id, const char *exp_tag, psS64 guide_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb)5544 { 5545 chip PendingExpRow*_object;5546 5547 _object = psAlloc(sizeof(chip PendingExpRow));5548 psMemSetDeallocator(_object, (psFreeFunc)chip PendingExpRowFree);5349 static void chipRunRowFree(chipRunRow *object); 5350 5351 chipRunRow *chipRunRowAlloc(psS64 chip_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *reduction, const char *expgroup, const char *dvodb) 5352 { 5353 chipRunRow *_object; 5354 5355 _object = psAlloc(sizeof(chipRunRow)); 5356 psMemSetDeallocator(_object, (psFreeFunc)chipRunRowFree); 5549 5357 5550 5358 _object->chip_id = chip_id; 5551 _object->exp_tag = psStringCopy(exp_tag); 5552 _object->guide_id = guide_id; 5359 _object->state = psStringCopy(state); 5553 5360 _object->workdir = psStringCopy(workdir); 5361 _object->workdir_state = psStringCopy(workdir_state); 5554 5362 _object->label = psStringCopy(label); 5555 5363 _object->reduction = psStringCopy(reduction); … … 5560 5368 } 5561 5369 5562 static void chip PendingExpRowFree(chipPendingExpRow *object)5563 { 5564 psFree(object-> exp_tag);5370 static void chipRunRowFree(chipRunRow *object) 5371 { 5372 psFree(object->state); 5565 5373 psFree(object->workdir); 5374 psFree(object->workdir_state); 5566 5375 psFree(object->label); 5567 5376 psFree(object->reduction); … … 5570 5379 } 5571 5380 5572 bool chip PendingExpCreateTable(psDB *dbh)5381 bool chipRunCreateTable(psDB *dbh) 5573 5382 { 5574 5383 psMetadata *md = psMetadataAlloc(); … … 5578 5387 return false; 5579 5388 } 5580 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) { 5581 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 5582 psFree(md); 5583 return false; 5584 } 5585 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, "Not NULL", 0)) { 5586 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id"); 5389 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "key", "64")) { 5390 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 5587 5391 psFree(md); 5588 5392 return false; … … 5593 5397 return false; 5594 5398 } 5399 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, "key", "64")) { 5400 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 5401 psFree(md); 5402 return false; 5403 } 5595 5404 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "key", "64")) { 5596 5405 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); … … 5614 5423 } 5615 5424 5616 bool status = psDBCreateTable(dbh, CHIP PENDINGEXP_TABLE_NAME, md);5425 bool status = psDBCreateTable(dbh, CHIPRUN_TABLE_NAME, md); 5617 5426 5618 5427 psFree(md); … … 5621 5430 } 5622 5431 5623 bool chip PendingExpDropTable(psDB *dbh)5624 { 5625 return psDBDropTable(dbh, CHIP PENDINGEXP_TABLE_NAME);5626 } 5627 5628 bool chip PendingExpInsert(psDB * dbh, psS64 chip_id, const char *exp_tag, psS64 guide_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb)5432 bool chipRunDropTable(psDB *dbh) 5433 { 5434 return psDBDropTable(dbh, CHIPRUN_TABLE_NAME); 5435 } 5436 5437 bool chipRunInsert(psDB * dbh, psS64 chip_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *reduction, const char *expgroup, const char *dvodb) 5629 5438 { 5630 5439 psMetadata *md = psMetadataAlloc(); … … 5634 5443 return false; 5635 5444 } 5636 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) { 5637 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 5638 psFree(md); 5639 return false; 5640 } 5641 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, NULL, guide_id)) { 5642 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id"); 5445 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 5446 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 5643 5447 psFree(md); 5644 5448 return false; … … 5649 5453 return false; 5650 5454 } 5455 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, workdir_state)) { 5456 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 5457 psFree(md); 5458 return false; 5459 } 5651 5460 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) { 5652 5461 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); … … 5670 5479 } 5671 5480 5672 bool status = psDBInsertOneRow(dbh, CHIP PENDINGEXP_TABLE_NAME, md);5481 bool status = psDBInsertOneRow(dbh, CHIPRUN_TABLE_NAME, md); 5673 5482 psFree(md); 5674 5483 … … 5676 5485 } 5677 5486 5678 long long chip PendingExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)5487 long long chipRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 5679 5488 { 5680 5489 long long deleted = 0; 5681 5490 5682 long long count = psDBDeleteRows(dbh, CHIP PENDINGEXP_TABLE_NAME, where, limit);5491 long long count = psDBDeleteRows(dbh, CHIPRUN_TABLE_NAME, where, limit); 5683 5492 if (count < 0) { 5684 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingExp");5493 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipRun"); 5685 5494 return count; 5686 5495 … … 5690 5499 return deleted; 5691 5500 } 5692 bool chip PendingExpInsertObject(psDB *dbh, chipPendingExpRow *object)5693 { 5694 return chip PendingExpInsert(dbh, object->chip_id, object->exp_tag, object->guide_id, object->workdir, object->label, object->reduction, object->expgroup, object->dvodb);5695 } 5696 5697 bool chip PendingExpInsertObjects(psDB *dbh, psArray *objects)5501 bool chipRunInsertObject(psDB *dbh, chipRunRow *object) 5502 { 5503 return chipRunInsert(dbh, object->chip_id, object->state, object->workdir, object->workdir_state, object->label, object->reduction, object->expgroup, object->dvodb); 5504 } 5505 5506 bool chipRunInsertObjects(psDB *dbh, psArray *objects) 5698 5507 { 5699 5508 for (long i = 0; i < psArrayLength(objects); i++) { 5700 if (!chip PendingExpInsertObject(dbh, objects->data[i])) {5509 if (!chipRunInsertObject(dbh, objects->data[i])) { 5701 5510 return false; 5702 5511 } … … 5706 5515 } 5707 5516 5708 bool chip PendingExpInsertFits(psDB *dbh, const psFits *fits)5517 bool chipRunInsertFits(psDB *dbh, const psFits *fits) 5709 5518 { 5710 5519 psArray *rowSet; 5711 5520 5712 // move to (the first?) extension named CHIP PENDINGEXP_TABLE_NAME5713 if (!psFitsMoveExtName(fits, CHIP PENDINGEXP_TABLE_NAME)) {5714 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIP PENDINGEXP_TABLE_NAME);5521 // move to (the first?) extension named CHIPRUN_TABLE_NAME 5522 if (!psFitsMoveExtName(fits, CHIPRUN_TABLE_NAME)) { 5523 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIPRUN_TABLE_NAME); 5715 5524 return false; 5716 5525 } … … 5730 5539 } 5731 5540 5732 if (!psDBInsertRows(dbh, CHIP PENDINGEXP_TABLE_NAME, rowSet)) {5541 if (!psDBInsertRows(dbh, CHIPRUN_TABLE_NAME, rowSet)) { 5733 5542 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 5734 5543 psFree(rowSet); … … 5741 5550 } 5742 5551 5743 bool chip PendingExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)5552 bool chipRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 5744 5553 { 5745 5554 psArray *rowSet; 5746 5555 5747 rowSet = psDBSelectRows(dbh, CHIP PENDINGEXP_TABLE_NAME, where, limit);5556 rowSet = psDBSelectRows(dbh, CHIPRUN_TABLE_NAME, where, limit); 5748 5557 if (!rowSet) { 5749 5558 return false; … … 5751 5560 5752 5561 // output to fits 5753 if (!psFitsWriteTable(fits, NULL, rowSet, CHIP PENDINGEXP_TABLE_NAME)) {5562 if (!psFitsWriteTable(fits, NULL, rowSet, CHIPRUN_TABLE_NAME)) { 5754 5563 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 5755 5564 psFree(rowSet); … … 5762 5571 } 5763 5572 5764 psMetadata *chip PendingExpMetadataFromObject(const chipPendingExpRow *object)5573 psMetadata *chipRunMetadataFromObject(const chipRunRow *object) 5765 5574 { 5766 5575 psMetadata *md = psMetadataAlloc(); … … 5770 5579 return false; 5771 5580 } 5772 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) { 5773 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 5774 psFree(md); 5775 return false; 5776 } 5777 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, NULL, object->guide_id)) { 5778 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id"); 5581 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 5582 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 5779 5583 psFree(md); 5780 5584 return false; … … 5785 5589 return false; 5786 5590 } 5591 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, object->workdir_state)) { 5592 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 5593 psFree(md); 5594 return false; 5595 } 5787 5596 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) { 5788 5597 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); … … 5810 5619 } 5811 5620 5812 chip PendingExpRow *chipPendingExpObjectFromMetadata(psMetadata *md)5621 chipRunRow *chipRunObjectFromMetadata(psMetadata *md) 5813 5622 { 5814 5623 … … 5819 5628 return false; 5820 5629 } 5821 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag"); 5822 if (!status) { 5823 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag"); 5824 return false; 5825 } 5826 psS64 guide_id = psMetadataLookupS64(&status, md, "guide_id"); 5827 if (!status) { 5828 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item guide_id"); 5630 char* state = psMetadataLookupPtr(&status, md, "state"); 5631 if (!status) { 5632 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 5829 5633 return false; 5830 5634 } … … 5834 5638 return false; 5835 5639 } 5640 char* workdir_state = psMetadataLookupPtr(&status, md, "workdir_state"); 5641 if (!status) { 5642 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir_state"); 5643 return false; 5644 } 5836 5645 char* label = psMetadataLookupPtr(&status, md, "label"); 5837 5646 if (!status) { … … 5855 5664 } 5856 5665 5857 return chip PendingExpRowAlloc(chip_id, exp_tag, guide_id, workdir, label, reduction, expgroup, dvodb);5858 } 5859 psArray *chip PendingExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)5666 return chipRunRowAlloc(chip_id, state, workdir, workdir_state, label, reduction, expgroup, dvodb); 5667 } 5668 psArray *chipRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 5860 5669 { 5861 5670 psArray *rowSet; … … 5863 5672 psU64 i; 5864 5673 5865 rowSet = psDBSelectRows(dbh, CHIP PENDINGEXP_TABLE_NAME, where, limit);5674 rowSet = psDBSelectRows(dbh, CHIPRUN_TABLE_NAME, where, limit); 5866 5675 if (!rowSet) { 5867 5676 return NULL; … … 5873 5682 5874 5683 for (i = 0; i < rowSet->n; i++) { 5875 chip PendingExpRow *object = chipPendingExpObjectFromMetadata(rowSet->data[i]);5684 chipRunRow *object = chipRunObjectFromMetadata(rowSet->data[i]); 5876 5685 psArrayAdd(returnSet, 0, object); 5877 5686 psFree(object); … … 5882 5691 return returnSet; 5883 5692 } 5884 bool chip PendingExpDeleteObject(psDB *dbh, const chipPendingExpRow *object)5885 { 5886 psMetadata *where = chip PendingExpMetadataFromObject(object);5887 long long count = psDBDeleteRows(dbh, CHIP PENDINGEXP_TABLE_NAME, where, 0);5693 bool chipRunDeleteObject(psDB *dbh, const chipRunRow *object) 5694 { 5695 psMetadata *where = chipRunMetadataFromObject(object); 5696 long long count = psDBDeleteRows(dbh, CHIPRUN_TABLE_NAME, where, 0); 5888 5697 psFree(where); 5889 5698 if (count < 0) { 5890 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingExp");5699 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipRun"); 5891 5700 return false; 5892 5701 } … … 5894 5703 // XXX should this be a psAbort() instead? It is possible that 5895 5704 // having an object match multiple rows was by design. 5896 psError(PS_ERR_UNKNOWN, true, "chip PendingExpRow object matched more then one row. Check your database schema");5897 return false; 5898 } 5899 5900 return true; 5901 } 5902 long long chip PendingExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)5705 psError(PS_ERR_UNKNOWN, true, "chipRunRow object matched more then one row. Check your database schema"); 5706 return false; 5707 } 5708 5709 return true; 5710 } 5711 long long chipRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 5903 5712 { 5904 5713 long long deleted = 0; 5905 5714 5906 5715 for (long long i = 0; i < objects->n; i++) { 5907 chip PendingExpRow *object = objects->data[i];5908 psMetadata *where = chip PendingExpMetadataFromObject(object);5909 long long count = psDBDeleteRows(dbh, CHIP PENDINGEXP_TABLE_NAME, where, limit);5716 chipRunRow *object = objects->data[i]; 5717 psMetadata *where = chipRunMetadataFromObject(object); 5718 long long count = psDBDeleteRows(dbh, CHIPRUN_TABLE_NAME, where, limit); 5910 5719 psFree(where); 5911 5720 if (count < 0) { 5912 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingExp");5721 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipRun"); 5913 5722 return count; 5914 5723 } … … 5919 5728 return deleted; 5920 5729 } 5921 bool chip PendingExpPrintObjects(FILE *stream, psArray *objects, bool mdcf)5730 bool chipRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 5922 5731 { 5923 5732 PS_ASSERT_PTR_NON_NULL(objects, false); … … 5925 5734 psMetadata *output = psMetadataAlloc(); 5926 5735 for (long i = 0; i < psArrayLength(objects); i++) { 5927 psMetadata *md = chip PendingExpMetadataFromObject(objects->data[i]);5736 psMetadata *md = chipRunMetadataFromObject(objects->data[i]); 5928 5737 if (!psMetadataAddMetadata( 5929 5738 output, 5930 5739 PS_LIST_TAIL, 5931 CHIP PENDINGEXP_TABLE_NAME,5740 CHIPRUN_TABLE_NAME, 5932 5741 PS_META_DUPLICATE_OK, 5933 5742 NULL, … … 5950 5759 return true; 5951 5760 } 5952 bool chip PendingExpPrintObject(FILE *stream, chipPendingExpRow *object, bool mdcf)5761 bool chipRunPrintObject(FILE *stream, chipRunRow *object, bool mdcf) 5953 5762 { 5954 5763 PS_ASSERT_PTR_NON_NULL(object, false); 5955 5764 5956 psMetadata *md = chip PendingExpMetadataFromObject(object);5765 psMetadata *md = chipRunMetadataFromObject(object); 5957 5766 5958 5767 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 5965 5774 return true; 5966 5775 } 5967 static void chip PendingImfileRowFree(chipPendingImfileRow *object);5968 5969 chip PendingImfileRow *chipPendingImfileRowAlloc(psS64 chip_id, const char *class_id, const char *uri)5970 { 5971 chip PendingImfileRow *_object;5972 5973 _object = psAlloc(sizeof(chip PendingImfileRow));5974 psMemSetDeallocator(_object, (psFreeFunc)chip PendingImfileRowFree);5776 static void chipInputImfileRowFree(chipInputImfileRow *object); 5777 5778 chipInputImfileRow *chipInputImfileRowAlloc(psS64 chip_id, psS64 exp_id, const char *class_id) 5779 { 5780 chipInputImfileRow *_object; 5781 5782 _object = psAlloc(sizeof(chipInputImfileRow)); 5783 psMemSetDeallocator(_object, (psFreeFunc)chipInputImfileRowFree); 5975 5784 5976 5785 _object->chip_id = chip_id; 5786 _object->exp_id = exp_id; 5977 5787 _object->class_id = psStringCopy(class_id); 5978 _object->uri = psStringCopy(uri);5979 5788 5980 5789 return _object; 5981 5790 } 5982 5791 5983 static void chip PendingImfileRowFree(chipPendingImfileRow *object)5792 static void chipInputImfileRowFree(chipInputImfileRow *object) 5984 5793 { 5985 5794 psFree(object->class_id); 5986 psFree(object->uri); 5987 } 5988 5989 bool chipPendingImfileCreateTable(psDB *dbh) 5795 } 5796 5797 bool chipInputImfileCreateTable(psDB *dbh) 5990 5798 { 5991 5799 psMetadata *md = psMetadataAlloc(); 5992 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key ", 0)) {5800 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey (chip_id) ref chipRun(chip_id)", 0)) { 5993 5801 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 5802 psFree(md); 5803 return false; 5804 } 5805 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key fkey (exp_id, class_id) ref rawImfile (exp_id, class_id)", 64)) { 5806 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5994 5807 psFree(md); 5995 5808 return false; … … 6000 5813 return false; 6001 5814 } 6002 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, "255")) { 6003 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 6004 psFree(md); 6005 return false; 6006 } 6007 6008 bool status = psDBCreateTable(dbh, CHIPPENDINGIMFILE_TABLE_NAME, md); 5815 5816 bool status = psDBCreateTable(dbh, CHIPINPUTIMFILE_TABLE_NAME, md); 6009 5817 6010 5818 psFree(md); … … 6013 5821 } 6014 5822 6015 bool chip PendingImfileDropTable(psDB *dbh)6016 { 6017 return psDBDropTable(dbh, CHIP PENDINGIMFILE_TABLE_NAME);6018 } 6019 6020 bool chip PendingImfileInsert(psDB * dbh, psS64 chip_id, const char *class_id, const char *uri)5823 bool chipInputImfileDropTable(psDB *dbh) 5824 { 5825 return psDBDropTable(dbh, CHIPINPUTIMFILE_TABLE_NAME); 5826 } 5827 5828 bool chipInputImfileInsert(psDB * dbh, psS64 chip_id, psS64 exp_id, const char *class_id) 6021 5829 { 6022 5830 psMetadata *md = psMetadataAlloc(); … … 6026 5834 return false; 6027 5835 } 5836 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 5837 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5838 psFree(md); 5839 return false; 5840 } 6028 5841 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, class_id)) { 6029 5842 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 6031 5844 return false; 6032 5845 } 6033 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, uri)) { 6034 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 6035 psFree(md); 6036 return false; 6037 } 6038 6039 bool status = psDBInsertOneRow(dbh, CHIPPENDINGIMFILE_TABLE_NAME, md); 5846 5847 bool status = psDBInsertOneRow(dbh, CHIPINPUTIMFILE_TABLE_NAME, md); 6040 5848 psFree(md); 6041 5849 … … 6043 5851 } 6044 5852 6045 long long chip PendingImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)5853 long long chipInputImfileDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 6046 5854 { 6047 5855 long long deleted = 0; 6048 5856 6049 long long count = psDBDeleteRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, where, limit);5857 long long count = psDBDeleteRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, where, limit); 6050 5858 if (count < 0) { 6051 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingImfile");5859 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipInputImfile"); 6052 5860 return count; 6053 5861 … … 6057 5865 return deleted; 6058 5866 } 6059 bool chip PendingImfileInsertObject(psDB *dbh, chipPendingImfileRow *object)6060 { 6061 return chip PendingImfileInsert(dbh, object->chip_id, object->class_id, object->uri);6062 } 6063 6064 bool chip PendingImfileInsertObjects(psDB *dbh, psArray *objects)5867 bool chipInputImfileInsertObject(psDB *dbh, chipInputImfileRow *object) 5868 { 5869 return chipInputImfileInsert(dbh, object->chip_id, object->exp_id, object->class_id); 5870 } 5871 5872 bool chipInputImfileInsertObjects(psDB *dbh, psArray *objects) 6065 5873 { 6066 5874 for (long i = 0; i < psArrayLength(objects); i++) { 6067 if (!chip PendingImfileInsertObject(dbh, objects->data[i])) {5875 if (!chipInputImfileInsertObject(dbh, objects->data[i])) { 6068 5876 return false; 6069 5877 } … … 6073 5881 } 6074 5882 6075 bool chip PendingImfileInsertFits(psDB *dbh, const psFits *fits)5883 bool chipInputImfileInsertFits(psDB *dbh, const psFits *fits) 6076 5884 { 6077 5885 psArray *rowSet; 6078 5886 6079 // move to (the first?) extension named CHIP PENDINGIMFILE_TABLE_NAME6080 if (!psFitsMoveExtName(fits, CHIP PENDINGIMFILE_TABLE_NAME)) {6081 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIP PENDINGIMFILE_TABLE_NAME);5887 // move to (the first?) extension named CHIPINPUTIMFILE_TABLE_NAME 5888 if (!psFitsMoveExtName(fits, CHIPINPUTIMFILE_TABLE_NAME)) { 5889 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIPINPUTIMFILE_TABLE_NAME); 6082 5890 return false; 6083 5891 } … … 6097 5905 } 6098 5906 6099 if (!psDBInsertRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, rowSet)) {5907 if (!psDBInsertRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, rowSet)) { 6100 5908 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 6101 5909 psFree(rowSet); … … 6108 5916 } 6109 5917 6110 bool chip PendingImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)5918 bool chipInputImfileSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 6111 5919 { 6112 5920 psArray *rowSet; 6113 5921 6114 rowSet = psDBSelectRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, where, limit);5922 rowSet = psDBSelectRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, where, limit); 6115 5923 if (!rowSet) { 6116 5924 return false; … … 6118 5926 6119 5927 // output to fits 6120 if (!psFitsWriteTable(fits, NULL, rowSet, CHIP PENDINGIMFILE_TABLE_NAME)) {5928 if (!psFitsWriteTable(fits, NULL, rowSet, CHIPINPUTIMFILE_TABLE_NAME)) { 6121 5929 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 6122 5930 psFree(rowSet); … … 6129 5937 } 6130 5938 6131 psMetadata *chip PendingImfileMetadataFromObject(const chipPendingImfileRow *object)5939 psMetadata *chipInputImfileMetadataFromObject(const chipInputImfileRow *object) 6132 5940 { 6133 5941 psMetadata *md = psMetadataAlloc(); … … 6137 5945 return false; 6138 5946 } 5947 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 5948 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5949 psFree(md); 5950 return false; 5951 } 6139 5952 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 6140 5953 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 6142 5955 return false; 6143 5956 } 6144 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) {6145 psError(PS_ERR_UNKNOWN, false, "failed to add item uri");6146 psFree(md);6147 return false;6148 }6149 5957 6150 5958 … … 6152 5960 } 6153 5961 6154 chip PendingImfileRow *chipPendingImfileObjectFromMetadata(psMetadata *md)5962 chipInputImfileRow *chipInputImfileObjectFromMetadata(psMetadata *md) 6155 5963 { 6156 5964 … … 6161 5969 return false; 6162 5970 } 5971 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 5972 if (!status) { 5973 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 5974 return false; 5975 } 6163 5976 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 6164 5977 if (!status) { … … 6166 5979 return false; 6167 5980 } 6168 char* uri = psMetadataLookupPtr(&status, md, "uri"); 6169 if (!status) { 6170 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item uri"); 6171 return false; 6172 } 6173 6174 return chipPendingImfileRowAlloc(chip_id, class_id, uri); 6175 } 6176 psArray *chipPendingImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 5981 5982 return chipInputImfileRowAlloc(chip_id, exp_id, class_id); 5983 } 5984 psArray *chipInputImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 6177 5985 { 6178 5986 psArray *rowSet; … … 6180 5988 psU64 i; 6181 5989 6182 rowSet = psDBSelectRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, where, limit);5990 rowSet = psDBSelectRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, where, limit); 6183 5991 if (!rowSet) { 6184 5992 return NULL; … … 6190 5998 6191 5999 for (i = 0; i < rowSet->n; i++) { 6192 chip PendingImfileRow *object = chipPendingImfileObjectFromMetadata(rowSet->data[i]);6000 chipInputImfileRow *object = chipInputImfileObjectFromMetadata(rowSet->data[i]); 6193 6001 psArrayAdd(returnSet, 0, object); 6194 6002 psFree(object); … … 6199 6007 return returnSet; 6200 6008 } 6201 bool chip PendingImfileDeleteObject(psDB *dbh, const chipPendingImfileRow *object)6202 { 6203 psMetadata *where = chip PendingImfileMetadataFromObject(object);6204 long long count = psDBDeleteRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, where, 0);6009 bool chipInputImfileDeleteObject(psDB *dbh, const chipInputImfileRow *object) 6010 { 6011 psMetadata *where = chipInputImfileMetadataFromObject(object); 6012 long long count = psDBDeleteRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, where, 0); 6205 6013 psFree(where); 6206 6014 if (count < 0) { 6207 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingImfile");6015 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipInputImfile"); 6208 6016 return false; 6209 6017 } … … 6211 6019 // XXX should this be a psAbort() instead? It is possible that 6212 6020 // having an object match multiple rows was by design. 6213 psError(PS_ERR_UNKNOWN, true, "chip PendingImfileRow object matched more then one row. Check your database schema");6214 return false; 6215 } 6216 6217 return true; 6218 } 6219 long long chip PendingImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)6021 psError(PS_ERR_UNKNOWN, true, "chipInputImfileRow object matched more then one row. Check your database schema"); 6022 return false; 6023 } 6024 6025 return true; 6026 } 6027 long long chipInputImfileDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 6220 6028 { 6221 6029 long long deleted = 0; 6222 6030 6223 6031 for (long long i = 0; i < objects->n; i++) { 6224 chip PendingImfileRow *object = objects->data[i];6225 psMetadata *where = chip PendingImfileMetadataFromObject(object);6226 long long count = psDBDeleteRows(dbh, CHIP PENDINGIMFILE_TABLE_NAME, where, limit);6032 chipInputImfileRow *object = objects->data[i]; 6033 psMetadata *where = chipInputImfileMetadataFromObject(object); 6034 long long count = psDBDeleteRows(dbh, CHIPINPUTIMFILE_TABLE_NAME, where, limit); 6227 6035 psFree(where); 6228 6036 if (count < 0) { 6229 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chip PendingImfile");6037 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipInputImfile"); 6230 6038 return count; 6231 6039 } … … 6236 6044 return deleted; 6237 6045 } 6238 bool chip PendingImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf)6046 bool chipInputImfilePrintObjects(FILE *stream, psArray *objects, bool mdcf) 6239 6047 { 6240 6048 PS_ASSERT_PTR_NON_NULL(objects, false); … … 6242 6050 psMetadata *output = psMetadataAlloc(); 6243 6051 for (long i = 0; i < psArrayLength(objects); i++) { 6244 psMetadata *md = chip PendingImfileMetadataFromObject(objects->data[i]);6052 psMetadata *md = chipInputImfileMetadataFromObject(objects->data[i]); 6245 6053 if (!psMetadataAddMetadata( 6246 6054 output, 6247 6055 PS_LIST_TAIL, 6248 CHIP PENDINGIMFILE_TABLE_NAME,6056 CHIPINPUTIMFILE_TABLE_NAME, 6249 6057 PS_META_DUPLICATE_OK, 6250 6058 NULL, … … 6267 6075 return true; 6268 6076 } 6269 bool chip PendingImfilePrintObject(FILE *stream, chipPendingImfileRow *object, bool mdcf)6077 bool chipInputImfilePrintObject(FILE *stream, chipInputImfileRow *object, bool mdcf) 6270 6078 { 6271 6079 PS_ASSERT_PTR_NON_NULL(object, false); 6272 6080 6273 psMetadata *md = chip PendingImfileMetadataFromObject(object);6081 psMetadata *md = chipInputImfileMetadataFromObject(object); 6274 6082 6275 6083 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 6282 6090 return true; 6283 6091 } 6284 static void chipProcessedExpRowFree(chipProcessedExpRow *object);6285 6286 chipProcessedExpRow *chipProcessedExpRowAlloc(psS64 chip_id, const char *exp_tag, psS64 guide_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb)6287 {6288 chipProcessedExpRow *_object;6289 6290 _object = psAlloc(sizeof(chipProcessedExpRow));6291 psMemSetDeallocator(_object, (psFreeFunc)chipProcessedExpRowFree);6292 6293 _object->chip_id = chip_id;6294 _object->exp_tag = psStringCopy(exp_tag);6295 _object->guide_id = guide_id;6296 _object->workdir = psStringCopy(workdir);6297 _object->label = psStringCopy(label);6298 _object->reduction = psStringCopy(reduction);6299 _object->expgroup = psStringCopy(expgroup);6300 _object->dvodb = psStringCopy(dvodb);6301 6302 return _object;6303 }6304 6305 static void chipProcessedExpRowFree(chipProcessedExpRow *object)6306 {6307 psFree(object->exp_tag);6308 psFree(object->workdir);6309 psFree(object->label);6310 psFree(object->reduction);6311 psFree(object->expgroup);6312 psFree(object->dvodb);6313 }6314 6315 bool chipProcessedExpCreateTable(psDB *dbh)6316 {6317 psMetadata *md = psMetadataAlloc();6318 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key", 0)) {6319 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");6320 psFree(md);6321 return false;6322 }6323 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, "Primary Key", "64")) {6324 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");6325 psFree(md);6326 return false;6327 }6328 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, "Not NULL", 0)) {6329 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id");6330 psFree(md);6331 return false;6332 }6333 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) {6334 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");6335 psFree(md);6336 return false;6337 }6338 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "key", "64")) {6339 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6340 psFree(md);6341 return false;6342 }6343 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, "64")) {6344 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");6345 psFree(md);6346 return false;6347 }6348 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, "key", "64")) {6349 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");6350 psFree(md);6351 return false;6352 }6353 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, "255")) {6354 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");6355 psFree(md);6356 return false;6357 }6358 6359 bool status = psDBCreateTable(dbh, CHIPPROCESSEDEXP_TABLE_NAME, md);6360 6361 psFree(md);6362 6363 return status;6364 }6365 6366 bool chipProcessedExpDropTable(psDB *dbh)6367 {6368 return psDBDropTable(dbh, CHIPPROCESSEDEXP_TABLE_NAME);6369 }6370 6371 bool chipProcessedExpInsert(psDB * dbh, psS64 chip_id, const char *exp_tag, psS64 guide_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb)6372 {6373 psMetadata *md = psMetadataAlloc();6374 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) {6375 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");6376 psFree(md);6377 return false;6378 }6379 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, exp_tag)) {6380 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");6381 psFree(md);6382 return false;6383 }6384 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, NULL, guide_id)) {6385 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id");6386 psFree(md);6387 return false;6388 }6389 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) {6390 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");6391 psFree(md);6392 return false;6393 }6394 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) {6395 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6396 psFree(md);6397 return false;6398 }6399 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, reduction)) {6400 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");6401 psFree(md);6402 return false;6403 }6404 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, expgroup)) {6405 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");6406 psFree(md);6407 return false;6408 }6409 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, dvodb)) {6410 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");6411 psFree(md);6412 return false;6413 }6414 6415 bool status = psDBInsertOneRow(dbh, CHIPPROCESSEDEXP_TABLE_NAME, md);6416 psFree(md);6417 6418 return status;6419 }6420 6421 long long chipProcessedExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)6422 {6423 long long deleted = 0;6424 6425 long long count = psDBDeleteRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, where, limit);6426 if (count < 0) {6427 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipProcessedExp");6428 return count;6429 6430 deleted += count;6431 }6432 6433 return deleted;6434 }6435 bool chipProcessedExpInsertObject(psDB *dbh, chipProcessedExpRow *object)6436 {6437 return chipProcessedExpInsert(dbh, object->chip_id, object->exp_tag, object->guide_id, object->workdir, object->label, object->reduction, object->expgroup, object->dvodb);6438 }6439 6440 bool chipProcessedExpInsertObjects(psDB *dbh, psArray *objects)6441 {6442 for (long i = 0; i < psArrayLength(objects); i++) {6443 if (!chipProcessedExpInsertObject(dbh, objects->data[i])) {6444 return false;6445 }6446 }6447 6448 return true;6449 }6450 6451 bool chipProcessedExpInsertFits(psDB *dbh, const psFits *fits)6452 {6453 psArray *rowSet;6454 6455 // move to (the first?) extension named CHIPPROCESSEDEXP_TABLE_NAME6456 if (!psFitsMoveExtName(fits, CHIPPROCESSEDEXP_TABLE_NAME)) {6457 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIPPROCESSEDEXP_TABLE_NAME);6458 return false;6459 }6460 6461 // check HDU type6462 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) {6463 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");6464 return false;6465 }6466 6467 // read fits table6468 rowSet = psFitsReadTable(fits);6469 if (!rowSet) {6470 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");6471 psFree(rowSet);6472 return false;6473 }6474 6475 if (!psDBInsertRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, rowSet)) {6476 psError(PS_ERR_UNKNOWN, false, "databse insert failed");6477 psFree(rowSet);6478 return false;6479 }6480 6481 psFree(rowSet);6482 6483 return true;6484 }6485 6486 bool chipProcessedExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)6487 {6488 psArray *rowSet;6489 6490 rowSet = psDBSelectRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, where, limit);6491 if (!rowSet) {6492 return false;6493 }6494 6495 // output to fits6496 if (!psFitsWriteTable(fits, NULL, rowSet, CHIPPROCESSEDEXP_TABLE_NAME)) {6497 psError(PS_ERR_UNKNOWN, false, "FITS table write failed");6498 psFree(rowSet);6499 return false;6500 }6501 6502 psFree(rowSet);6503 6504 return true;6505 }6506 6507 psMetadata *chipProcessedExpMetadataFromObject(const chipProcessedExpRow *object)6508 {6509 psMetadata *md = psMetadataAlloc();6510 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, object->chip_id)) {6511 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");6512 psFree(md);6513 return false;6514 }6515 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_tag", PS_DATA_STRING, NULL, object->exp_tag)) {6516 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");6517 psFree(md);6518 return false;6519 }6520 if (!psMetadataAdd(md, PS_LIST_TAIL, "guide_id", PS_DATA_S64, NULL, object->guide_id)) {6521 psError(PS_ERR_UNKNOWN, false, "failed to add item guide_id");6522 psFree(md);6523 return false;6524 }6525 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) {6526 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");6527 psFree(md);6528 return false;6529 }6530 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) {6531 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6532 psFree(md);6533 return false;6534 }6535 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, object->reduction)) {6536 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");6537 psFree(md);6538 return false;6539 }6540 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, object->expgroup)) {6541 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");6542 psFree(md);6543 return false;6544 }6545 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, object->dvodb)) {6546 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");6547 psFree(md);6548 return false;6549 }6550 6551 6552 return md;6553 }6554 6555 chipProcessedExpRow *chipProcessedExpObjectFromMetadata(psMetadata *md)6556 {6557 6558 bool status = false;6559 psS64 chip_id = psMetadataLookupS64(&status, md, "chip_id");6560 if (!status) {6561 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item chip_id");6562 return false;6563 }6564 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");6565 if (!status) {6566 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_tag");6567 return false;6568 }6569 psS64 guide_id = psMetadataLookupS64(&status, md, "guide_id");6570 if (!status) {6571 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item guide_id");6572 return false;6573 }6574 char* workdir = psMetadataLookupPtr(&status, md, "workdir");6575 if (!status) {6576 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir");6577 return false;6578 }6579 char* label = psMetadataLookupPtr(&status, md, "label");6580 if (!status) {6581 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label");6582 return false;6583 }6584 char* reduction = psMetadataLookupPtr(&status, md, "reduction");6585 if (!status) {6586 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item reduction");6587 return false;6588 }6589 char* expgroup = psMetadataLookupPtr(&status, md, "expgroup");6590 if (!status) {6591 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item expgroup");6592 return false;6593 }6594 char* dvodb = psMetadataLookupPtr(&status, md, "dvodb");6595 if (!status) {6596 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dvodb");6597 return false;6598 }6599 6600 return chipProcessedExpRowAlloc(chip_id, exp_tag, guide_id, workdir, label, reduction, expgroup, dvodb);6601 }6602 psArray *chipProcessedExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)6603 {6604 psArray *rowSet;6605 psArray *returnSet;6606 psU64 i;6607 6608 rowSet = psDBSelectRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, where, limit);6609 if (!rowSet) {6610 return NULL;6611 }6612 6613 // convert psMetadata rows to row objects6614 6615 returnSet = psArrayAllocEmpty(rowSet->n);6616 6617 for (i = 0; i < rowSet->n; i++) {6618 chipProcessedExpRow *object = chipProcessedExpObjectFromMetadata(rowSet->data[i]);6619 psArrayAdd(returnSet, 0, object);6620 psFree(object);6621 }6622 6623 psFree(rowSet);6624 6625 return returnSet;6626 }6627 bool chipProcessedExpDeleteObject(psDB *dbh, const chipProcessedExpRow *object)6628 {6629 psMetadata *where = chipProcessedExpMetadataFromObject(object);6630 long long count = psDBDeleteRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, where, 0);6631 psFree(where);6632 if (count < 0) {6633 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipProcessedExp");6634 return false;6635 }6636 if (count > 1) {6637 // XXX should this be a psAbort() instead? It is possible that6638 // having an object match multiple rows was by design.6639 psError(PS_ERR_UNKNOWN, true, "chipProcessedExpRow object matched more then one row. Check your database schema");6640 return false;6641 }6642 6643 return true;6644 }6645 long long chipProcessedExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)6646 {6647 long long deleted = 0;6648 6649 for (long long i = 0; i < objects->n; i++) {6650 chipProcessedExpRow *object = objects->data[i];6651 psMetadata *where = chipProcessedExpMetadataFromObject(object);6652 long long count = psDBDeleteRows(dbh, CHIPPROCESSEDEXP_TABLE_NAME, where, limit);6653 psFree(where);6654 if (count < 0) {6655 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipProcessedExp");6656 return count;6657 }6658 6659 deleted += count;6660 }6661 6662 return deleted;6663 }6664 bool chipProcessedExpPrintObjects(FILE *stream, psArray *objects, bool mdcf)6665 {6666 PS_ASSERT_PTR_NON_NULL(objects, false);6667 6668 psMetadata *output = psMetadataAlloc();6669 for (long i = 0; i < psArrayLength(objects); i++) {6670 psMetadata *md = chipProcessedExpMetadataFromObject(objects->data[i]);6671 if (!psMetadataAddMetadata(6672 output,6673 PS_LIST_TAIL,6674 CHIPPROCESSEDEXP_TABLE_NAME,6675 PS_META_DUPLICATE_OK,6676 NULL,6677 md6678 )) {6679 psError(PS_ERR_UNKNOWN, false, "failed to add metadata");6680 psFree(md);6681 psFree(output);6682 return false;6683 }6684 psFree(md);6685 }6686 6687 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {6688 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");6689 psFree(output);6690 }6691 psFree(output);6692 6693 return true;6694 }6695 bool chipProcessedExpPrintObject(FILE *stream, chipProcessedExpRow *object, bool mdcf)6696 {6697 PS_ASSERT_PTR_NON_NULL(object, false);6698 6699 psMetadata *md = chipProcessedExpMetadataFromObject(object);6700 6701 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {6702 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");6703 psFree(md);6704 }6705 6706 psFree(md);6707 6708 return true;6709 }6710 static void chipMaskRowFree(chipMaskRow *object);6711 6712 chipMaskRow *chipMaskRowAlloc(const char *label)6713 {6714 chipMaskRow *_object;6715 6716 _object = psAlloc(sizeof(chipMaskRow));6717 psMemSetDeallocator(_object, (psFreeFunc)chipMaskRowFree);6718 6719 _object->label = psStringCopy(label);6720 6721 return _object;6722 }6723 6724 static void chipMaskRowFree(chipMaskRow *object)6725 {6726 psFree(object->label);6727 }6728 6729 bool chipMaskCreateTable(psDB *dbh)6730 {6731 psMetadata *md = psMetadataAlloc();6732 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "Primary Key", "64")) {6733 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6734 psFree(md);6735 return false;6736 }6737 6738 bool status = psDBCreateTable(dbh, CHIPMASK_TABLE_NAME, md);6739 6740 psFree(md);6741 6742 return status;6743 }6744 6745 bool chipMaskDropTable(psDB *dbh)6746 {6747 return psDBDropTable(dbh, CHIPMASK_TABLE_NAME);6748 }6749 6750 bool chipMaskInsert(psDB * dbh, const char *label)6751 {6752 psMetadata *md = psMetadataAlloc();6753 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) {6754 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6755 psFree(md);6756 return false;6757 }6758 6759 bool status = psDBInsertOneRow(dbh, CHIPMASK_TABLE_NAME, md);6760 psFree(md);6761 6762 return status;6763 }6764 6765 long long chipMaskDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)6766 {6767 long long deleted = 0;6768 6769 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, limit);6770 if (count < 0) {6771 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask");6772 return count;6773 6774 deleted += count;6775 }6776 6777 return deleted;6778 }6779 bool chipMaskInsertObject(psDB *dbh, chipMaskRow *object)6780 {6781 return chipMaskInsert(dbh, object->label);6782 }6783 6784 bool chipMaskInsertObjects(psDB *dbh, psArray *objects)6785 {6786 for (long i = 0; i < psArrayLength(objects); i++) {6787 if (!chipMaskInsertObject(dbh, objects->data[i])) {6788 return false;6789 }6790 }6791 6792 return true;6793 }6794 6795 bool chipMaskInsertFits(psDB *dbh, const psFits *fits)6796 {6797 psArray *rowSet;6798 6799 // move to (the first?) extension named CHIPMASK_TABLE_NAME6800 if (!psFitsMoveExtName(fits, CHIPMASK_TABLE_NAME)) {6801 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIPMASK_TABLE_NAME);6802 return false;6803 }6804 6805 // check HDU type6806 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) {6807 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE");6808 return false;6809 }6810 6811 // read fits table6812 rowSet = psFitsReadTable(fits);6813 if (!rowSet) {6814 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty");6815 psFree(rowSet);6816 return false;6817 }6818 6819 if (!psDBInsertRows(dbh, CHIPMASK_TABLE_NAME, rowSet)) {6820 psError(PS_ERR_UNKNOWN, false, "databse insert failed");6821 psFree(rowSet);6822 return false;6823 }6824 6825 psFree(rowSet);6826 6827 return true;6828 }6829 6830 bool chipMaskSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)6831 {6832 psArray *rowSet;6833 6834 rowSet = psDBSelectRows(dbh, CHIPMASK_TABLE_NAME, where, limit);6835 if (!rowSet) {6836 return false;6837 }6838 6839 // output to fits6840 if (!psFitsWriteTable(fits, NULL, rowSet, CHIPMASK_TABLE_NAME)) {6841 psError(PS_ERR_UNKNOWN, false, "FITS table write failed");6842 psFree(rowSet);6843 return false;6844 }6845 6846 psFree(rowSet);6847 6848 return true;6849 }6850 6851 psMetadata *chipMaskMetadataFromObject(const chipMaskRow *object)6852 {6853 psMetadata *md = psMetadataAlloc();6854 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) {6855 psError(PS_ERR_UNKNOWN, false, "failed to add item label");6856 psFree(md);6857 return false;6858 }6859 6860 6861 return md;6862 }6863 6864 chipMaskRow *chipMaskObjectFromMetadata(psMetadata *md)6865 {6866 6867 bool status = false;6868 char* label = psMetadataLookupPtr(&status, md, "label");6869 if (!status) {6870 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label");6871 return false;6872 }6873 6874 return chipMaskRowAlloc(label);6875 }6876 psArray *chipMaskSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)6877 {6878 psArray *rowSet;6879 psArray *returnSet;6880 psU64 i;6881 6882 rowSet = psDBSelectRows(dbh, CHIPMASK_TABLE_NAME, where, limit);6883 if (!rowSet) {6884 return NULL;6885 }6886 6887 // convert psMetadata rows to row objects6888 6889 returnSet = psArrayAllocEmpty(rowSet->n);6890 6891 for (i = 0; i < rowSet->n; i++) {6892 chipMaskRow *object = chipMaskObjectFromMetadata(rowSet->data[i]);6893 psArrayAdd(returnSet, 0, object);6894 psFree(object);6895 }6896 6897 psFree(rowSet);6898 6899 return returnSet;6900 }6901 bool chipMaskDeleteObject(psDB *dbh, const chipMaskRow *object)6902 {6903 psMetadata *where = chipMaskMetadataFromObject(object);6904 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, 0);6905 psFree(where);6906 if (count < 0) {6907 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask");6908 return false;6909 }6910 if (count > 1) {6911 // XXX should this be a psAbort() instead? It is possible that6912 // having an object match multiple rows was by design.6913 psError(PS_ERR_UNKNOWN, true, "chipMaskRow object matched more then one row. Check your database schema");6914 return false;6915 }6916 6917 return true;6918 }6919 long long chipMaskDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)6920 {6921 long long deleted = 0;6922 6923 for (long long i = 0; i < objects->n; i++) {6924 chipMaskRow *object = objects->data[i];6925 psMetadata *where = chipMaskMetadataFromObject(object);6926 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, limit);6927 psFree(where);6928 if (count < 0) {6929 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask");6930 return count;6931 }6932 6933 deleted += count;6934 }6935 6936 return deleted;6937 }6938 bool chipMaskPrintObjects(FILE *stream, psArray *objects, bool mdcf)6939 {6940 PS_ASSERT_PTR_NON_NULL(objects, false);6941 6942 psMetadata *output = psMetadataAlloc();6943 for (long i = 0; i < psArrayLength(objects); i++) {6944 psMetadata *md = chipMaskMetadataFromObject(objects->data[i]);6945 if (!psMetadataAddMetadata(6946 output,6947 PS_LIST_TAIL,6948 CHIPMASK_TABLE_NAME,6949 PS_META_DUPLICATE_OK,6950 NULL,6951 md6952 )) {6953 psError(PS_ERR_UNKNOWN, false, "failed to add metadata");6954 psFree(md);6955 psFree(output);6956 return false;6957 }6958 psFree(md);6959 }6960 6961 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) {6962 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");6963 psFree(output);6964 }6965 psFree(output);6966 6967 return true;6968 }6969 bool chipMaskPrintObject(FILE *stream, chipMaskRow *object, bool mdcf)6970 {6971 PS_ASSERT_PTR_NON_NULL(object, false);6972 6973 psMetadata *md = chipMaskMetadataFromObject(object);6974 6975 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) {6976 psError(PS_ERR_UNKNOWN, false, "failed to print metadata");6977 psFree(md);6978 }6979 6980 psFree(md);6981 6982 return true;6983 }6984 6092 static void chipProcessedImfileRowFree(chipProcessedImfileRow *object); 6985 6093 6986 chipProcessedImfileRow *chipProcessedImfileRowAlloc(psS64 chip_id, const char *class_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)6094 chipProcessedImfileRow *chipProcessedImfileRowAlloc(psS64 chip_id, psS64 exp_id, const char *class_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 6987 6095 { 6988 6096 chipProcessedImfileRow *_object; … … 6992 6100 6993 6101 _object->chip_id = chip_id; 6102 _object->exp_id = exp_id; 6994 6103 _object->class_id = psStringCopy(class_id); 6995 6104 _object->uri = psStringCopy(uri); … … 7028 6137 { 7029 6138 psMetadata *md = psMetadataAlloc(); 7030 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key ", 0)) {6139 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey (chip_id, exp_id, class_id) ref chipInputImfile(chip_id, exp_id, class_id)", 0)) { 7031 6140 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 6141 psFree(md); 6142 return false; 6143 } 6144 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 6145 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 7032 6146 psFree(md); 7033 6147 return false; … … 7156 6270 } 7157 6271 7158 bool chipProcessedImfileInsert(psDB * dbh, psS64 chip_id, const char *class_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)6272 bool chipProcessedImfileInsert(psDB * dbh, psS64 chip_id, psS64 exp_id, const char *class_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 bias, psF32 bias_stdev, psF32 fringe_0, psF32 fringe_1, psF32 fringe_2, psF32 sigma_ra, psF32 sigma_dec, psF32 ap_resid, psF32 ap_resid_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 7159 6273 { 7160 6274 psMetadata *md = psMetadataAlloc(); 7161 6275 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) { 7162 6276 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 6277 psFree(md); 6278 return false; 6279 } 6280 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 6281 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 7163 6282 psFree(md); 7164 6283 return false; … … 7297 6416 bool chipProcessedImfileInsertObject(psDB *dbh, chipProcessedImfileRow *object) 7298 6417 { 7299 return chipProcessedImfileInsert(dbh, object->chip_id, object-> class_id, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bias, object->bias_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->sigma_ra, object->sigma_dec, object->ap_resid, object->ap_resid_stdev, object->fwhm, object->fwhm_range, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault);6418 return chipProcessedImfileInsert(dbh, object->chip_id, object->exp_id, object->class_id, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bias, object->bias_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->sigma_ra, object->sigma_dec, object->ap_resid, object->ap_resid_stdev, object->fwhm, object->fwhm_range, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault); 7300 6419 } 7301 6420 … … 7375 6494 return false; 7376 6495 } 6496 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 6497 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 6498 psFree(md); 6499 return false; 6500 } 7377 6501 if (!psMetadataAdd(md, PS_LIST_TAIL, "class_id", PS_DATA_STRING, NULL, object->class_id)) { 7378 6502 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); … … 7499 6623 return false; 7500 6624 } 6625 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 6626 if (!status) { 6627 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 6628 return false; 6629 } 7501 6630 char* class_id = psMetadataLookupPtr(&status, md, "class_id"); 7502 6631 if (!status) { … … 7610 6739 } 7611 6740 7612 return chipProcessedImfileRowAlloc(chip_id, class_id, uri, bg, bg_stdev, bg_mean_stdev, bias, bias_stdev, fringe_0, fringe_1, fringe_2, sigma_ra, sigma_dec, ap_resid, ap_resid_stdev, fwhm, fwhm_range, n_stars, n_extended, n_cr, n_astrom, path_base, fault);6741 return chipProcessedImfileRowAlloc(chip_id, exp_id, class_id, uri, bg, bg_stdev, bg_mean_stdev, bias, bias_stdev, fringe_0, fringe_1, fringe_2, sigma_ra, sigma_dec, ap_resid, ap_resid_stdev, fwhm, fwhm_range, n_stars, n_extended, n_cr, n_astrom, path_base, fault); 7613 6742 } 7614 6743 psArray *chipProcessedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 7720 6849 return true; 7721 6850 } 7722 static void camPendingExpRowFree(camPendingExpRow *object); 7723 7724 camPendingExpRow *camPendingExpRowAlloc(psS64 cam_id, psS64 chip_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb) 7725 { 7726 camPendingExpRow *_object; 7727 7728 _object = psAlloc(sizeof(camPendingExpRow)); 7729 psMemSetDeallocator(_object, (psFreeFunc)camPendingExpRowFree); 7730 7731 _object->cam_id = cam_id; 7732 _object->chip_id = chip_id; 7733 _object->workdir = psStringCopy(workdir); 6851 static void chipMaskRowFree(chipMaskRow *object); 6852 6853 chipMaskRow *chipMaskRowAlloc(const char *label) 6854 { 6855 chipMaskRow *_object; 6856 6857 _object = psAlloc(sizeof(chipMaskRow)); 6858 psMemSetDeallocator(_object, (psFreeFunc)chipMaskRowFree); 6859 7734 6860 _object->label = psStringCopy(label); 7735 _object->reduction = psStringCopy(reduction);7736 _object->expgroup = psStringCopy(expgroup);7737 _object->dvodb = psStringCopy(dvodb);7738 6861 7739 6862 return _object; 7740 6863 } 7741 6864 7742 static void camPendingExpRowFree(camPendingExpRow *object) 7743 { 7744 psFree(object->workdir); 6865 static void chipMaskRowFree(chipMaskRow *object) 6866 { 7745 6867 psFree(object->label); 7746 psFree(object->reduction); 7747 psFree(object->expgroup); 7748 psFree(object->dvodb); 7749 } 7750 7751 bool camPendingExpCreateTable(psDB *dbh) 6868 } 6869 6870 bool chipMaskCreateTable(psDB *dbh) 7752 6871 { 7753 6872 psMetadata *md = psMetadataAlloc(); 7754 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, "Primary Key AUTO_INCREMENT", 0)) { 7755 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 7756 psFree(md); 7757 return false; 7758 } 7759 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(chip_id) ref chipProcessedExp(chip_id)", 0)) { 7760 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 7761 psFree(md); 7762 return false; 7763 } 7764 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) { 7765 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 7766 psFree(md); 7767 return false; 7768 } 7769 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "key", "64")) { 6873 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "Primary Key", "64")) { 7770 6874 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 7771 6875 psFree(md); 7772 6876 return false; 7773 6877 } 7774 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, "64")) { 7775 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 7776 psFree(md); 7777 return false; 7778 } 7779 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, "key", "64")) { 7780 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 7781 psFree(md); 7782 return false; 7783 } 7784 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, "255")) { 7785 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 7786 psFree(md); 7787 return false; 7788 } 7789 7790 bool status = psDBCreateTable(dbh, CAMPENDINGEXP_TABLE_NAME, md); 6878 6879 bool status = psDBCreateTable(dbh, CHIPMASK_TABLE_NAME, md); 7791 6880 7792 6881 psFree(md); … … 7795 6884 } 7796 6885 7797 bool c amPendingExpDropTable(psDB *dbh)7798 { 7799 return psDBDropTable(dbh, C AMPENDINGEXP_TABLE_NAME);7800 } 7801 7802 bool c amPendingExpInsert(psDB * dbh, psS64 cam_id, psS64 chip_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb)6886 bool chipMaskDropTable(psDB *dbh) 6887 { 6888 return psDBDropTable(dbh, CHIPMASK_TABLE_NAME); 6889 } 6890 6891 bool chipMaskInsert(psDB * dbh, const char *label) 7803 6892 { 7804 6893 psMetadata *md = psMetadataAlloc(); 7805 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, cam_id)) {7806 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");7807 psFree(md);7808 return false;7809 }7810 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) {7811 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");7812 psFree(md);7813 return false;7814 }7815 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) {7816 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");7817 psFree(md);7818 return false;7819 }7820 6894 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) { 7821 6895 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); … … 7823 6897 return false; 7824 6898 } 7825 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, reduction)) { 7826 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 7827 psFree(md); 7828 return false; 7829 } 7830 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, expgroup)) { 7831 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 7832 psFree(md); 7833 return false; 7834 } 7835 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, dvodb)) { 7836 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 7837 psFree(md); 7838 return false; 7839 } 7840 7841 bool status = psDBInsertOneRow(dbh, CAMPENDINGEXP_TABLE_NAME, md); 6899 6900 bool status = psDBInsertOneRow(dbh, CHIPMASK_TABLE_NAME, md); 7842 6901 psFree(md); 7843 6902 … … 7845 6904 } 7846 6905 7847 long long c amPendingExpDelete(psDB *dbh, const psMetadata *where, unsigned long long limit)6906 long long chipMaskDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 7848 6907 { 7849 6908 long long deleted = 0; 7850 6909 7851 long long count = psDBDeleteRows(dbh, C AMPENDINGEXP_TABLE_NAME, where, limit);6910 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, limit); 7852 6911 if (count < 0) { 7853 psError(PS_ERR_UNKNOWN, true, "failed to delete row from c amPendingExp");6912 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask"); 7854 6913 return count; 7855 6914 … … 7859 6918 return deleted; 7860 6919 } 7861 bool c amPendingExpInsertObject(psDB *dbh, camPendingExpRow *object)7862 { 7863 return c amPendingExpInsert(dbh, object->cam_id, object->chip_id, object->workdir, object->label, object->reduction, object->expgroup, object->dvodb);7864 } 7865 7866 bool c amPendingExpInsertObjects(psDB *dbh, psArray *objects)6920 bool chipMaskInsertObject(psDB *dbh, chipMaskRow *object) 6921 { 6922 return chipMaskInsert(dbh, object->label); 6923 } 6924 6925 bool chipMaskInsertObjects(psDB *dbh, psArray *objects) 7867 6926 { 7868 6927 for (long i = 0; i < psArrayLength(objects); i++) { 7869 if (!c amPendingExpInsertObject(dbh, objects->data[i])) {6928 if (!chipMaskInsertObject(dbh, objects->data[i])) { 7870 6929 return false; 7871 6930 } … … 7875 6934 } 7876 6935 7877 bool c amPendingExpInsertFits(psDB *dbh, const psFits *fits)6936 bool chipMaskInsertFits(psDB *dbh, const psFits *fits) 7878 6937 { 7879 6938 psArray *rowSet; 7880 6939 7881 // move to (the first?) extension named C AMPENDINGEXP_TABLE_NAME7882 if (!psFitsMoveExtName(fits, C AMPENDINGEXP_TABLE_NAME)) {7883 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", C AMPENDINGEXP_TABLE_NAME);6940 // move to (the first?) extension named CHIPMASK_TABLE_NAME 6941 if (!psFitsMoveExtName(fits, CHIPMASK_TABLE_NAME)) { 6942 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CHIPMASK_TABLE_NAME); 7884 6943 return false; 7885 6944 } … … 7899 6958 } 7900 6959 7901 if (!psDBInsertRows(dbh, C AMPENDINGEXP_TABLE_NAME, rowSet)) {6960 if (!psDBInsertRows(dbh, CHIPMASK_TABLE_NAME, rowSet)) { 7902 6961 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 7903 6962 psFree(rowSet); … … 7910 6969 } 7911 6970 7912 bool c amPendingExpSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit)6971 bool chipMaskSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 7913 6972 { 7914 6973 psArray *rowSet; 7915 6974 7916 rowSet = psDBSelectRows(dbh, C AMPENDINGEXP_TABLE_NAME, where, limit);6975 rowSet = psDBSelectRows(dbh, CHIPMASK_TABLE_NAME, where, limit); 7917 6976 if (!rowSet) { 7918 6977 return false; … … 7920 6979 7921 6980 // output to fits 7922 if (!psFitsWriteTable(fits, NULL, rowSet, C AMPENDINGEXP_TABLE_NAME)) {6981 if (!psFitsWriteTable(fits, NULL, rowSet, CHIPMASK_TABLE_NAME)) { 7923 6982 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 7924 6983 psFree(rowSet); … … 7931 6990 } 7932 6991 7933 psMetadata *c amPendingExpMetadataFromObject(const camPendingExpRow *object)6992 psMetadata *chipMaskMetadataFromObject(const chipMaskRow *object) 7934 6993 { 7935 6994 psMetadata *md = psMetadataAlloc(); 7936 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, object->cam_id)) {7937 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id");7938 psFree(md);7939 return false;7940 }7941 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, object->chip_id)) {7942 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");7943 psFree(md);7944 return false;7945 }7946 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) {7947 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");7948 psFree(md);7949 return false;7950 }7951 6995 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) { 7952 6996 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); … … 7954 6998 return false; 7955 6999 } 7956 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, object->reduction)) {7957 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");7958 psFree(md);7959 return false;7960 }7961 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, object->expgroup)) {7962 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");7963 psFree(md);7964 return false;7965 }7966 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, object->dvodb)) {7967 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");7968 psFree(md);7969 return false;7970 }7971 7000 7972 7001 … … 7974 7003 } 7975 7004 7976 c amPendingExpRow *camPendingExpObjectFromMetadata(psMetadata *md)7005 chipMaskRow *chipMaskObjectFromMetadata(psMetadata *md) 7977 7006 { 7978 7007 7979 7008 bool status = false; 7980 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id");7981 if (!status) {7982 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item cam_id");7983 return false;7984 }7985 psS64 chip_id = psMetadataLookupS64(&status, md, "chip_id");7986 if (!status) {7987 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item chip_id");7988 return false;7989 }7990 char* workdir = psMetadataLookupPtr(&status, md, "workdir");7991 if (!status) {7992 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir");7993 return false;7994 }7995 7009 char* label = psMetadataLookupPtr(&status, md, "label"); 7996 7010 if (!status) { … … 7998 7012 return false; 7999 7013 } 8000 char* reduction = psMetadataLookupPtr(&status, md, "reduction"); 8001 if (!status) { 8002 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item reduction"); 8003 return false; 8004 } 8005 char* expgroup = psMetadataLookupPtr(&status, md, "expgroup"); 8006 if (!status) { 8007 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item expgroup"); 8008 return false; 8009 } 8010 char* dvodb = psMetadataLookupPtr(&status, md, "dvodb"); 8011 if (!status) { 8012 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dvodb"); 8013 return false; 8014 } 8015 8016 return camPendingExpRowAlloc(cam_id, chip_id, workdir, label, reduction, expgroup, dvodb); 8017 } 8018 psArray *camPendingExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 7014 7015 return chipMaskRowAlloc(label); 7016 } 7017 psArray *chipMaskSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 8019 7018 { 8020 7019 psArray *rowSet; … … 8022 7021 psU64 i; 8023 7022 8024 rowSet = psDBSelectRows(dbh, C AMPENDINGEXP_TABLE_NAME, where, limit);7023 rowSet = psDBSelectRows(dbh, CHIPMASK_TABLE_NAME, where, limit); 8025 7024 if (!rowSet) { 8026 7025 return NULL; … … 8032 7031 8033 7032 for (i = 0; i < rowSet->n; i++) { 8034 c amPendingExpRow *object = camPendingExpObjectFromMetadata(rowSet->data[i]);7033 chipMaskRow *object = chipMaskObjectFromMetadata(rowSet->data[i]); 8035 7034 psArrayAdd(returnSet, 0, object); 8036 7035 psFree(object); … … 8041 7040 return returnSet; 8042 7041 } 8043 bool c amPendingExpDeleteObject(psDB *dbh, const camPendingExpRow *object)8044 { 8045 psMetadata *where = c amPendingExpMetadataFromObject(object);8046 long long count = psDBDeleteRows(dbh, C AMPENDINGEXP_TABLE_NAME, where, 0);7042 bool chipMaskDeleteObject(psDB *dbh, const chipMaskRow *object) 7043 { 7044 psMetadata *where = chipMaskMetadataFromObject(object); 7045 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, 0); 8047 7046 psFree(where); 8048 7047 if (count < 0) { 8049 psError(PS_ERR_UNKNOWN, true, "failed to delete row from c amPendingExp");7048 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask"); 8050 7049 return false; 8051 7050 } … … 8053 7052 // XXX should this be a psAbort() instead? It is possible that 8054 7053 // having an object match multiple rows was by design. 8055 psError(PS_ERR_UNKNOWN, true, "c amPendingExpRow object matched more then one row. Check your database schema");8056 return false; 8057 } 8058 8059 return true; 8060 } 8061 long long c amPendingExpDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit)7054 psError(PS_ERR_UNKNOWN, true, "chipMaskRow object matched more then one row. Check your database schema"); 7055 return false; 7056 } 7057 7058 return true; 7059 } 7060 long long chipMaskDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 8062 7061 { 8063 7062 long long deleted = 0; 8064 7063 8065 7064 for (long long i = 0; i < objects->n; i++) { 8066 c amPendingExpRow *object = objects->data[i];8067 psMetadata *where = c amPendingExpMetadataFromObject(object);8068 long long count = psDBDeleteRows(dbh, C AMPENDINGEXP_TABLE_NAME, where, limit);7065 chipMaskRow *object = objects->data[i]; 7066 psMetadata *where = chipMaskMetadataFromObject(object); 7067 long long count = psDBDeleteRows(dbh, CHIPMASK_TABLE_NAME, where, limit); 8069 7068 psFree(where); 8070 7069 if (count < 0) { 8071 psError(PS_ERR_UNKNOWN, true, "failed to delete row from c amPendingExp");7070 psError(PS_ERR_UNKNOWN, true, "failed to delete row from chipMask"); 8072 7071 return count; 8073 7072 } … … 8078 7077 return deleted; 8079 7078 } 8080 bool c amPendingExpPrintObjects(FILE *stream, psArray *objects, bool mdcf)7079 bool chipMaskPrintObjects(FILE *stream, psArray *objects, bool mdcf) 8081 7080 { 8082 7081 PS_ASSERT_PTR_NON_NULL(objects, false); … … 8084 7083 psMetadata *output = psMetadataAlloc(); 8085 7084 for (long i = 0; i < psArrayLength(objects); i++) { 8086 psMetadata *md = c amPendingExpMetadataFromObject(objects->data[i]);7085 psMetadata *md = chipMaskMetadataFromObject(objects->data[i]); 8087 7086 if (!psMetadataAddMetadata( 8088 7087 output, 8089 7088 PS_LIST_TAIL, 8090 C AMPENDINGEXP_TABLE_NAME,7089 CHIPMASK_TABLE_NAME, 8091 7090 PS_META_DUPLICATE_OK, 8092 7091 NULL, … … 8109 7108 return true; 8110 7109 } 8111 bool c amPendingExpPrintObject(FILE *stream, camPendingExpRow *object, bool mdcf)7110 bool chipMaskPrintObject(FILE *stream, chipMaskRow *object, bool mdcf) 8112 7111 { 8113 7112 PS_ASSERT_PTR_NON_NULL(object, false); 8114 7113 8115 psMetadata *md = c amPendingExpMetadataFromObject(object);7114 psMetadata *md = chipMaskMetadataFromObject(object); 8116 7115 8117 7116 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { … … 8124 7123 return true; 8125 7124 } 8126 static void cam ProcessedExpRowFree(camProcessedExpRow *object);8127 8128 cam ProcessedExpRow *camProcessedExpRowAlloc(psS64 cam_id, psS64 chip_id, const char *workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 sigma_ra, psF32 sigma_dec, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)8129 { 8130 cam ProcessedExpRow*_object;8131 8132 _object = psAlloc(sizeof(cam ProcessedExpRow));8133 psMemSetDeallocator(_object, (psFreeFunc)cam ProcessedExpRowFree);7125 static void camRunRowFree(camRunRow *object); 7126 7127 camRunRow *camRunRowAlloc(psS64 cam_id, psS64 chip_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *reduction, const char *expgroup, const char *dvodb) 7128 { 7129 camRunRow *_object; 7130 7131 _object = psAlloc(sizeof(camRunRow)); 7132 psMemSetDeallocator(_object, (psFreeFunc)camRunRowFree); 8134 7133 8135 7134 _object->cam_id = cam_id; 8136 7135 _object->chip_id = chip_id; 7136 _object->state = psStringCopy(state); 8137 7137 _object->workdir = psStringCopy(workdir); 7138 _object->workdir_state = psStringCopy(workdir_state); 8138 7139 _object->label = psStringCopy(label); 8139 7140 _object->reduction = psStringCopy(reduction); 8140 7141 _object->expgroup = psStringCopy(expgroup); 8141 7142 _object->dvodb = psStringCopy(dvodb); 7143 7144 return _object; 7145 } 7146 7147 static void camRunRowFree(camRunRow *object) 7148 { 7149 psFree(object->state); 7150 psFree(object->workdir); 7151 psFree(object->workdir_state); 7152 psFree(object->label); 7153 psFree(object->reduction); 7154 psFree(object->expgroup); 7155 psFree(object->dvodb); 7156 } 7157 7158 bool camRunCreateTable(psDB *dbh) 7159 { 7160 psMetadata *md = psMetadataAlloc(); 7161 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, "Primary Key AUTO_INCREMENT", 0)) { 7162 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 7163 psFree(md); 7164 return false; 7165 } 7166 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(chip_id) ref chipRun(chip_id)", 0)) { 7167 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 7168 psFree(md); 7169 return false; 7170 } 7171 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, "key", "64")) { 7172 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 7173 psFree(md); 7174 return false; 7175 } 7176 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) { 7177 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 7178 psFree(md); 7179 return false; 7180 } 7181 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, "key", "64")) { 7182 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 7183 psFree(md); 7184 return false; 7185 } 7186 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "key", "64")) { 7187 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 7188 psFree(md); 7189 return false; 7190 } 7191 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, "64")) { 7192 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 7193 psFree(md); 7194 return false; 7195 } 7196 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, "key", "64")) { 7197 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 7198 psFree(md); 7199 return false; 7200 } 7201 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, "255")) { 7202 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 7203 psFree(md); 7204 return false; 7205 } 7206 7207 bool status = psDBCreateTable(dbh, CAMRUN_TABLE_NAME, md); 7208 7209 psFree(md); 7210 7211 return status; 7212 } 7213 7214 bool camRunDropTable(psDB *dbh) 7215 { 7216 return psDBDropTable(dbh, CAMRUN_TABLE_NAME); 7217 } 7218 7219 bool camRunInsert(psDB * dbh, psS64 cam_id, psS64 chip_id, const char *state, const char *workdir, const char *workdir_state, const char *label, const char *reduction, const char *expgroup, const char *dvodb) 7220 { 7221 psMetadata *md = psMetadataAlloc(); 7222 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, cam_id)) { 7223 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 7224 psFree(md); 7225 return false; 7226 } 7227 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) { 7228 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 7229 psFree(md); 7230 return false; 7231 } 7232 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, state)) { 7233 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 7234 psFree(md); 7235 return false; 7236 } 7237 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) { 7238 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 7239 psFree(md); 7240 return false; 7241 } 7242 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, workdir_state)) { 7243 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 7244 psFree(md); 7245 return false; 7246 } 7247 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) { 7248 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 7249 psFree(md); 7250 return false; 7251 } 7252 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, reduction)) { 7253 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 7254 psFree(md); 7255 return false; 7256 } 7257 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, expgroup)) { 7258 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 7259 psFree(md); 7260 return false; 7261 } 7262 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, dvodb)) { 7263 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 7264 psFree(md); 7265 return false; 7266 } 7267 7268 bool status = psDBInsertOneRow(dbh, CAMRUN_TABLE_NAME, md); 7269 psFree(md); 7270 7271 return status; 7272 } 7273 7274 long long camRunDelete(psDB *dbh, const psMetadata *where, unsigned long long limit) 7275 { 7276 long long deleted = 0; 7277 7278 long long count = psDBDeleteRows(dbh, CAMRUN_TABLE_NAME, where, limit); 7279 if (count < 0) { 7280 psError(PS_ERR_UNKNOWN, true, "failed to delete row from camRun"); 7281 return count; 7282 7283 deleted += count; 7284 } 7285 7286 return deleted; 7287 } 7288 bool camRunInsertObject(psDB *dbh, camRunRow *object) 7289 { 7290 return camRunInsert(dbh, object->cam_id, object->chip_id, object->state, object->workdir, object->workdir_state, object->label, object->reduction, object->expgroup, object->dvodb); 7291 } 7292 7293 bool camRunInsertObjects(psDB *dbh, psArray *objects) 7294 { 7295 for (long i = 0; i < psArrayLength(objects); i++) { 7296 if (!camRunInsertObject(dbh, objects->data[i])) { 7297 return false; 7298 } 7299 } 7300 7301 return true; 7302 } 7303 7304 bool camRunInsertFits(psDB *dbh, const psFits *fits) 7305 { 7306 psArray *rowSet; 7307 7308 // move to (the first?) extension named CAMRUN_TABLE_NAME 7309 if (!psFitsMoveExtName(fits, CAMRUN_TABLE_NAME)) { 7310 psError(PS_ERR_UNKNOWN, true, "failed to find FITS extension %s", CAMRUN_TABLE_NAME); 7311 return false; 7312 } 7313 7314 // check HDU type 7315 if (psFitsGetExtType(fits) != PS_FITS_TYPE_BINARY_TABLE) { 7316 psError(PS_ERR_UNKNOWN, true, "FITS HDU type is not PS_FITS_TYPE_BINARY_TABLE"); 7317 return false; 7318 } 7319 7320 // read fits table 7321 rowSet = psFitsReadTable(fits); 7322 if (!rowSet) { 7323 psError(PS_ERR_UNKNOWN, true, "FITS read error or FITS table is empty"); 7324 psFree(rowSet); 7325 return false; 7326 } 7327 7328 if (!psDBInsertRows(dbh, CAMRUN_TABLE_NAME, rowSet)) { 7329 psError(PS_ERR_UNKNOWN, false, "databse insert failed"); 7330 psFree(rowSet); 7331 return false; 7332 } 7333 7334 psFree(rowSet); 7335 7336 return true; 7337 } 7338 7339 bool camRunSelectRowsFits(psDB *dbh, psFits *fits, const psMetadata *where, unsigned long long limit) 7340 { 7341 psArray *rowSet; 7342 7343 rowSet = psDBSelectRows(dbh, CAMRUN_TABLE_NAME, where, limit); 7344 if (!rowSet) { 7345 return false; 7346 } 7347 7348 // output to fits 7349 if (!psFitsWriteTable(fits, NULL, rowSet, CAMRUN_TABLE_NAME)) { 7350 psError(PS_ERR_UNKNOWN, false, "FITS table write failed"); 7351 psFree(rowSet); 7352 return false; 7353 } 7354 7355 psFree(rowSet); 7356 7357 return true; 7358 } 7359 7360 psMetadata *camRunMetadataFromObject(const camRunRow *object) 7361 { 7362 psMetadata *md = psMetadataAlloc(); 7363 if (!psMetadataAdd(md, PS_LIST_TAIL, "cam_id", PS_DATA_S64, NULL, object->cam_id)) { 7364 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 7365 psFree(md); 7366 return false; 7367 } 7368 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, object->chip_id)) { 7369 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 7370 psFree(md); 7371 return false; 7372 } 7373 if (!psMetadataAdd(md, PS_LIST_TAIL, "state", PS_DATA_STRING, NULL, object->state)) { 7374 psError(PS_ERR_UNKNOWN, false, "failed to add item state"); 7375 psFree(md); 7376 return false; 7377 } 7378 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) { 7379 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir"); 7380 psFree(md); 7381 return false; 7382 } 7383 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir_state", PS_DATA_STRING, NULL, object->workdir_state)) { 7384 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir_state"); 7385 psFree(md); 7386 return false; 7387 } 7388 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) { 7389 psError(PS_ERR_UNKNOWN, false, "failed to add item label"); 7390 psFree(md); 7391 return false; 7392 } 7393 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, object->reduction)) { 7394 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction"); 7395 psFree(md); 7396 return false; 7397 } 7398 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, object->expgroup)) { 7399 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup"); 7400 psFree(md); 7401 return false; 7402 } 7403 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, object->dvodb)) { 7404 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb"); 7405 psFree(md); 7406 return false; 7407 } 7408 7409 7410 return md; 7411 } 7412 7413 camRunRow *camRunObjectFromMetadata(psMetadata *md) 7414 { 7415 7416 bool status = false; 7417 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id"); 7418 if (!status) { 7419 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item cam_id"); 7420 return false; 7421 } 7422 psS64 chip_id = psMetadataLookupS64(&status, md, "chip_id"); 7423 if (!status) { 7424 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item chip_id"); 7425 return false; 7426 } 7427 char* state = psMetadataLookupPtr(&status, md, "state"); 7428 if (!status) { 7429 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item state"); 7430 return false; 7431 } 7432 char* workdir = psMetadataLookupPtr(&status, md, "workdir"); 7433 if (!status) { 7434 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir"); 7435 return false; 7436 } 7437 char* workdir_state = psMetadataLookupPtr(&status, md, "workdir_state"); 7438 if (!status) { 7439 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir_state"); 7440 return false; 7441 } 7442 char* label = psMetadataLookupPtr(&status, md, "label"); 7443 if (!status) { 7444 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label"); 7445 return false; 7446 } 7447 char* reduction = psMetadataLookupPtr(&status, md, "reduction"); 7448 if (!status) { 7449 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item reduction"); 7450 return false; 7451 } 7452 char* expgroup = psMetadataLookupPtr(&status, md, "expgroup"); 7453 if (!status) { 7454 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item expgroup"); 7455 return false; 7456 } 7457 char* dvodb = psMetadataLookupPtr(&status, md, "dvodb"); 7458 if (!status) { 7459 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dvodb"); 7460 return false; 7461 } 7462 7463 return camRunRowAlloc(cam_id, chip_id, state, workdir, workdir_state, label, reduction, expgroup, dvodb); 7464 } 7465 psArray *camRunSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) 7466 { 7467 psArray *rowSet; 7468 psArray *returnSet; 7469 psU64 i; 7470 7471 rowSet = psDBSelectRows(dbh, CAMRUN_TABLE_NAME, where, limit); 7472 if (!rowSet) { 7473 return NULL; 7474 } 7475 7476 // convert psMetadata rows to row objects 7477 7478 returnSet = psArrayAllocEmpty(rowSet->n); 7479 7480 for (i = 0; i < rowSet->n; i++) { 7481 camRunRow *object = camRunObjectFromMetadata(rowSet->data[i]); 7482 psArrayAdd(returnSet, 0, object); 7483 psFree(object); 7484 } 7485 7486 psFree(rowSet); 7487 7488 return returnSet; 7489 } 7490 bool camRunDeleteObject(psDB *dbh, const camRunRow *object) 7491 { 7492 psMetadata *where = camRunMetadataFromObject(object); 7493 long long count = psDBDeleteRows(dbh, CAMRUN_TABLE_NAME, where, 0); 7494 psFree(where); 7495 if (count < 0) { 7496 psError(PS_ERR_UNKNOWN, true, "failed to delete row from camRun"); 7497 return false; 7498 } 7499 if (count > 1) { 7500 // XXX should this be a psAbort() instead? It is possible that 7501 // having an object match multiple rows was by design. 7502 psError(PS_ERR_UNKNOWN, true, "camRunRow object matched more then one row. Check your database schema"); 7503 return false; 7504 } 7505 7506 return true; 7507 } 7508 long long camRunDeleteRowObjects(psDB *dbh, const psArray *objects, unsigned long long limit) 7509 { 7510 long long deleted = 0; 7511 7512 for (long long i = 0; i < objects->n; i++) { 7513 camRunRow *object = objects->data[i]; 7514 psMetadata *where = camRunMetadataFromObject(object); 7515 long long count = psDBDeleteRows(dbh, CAMRUN_TABLE_NAME, where, limit); 7516 psFree(where); 7517 if (count < 0) { 7518 psError(PS_ERR_UNKNOWN, true, "failed to delete row from camRun"); 7519 return count; 7520 } 7521 7522 deleted += count; 7523 } 7524 7525 return deleted; 7526 } 7527 bool camRunPrintObjects(FILE *stream, psArray *objects, bool mdcf) 7528 { 7529 PS_ASSERT_PTR_NON_NULL(objects, false); 7530 7531 psMetadata *output = psMetadataAlloc(); 7532 for (long i = 0; i < psArrayLength(objects); i++) { 7533 psMetadata *md = camRunMetadataFromObject(objects->data[i]); 7534 if (!psMetadataAddMetadata( 7535 output, 7536 PS_LIST_TAIL, 7537 CAMRUN_TABLE_NAME, 7538 PS_META_DUPLICATE_OK, 7539 NULL, 7540 md 7541 )) { 7542 psError(PS_ERR_UNKNOWN, false, "failed to add metadata"); 7543 psFree(md); 7544 psFree(output); 7545 return false; 7546 } 7547 psFree(md); 7548 } 7549 7550 if (!ippdbPrintMetadataRaw(stream, output, mdcf)) { 7551 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 7552 psFree(output); 7553 } 7554 psFree(output); 7555 7556 return true; 7557 } 7558 bool camRunPrintObject(FILE *stream, camRunRow *object, bool mdcf) 7559 { 7560 PS_ASSERT_PTR_NON_NULL(object, false); 7561 7562 psMetadata *md = camRunMetadataFromObject(object); 7563 7564 if (!ippdbPrintMetadataRaw(stream, md, mdcf)) { 7565 psError(PS_ERR_UNKNOWN, false, "failed to print metadata"); 7566 psFree(md); 7567 } 7568 7569 psFree(md); 7570 7571 return true; 7572 } 7573 static void camProcessedExpRowFree(camProcessedExpRow *object); 7574 7575 camProcessedExpRow *camProcessedExpRowAlloc(psS64 cam_id, psS64 chip_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 sigma_ra, psF32 sigma_dec, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 7576 { 7577 camProcessedExpRow *_object; 7578 7579 _object = psAlloc(sizeof(camProcessedExpRow)); 7580 psMemSetDeallocator(_object, (psFreeFunc)camProcessedExpRowFree); 7581 7582 _object->cam_id = cam_id; 7583 _object->chip_id = chip_id; 8142 7584 _object->uri = psStringCopy(uri); 8143 7585 _object->bg = bg; … … 8162 7604 static void camProcessedExpRowFree(camProcessedExpRow *object) 8163 7605 { 8164 psFree(object->workdir);8165 psFree(object->label);8166 psFree(object->reduction);8167 psFree(object->expgroup);8168 psFree(object->dvodb);8169 7606 psFree(object->uri); 8170 7607 psFree(object->path_base); … … 8179 7616 return false; 8180 7617 } 8181 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(c hip_id) ref chipProcessedExp(chip_id)", 0)) {7618 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, "Primary Key fkey(cam_id, chip_id) ref camRun(cam_id, chip_id)", 0)) { 8182 7619 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 8183 psFree(md);8184 return false;8185 }8186 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, "255")) {8187 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");8188 psFree(md);8189 return false;8190 }8191 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, "key", "64")) {8192 psError(PS_ERR_UNKNOWN, false, "failed to add item label");8193 psFree(md);8194 return false;8195 }8196 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, "64")) {8197 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");8198 psFree(md);8199 return false;8200 }8201 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, "key", "64")) {8202 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");8203 psFree(md);8204 return false;8205 }8206 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, "255")) {8207 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");8208 7620 psFree(md); 8209 7621 return false; … … 8302 7714 } 8303 7715 8304 bool camProcessedExpInsert(psDB * dbh, psS64 cam_id, psS64 chip_id, const char * workdir, const char *label, const char *reduction, const char *expgroup, const char *dvodb, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 sigma_ra, psF32 sigma_dec, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault)7716 bool camProcessedExpInsert(psDB * dbh, psS64 cam_id, psS64 chip_id, const char *uri, psF32 bg, psF32 bg_stdev, psF32 bg_mean_stdev, psF32 sigma_ra, psF32 sigma_dec, psF32 zp_mean, psF32 zp_stdev, psF32 fwhm, psF32 fwhm_range, psS32 n_stars, psS32 n_extended, psS32 n_cr, psS32 n_astrom, const char *path_base, psS16 fault) 8305 7717 { 8306 7718 psMetadata *md = psMetadataAlloc(); … … 8312 7724 if (!psMetadataAdd(md, PS_LIST_TAIL, "chip_id", PS_DATA_S64, NULL, chip_id)) { 8313 7725 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 8314 psFree(md);8315 return false;8316 }8317 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, workdir)) {8318 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");8319 psFree(md);8320 return false;8321 }8322 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, label)) {8323 psError(PS_ERR_UNKNOWN, false, "failed to add item label");8324 psFree(md);8325 return false;8326 }8327 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, reduction)) {8328 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");8329 psFree(md);8330 return false;8331 }8332 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, expgroup)) {8333 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");8334 psFree(md);8335 return false;8336 }8337 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, dvodb)) {8338 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");8339 7726 psFree(md); 8340 7727 return false; … … 8443 7830 bool camProcessedExpInsertObject(psDB *dbh, camProcessedExpRow *object) 8444 7831 { 8445 return camProcessedExpInsert(dbh, object->cam_id, object->chip_id, object-> workdir, object->label, object->reduction, object->expgroup, object->dvodb, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->sigma_ra, object->sigma_dec, object->zp_mean, object->zp_stdev, object->fwhm, object->fwhm_range, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault);7832 return camProcessedExpInsert(dbh, object->cam_id, object->chip_id, object->uri, object->bg, object->bg_stdev, object->bg_mean_stdev, object->sigma_ra, object->sigma_dec, object->zp_mean, object->zp_stdev, object->fwhm, object->fwhm_range, object->n_stars, object->n_extended, object->n_cr, object->n_astrom, object->path_base, object->fault); 8446 7833 } 8447 7834 … … 8526 7913 return false; 8527 7914 } 8528 if (!psMetadataAdd(md, PS_LIST_TAIL, "workdir", PS_DATA_STRING, NULL, object->workdir)) {8529 psError(PS_ERR_UNKNOWN, false, "failed to add item workdir");8530 psFree(md);8531 return false;8532 }8533 if (!psMetadataAdd(md, PS_LIST_TAIL, "label", PS_DATA_STRING, NULL, object->label)) {8534 psError(PS_ERR_UNKNOWN, false, "failed to add item label");8535 psFree(md);8536 return false;8537 }8538 if (!psMetadataAdd(md, PS_LIST_TAIL, "reduction", PS_DATA_STRING, NULL, object->reduction)) {8539 psError(PS_ERR_UNKNOWN, false, "failed to add item reduction");8540 psFree(md);8541 return false;8542 }8543 if (!psMetadataAdd(md, PS_LIST_TAIL, "expgroup", PS_DATA_STRING, NULL, object->expgroup)) {8544 psError(PS_ERR_UNKNOWN, false, "failed to add item expgroup");8545 psFree(md);8546 return false;8547 }8548 if (!psMetadataAdd(md, PS_LIST_TAIL, "dvodb", PS_DATA_STRING, NULL, object->dvodb)) {8549 psError(PS_ERR_UNKNOWN, false, "failed to add item dvodb");8550 psFree(md);8551 return false;8552 }8553 7915 if (!psMetadataAdd(md, PS_LIST_TAIL, "uri", PS_DATA_STRING, NULL, object->uri)) { 8554 7916 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); … … 8650 8012 return false; 8651 8013 } 8652 char* workdir = psMetadataLookupPtr(&status, md, "workdir");8653 if (!status) {8654 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item workdir");8655 return false;8656 }8657 char* label = psMetadataLookupPtr(&status, md, "label");8658 if (!status) {8659 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item label");8660 return false;8661 }8662 char* reduction = psMetadataLookupPtr(&status, md, "reduction");8663 if (!status) {8664 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item reduction");8665 return false;8666 }8667 char* expgroup = psMetadataLookupPtr(&status, md, "expgroup");8668 if (!status) {8669 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item expgroup");8670 return false;8671 }8672 char* dvodb = psMetadataLookupPtr(&status, md, "dvodb");8673 if (!status) {8674 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item dvodb");8675 return false;8676 }8677 8014 char* uri = psMetadataLookupPtr(&status, md, "uri"); 8678 8015 if (!status) { … … 8756 8093 } 8757 8094 8758 return camProcessedExpRowAlloc(cam_id, chip_id, workdir, label, reduction, expgroup, dvodb,uri, bg, bg_stdev, bg_mean_stdev, sigma_ra, sigma_dec, zp_mean, zp_stdev, fwhm, fwhm_range, n_stars, n_extended, n_cr, n_astrom, path_base, fault);8095 return camProcessedExpRowAlloc(cam_id, chip_id, uri, bg, bg_stdev, bg_mean_stdev, sigma_ra, sigma_dec, zp_mean, zp_stdev, fwhm, fwhm_range, n_stars, n_extended, n_cr, n_astrom, path_base, fault); 8759 8096 } 8760 8097 psArray *camProcessedExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 13704 13041 static void detInputExpRowFree(detInputExpRow *object); 13705 13042 13706 detInputExpRow *detInputExpRowAlloc(psS64 det_id, psS32 iteration, const char *exp_tag, bool include)13043 detInputExpRow *detInputExpRowAlloc(psS64 det_id, psS32 iteration, psS64 exp_id, bool include) 13707 13044 { 13708 13045 detInputExpRow *_object; … … 13713 13050 _object->det_id = det_id; 13714 13051 _object->iteration = iteration; 13715 _object->exp_ tag = psStringCopy(exp_tag);13052 _object->exp_id = exp_id; 13716 13053 _object->include = include; 13717 13054 … … 13721 13058 static void detInputExpRowFree(detInputExpRow *object) 13722 13059 { 13723 psFree(object->exp_tag);13724 13060 } 13725 13061 … … 13737 13073 return false; 13738 13074 } 13739 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Primary Key", "64")) {13740 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13075 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 13076 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 13741 13077 psFree(md); 13742 13078 return false; … … 13760 13096 } 13761 13097 13762 bool detInputExpInsert(psDB * dbh, psS64 det_id, psS32 iteration, const char *exp_tag, bool include)13098 bool detInputExpInsert(psDB * dbh, psS64 det_id, psS32 iteration, psS64 exp_id, bool include) 13763 13099 { 13764 13100 psMetadata *md = psMetadataAlloc(); … … 13773 13109 return false; 13774 13110 } 13775 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {13776 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13111 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 13112 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 13777 13113 psFree(md); 13778 13114 return false; … … 13806 13142 bool detInputExpInsertObject(psDB *dbh, detInputExpRow *object) 13807 13143 { 13808 return detInputExpInsert(dbh, object->det_id, object->iteration, object->exp_ tag, object->include);13144 return detInputExpInsert(dbh, object->det_id, object->iteration, object->exp_id, object->include); 13809 13145 } 13810 13146 … … 13889 13225 return false; 13890 13226 } 13891 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {13892 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13227 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 13228 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 13893 13229 psFree(md); 13894 13230 return false; … … 13918 13254 return false; 13919 13255 } 13920 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");13921 if (!status) { 13922 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");13256 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 13257 if (!status) { 13258 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 13923 13259 return false; 13924 13260 } … … 13929 13265 } 13930 13266 13931 return detInputExpRowAlloc(det_id, iteration, exp_ tag, include);13267 return detInputExpRowAlloc(det_id, iteration, exp_id, include); 13932 13268 } 13933 13269 psArray *detInputExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 14041 13377 static void detProcessedImfileRowFree(detProcessedImfileRow *object); 14042 13378 14043 detProcessedImfileRow *detProcessedImfileRowAlloc(psS64 det_id, const char *exp_tag, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)13379 detProcessedImfileRow *detProcessedImfileRowAlloc(psS64 det_id, psS64 exp_id, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 14044 13380 { 14045 13381 detProcessedImfileRow *_object; … … 14049 13385 14050 13386 _object->det_id = det_id; 14051 _object->exp_ tag = psStringCopy(exp_tag);13387 _object->exp_id = exp_id; 14052 13388 _object->class_id = psStringCopy(class_id); 14053 13389 _object->uri = psStringCopy(uri); … … 14072 13408 static void detProcessedImfileRowFree(detProcessedImfileRow *object) 14073 13409 { 14074 psFree(object->exp_tag);14075 13410 psFree(object->class_id); 14076 13411 psFree(object->uri); … … 14087 13422 return false; 14088 13423 } 14089 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Primary Key", "64")) {14090 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13424 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 13425 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14091 13426 psFree(md); 14092 13427 return false; … … 14185 13520 } 14186 13521 14187 bool detProcessedImfileInsert(psDB * dbh, psS64 det_id, const char *exp_tag, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)13522 bool detProcessedImfileInsert(psDB * dbh, psS64 det_id, psS64 exp_id, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 14188 13523 { 14189 13524 psMetadata *md = psMetadataAlloc(); … … 14193 13528 return false; 14194 13529 } 14195 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {14196 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13530 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 13531 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14197 13532 psFree(md); 14198 13533 return false; … … 14301 13636 bool detProcessedImfileInsertObject(psDB *dbh, detProcessedImfileRow *object) 14302 13637 { 14303 return detProcessedImfileInsert(dbh, object->det_id, object->exp_ tag, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault);13638 return detProcessedImfileInsert(dbh, object->det_id, object->exp_id, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault); 14304 13639 } 14305 13640 … … 14379 13714 return false; 14380 13715 } 14381 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {14382 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");13716 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 13717 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14383 13718 psFree(md); 14384 13719 return false; … … 14478 13813 return false; 14479 13814 } 14480 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");14481 if (!status) { 14482 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");13815 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 13816 if (!status) { 13817 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 14483 13818 return false; 14484 13819 } … … 14564 13899 } 14565 13900 14566 return detProcessedImfileRowAlloc(det_id, exp_ tag, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault);13901 return detProcessedImfileRowAlloc(det_id, exp_id, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault); 14567 13902 } 14568 13903 psArray *detProcessedImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 14676 14011 static void detProcessedExpRowFree(detProcessedExpRow *object); 14677 14012 14678 detProcessedExpRow *detProcessedExpRowAlloc(psS64 det_id, const char *exp_tag, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)14013 detProcessedExpRow *detProcessedExpRowAlloc(psS64 det_id, psS64 exp_id, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 14679 14014 { 14680 14015 detProcessedExpRow *_object; … … 14684 14019 14685 14020 _object->det_id = det_id; 14686 _object->exp_ tag = psStringCopy(exp_tag);14021 _object->exp_id = exp_id; 14687 14022 _object->recipe = psStringCopy(recipe); 14688 14023 _object->bg = bg; … … 14705 14040 static void detProcessedExpRowFree(detProcessedExpRow *object) 14706 14041 { 14707 psFree(object->exp_tag);14708 14042 psFree(object->recipe); 14709 14043 psFree(object->path_base); … … 14718 14052 return false; 14719 14053 } 14720 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Primary Key", "64")) {14721 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");14054 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 14055 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14722 14056 psFree(md); 14723 14057 return false; … … 14806 14140 } 14807 14141 14808 bool detProcessedExpInsert(psDB * dbh, psS64 det_id, const char *exp_tag, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)14142 bool detProcessedExpInsert(psDB * dbh, psS64 det_id, psS64 exp_id, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 14809 14143 { 14810 14144 psMetadata *md = psMetadataAlloc(); … … 14814 14148 return false; 14815 14149 } 14816 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {14817 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");14150 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 14151 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14818 14152 psFree(md); 14819 14153 return false; … … 14912 14246 bool detProcessedExpInsertObject(psDB *dbh, detProcessedExpRow *object) 14913 14247 { 14914 return detProcessedExpInsert(dbh, object->det_id, object->exp_ tag, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault);14248 return detProcessedExpInsert(dbh, object->det_id, object->exp_id, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault); 14915 14249 } 14916 14250 … … 14990 14324 return false; 14991 14325 } 14992 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {14993 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");14326 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 14327 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 14994 14328 psFree(md); 14995 14329 return false; … … 15079 14413 return false; 15080 14414 } 15081 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");15082 if (!status) { 15083 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");14415 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 14416 if (!status) { 14417 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 15084 14418 return false; 15085 14419 } … … 15155 14489 } 15156 14490 15157 return detProcessedExpRowAlloc(det_id, exp_ tag, recipe, bg, bg_stdev, bg_mean_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault);14491 return detProcessedExpRowAlloc(det_id, exp_id, recipe, bg, bg_stdev, bg_mean_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault); 15158 14492 } 15159 14493 psArray *detProcessedExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 17250 16584 static void detResidImfileRowFree(detResidImfileRow *object); 17251 16585 17252 detResidImfileRow *detResidImfileRowAlloc(psS64 det_id, psS32 iteration, const char *exp_tag, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)16586 detResidImfileRow *detResidImfileRowAlloc(psS64 det_id, psS32 iteration, psS64 exp_id, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 17253 16587 { 17254 16588 detResidImfileRow *_object; … … 17259 16593 _object->det_id = det_id; 17260 16594 _object->iteration = iteration; 17261 _object->exp_ tag = psStringCopy(exp_tag);16595 _object->exp_id = exp_id; 17262 16596 _object->class_id = psStringCopy(class_id); 17263 16597 _object->uri = psStringCopy(uri); … … 17283 16617 static void detResidImfileRowFree(detResidImfileRow *object) 17284 16618 { 17285 psFree(object->exp_tag);17286 16619 psFree(object->class_id); 17287 16620 psFree(object->uri); … … 17303 16636 return false; 17304 16637 } 17305 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Primary Key", "64")) {17306 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");16638 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 16639 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 17307 16640 psFree(md); 17308 16641 return false; … … 17406 16739 } 17407 16740 17408 bool detResidImfileInsert(psDB * dbh, psS64 det_id, psS32 iteration, const char *exp_tag, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault)16741 bool detResidImfileInsert(psDB * dbh, psS64 det_id, psS32 iteration, psS64 exp_id, const char *class_id, const char *uri, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, psS16 fault) 17409 16742 { 17410 16743 psMetadata *md = psMetadataAlloc(); … … 17419 16752 return false; 17420 16753 } 17421 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {17422 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");16754 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 16755 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 17423 16756 psFree(md); 17424 16757 return false; … … 17532 16865 bool detResidImfileInsertObject(psDB *dbh, detResidImfileRow *object) 17533 16866 { 17534 return detResidImfileInsert(dbh, object->det_id, object->iteration, object->exp_ tag, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bin_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault);16867 return detResidImfileInsert(dbh, object->det_id, object->iteration, object->exp_id, object->class_id, object->uri, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bin_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->fault); 17535 16868 } 17536 16869 … … 17615 16948 return false; 17616 16949 } 17617 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {17618 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");16950 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 16951 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 17619 16952 psFree(md); 17620 16953 return false; … … 17724 17057 return false; 17725 17058 } 17726 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");17727 if (!status) { 17728 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");17059 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 17060 if (!status) { 17061 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 17729 17062 return false; 17730 17063 } … … 17815 17148 } 17816 17149 17817 return detResidImfileRowAlloc(det_id, iteration, exp_ tag, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, bin_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault);17150 return detResidImfileRowAlloc(det_id, iteration, exp_id, class_id, uri, recipe, bg, bg_stdev, bg_mean_stdev, bin_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, fault); 17818 17151 } 17819 17152 psArray *detResidImfileSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) … … 17927 17260 static void detResidExpRowFree(detResidExpRow *object); 17928 17261 17929 detResidExpRow *detResidExpRowAlloc(psS64 det_id, psS32 iteration, const char *exp_tag, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, bool accept, psS16 fault)17262 detResidExpRow *detResidExpRowAlloc(psS64 det_id, psS32 iteration, psS64 exp_id, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, bool accept, psS16 fault) 17930 17263 { 17931 17264 detResidExpRow *_object; … … 17936 17269 _object->det_id = det_id; 17937 17270 _object->iteration = iteration; 17938 _object->exp_ tag = psStringCopy(exp_tag);17271 _object->exp_id = exp_id; 17939 17272 _object->recipe = psStringCopy(recipe); 17940 17273 _object->bg = bg; … … 17959 17292 static void detResidExpRowFree(detResidExpRow *object) 17960 17293 { 17961 psFree(object->exp_tag);17962 17294 psFree(object->recipe); 17963 17295 psFree(object->path_base); … … 17977 17309 return false; 17978 17310 } 17979 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, "Primary Key", "64")) {17980 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");17311 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, "Primary Key", 64)) { 17312 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 17981 17313 psFree(md); 17982 17314 return false; … … 18075 17407 } 18076 17408 18077 bool detResidExpInsert(psDB * dbh, psS64 det_id, psS32 iteration, const char *exp_tag, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, bool accept, psS16 fault)17409 bool detResidExpInsert(psDB * dbh, psS64 det_id, psS32 iteration, psS64 exp_id, const char *recipe, psF64 bg, psF64 bg_stdev, psF64 bg_mean_stdev, psF64 bin_stdev, psF64 fringe_0, psF64 fringe_1, psF64 fringe_2, psF64 user_1, psF64 user_2, psF64 user_3, psF64 user_4, psF64 user_5, const char *path_base, bool accept, psS16 fault) 18078 17410 { 18079 17411 psMetadata *md = psMetadataAlloc(); … … 18088 17420 return false; 18089 17421 } 18090 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, exp_tag)) {18091 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");17422 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, exp_id)) { 17423 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 18092 17424 psFree(md); 18093 17425 return false; … … 18196 17528 bool detResidExpInsertObject(psDB *dbh, detResidExpRow *object) 18197 17529 { 18198 return detResidExpInsert(dbh, object->det_id, object->iteration, object->exp_ tag, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bin_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->accept, object->fault);17530 return detResidExpInsert(dbh, object->det_id, object->iteration, object->exp_id, object->recipe, object->bg, object->bg_stdev, object->bg_mean_stdev, object->bin_stdev, object->fringe_0, object->fringe_1, object->fringe_2, object->user_1, object->user_2, object->user_3, object->user_4, object->user_5, object->path_base, object->accept, object->fault); 18199 17531 } 18200 17532 … … 18279 17611 return false; 18280 17612 } 18281 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_ tag", PS_DATA_STRING, NULL, object->exp_tag)) {18282 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_ tag");17613 if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_id", PS_DATA_S64, NULL, object->exp_id)) { 17614 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 18283 17615 psFree(md); 18284 17616 return false; … … 18383 17715 return false; 18384 17716 } 18385 char* exp_tag = psMetadataLookupPtr(&status, md, "exp_tag");18386 if (!status) { 18387 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_ tag");17717 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 17718 if (!status) { 17719 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item exp_id"); 18388 17720 return false; 18389 17721 } … … 18469 17801 } 18470 17802 18471 return detResidExpRowAlloc(det_id, iteration, exp_ tag, recipe, bg, bg_stdev, bg_mean_stdev, bin_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, accept, fault);17803 return detResidExpRowAlloc(det_id, iteration, exp_id, recipe, bg, bg_stdev, bg_mean_stdev, bin_stdev, fringe_0, fringe_1, fringe_2, user_1, user_2, user_3, user_4, user_5, path_base, accept, fault); 18472 17804 } 18473 17805 psArray *detResidExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit) -
trunk/ippdb/src/ippdb.h
r13937 r14061 125 125 ); 126 126 127 /** expTagCounterRow data structure128 * 129 * Structure for representing a single row of expTagCountertable data.127 /** summitExpRow data structure 128 * 129 * Structure for representing a single row of summitExp table data. 130 130 */ 131 131 132 132 typedef struct { 133 psU64 counter; 134 } expTagCounterRow; 135 136 /** Creates a new expTagCounterRow object 137 * 138 * @return A new expTagCounterRow object or NULL on failure. 139 */ 140 141 expTagCounterRow *expTagCounterRowAlloc( 142 psU64 counter 143 ); 144 145 /** Creates a new expTagCounter table 146 * 147 * @return true on success 148 */ 149 150 bool expTagCounterCreateTable( 151 psDB *dbh ///< Database handle 152 ); 153 154 /** Deletes a expTagCounter table 155 * 156 * @return true on success 157 */ 158 159 bool expTagCounterDropTable( 160 psDB *dbh ///< Database handle 161 ); 162 163 /** Insert a single row into a table 164 * 165 * This function constructs and inserts a single row based on it's parameters. 166 * 167 * @return true on success 168 */ 169 170 bool expTagCounterInsert( 171 psDB *dbh, ///< Database handle 172 psU64 counter 173 ); 174 175 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 176 * 177 * @return A The number of rows removed or a negative value on error 178 */ 179 180 long long expTagCounterDelete( 181 psDB *dbh, ///< Database handle 182 const psMetadata *where, ///< Row match criteria 183 unsigned long long limit ///< Maximum number of elements to delete 184 ); 185 186 /** Insert a single expTagCounterRow object into a table 187 * 188 * This function constructs and inserts a single row based on it's parameters. 189 * 190 * @return true on success 191 */ 192 193 bool expTagCounterInsertObject( 194 psDB *dbh, ///< Database handle 195 expTagCounterRow *object ///< expTagCounterRow object 196 ); 197 198 /** Insert an array of expTagCounterRow object into a table 199 * 200 * This function constructs and inserts multiple rows based on it's parameters. 201 * 202 * @return true on success 203 */ 204 205 bool expTagCounterInsertObjects( 206 psDB *dbh, ///< Database handle 207 psArray *objects ///< array of expTagCounterRow objects 208 ); 209 210 /** Insert data from a binary FITS table expTagCounterRow into the database 211 * 212 * This function expects a psFits object with a FITS table as the first 213 * extension. The table must have at least one row of data in it, that is of 214 * the appropriate format (number of columns and their type). All other 215 * extensions are ignored. 216 * 217 * @return true on success 218 */ 219 220 bool expTagCounterInsertFits( 221 psDB *dbh, ///< Database handle 222 const psFits *fits ///< psFits object 223 ); 224 225 /** Selects up to limit from the database and returns them in a binary FITS table 226 * 227 * This function assumes an empty psFits object and will create a FITS table 228 * as the first extension. 229 * 230 * See psDBSelectRows() for documentation on the format of where. 231 * 232 * @return true on success 233 */ 234 235 bool expTagCounterSelectRowsFits( 236 psDB *dbh, ///< Database handle 237 psFits *fits, ///< psFits object 238 const psMetadata *where, ///< Row match criteria 239 unsigned long long limit ///< Maximum number of elements to return 240 ); 241 242 /** Convert a expTagCounterRow into an equivalent psMetadata 243 * 244 * @return A psMetadata pointer or NULL on error 245 */ 246 247 psMetadata *expTagCounterMetadataFromObject( 248 const expTagCounterRow *object ///< fooRow to convert into a psMetadata 249 ); 250 251 /** Convert a psMetadata into an equivalent fooRow 252 * 253 * @return A expTagCounterRow pointer or NULL on error 254 */ 255 256 expTagCounterRow *expTagCounterObjectFromMetadata( 257 psMetadata *md ///< psMetadata to convert into a fooRow 258 ); 259 /** Selects up to limit rows from the database and returns as expTagCounterRow objects in a psArray 260 * 261 * See psDBSelectRows() for documentation on the format of where. 262 * 263 * @return A psArray pointer or NULL on error 264 */ 265 266 psArray *expTagCounterSelectRowObjects( 267 psDB *dbh, ///< Database handle 268 const psMetadata *where, ///< Row match criteria 269 unsigned long long limit ///< Maximum number of elements to return 270 ); 271 /** Deletes a row from the database coresponding to an expTagCounter 272 * 273 * Note that a 'where' search psMetadata is constructed from each object and 274 * used to find rows to delete. 275 * 276 * @return A The number of rows removed or a negative value on error 277 */ 278 279 bool expTagCounterDeleteObject( 280 psDB *dbh, ///< Database handle 281 const expTagCounterRow *object ///< Object to delete 282 ); 283 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 284 * 285 * Note that a 'where' search psMetadata is constructed from each object and 286 * used to find rows to delete. 287 * 288 * @return A The number of rows removed or a negative value on error 289 */ 290 291 long long expTagCounterDeleteRowObjects( 292 psDB *dbh, ///< Database handle 293 const psArray *objects, ///< Array of objects to delete 294 unsigned long long limit ///< Maximum number of elements to delete 295 ); 296 /** Formats and prints an array of expTagCounterRow objects 297 * 298 * When mdcf is set the formated output is in psMetadataConfig 299 * format, otherwise it is in a simple tabular format. 300 * 301 * @return true on success 302 */ 303 304 bool expTagCounterPrintObjects( 305 FILE *stream, ///< a stream 306 psArray *objects, ///< An array of expTagCounterRow objects 307 bool mdcf ///< format as mdconfig or simple 308 ); 309 /** Formats and prints an expTagCounterRow object 310 * 311 * When mdcf is set the formated output is in psMetadataConfig 312 * format, otherwise it is in a simple tabular format. 313 * 314 * @return true on success 315 */ 316 317 bool expTagCounterPrintObject( 318 FILE *stream, ///< a stream 319 expTagCounterRow *object, ///< an expTagCounterRow object 320 bool mdcf ///< format as mdconfig or simple 321 ); 322 /** summitExpRow data structure 323 * 324 * Structure for representing a single row of summitExp table data. 325 */ 326 327 typedef struct { 328 char *exp_id; 133 char *exp_name; 329 134 char *camera; 330 135 char *telescope; … … 341 146 342 147 summitExpRow *summitExpRowAlloc( 343 const char *exp_ id,148 const char *exp_name, 344 149 const char *camera, 345 150 const char *telescope, … … 377 182 bool summitExpInsert( 378 183 psDB *dbh, ///< Database handle 379 const char *exp_ id,184 const char *exp_name, 380 185 const char *camera, 381 186 const char *telescope, … … 539 344 540 345 typedef struct { 541 char *exp_ id;346 char *exp_name; 542 347 char *camera; 543 348 char *telescope; … … 556 361 557 362 summitImfileRow *summitImfileRowAlloc( 558 const char *exp_ id,363 const char *exp_name, 559 364 const char *camera, 560 365 const char *telescope, … … 594 399 bool summitImfileInsert( 595 400 psDB *dbh, ///< Database handle 596 const char *exp_ id,401 const char *exp_name, 597 402 const char *camera, 598 403 const char *telescope, … … 758 563 759 564 typedef struct { 760 char *exp_ id;565 char *exp_name; 761 566 char *camera; 762 567 char *telescope; … … 769 574 770 575 pzPendingExpRow *pzPendingExpRowAlloc( 771 const char *exp_ id,576 const char *exp_name, 772 577 const char *camera, 773 578 const char *telescope … … 801 606 bool pzPendingExpInsert( 802 607 psDB *dbh, ///< Database handle 803 const char *exp_ id,608 const char *exp_name, 804 609 const char *camera, 805 610 const char *telescope … … 959 764 960 765 typedef struct { 961 char *exp_ id;766 char *exp_name; 962 767 char *camera; 963 768 char *telescope; 964 769 char *class; 965 770 char *class_id; 966 char *exp_tag;771 psS64 exp_id; 967 772 } pzPendingImfileRow; 968 773 … … 973 778 974 779 pzPendingImfileRow *pzPendingImfileRowAlloc( 975 const char *exp_ id,780 const char *exp_name, 976 781 const char *camera, 977 782 const char *telescope, 978 783 const char *class, 979 784 const char *class_id, 980 const char *exp_tag785 psS64 exp_id 981 786 ); 982 787 … … 1008 813 bool pzPendingImfileInsert( 1009 814 psDB *dbh, ///< Database handle 1010 const char *exp_ id,815 const char *exp_name, 1011 816 const char *camera, 1012 817 const char *telescope, 1013 818 const char *class, 1014 819 const char *class_id, 1015 const char *exp_tag820 psS64 exp_id 1016 821 ); 1017 822 … … 1169 974 1170 975 typedef struct { 1171 char *exp_ id;976 char *exp_name; 1172 977 char *camera; 1173 978 char *telescope; … … 1180 985 1181 986 pzDoneExpRow *pzDoneExpRowAlloc( 1182 const char *exp_ id,987 const char *exp_name, 1183 988 const char *camera, 1184 989 const char *telescope … … 1212 1017 bool pzDoneExpInsert( 1213 1018 psDB *dbh, ///< Database handle 1214 const char *exp_ id,1019 const char *exp_name, 1215 1020 const char *camera, 1216 1021 const char *telescope … … 1370 1175 1371 1176 typedef struct { 1372 char *exp_ id;1177 char *exp_name; 1373 1178 char *camera; 1374 1179 char *telescope; 1375 1180 char *class; 1376 1181 char *class_id; 1377 char *exp_tag;1182 psS64 exp_id; 1378 1183 char *uri; 1379 1184 } pzDoneImfileRow; … … 1385 1190 1386 1191 pzDoneImfileRow *pzDoneImfileRowAlloc( 1387 const char *exp_ id,1192 const char *exp_name, 1388 1193 const char *camera, 1389 1194 const char *telescope, 1390 1195 const char *class, 1391 1196 const char *class_id, 1392 const char *exp_tag,1197 psS64 exp_id, 1393 1198 const char *uri 1394 1199 ); … … 1421 1226 bool pzDoneImfileInsert( 1422 1227 psDB *dbh, ///< Database handle 1423 const char *exp_ id,1228 const char *exp_name, 1424 1229 const char *camera, 1425 1230 const char *telescope, 1426 1231 const char *class, 1427 1232 const char *class_id, 1428 const char *exp_tag,1233 psS64 exp_id, 1429 1234 const char *uri 1430 1235 ); … … 1583 1388 1584 1389 typedef struct { 1585 char *exp_tag;1586 char * exp_id;1587 char * camera;1588 char *t elescope;1589 psS32 imfiles;1390 psS64 exp_id; 1391 char *tmp_exp_name; 1392 char *tmp_camera; 1393 char *tmp_telescope; 1394 char *state; 1590 1395 char *workdir; 1396 char *workdir_state; 1591 1397 } newExpRow; 1592 1398 … … 1597 1403 1598 1404 newExpRow *newExpRowAlloc( 1599 const char *exp_tag, 1600 const char *exp_id, 1601 const char *camera, 1602 const char *telescope, 1603 psS32 imfiles, 1604 const char *workdir 1405 psS64 exp_id, 1406 const char *tmp_exp_name, 1407 const char *tmp_camera, 1408 const char *tmp_telescope, 1409 const char *state, 1410 const char *workdir, 1411 const char *workdir_state 1605 1412 ); 1606 1413 … … 1632 1439 bool newExpInsert( 1633 1440 psDB *dbh, ///< Database handle 1634 const char *exp_tag, 1635 const char *exp_id, 1636 const char *camera, 1637 const char *telescope, 1638 psS32 imfiles, 1639 const char *workdir 1441 psS64 exp_id, 1442 const char *tmp_exp_name, 1443 const char *tmp_camera, 1444 const char *tmp_telescope, 1445 const char *state, 1446 const char *workdir, 1447 const char *workdir_state 1640 1448 ); 1641 1449 … … 1793 1601 1794 1602 typedef struct { 1795 char *exp_tag; 1796 char *class; 1797 char *class_id; 1603 psS64 exp_id; 1604 char *tmp_class_id; 1798 1605 char *uri; 1799 1606 } newImfileRow; … … 1805 1612 1806 1613 newImfileRow *newImfileRowAlloc( 1807 const char *exp_tag, 1808 const char *class, 1809 const char *class_id, 1614 psS64 exp_id, 1615 const char *tmp_class_id, 1810 1616 const char *uri 1811 1617 ); … … 1838 1644 bool newImfileInsert( 1839 1645 psDB *dbh, ///< Database handle 1840 const char *exp_tag, 1841 const char *class, 1842 const char *class_id, 1646 psS64 exp_id, 1647 const char *tmp_class_id, 1843 1648 const char *uri 1844 1649 ); … … 1997 1802 1998 1803 typedef struct { 1999 char *exp_tag;2000 char *exp_ id;1804 psS64 exp_id; 1805 char *exp_name; 2001 1806 char *camera; 2002 1807 char *telescope; 2003 1808 psTime* dateobs; 1809 char *exp_tag; 2004 1810 char *exp_type; 2005 psS32 imfiles;2006 1811 char *filelevel; 2007 1812 char *workdir; … … 2035 1840 2036 1841 rawExpRow *rawExpRowAlloc( 2037 const char *exp_tag,2038 const char *exp_ id,1842 psS64 exp_id, 1843 const char *exp_name, 2039 1844 const char *camera, 2040 1845 const char *telescope, 2041 1846 psTime* dateobs, 1847 const char *exp_tag, 2042 1848 const char *exp_type, 2043 psS32 imfiles,2044 1849 const char *filelevel, 2045 1850 const char *workdir, … … 2094 1899 bool rawExpInsert( 2095 1900 psDB *dbh, ///< Database handle 2096 const char *exp_tag,2097 const char *exp_ id,1901 psS64 exp_id, 1902 const char *exp_name, 2098 1903 const char *camera, 2099 1904 const char *telescope, 2100 1905 psTime* dateobs, 1906 const char *exp_tag, 2101 1907 const char *exp_type, 2102 psS32 imfiles,2103 1908 const char *filelevel, 2104 1909 const char *workdir, … … 2279 2084 2280 2085 typedef struct { 2281 char *exp_tag; 2086 psS64 exp_id; 2087 char *exp_name; 2088 char *camera; 2089 char *telescope; 2090 psTime* dateobs; 2091 char *tmp_class_id; 2282 2092 char *class_id; 2283 2093 char *uri; … … 2303 2113 psF64 user_5; 2304 2114 char *object; 2305 psTime* dateobs;2306 2115 psS16 fault; 2307 2116 } rawImfileRow; … … 2313 2122 2314 2123 rawImfileRow *rawImfileRowAlloc( 2315 const char *exp_tag, 2124 psS64 exp_id, 2125 const char *exp_name, 2126 const char *camera, 2127 const char *telescope, 2128 psTime* dateobs, 2129 const char *tmp_class_id, 2316 2130 const char *class_id, 2317 2131 const char *uri, … … 2337 2151 psF64 user_5, 2338 2152 const char *object, 2339 psTime* dateobs,2340 2153 psS16 fault 2341 2154 ); … … 2368 2181 bool rawImfileInsert( 2369 2182 psDB *dbh, ///< Database handle 2370 const char *exp_tag, 2183 psS64 exp_id, 2184 const char *exp_name, 2185 const char *camera, 2186 const char *telescope, 2187 psTime* dateobs, 2188 const char *tmp_class_id, 2371 2189 const char *class_id, 2372 2190 const char *uri, … … 2392 2210 psF64 user_5, 2393 2211 const char *object, 2394 psTime* dateobs,2395 2212 psS16 fault 2396 2213 ); … … 2550 2367 typedef struct { 2551 2368 psS64 guide_id; 2552 char *exp_tag;2369 psS64 exp_id; 2553 2370 char *recipe; 2554 2371 } guidePendingExpRow; … … 2561 2378 guidePendingExpRow *guidePendingExpRowAlloc( 2562 2379 psS64 guide_id, 2563 const char *exp_tag,2380 psS64 exp_id, 2564 2381 const char *recipe 2565 2382 ); … … 2593 2410 psDB *dbh, ///< Database handle 2594 2411 psS64 guide_id, 2595 const char *exp_tag,2412 psS64 exp_id, 2596 2413 const char *recipe 2597 2414 ); … … 2744 2561 bool mdcf ///< format as mdconfig or simple 2745 2562 ); 2746 /** chip PendingExpRow data structure2747 * 2748 * Structure for representing a single row of chip PendingExptable data.2563 /** chipRunRow data structure 2564 * 2565 * Structure for representing a single row of chipRun table data. 2749 2566 */ 2750 2567 2751 2568 typedef struct { 2752 2569 psS64 chip_id; 2753 char *exp_tag; 2754 psS64 guide_id; 2570 char *state; 2755 2571 char *workdir; 2572 char *workdir_state; 2756 2573 char *label; 2757 2574 char *reduction; 2758 2575 char *expgroup; 2759 2576 char *dvodb; 2760 } chip PendingExpRow;2761 2762 /** Creates a new chip PendingExpRow object2763 * 2764 * @return A new chip PendingExpRow object or NULL on failure.2765 */ 2766 2767 chip PendingExpRow *chipPendingExpRowAlloc(2577 } chipRunRow; 2578 2579 /** Creates a new chipRunRow object 2580 * 2581 * @return A new chipRunRow object or NULL on failure. 2582 */ 2583 2584 chipRunRow *chipRunRowAlloc( 2768 2585 psS64 chip_id, 2769 const char *exp_tag, 2770 psS64 guide_id, 2586 const char *state, 2771 2587 const char *workdir, 2588 const char *workdir_state, 2772 2589 const char *label, 2773 2590 const char *reduction, … … 2776 2593 ); 2777 2594 2778 /** Creates a new chip PendingExptable2779 * 2780 * @return true on success 2781 */ 2782 2783 bool chip PendingExpCreateTable(2595 /** Creates a new chipRun table 2596 * 2597 * @return true on success 2598 */ 2599 2600 bool chipRunCreateTable( 2784 2601 psDB *dbh ///< Database handle 2785 2602 ); 2786 2603 2787 /** Deletes a chip PendingExptable2788 * 2789 * @return true on success 2790 */ 2791 2792 bool chip PendingExpDropTable(2604 /** Deletes a chipRun table 2605 * 2606 * @return true on success 2607 */ 2608 2609 bool chipRunDropTable( 2793 2610 psDB *dbh ///< Database handle 2794 2611 ); … … 2801 2618 */ 2802 2619 2803 bool chip PendingExpInsert(2620 bool chipRunInsert( 2804 2621 psDB *dbh, ///< Database handle 2805 2622 psS64 chip_id, 2806 const char *exp_tag, 2807 psS64 guide_id, 2623 const char *state, 2808 2624 const char *workdir, 2625 const char *workdir_state, 2809 2626 const char *label, 2810 2627 const char *reduction, … … 2818 2635 */ 2819 2636 2820 long long chip PendingExpDelete(2637 long long chipRunDelete( 2821 2638 psDB *dbh, ///< Database handle 2822 2639 const psMetadata *where, ///< Row match criteria … … 2824 2641 ); 2825 2642 2826 /** Insert a single chip PendingExpRow object into a table2643 /** Insert a single chipRunRow object into a table 2827 2644 * 2828 2645 * This function constructs and inserts a single row based on it's parameters. … … 2831 2648 */ 2832 2649 2833 bool chip PendingExpInsertObject(2834 psDB *dbh, ///< Database handle 2835 chip PendingExpRow *object ///< chipPendingExpRow object2836 ); 2837 2838 /** Insert an array of chip PendingExpRow object into a table2650 bool chipRunInsertObject( 2651 psDB *dbh, ///< Database handle 2652 chipRunRow *object ///< chipRunRow object 2653 ); 2654 2655 /** Insert an array of chipRunRow object into a table 2839 2656 * 2840 2657 * This function constructs and inserts multiple rows based on it's parameters. … … 2843 2660 */ 2844 2661 2845 bool chip PendingExpInsertObjects(2846 psDB *dbh, ///< Database handle 2847 psArray *objects ///< array of chip PendingExpRow objects2848 ); 2849 2850 /** Insert data from a binary FITS table chip PendingExpRow into the database2662 bool chipRunInsertObjects( 2663 psDB *dbh, ///< Database handle 2664 psArray *objects ///< array of chipRunRow objects 2665 ); 2666 2667 /** Insert data from a binary FITS table chipRunRow into the database 2851 2668 * 2852 2669 * This function expects a psFits object with a FITS table as the first … … 2858 2675 */ 2859 2676 2860 bool chip PendingExpInsertFits(2677 bool chipRunInsertFits( 2861 2678 psDB *dbh, ///< Database handle 2862 2679 const psFits *fits ///< psFits object … … 2873 2690 */ 2874 2691 2875 bool chip PendingExpSelectRowsFits(2692 bool chipRunSelectRowsFits( 2876 2693 psDB *dbh, ///< Database handle 2877 2694 psFits *fits, ///< psFits object … … 2880 2697 ); 2881 2698 2882 /** Convert a chip PendingExpRow into an equivalent psMetadata2699 /** Convert a chipRunRow into an equivalent psMetadata 2883 2700 * 2884 2701 * @return A psMetadata pointer or NULL on error 2885 2702 */ 2886 2703 2887 psMetadata *chip PendingExpMetadataFromObject(2888 const chip PendingExpRow *object ///< fooRow to convert into a psMetadata2704 psMetadata *chipRunMetadataFromObject( 2705 const chipRunRow *object ///< fooRow to convert into a psMetadata 2889 2706 ); 2890 2707 2891 2708 /** Convert a psMetadata into an equivalent fooRow 2892 2709 * 2893 * @return A chip PendingExpRow pointer or NULL on error2894 */ 2895 2896 chip PendingExpRow *chipPendingExpObjectFromMetadata(2710 * @return A chipRunRow pointer or NULL on error 2711 */ 2712 2713 chipRunRow *chipRunObjectFromMetadata( 2897 2714 psMetadata *md ///< psMetadata to convert into a fooRow 2898 2715 ); 2899 /** Selects up to limit rows from the database and returns as chip PendingExpRow objects in a psArray2716 /** Selects up to limit rows from the database and returns as chipRunRow objects in a psArray 2900 2717 * 2901 2718 * See psDBSelectRows() for documentation on the format of where. … … 2904 2721 */ 2905 2722 2906 psArray *chip PendingExpSelectRowObjects(2723 psArray *chipRunSelectRowObjects( 2907 2724 psDB *dbh, ///< Database handle 2908 2725 const psMetadata *where, ///< Row match criteria 2909 2726 unsigned long long limit ///< Maximum number of elements to return 2910 2727 ); 2911 /** Deletes a row from the database coresponding to an chip PendingExp2728 /** Deletes a row from the database coresponding to an chipRun 2912 2729 * 2913 2730 * Note that a 'where' search psMetadata is constructed from each object and … … 2917 2734 */ 2918 2735 2919 bool chip PendingExpDeleteObject(2920 psDB *dbh, ///< Database handle 2921 const chip PendingExpRow *object ///< Object to delete2736 bool chipRunDeleteObject( 2737 psDB *dbh, ///< Database handle 2738 const chipRunRow *object ///< Object to delete 2922 2739 ); 2923 2740 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 2929 2746 */ 2930 2747 2931 long long chip PendingExpDeleteRowObjects(2748 long long chipRunDeleteRowObjects( 2932 2749 psDB *dbh, ///< Database handle 2933 2750 const psArray *objects, ///< Array of objects to delete 2934 2751 unsigned long long limit ///< Maximum number of elements to delete 2935 2752 ); 2936 /** Formats and prints an array of chip PendingExpRow objects2753 /** Formats and prints an array of chipRunRow objects 2937 2754 * 2938 2755 * When mdcf is set the formated output is in psMetadataConfig … … 2942 2759 */ 2943 2760 2944 bool chip PendingExpPrintObjects(2761 bool chipRunPrintObjects( 2945 2762 FILE *stream, ///< a stream 2946 psArray *objects, ///< An array of chip PendingExpRow objects2763 psArray *objects, ///< An array of chipRunRow objects 2947 2764 bool mdcf ///< format as mdconfig or simple 2948 2765 ); 2949 /** Formats and prints an chip PendingExpRow object2766 /** Formats and prints an chipRunRow object 2950 2767 * 2951 2768 * When mdcf is set the formated output is in psMetadataConfig … … 2955 2772 */ 2956 2773 2957 bool chip PendingExpPrintObject(2774 bool chipRunPrintObject( 2958 2775 FILE *stream, ///< a stream 2959 chip PendingExpRow *object, ///< an chipPendingExpRow object2776 chipRunRow *object, ///< an chipRunRow object 2960 2777 bool mdcf ///< format as mdconfig or simple 2961 2778 ); 2962 /** chip PendingImfileRow data structure2963 * 2964 * Structure for representing a single row of chip PendingImfile table data.2779 /** chipInputImfileRow data structure 2780 * 2781 * Structure for representing a single row of chipInputImfile table data. 2965 2782 */ 2966 2783 2967 2784 typedef struct { 2968 2785 psS64 chip_id; 2786 psS64 exp_id; 2969 2787 char *class_id; 2970 char *uri; 2971 } chipPendingImfileRow; 2972 2973 /** Creates a new chipPendingImfileRow object 2974 * 2975 * @return A new chipPendingImfileRow object or NULL on failure. 2976 */ 2977 2978 chipPendingImfileRow *chipPendingImfileRowAlloc( 2788 } chipInputImfileRow; 2789 2790 /** Creates a new chipInputImfileRow object 2791 * 2792 * @return A new chipInputImfileRow object or NULL on failure. 2793 */ 2794 2795 chipInputImfileRow *chipInputImfileRowAlloc( 2979 2796 psS64 chip_id, 2980 const char *class_id,2981 const char * uri2982 ); 2983 2984 /** Creates a new chip PendingImfile table2985 * 2986 * @return true on success 2987 */ 2988 2989 bool chip PendingImfileCreateTable(2797 psS64 exp_id, 2798 const char *class_id 2799 ); 2800 2801 /** Creates a new chipInputImfile table 2802 * 2803 * @return true on success 2804 */ 2805 2806 bool chipInputImfileCreateTable( 2990 2807 psDB *dbh ///< Database handle 2991 2808 ); 2992 2809 2993 /** Deletes a chip PendingImfile table2994 * 2995 * @return true on success 2996 */ 2997 2998 bool chip PendingImfileDropTable(2810 /** Deletes a chipInputImfile table 2811 * 2812 * @return true on success 2813 */ 2814 2815 bool chipInputImfileDropTable( 2999 2816 psDB *dbh ///< Database handle 3000 2817 ); … … 3007 2824 */ 3008 2825 3009 bool chip PendingImfileInsert(2826 bool chipInputImfileInsert( 3010 2827 psDB *dbh, ///< Database handle 3011 2828 psS64 chip_id, 3012 const char *class_id,3013 const char * uri2829 psS64 exp_id, 2830 const char *class_id 3014 2831 ); 3015 2832 … … 3019 2836 */ 3020 2837 3021 long long chip PendingImfileDelete(2838 long long chipInputImfileDelete( 3022 2839 psDB *dbh, ///< Database handle 3023 2840 const psMetadata *where, ///< Row match criteria … … 3025 2842 ); 3026 2843 3027 /** Insert a single chip PendingImfileRow object into a table2844 /** Insert a single chipInputImfileRow object into a table 3028 2845 * 3029 2846 * This function constructs and inserts a single row based on it's parameters. … … 3032 2849 */ 3033 2850 3034 bool chip PendingImfileInsertObject(3035 psDB *dbh, ///< Database handle 3036 chip PendingImfileRow *object ///< chipPendingImfileRow object3037 ); 3038 3039 /** Insert an array of chip PendingImfileRow object into a table2851 bool chipInputImfileInsertObject( 2852 psDB *dbh, ///< Database handle 2853 chipInputImfileRow *object ///< chipInputImfileRow object 2854 ); 2855 2856 /** Insert an array of chipInputImfileRow object into a table 3040 2857 * 3041 2858 * This function constructs and inserts multiple rows based on it's parameters. … … 3044 2861 */ 3045 2862 3046 bool chip PendingImfileInsertObjects(3047 psDB *dbh, ///< Database handle 3048 psArray *objects ///< array of chip PendingImfileRow objects3049 ); 3050 3051 /** Insert data from a binary FITS table chip PendingImfileRow into the database2863 bool chipInputImfileInsertObjects( 2864 psDB *dbh, ///< Database handle 2865 psArray *objects ///< array of chipInputImfileRow objects 2866 ); 2867 2868 /** Insert data from a binary FITS table chipInputImfileRow into the database 3052 2869 * 3053 2870 * This function expects a psFits object with a FITS table as the first … … 3059 2876 */ 3060 2877 3061 bool chip PendingImfileInsertFits(2878 bool chipInputImfileInsertFits( 3062 2879 psDB *dbh, ///< Database handle 3063 2880 const psFits *fits ///< psFits object … … 3074 2891 */ 3075 2892 3076 bool chip PendingImfileSelectRowsFits(2893 bool chipInputImfileSelectRowsFits( 3077 2894 psDB *dbh, ///< Database handle 3078 2895 psFits *fits, ///< psFits object … … 3081 2898 ); 3082 2899 3083 /** Convert a chip PendingImfileRow into an equivalent psMetadata2900 /** Convert a chipInputImfileRow into an equivalent psMetadata 3084 2901 * 3085 2902 * @return A psMetadata pointer or NULL on error 3086 2903 */ 3087 2904 3088 psMetadata *chip PendingImfileMetadataFromObject(3089 const chip PendingImfileRow *object ///< fooRow to convert into a psMetadata2905 psMetadata *chipInputImfileMetadataFromObject( 2906 const chipInputImfileRow *object ///< fooRow to convert into a psMetadata 3090 2907 ); 3091 2908 3092 2909 /** Convert a psMetadata into an equivalent fooRow 3093 2910 * 3094 * @return A chip PendingImfileRow pointer or NULL on error3095 */ 3096 3097 chip PendingImfileRow *chipPendingImfileObjectFromMetadata(2911 * @return A chipInputImfileRow pointer or NULL on error 2912 */ 2913 2914 chipInputImfileRow *chipInputImfileObjectFromMetadata( 3098 2915 psMetadata *md ///< psMetadata to convert into a fooRow 3099 2916 ); 3100 /** Selects up to limit rows from the database and returns as chip PendingImfileRow objects in a psArray2917 /** Selects up to limit rows from the database and returns as chipInputImfileRow objects in a psArray 3101 2918 * 3102 2919 * See psDBSelectRows() for documentation on the format of where. … … 3105 2922 */ 3106 2923 3107 psArray *chip PendingImfileSelectRowObjects(2924 psArray *chipInputImfileSelectRowObjects( 3108 2925 psDB *dbh, ///< Database handle 3109 2926 const psMetadata *where, ///< Row match criteria 3110 2927 unsigned long long limit ///< Maximum number of elements to return 3111 2928 ); 3112 /** Deletes a row from the database coresponding to an chip PendingImfile2929 /** Deletes a row from the database coresponding to an chipInputImfile 3113 2930 * 3114 2931 * Note that a 'where' search psMetadata is constructed from each object and … … 3118 2935 */ 3119 2936 3120 bool chip PendingImfileDeleteObject(3121 psDB *dbh, ///< Database handle 3122 const chip PendingImfileRow *object ///< Object to delete2937 bool chipInputImfileDeleteObject( 2938 psDB *dbh, ///< Database handle 2939 const chipInputImfileRow *object ///< Object to delete 3123 2940 ); 3124 2941 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 3130 2947 */ 3131 2948 3132 long long chip PendingImfileDeleteRowObjects(2949 long long chipInputImfileDeleteRowObjects( 3133 2950 psDB *dbh, ///< Database handle 3134 2951 const psArray *objects, ///< Array of objects to delete 3135 2952 unsigned long long limit ///< Maximum number of elements to delete 3136 2953 ); 3137 /** Formats and prints an array of chip PendingImfileRow objects2954 /** Formats and prints an array of chipInputImfileRow objects 3138 2955 * 3139 2956 * When mdcf is set the formated output is in psMetadataConfig … … 3143 2960 */ 3144 2961 3145 bool chip PendingImfilePrintObjects(2962 bool chipInputImfilePrintObjects( 3146 2963 FILE *stream, ///< a stream 3147 psArray *objects, ///< An array of chip PendingImfileRow objects2964 psArray *objects, ///< An array of chipInputImfileRow objects 3148 2965 bool mdcf ///< format as mdconfig or simple 3149 2966 ); 3150 /** Formats and prints an chip PendingImfileRow object2967 /** Formats and prints an chipInputImfileRow object 3151 2968 * 3152 2969 * When mdcf is set the formated output is in psMetadataConfig … … 3156 2973 */ 3157 2974 3158 bool chip PendingImfilePrintObject(2975 bool chipInputImfilePrintObject( 3159 2976 FILE *stream, ///< a stream 3160 chip PendingImfileRow *object, ///< an chipPendingImfileRow object2977 chipInputImfileRow *object, ///< an chipInputImfileRow object 3161 2978 bool mdcf ///< format as mdconfig or simple 3162 2979 ); 3163 /** chipProcessed ExpRow data structure3164 * 3165 * Structure for representing a single row of chipProcessed Exptable data.2980 /** chipProcessedImfileRow data structure 2981 * 2982 * Structure for representing a single row of chipProcessedImfile table data. 3166 2983 */ 3167 2984 3168 2985 typedef struct { 3169 2986 psS64 chip_id; 3170 char *exp_tag; 3171 psS64 guide_id; 3172 char *workdir; 3173 char *label; 3174 char *reduction; 3175 char *expgroup; 3176 char *dvodb; 3177 } chipProcessedExpRow; 3178 3179 /** Creates a new chipProcessedExpRow object 3180 * 3181 * @return A new chipProcessedExpRow object or NULL on failure. 3182 */ 3183 3184 chipProcessedExpRow *chipProcessedExpRowAlloc( 3185 psS64 chip_id, 3186 const char *exp_tag, 3187 psS64 guide_id, 3188 const char *workdir, 3189 const char *label, 3190 const char *reduction, 3191 const char *expgroup, 3192 const char *dvodb 3193 ); 3194 3195 /** Creates a new chipProcessedExp table 3196 * 3197 * @return true on success 3198 */ 3199 3200 bool chipProcessedExpCreateTable( 3201 psDB *dbh ///< Database handle 3202 ); 3203 3204 /** Deletes a chipProcessedExp table 3205 * 3206 * @return true on success 3207 */ 3208 3209 bool chipProcessedExpDropTable( 3210 psDB *dbh ///< Database handle 3211 ); 3212 3213 /** Insert a single row into a table 3214 * 3215 * This function constructs and inserts a single row based on it's parameters. 3216 * 3217 * @return true on success 3218 */ 3219 3220 bool chipProcessedExpInsert( 3221 psDB *dbh, ///< Database handle 3222 psS64 chip_id, 3223 const char *exp_tag, 3224 psS64 guide_id, 3225 const char *workdir, 3226 const char *label, 3227 const char *reduction, 3228 const char *expgroup, 3229 const char *dvodb 3230 ); 3231 3232 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3233 * 3234 * @return A The number of rows removed or a negative value on error 3235 */ 3236 3237 long long chipProcessedExpDelete( 3238 psDB *dbh, ///< Database handle 3239 const psMetadata *where, ///< Row match criteria 3240 unsigned long long limit ///< Maximum number of elements to delete 3241 ); 3242 3243 /** Insert a single chipProcessedExpRow object into a table 3244 * 3245 * This function constructs and inserts a single row based on it's parameters. 3246 * 3247 * @return true on success 3248 */ 3249 3250 bool chipProcessedExpInsertObject( 3251 psDB *dbh, ///< Database handle 3252 chipProcessedExpRow *object ///< chipProcessedExpRow object 3253 ); 3254 3255 /** Insert an array of chipProcessedExpRow object into a table 3256 * 3257 * This function constructs and inserts multiple rows based on it's parameters. 3258 * 3259 * @return true on success 3260 */ 3261 3262 bool chipProcessedExpInsertObjects( 3263 psDB *dbh, ///< Database handle 3264 psArray *objects ///< array of chipProcessedExpRow objects 3265 ); 3266 3267 /** Insert data from a binary FITS table chipProcessedExpRow into the database 3268 * 3269 * This function expects a psFits object with a FITS table as the first 3270 * extension. The table must have at least one row of data in it, that is of 3271 * the appropriate format (number of columns and their type). All other 3272 * extensions are ignored. 3273 * 3274 * @return true on success 3275 */ 3276 3277 bool chipProcessedExpInsertFits( 3278 psDB *dbh, ///< Database handle 3279 const psFits *fits ///< psFits object 3280 ); 3281 3282 /** Selects up to limit from the database and returns them in a binary FITS table 3283 * 3284 * This function assumes an empty psFits object and will create a FITS table 3285 * as the first extension. 3286 * 3287 * See psDBSelectRows() for documentation on the format of where. 3288 * 3289 * @return true on success 3290 */ 3291 3292 bool chipProcessedExpSelectRowsFits( 3293 psDB *dbh, ///< Database handle 3294 psFits *fits, ///< psFits object 3295 const psMetadata *where, ///< Row match criteria 3296 unsigned long long limit ///< Maximum number of elements to return 3297 ); 3298 3299 /** Convert a chipProcessedExpRow into an equivalent psMetadata 3300 * 3301 * @return A psMetadata pointer or NULL on error 3302 */ 3303 3304 psMetadata *chipProcessedExpMetadataFromObject( 3305 const chipProcessedExpRow *object ///< fooRow to convert into a psMetadata 3306 ); 3307 3308 /** Convert a psMetadata into an equivalent fooRow 3309 * 3310 * @return A chipProcessedExpRow pointer or NULL on error 3311 */ 3312 3313 chipProcessedExpRow *chipProcessedExpObjectFromMetadata( 3314 psMetadata *md ///< psMetadata to convert into a fooRow 3315 ); 3316 /** Selects up to limit rows from the database and returns as chipProcessedExpRow objects in a psArray 3317 * 3318 * See psDBSelectRows() for documentation on the format of where. 3319 * 3320 * @return A psArray pointer or NULL on error 3321 */ 3322 3323 psArray *chipProcessedExpSelectRowObjects( 3324 psDB *dbh, ///< Database handle 3325 const psMetadata *where, ///< Row match criteria 3326 unsigned long long limit ///< Maximum number of elements to return 3327 ); 3328 /** Deletes a row from the database coresponding to an chipProcessedExp 3329 * 3330 * Note that a 'where' search psMetadata is constructed from each object and 3331 * used to find rows to delete. 3332 * 3333 * @return A The number of rows removed or a negative value on error 3334 */ 3335 3336 bool chipProcessedExpDeleteObject( 3337 psDB *dbh, ///< Database handle 3338 const chipProcessedExpRow *object ///< Object to delete 3339 ); 3340 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3341 * 3342 * Note that a 'where' search psMetadata is constructed from each object and 3343 * used to find rows to delete. 3344 * 3345 * @return A The number of rows removed or a negative value on error 3346 */ 3347 3348 long long chipProcessedExpDeleteRowObjects( 3349 psDB *dbh, ///< Database handle 3350 const psArray *objects, ///< Array of objects to delete 3351 unsigned long long limit ///< Maximum number of elements to delete 3352 ); 3353 /** Formats and prints an array of chipProcessedExpRow objects 3354 * 3355 * When mdcf is set the formated output is in psMetadataConfig 3356 * format, otherwise it is in a simple tabular format. 3357 * 3358 * @return true on success 3359 */ 3360 3361 bool chipProcessedExpPrintObjects( 3362 FILE *stream, ///< a stream 3363 psArray *objects, ///< An array of chipProcessedExpRow objects 3364 bool mdcf ///< format as mdconfig or simple 3365 ); 3366 /** Formats and prints an chipProcessedExpRow object 3367 * 3368 * When mdcf is set the formated output is in psMetadataConfig 3369 * format, otherwise it is in a simple tabular format. 3370 * 3371 * @return true on success 3372 */ 3373 3374 bool chipProcessedExpPrintObject( 3375 FILE *stream, ///< a stream 3376 chipProcessedExpRow *object, ///< an chipProcessedExpRow object 3377 bool mdcf ///< format as mdconfig or simple 3378 ); 3379 /** chipMaskRow data structure 3380 * 3381 * Structure for representing a single row of chipMask table data. 3382 */ 3383 3384 typedef struct { 3385 char *label; 3386 } chipMaskRow; 3387 3388 /** Creates a new chipMaskRow object 3389 * 3390 * @return A new chipMaskRow object or NULL on failure. 3391 */ 3392 3393 chipMaskRow *chipMaskRowAlloc( 3394 const char *label 3395 ); 3396 3397 /** Creates a new chipMask table 3398 * 3399 * @return true on success 3400 */ 3401 3402 bool chipMaskCreateTable( 3403 psDB *dbh ///< Database handle 3404 ); 3405 3406 /** Deletes a chipMask table 3407 * 3408 * @return true on success 3409 */ 3410 3411 bool chipMaskDropTable( 3412 psDB *dbh ///< Database handle 3413 ); 3414 3415 /** Insert a single row into a table 3416 * 3417 * This function constructs and inserts a single row based on it's parameters. 3418 * 3419 * @return true on success 3420 */ 3421 3422 bool chipMaskInsert( 3423 psDB *dbh, ///< Database handle 3424 const char *label 3425 ); 3426 3427 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3428 * 3429 * @return A The number of rows removed or a negative value on error 3430 */ 3431 3432 long long chipMaskDelete( 3433 psDB *dbh, ///< Database handle 3434 const psMetadata *where, ///< Row match criteria 3435 unsigned long long limit ///< Maximum number of elements to delete 3436 ); 3437 3438 /** Insert a single chipMaskRow object into a table 3439 * 3440 * This function constructs and inserts a single row based on it's parameters. 3441 * 3442 * @return true on success 3443 */ 3444 3445 bool chipMaskInsertObject( 3446 psDB *dbh, ///< Database handle 3447 chipMaskRow *object ///< chipMaskRow object 3448 ); 3449 3450 /** Insert an array of chipMaskRow object into a table 3451 * 3452 * This function constructs and inserts multiple rows based on it's parameters. 3453 * 3454 * @return true on success 3455 */ 3456 3457 bool chipMaskInsertObjects( 3458 psDB *dbh, ///< Database handle 3459 psArray *objects ///< array of chipMaskRow objects 3460 ); 3461 3462 /** Insert data from a binary FITS table chipMaskRow into the database 3463 * 3464 * This function expects a psFits object with a FITS table as the first 3465 * extension. The table must have at least one row of data in it, that is of 3466 * the appropriate format (number of columns and their type). All other 3467 * extensions are ignored. 3468 * 3469 * @return true on success 3470 */ 3471 3472 bool chipMaskInsertFits( 3473 psDB *dbh, ///< Database handle 3474 const psFits *fits ///< psFits object 3475 ); 3476 3477 /** Selects up to limit from the database and returns them in a binary FITS table 3478 * 3479 * This function assumes an empty psFits object and will create a FITS table 3480 * as the first extension. 3481 * 3482 * See psDBSelectRows() for documentation on the format of where. 3483 * 3484 * @return true on success 3485 */ 3486 3487 bool chipMaskSelectRowsFits( 3488 psDB *dbh, ///< Database handle 3489 psFits *fits, ///< psFits object 3490 const psMetadata *where, ///< Row match criteria 3491 unsigned long long limit ///< Maximum number of elements to return 3492 ); 3493 3494 /** Convert a chipMaskRow into an equivalent psMetadata 3495 * 3496 * @return A psMetadata pointer or NULL on error 3497 */ 3498 3499 psMetadata *chipMaskMetadataFromObject( 3500 const chipMaskRow *object ///< fooRow to convert into a psMetadata 3501 ); 3502 3503 /** Convert a psMetadata into an equivalent fooRow 3504 * 3505 * @return A chipMaskRow pointer or NULL on error 3506 */ 3507 3508 chipMaskRow *chipMaskObjectFromMetadata( 3509 psMetadata *md ///< psMetadata to convert into a fooRow 3510 ); 3511 /** Selects up to limit rows from the database and returns as chipMaskRow objects in a psArray 3512 * 3513 * See psDBSelectRows() for documentation on the format of where. 3514 * 3515 * @return A psArray pointer or NULL on error 3516 */ 3517 3518 psArray *chipMaskSelectRowObjects( 3519 psDB *dbh, ///< Database handle 3520 const psMetadata *where, ///< Row match criteria 3521 unsigned long long limit ///< Maximum number of elements to return 3522 ); 3523 /** Deletes a row from the database coresponding to an chipMask 3524 * 3525 * Note that a 'where' search psMetadata is constructed from each object and 3526 * used to find rows to delete. 3527 * 3528 * @return A The number of rows removed or a negative value on error 3529 */ 3530 3531 bool chipMaskDeleteObject( 3532 psDB *dbh, ///< Database handle 3533 const chipMaskRow *object ///< Object to delete 3534 ); 3535 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3536 * 3537 * Note that a 'where' search psMetadata is constructed from each object and 3538 * used to find rows to delete. 3539 * 3540 * @return A The number of rows removed or a negative value on error 3541 */ 3542 3543 long long chipMaskDeleteRowObjects( 3544 psDB *dbh, ///< Database handle 3545 const psArray *objects, ///< Array of objects to delete 3546 unsigned long long limit ///< Maximum number of elements to delete 3547 ); 3548 /** Formats and prints an array of chipMaskRow objects 3549 * 3550 * When mdcf is set the formated output is in psMetadataConfig 3551 * format, otherwise it is in a simple tabular format. 3552 * 3553 * @return true on success 3554 */ 3555 3556 bool chipMaskPrintObjects( 3557 FILE *stream, ///< a stream 3558 psArray *objects, ///< An array of chipMaskRow objects 3559 bool mdcf ///< format as mdconfig or simple 3560 ); 3561 /** Formats and prints an chipMaskRow object 3562 * 3563 * When mdcf is set the formated output is in psMetadataConfig 3564 * format, otherwise it is in a simple tabular format. 3565 * 3566 * @return true on success 3567 */ 3568 3569 bool chipMaskPrintObject( 3570 FILE *stream, ///< a stream 3571 chipMaskRow *object, ///< an chipMaskRow object 3572 bool mdcf ///< format as mdconfig or simple 3573 ); 3574 /** chipProcessedImfileRow data structure 3575 * 3576 * Structure for representing a single row of chipProcessedImfile table data. 3577 */ 3578 3579 typedef struct { 3580 psS64 chip_id; 2987 psS64 exp_id; 3581 2988 char *class_id; 3582 2989 char *uri; … … 3610 3017 chipProcessedImfileRow *chipProcessedImfileRowAlloc( 3611 3018 psS64 chip_id, 3019 psS64 exp_id, 3612 3020 const char *class_id, 3613 3021 const char *uri, … … 3662 3070 psDB *dbh, ///< Database handle 3663 3071 psS64 chip_id, 3072 psS64 exp_id, 3664 3073 const char *class_id, 3665 3074 const char *uri, … … 3833 3242 bool mdcf ///< format as mdconfig or simple 3834 3243 ); 3835 /** camPendingExpRow data structure 3836 * 3837 * Structure for representing a single row of camPendingExp table data. 3244 /** chipMaskRow data structure 3245 * 3246 * Structure for representing a single row of chipMask table data. 3247 */ 3248 3249 typedef struct { 3250 char *label; 3251 } chipMaskRow; 3252 3253 /** Creates a new chipMaskRow object 3254 * 3255 * @return A new chipMaskRow object or NULL on failure. 3256 */ 3257 3258 chipMaskRow *chipMaskRowAlloc( 3259 const char *label 3260 ); 3261 3262 /** Creates a new chipMask table 3263 * 3264 * @return true on success 3265 */ 3266 3267 bool chipMaskCreateTable( 3268 psDB *dbh ///< Database handle 3269 ); 3270 3271 /** Deletes a chipMask table 3272 * 3273 * @return true on success 3274 */ 3275 3276 bool chipMaskDropTable( 3277 psDB *dbh ///< Database handle 3278 ); 3279 3280 /** Insert a single row into a table 3281 * 3282 * This function constructs and inserts a single row based on it's parameters. 3283 * 3284 * @return true on success 3285 */ 3286 3287 bool chipMaskInsert( 3288 psDB *dbh, ///< Database handle 3289 const char *label 3290 ); 3291 3292 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3293 * 3294 * @return A The number of rows removed or a negative value on error 3295 */ 3296 3297 long long chipMaskDelete( 3298 psDB *dbh, ///< Database handle 3299 const psMetadata *where, ///< Row match criteria 3300 unsigned long long limit ///< Maximum number of elements to delete 3301 ); 3302 3303 /** Insert a single chipMaskRow object into a table 3304 * 3305 * This function constructs and inserts a single row based on it's parameters. 3306 * 3307 * @return true on success 3308 */ 3309 3310 bool chipMaskInsertObject( 3311 psDB *dbh, ///< Database handle 3312 chipMaskRow *object ///< chipMaskRow object 3313 ); 3314 3315 /** Insert an array of chipMaskRow object into a table 3316 * 3317 * This function constructs and inserts multiple rows based on it's parameters. 3318 * 3319 * @return true on success 3320 */ 3321 3322 bool chipMaskInsertObjects( 3323 psDB *dbh, ///< Database handle 3324 psArray *objects ///< array of chipMaskRow objects 3325 ); 3326 3327 /** Insert data from a binary FITS table chipMaskRow into the database 3328 * 3329 * This function expects a psFits object with a FITS table as the first 3330 * extension. The table must have at least one row of data in it, that is of 3331 * the appropriate format (number of columns and their type). All other 3332 * extensions are ignored. 3333 * 3334 * @return true on success 3335 */ 3336 3337 bool chipMaskInsertFits( 3338 psDB *dbh, ///< Database handle 3339 const psFits *fits ///< psFits object 3340 ); 3341 3342 /** Selects up to limit from the database and returns them in a binary FITS table 3343 * 3344 * This function assumes an empty psFits object and will create a FITS table 3345 * as the first extension. 3346 * 3347 * See psDBSelectRows() for documentation on the format of where. 3348 * 3349 * @return true on success 3350 */ 3351 3352 bool chipMaskSelectRowsFits( 3353 psDB *dbh, ///< Database handle 3354 psFits *fits, ///< psFits object 3355 const psMetadata *where, ///< Row match criteria 3356 unsigned long long limit ///< Maximum number of elements to return 3357 ); 3358 3359 /** Convert a chipMaskRow into an equivalent psMetadata 3360 * 3361 * @return A psMetadata pointer or NULL on error 3362 */ 3363 3364 psMetadata *chipMaskMetadataFromObject( 3365 const chipMaskRow *object ///< fooRow to convert into a psMetadata 3366 ); 3367 3368 /** Convert a psMetadata into an equivalent fooRow 3369 * 3370 * @return A chipMaskRow pointer or NULL on error 3371 */ 3372 3373 chipMaskRow *chipMaskObjectFromMetadata( 3374 psMetadata *md ///< psMetadata to convert into a fooRow 3375 ); 3376 /** Selects up to limit rows from the database and returns as chipMaskRow objects in a psArray 3377 * 3378 * See psDBSelectRows() for documentation on the format of where. 3379 * 3380 * @return A psArray pointer or NULL on error 3381 */ 3382 3383 psArray *chipMaskSelectRowObjects( 3384 psDB *dbh, ///< Database handle 3385 const psMetadata *where, ///< Row match criteria 3386 unsigned long long limit ///< Maximum number of elements to return 3387 ); 3388 /** Deletes a row from the database coresponding to an chipMask 3389 * 3390 * Note that a 'where' search psMetadata is constructed from each object and 3391 * used to find rows to delete. 3392 * 3393 * @return A The number of rows removed or a negative value on error 3394 */ 3395 3396 bool chipMaskDeleteObject( 3397 psDB *dbh, ///< Database handle 3398 const chipMaskRow *object ///< Object to delete 3399 ); 3400 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 3401 * 3402 * Note that a 'where' search psMetadata is constructed from each object and 3403 * used to find rows to delete. 3404 * 3405 * @return A The number of rows removed or a negative value on error 3406 */ 3407 3408 long long chipMaskDeleteRowObjects( 3409 psDB *dbh, ///< Database handle 3410 const psArray *objects, ///< Array of objects to delete 3411 unsigned long long limit ///< Maximum number of elements to delete 3412 ); 3413 /** Formats and prints an array of chipMaskRow objects 3414 * 3415 * When mdcf is set the formated output is in psMetadataConfig 3416 * format, otherwise it is in a simple tabular format. 3417 * 3418 * @return true on success 3419 */ 3420 3421 bool chipMaskPrintObjects( 3422 FILE *stream, ///< a stream 3423 psArray *objects, ///< An array of chipMaskRow objects 3424 bool mdcf ///< format as mdconfig or simple 3425 ); 3426 /** Formats and prints an chipMaskRow object 3427 * 3428 * When mdcf is set the formated output is in psMetadataConfig 3429 * format, otherwise it is in a simple tabular format. 3430 * 3431 * @return true on success 3432 */ 3433 3434 bool chipMaskPrintObject( 3435 FILE *stream, ///< a stream 3436 chipMaskRow *object, ///< an chipMaskRow object 3437 bool mdcf ///< format as mdconfig or simple 3438 ); 3439 /** camRunRow data structure 3440 * 3441 * Structure for representing a single row of camRun table data. 3838 3442 */ 3839 3443 … … 3841 3445 psS64 cam_id; 3842 3446 psS64 chip_id; 3447 char *state; 3843 3448 char *workdir; 3449 char *workdir_state; 3844 3450 char *label; 3845 3451 char *reduction; 3846 3452 char *expgroup; 3847 3453 char *dvodb; 3848 } cam PendingExpRow;3849 3850 /** Creates a new cam PendingExpRow object3851 * 3852 * @return A new cam PendingExpRow object or NULL on failure.3853 */ 3854 3855 cam PendingExpRow *camPendingExpRowAlloc(3454 } camRunRow; 3455 3456 /** Creates a new camRunRow object 3457 * 3458 * @return A new camRunRow object or NULL on failure. 3459 */ 3460 3461 camRunRow *camRunRowAlloc( 3856 3462 psS64 cam_id, 3857 3463 psS64 chip_id, 3464 const char *state, 3858 3465 const char *workdir, 3466 const char *workdir_state, 3859 3467 const char *label, 3860 3468 const char *reduction, … … 3863 3471 ); 3864 3472 3865 /** Creates a new cam PendingExptable3866 * 3867 * @return true on success 3868 */ 3869 3870 bool cam PendingExpCreateTable(3473 /** Creates a new camRun table 3474 * 3475 * @return true on success 3476 */ 3477 3478 bool camRunCreateTable( 3871 3479 psDB *dbh ///< Database handle 3872 3480 ); 3873 3481 3874 /** Deletes a cam PendingExptable3875 * 3876 * @return true on success 3877 */ 3878 3879 bool cam PendingExpDropTable(3482 /** Deletes a camRun table 3483 * 3484 * @return true on success 3485 */ 3486 3487 bool camRunDropTable( 3880 3488 psDB *dbh ///< Database handle 3881 3489 ); … … 3888 3496 */ 3889 3497 3890 bool cam PendingExpInsert(3498 bool camRunInsert( 3891 3499 psDB *dbh, ///< Database handle 3892 3500 psS64 cam_id, 3893 3501 psS64 chip_id, 3502 const char *state, 3894 3503 const char *workdir, 3504 const char *workdir_state, 3895 3505 const char *label, 3896 3506 const char *reduction, … … 3904 3514 */ 3905 3515 3906 long long cam PendingExpDelete(3516 long long camRunDelete( 3907 3517 psDB *dbh, ///< Database handle 3908 3518 const psMetadata *where, ///< Row match criteria … … 3910 3520 ); 3911 3521 3912 /** Insert a single cam PendingExpRow object into a table3522 /** Insert a single camRunRow object into a table 3913 3523 * 3914 3524 * This function constructs and inserts a single row based on it's parameters. … … 3917 3527 */ 3918 3528 3919 bool cam PendingExpInsertObject(3920 psDB *dbh, ///< Database handle 3921 cam PendingExpRow *object ///< camPendingExpRow object3922 ); 3923 3924 /** Insert an array of cam PendingExpRow object into a table3529 bool camRunInsertObject( 3530 psDB *dbh, ///< Database handle 3531 camRunRow *object ///< camRunRow object 3532 ); 3533 3534 /** Insert an array of camRunRow object into a table 3925 3535 * 3926 3536 * This function constructs and inserts multiple rows based on it's parameters. … … 3929 3539 */ 3930 3540 3931 bool cam PendingExpInsertObjects(3932 psDB *dbh, ///< Database handle 3933 psArray *objects ///< array of cam PendingExpRow objects3934 ); 3935 3936 /** Insert data from a binary FITS table cam PendingExpRow into the database3541 bool camRunInsertObjects( 3542 psDB *dbh, ///< Database handle 3543 psArray *objects ///< array of camRunRow objects 3544 ); 3545 3546 /** Insert data from a binary FITS table camRunRow into the database 3937 3547 * 3938 3548 * This function expects a psFits object with a FITS table as the first … … 3944 3554 */ 3945 3555 3946 bool cam PendingExpInsertFits(3556 bool camRunInsertFits( 3947 3557 psDB *dbh, ///< Database handle 3948 3558 const psFits *fits ///< psFits object … … 3959 3569 */ 3960 3570 3961 bool cam PendingExpSelectRowsFits(3571 bool camRunSelectRowsFits( 3962 3572 psDB *dbh, ///< Database handle 3963 3573 psFits *fits, ///< psFits object … … 3966 3576 ); 3967 3577 3968 /** Convert a cam PendingExpRow into an equivalent psMetadata3578 /** Convert a camRunRow into an equivalent psMetadata 3969 3579 * 3970 3580 * @return A psMetadata pointer or NULL on error 3971 3581 */ 3972 3582 3973 psMetadata *cam PendingExpMetadataFromObject(3974 const cam PendingExpRow *object ///< fooRow to convert into a psMetadata3583 psMetadata *camRunMetadataFromObject( 3584 const camRunRow *object ///< fooRow to convert into a psMetadata 3975 3585 ); 3976 3586 3977 3587 /** Convert a psMetadata into an equivalent fooRow 3978 3588 * 3979 * @return A cam PendingExpRow pointer or NULL on error3980 */ 3981 3982 cam PendingExpRow *camPendingExpObjectFromMetadata(3589 * @return A camRunRow pointer or NULL on error 3590 */ 3591 3592 camRunRow *camRunObjectFromMetadata( 3983 3593 psMetadata *md ///< psMetadata to convert into a fooRow 3984 3594 ); 3985 /** Selects up to limit rows from the database and returns as cam PendingExpRow objects in a psArray3595 /** Selects up to limit rows from the database and returns as camRunRow objects in a psArray 3986 3596 * 3987 3597 * See psDBSelectRows() for documentation on the format of where. … … 3990 3600 */ 3991 3601 3992 psArray *cam PendingExpSelectRowObjects(3602 psArray *camRunSelectRowObjects( 3993 3603 psDB *dbh, ///< Database handle 3994 3604 const psMetadata *where, ///< Row match criteria 3995 3605 unsigned long long limit ///< Maximum number of elements to return 3996 3606 ); 3997 /** Deletes a row from the database coresponding to an cam PendingExp3607 /** Deletes a row from the database coresponding to an camRun 3998 3608 * 3999 3609 * Note that a 'where' search psMetadata is constructed from each object and … … 4003 3613 */ 4004 3614 4005 bool cam PendingExpDeleteObject(4006 psDB *dbh, ///< Database handle 4007 const cam PendingExpRow *object ///< Object to delete3615 bool camRunDeleteObject( 3616 psDB *dbh, ///< Database handle 3617 const camRunRow *object ///< Object to delete 4008 3618 ); 4009 3619 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. … … 4015 3625 */ 4016 3626 4017 long long cam PendingExpDeleteRowObjects(3627 long long camRunDeleteRowObjects( 4018 3628 psDB *dbh, ///< Database handle 4019 3629 const psArray *objects, ///< Array of objects to delete 4020 3630 unsigned long long limit ///< Maximum number of elements to delete 4021 3631 ); 4022 /** Formats and prints an array of cam PendingExpRow objects3632 /** Formats and prints an array of camRunRow objects 4023 3633 * 4024 3634 * When mdcf is set the formated output is in psMetadataConfig … … 4028 3638 */ 4029 3639 4030 bool cam PendingExpPrintObjects(3640 bool camRunPrintObjects( 4031 3641 FILE *stream, ///< a stream 4032 psArray *objects, ///< An array of cam PendingExpRow objects3642 psArray *objects, ///< An array of camRunRow objects 4033 3643 bool mdcf ///< format as mdconfig or simple 4034 3644 ); 4035 /** Formats and prints an cam PendingExpRow object3645 /** Formats and prints an camRunRow object 4036 3646 * 4037 3647 * When mdcf is set the formated output is in psMetadataConfig … … 4041 3651 */ 4042 3652 4043 bool cam PendingExpPrintObject(3653 bool camRunPrintObject( 4044 3654 FILE *stream, ///< a stream 4045 cam PendingExpRow *object, ///< an camPendingExpRow object3655 camRunRow *object, ///< an camRunRow object 4046 3656 bool mdcf ///< format as mdconfig or simple 4047 3657 ); … … 4054 3664 psS64 cam_id; 4055 3665 psS64 chip_id; 4056 char *workdir;4057 char *label;4058 char *reduction;4059 char *expgroup;4060 char *dvodb;4061 3666 char *uri; 4062 3667 psF32 bg; … … 4085 3690 psS64 cam_id, 4086 3691 psS64 chip_id, 4087 const char *workdir,4088 const char *label,4089 const char *reduction,4090 const char *expgroup,4091 const char *dvodb,4092 3692 const char *uri, 4093 3693 psF32 bg, … … 4137 3737 psS64 cam_id, 4138 3738 psS64 chip_id, 4139 const char *workdir,4140 const char *label,4141 const char *reduction,4142 const char *expgroup,4143 const char *dvodb,4144 3739 const char *uri, 4145 3740 psF32 bg, … … 6871 6466 psS64 det_id; 6872 6467 psS32 iteration; 6873 char *exp_tag;6468 psS64 exp_id; 6874 6469 bool include; 6875 6470 } detInputExpRow; … … 6883 6478 psS64 det_id, 6884 6479 psS32 iteration, 6885 const char *exp_tag,6480 psS64 exp_id, 6886 6481 bool include 6887 6482 ); … … 6916 6511 psS64 det_id, 6917 6512 psS32 iteration, 6918 const char *exp_tag,6513 psS64 exp_id, 6919 6514 bool include 6920 6515 ); … … 7074 6669 typedef struct { 7075 6670 psS64 det_id; 7076 char *exp_tag;6671 psS64 exp_id; 7077 6672 char *class_id; 7078 6673 char *uri; … … 7100 6695 detProcessedImfileRow *detProcessedImfileRowAlloc( 7101 6696 psS64 det_id, 7102 const char *exp_tag,6697 psS64 exp_id, 7103 6698 const char *class_id, 7104 6699 const char *uri, … … 7147 6742 psDB *dbh, ///< Database handle 7148 6743 psS64 det_id, 7149 const char *exp_tag,6744 psS64 exp_id, 7150 6745 const char *class_id, 7151 6746 const char *uri, … … 7320 6915 typedef struct { 7321 6916 psS64 det_id; 7322 char *exp_tag;6917 psS64 exp_id; 7323 6918 char *recipe; 7324 6919 psF64 bg; … … 7344 6939 detProcessedExpRow *detProcessedExpRowAlloc( 7345 6940 psS64 det_id, 7346 const char *exp_tag,6941 psS64 exp_id, 7347 6942 const char *recipe, 7348 6943 psF64 bg, … … 7389 6984 psDB *dbh, ///< Database handle 7390 6985 psS64 det_id, 7391 const char *exp_tag,6986 psS64 exp_id, 7392 6987 const char *recipe, 7393 6988 psF64 bg, … … 8467 8062 psS64 det_id; 8468 8063 psS32 iteration; 8469 char *exp_tag;8064 psS64 exp_id; 8470 8065 char *class_id; 8471 8066 char *uri; … … 8495 8090 psS64 det_id, 8496 8091 psS32 iteration, 8497 const char *exp_tag,8092 psS64 exp_id, 8498 8093 const char *class_id, 8499 8094 const char *uri, … … 8544 8139 psS64 det_id, 8545 8140 psS32 iteration, 8546 const char *exp_tag,8141 psS64 exp_id, 8547 8142 const char *class_id, 8548 8143 const char *uri, … … 8719 8314 psS64 det_id; 8720 8315 psS32 iteration; 8721 char *exp_tag;8316 psS64 exp_id; 8722 8317 char *recipe; 8723 8318 psF64 bg; … … 8746 8341 psS64 det_id, 8747 8342 psS32 iteration, 8748 const char *exp_tag,8343 psS64 exp_id, 8749 8344 const char *recipe, 8750 8345 psF64 bg, … … 8794 8389 psS64 det_id, 8795 8390 psS32 iteration, 8796 const char *exp_tag,8391 psS64 exp_id, 8797 8392 const char *recipe, 8798 8393 psF64 bg,
Note:
See TracChangeset
for help on using the changeset viewer.
