- Timestamp:
- Oct 15, 2010, 6:39:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/haf_branches/ipp.rsync.20101015/ippTools/src/minidvodbtool.c
r29435 r29440 28 28 #include "pxtools.h" 29 29 #include "pxadd.h" 30 #include "pxminidvodb.h" 30 31 #include "minidvodbtool.h" 31 32 … … 90 91 psMetadata *where = psMetadataAlloc(); 91 92 pxcamGetSearchArgs (config, where); 92 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 93 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 94 pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label 95 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 93 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbRun.minidvodbRun_id", "=="); 94 pxAddLabelSearchArgs (config, where, "-minidvodb_group", "minidvodbRun.minidvodb_group", "=="); // define using camRun label 95 96 96 97 97 … … 102 102 } 103 103 104 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 105 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 106 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 107 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 108 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 109 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 110 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 111 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false); 112 PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false); 113 PXOPT_LOOKUP_BOOL(minidvodb, config->args, "-set_minidvodb", false); 114 PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false); 104 PXOPT_LOOKUP_STR(destination_host, config->args, "-set_destination_host", false, false); 105 PXOPT_LOOKUP_STR(minidvodb_rsync_path, config->args, "-set_minidvodb_rsync_path", false, false); 115 106 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 116 107 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 120 111 psString dvodb_string = NULL; 121 112 psString bare_query = NULL; 122 if (d vodb) {123 psTrace(" addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n", dvodb);113 if (destination_host) { 114 psTrace("minidvodbtool.c", PS_LOG_INFO, "destination_host argument found (%s) using minidvodbtool_find_minidvodb_id_dvo.sql\n", destination_host); 124 115 // find the cam_id of all the exposures that we want to queue up. 125 bare_query = pxDataGet(" addtool_find_cam_id_dvo.sql");116 bare_query = pxDataGet("minidvodbtool_find_minidvodb_id_dvo.sql"); 126 117 // user supplied dvodb 127 psStringAppend(&dvodb_string, " addRun.dvodb = '%s'", dvodb);118 psStringAppend(&dvodb_string, "minidvodbCopy.destination_host = '%s'", destination_host); 128 119 } else { 129 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n"); 130 // find the cam_id of all the exposures that we want to queue up. 131 bare_query = pxDataGet("addtool_find_cam_id.sql"); 132 // inherit dvodb from camRun, avoid matching NULL 133 psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)"); 134 } 120 psError(PS_ERR_UNKNOWN, false, "cannot queue minidvodbcopy run without a defined destination_host"); 121 122 return false; 123 } 135 124 if (!bare_query) { 136 125 psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement"); … … 155 144 psFree(where); 156 145 157 if (destreaked) { 158 psStringAppend(&query, " AND (camRun.magicked > 0)"); 159 } 160 161 if (!p_psDBRunQuery(config->dbh, query)) { 146 if (!p_psDBRunQuery(config->dbh, query)) { 162 147 psError(PS_ERR_UNKNOWN, false, "database error"); 163 148 psFree(query); … … 179 164 if (pretend) { 180 165 // negative simple so the default is true 181 if (!ippdbPrintMetadatas(stdout, output, " addRun", !simple)) {166 if (!ippdbPrintMetadatas(stdout, output, "minidvodbCopy", !simple)) { 182 167 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 183 168 psFree(output); … … 192 177 psMetadata *md = output->data[i]; 193 178 194 camRunRow *row = camRunObjectFromMetadata(md);179 minidvodbRunRow *row = minidvodbRunObjectFromMetadata(md); 195 180 if (!row) { 196 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");181 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into minidvodbRun"); 197 182 psFree(output); 198 183 return false; 199 184 } 200 185 201 if (! dvodb && !row->dvodb) {202 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);186 if (!minidvodb_rsync_path) { 187 psError(PS_ERR_UNKNOWN, false, "cannot queue minidvodbcopy run without a defined minidvodb_rsync_path: minidvodb_id %" PRId64, row->minidvodb_id); 203 188 psFree(output); 204 189 return false; 205 190 } 206 if (! workdir && !row->workdir) {207 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);191 if (!destination_host) { 192 psError(PS_ERR_UNKNOWN, false, "cannot queue minidvodbcopy run without a defined destination_host: minidvodb_id %" PRId64, row->minidvodb_id); 208 193 psFree(output); 209 194 return false; … … 230 215 psMetadata *md = output->data[i]; 231 216 232 camRunRow *row = camRunObjectFromMetadata(md);217 minidvodbRunRow *row = minidvodbRunObjectFromMetadata(md); 233 218 if (!row) { 234 219 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); … … 238 223 239 224 // queue the exp 240 if (!pxaddQueueByCamID(config, 241 row->cam_id, 242 workdir ? workdir : row->workdir, 243 reduction ? reduction : row->reduction, 244 label ? label : row->label, 245 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 246 dvodb ? dvodb : row->dvodb, 247 note ? note : NULL, 248 image_only, 249 minidvodb, 250 minidvodb_group, 251 minidvodb_name 225 if (!pxaddQueueByMinidvodbID(config, 226 row->minidvodb_id, 227 destination_host ? destination_host : "NULL", 228 minidvodb_rsync_path ?minidvodb_rsync_path : "NULL" 252 229 )) { 253 230 if (!psDBRollback(config->dbh)) { … … 255 232 } 256 233 psError(PS_ERR_UNKNOWN, false, 257 "failed to trying to queue chip_id: %" PRId64, row->cam_id);234 "failed to trying to queue minidvodb_id: %" PRId64, row->minidvodb_id); 258 235 psFree(row); 259 236 psFree(output); … … 553 530 psMetadata *where = psMetadataAlloc(); 554 531 PS_ASSERT_PTR_NON_NULL(config, false); 555 PXOPT_COPY_S64(config->args, where, "-minidvodb _id", "minidvodbCopy.minidvodb_id", "==");556 PXOPT_COPY_STR(config->args, where, "- minidvodb_group", "addRun.minidvodb_group", "==");532 PXOPT_COPY_S64(config->args, where, "-minidvodbcopy_id", "minidvodbCopy.minidvodbcopy_id", "=="); 533 PXOPT_COPY_STR(config->args, where, "-destination_host", "destination host", "=="); 557 534 558 535 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { … … 614 591 PS_ASSERT_PTR_NON_NULL(config, false); 615 592 psMetadata *where = psMetadataAlloc(); 616 617 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 618 PXOPT_LOOKUP_U64(merge_order, config->args, "-set_merge_order", false, false); 619 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 620 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-set_dtime_relphot", false, false); 621 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-set_dtime_resort", false, false); 622 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-set_dtime_merge", false, false); 623 593 PXOPT_LOOKUP_U64(minidvodbcopy_id, config->args, "-minidvodbcopy_id", false, false); 594 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", false, false); 595 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 596 PXOPT_LOOKUP_STR(host, config->args, "-host", false, false); 597 PXOPT_LOOKUP_STR(rsync_path, config->args, "-minidvodb_rsync_path", false, false); 598 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 599 600 PXOPT_LOOKUP_S16(set_fault, config->args, "-set_fault", false, false); 601 PXOPT_LOOKUP_STR(set_rsync_path, config->args, "-set_minidvodb_rsync_path", false, false); 602 PXOPT_LOOKUP_STR(set_host, config->args, "-set_destination_host", false, false); 603 PXOPT_LOOKUP_STR(set_state, config->args, "-set_state", false, false); 604 PXOPT_LOOKUP_F32(dtime, config->args, "-set_dtime", false, false); 605 PXOPT_COPY_S64(config->args, where, "-minidvodbcopy_id", "minidvodbCopy.minidvodbcopy_id", "=="); 624 606 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbCopy.minidvodb_id", "=="); 625 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "=="); 607 608 PXOPT_COPY_STR(config->args, where, "-state", "minidvodbCopy.state", "=="); 609 PXOPT_COPY_STR(config->args, where, "-host", "minidvodbCopy.destination_host", "=="); 610 PXOPT_COPY_STR(config->args, where, "-minidvodb_rsync_path", "minidvodbCopy.minidvodb_rsync_path", "=="); 626 611 627 612 … … 635 620 int cnt = 0; 636 621 psString comma = ","; 637 if ( fault) {638 psStringAppend(&query, " fault = %d", fault);622 if (set_fault) { 623 psStringAppend(&query, " fault = %d", set_fault); 639 624 cnt++; 640 625 } 641 626 642 if ( merge_order) {627 if (set_rsync_path) { 643 628 if (cnt) { 644 629 psStringAppend(&query, "%s", comma); 645 630 } 646 631 647 psStringAppend(&query, " m erge_order = %" PRId64, merge_order);632 psStringAppend(&query, " minidvodb_rsync_path = %s" , set_rsync_path); 648 633 cnt++; 649 634 } 650 635 651 if ( dtime_relphot) {636 if (set_host) { 652 637 if (cnt) { 653 638 psStringAppend(&query, "%s", comma); 654 639 } 655 psStringAppend(&query, " dtime_relphot = %f", dtime_relphot); 640 641 psStringAppend(&query, " destination_host = %s" , set_host); 656 642 cnt++; 657 643 } 658 644 659 if (dtime_resort) { 645 646 if (set_state) { 660 647 if (cnt) { 661 648 psStringAppend(&query, "%s", comma); 662 649 } 663 psStringAppend(&query, " dtime_resort = %f", dtime_resort); 650 651 psStringAppend(&query, " state = %s" , set_state); 664 652 cnt++; 665 653 } 666 654 667 if (dtime _merge) {655 if (dtime) { 668 656 if (cnt) { 669 657 psStringAppend(&query, "%s", comma); 670 658 } 671 psStringAppend(&query, " dtime _merge = %f", dtime_merge);659 psStringAppend(&query, " dtime = %f", dtime); 672 660 cnt++; 673 } 661 } 662 663 674 664 675 665 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.
