IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 15, 2010, 6:39:07 PM (16 years ago)
Author:
heather
Message:

minidvodbtool -update and -defineby work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/haf_branches/ipp.rsync.20101015/ippTools/src/minidvodbtool.c

    r29435 r29440  
    2828#include "pxtools.h"
    2929#include "pxadd.h"
     30#include "pxminidvodb.h"
    3031#include "minidvodbtool.h"
    3132
     
    9091    psMetadata *where = psMetadataAlloc();
    9192    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   
    9696
    9797
     
    102102    }
    103103
    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);
    115106    PXOPT_LOOKUP_BOOL(pretend,    config->args, "-pretend", false);
    116107    PXOPT_LOOKUP_BOOL(simple,     config->args, "-simple", false);
     
    120111    psString dvodb_string = NULL;
    121112    psString bare_query = NULL;
    122     if (dvodb) {
    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);
    124115        // 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");
    126117        // user supplied dvodb
    127         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     118        psStringAppend(&dvodb_string, "minidvodbCopy.destination_host = '%s'", destination_host);
    128119    } 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         }
    135124    if (!bare_query) {
    136125        psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     
    155144    psFree(where);
    156145
    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)) {
    162147        psError(PS_ERR_UNKNOWN, false, "database error");
    163148        psFree(query);
     
    179164    if (pretend) {
    180165        // negative simple so the default is true
    181         if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
     166        if (!ippdbPrintMetadatas(stdout, output, "minidvodbCopy", !simple)) {
    182167            psError(PS_ERR_UNKNOWN, false, "failed to print array");
    183168            psFree(output);
     
    192177        psMetadata *md = output->data[i];
    193178
    194         camRunRow *row = camRunObjectFromMetadata(md);
     179        minidvodbRunRow *row = minidvodbRunObjectFromMetadata(md);
    195180        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");
    197182            psFree(output);
    198183            return false;
    199184        }
    200185
    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);
    203188            psFree(output);
    204189            return false;
    205190        }
    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);
    208193            psFree(output);
    209194            return false;
     
    230215        psMetadata *md = output->data[i];
    231216
    232         camRunRow *row = camRunObjectFromMetadata(md);
     217        minidvodbRunRow *row = minidvodbRunObjectFromMetadata(md);
    233218        if (!row) {
    234219            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     
    238223
    239224        // 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"
    252229        )) {
    253230            if (!psDBRollback(config->dbh)) {
     
    255232            }
    256233            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);
    258235            psFree(row);
    259236            psFree(output);
     
    553530  psMetadata *where = psMetadataAlloc();
    554531  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", "==");
    557534
    558535  if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    614591  PS_ASSERT_PTR_NON_NULL(config, false);
    615592  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", "==");
    624606  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", "==");
    626611
    627612
     
    635620  int cnt = 0;
    636621  psString comma = ",";
    637   if (fault) {
    638     psStringAppend(&query, " fault = %d", fault);
     622  if (set_fault) {
     623    psStringAppend(&query, " fault = %d", set_fault);
    639624  cnt++;
    640625  }
    641626
    642   if (merge_order) {
     627  if (set_rsync_path) {
    643628    if (cnt) {
    644629      psStringAppend(&query, "%s", comma);
    645630    }
    646631
    647     psStringAppend(&query, " merge_order = %" PRId64, merge_order);
     632    psStringAppend(&query, " minidvodb_rsync_path = %s" , set_rsync_path);
    648633    cnt++;
    649634  }
    650635
    651   if (dtime_relphot) {
     636  if (set_host) {
    652637    if (cnt) {
    653638      psStringAppend(&query, "%s", comma);
    654639    }
    655     psStringAppend(&query, " dtime_relphot = %f", dtime_relphot);
     640
     641    psStringAppend(&query, " destination_host = %s" , set_host);
    656642    cnt++;
    657643  }
    658644
    659   if (dtime_resort) {
     645
     646  if (set_state) {
    660647    if (cnt) {
    661648      psStringAppend(&query, "%s", comma);
    662649    }
    663     psStringAppend(&query, " dtime_resort = %f", dtime_resort);
     650
     651    psStringAppend(&query, " state = %s" , set_state);
    664652    cnt++;
    665653  }
    666654
    667   if (dtime_merge) {
     655  if (dtime) {
    668656    if (cnt) {
    669657      psStringAppend(&query, "%s", comma);
    670658    }
    671     psStringAppend(&query, " dtime_merge = %f", dtime_merge);
     659    psStringAppend(&query, " dtime = %f", dtime);
    672660    cnt++;
    673  }
     661  }
     662
     663 
    674664
    675665  psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
Note: See TracChangeset for help on using the changeset viewer.