IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2006, 1:48:43 PM (20 years ago)
Author:
jhoblitt
Message:

factor out 'where' query from parameter generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/p2searchPendingFrames.c

    r6210 r6214  
    55    PS_ASSERT_PTR_NON_NULL(config, NULL);
    66
    7     psMetadata *where = psMetadataAlloc();
    8 
    9     if (config->camera_name != NULL) {
    10         psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
    11             config->camera_name);
    12     }
    13     if (config->filter != NULL) {
    14         psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
    15             config->filter);
    16     }
    17     /*
    18     if (config->exp_id != NULL) {
    19         psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
    20             config->exp_id);
    21     }
    22     if (config->class != NULL) {
    23         psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
    24             config->class);
    25     }
    26     if (config->class_id != NULL) {
    27         psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
    28             config->class_id);
    29     }
    30     */
    31     /*
    32     if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {
    33         psMetadataAddTime(where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);
    34         psMetadataAddTime(where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);
    35     }
    36     */
    37 
    38     // if no search criteria were added then set where to NULL to search for
    39     // everything
    40     // XXX fix handling of where
    41     if (where->list->n < 1) {
    42         psFree(where);
    43         where = NULL;
    44     }
    45 
    46     psArray *exposures = p2PendingExpSelectRowObjects(config->database, where, MAX_ROWS);
    47     psFree(where);
     7    psArray *exposures = p2PendingExpSelectRowObjects(config->database,
     8        config->where, MAX_ROWS);
    489    if (!exposures) {
    4910        psError(PS_ERR_UNKNOWN, false, "no p2PendingExp rows found");
     
    5718
    5819    // 'where' to select each exposure
    59     where = psMetadataAlloc();
     20    psMetadata *where = psMetadataAlloc();
    6021    for (int i = 0; i < exposures->n; i++) {
    6122        p2PendingExpRow *exposure = exposures->data[i];
     
    8243    PS_ASSERT_PTR_NON_NULL(config, NULL);
    8344
    84     psMetadata *where = psMetadataAlloc();
    85     if (config->camera_name != NULL) {
    86         if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
    87             config->camera_name)) {
    88             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    89             psFree(where);
    90             return NULL;
    91         }
    92     }
    93     if (config->filter != NULL) {
    94         psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
    95             config->filter);
    96     }
    97     if (config->exp_id != NULL) {
    98         psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
    99             config->exp_id);
    100     }
    101     if (config->class != NULL) {
    102         psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
    103             config->class);
    104     }
    105     if (config->class_id != NULL) {
    106         psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
    107             config->class_id);
    108     }
    109 
    110     if (where->list->n < 1) {
    111         psFree(where);
    112         where = NULL;
    113     }
    114 
    115     psArray *imfiles = p2PendingImfileSelectRowObjects(config->database, where,
    116         MAX_ROWS);
    117     psFree(where);
     45    psArray *imfiles = p2PendingImfileSelectRowObjects(config->database,
     46        config->where, MAX_ROWS);
    11847    if (!imfiles) {
    11948        psError(PS_ERR_UNKNOWN, false, "no rawScienceExp rows found");
     
    12958    PS_ASSERT_PTR_NON_NULL(config, NULL);
    13059
    131     psMetadata *where = psMetadataAlloc();
    132     if (config->camera_name != NULL) {
    133         if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
    134             config->camera_name)) {
    135             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
    136             psFree(where);
    137             return NULL;
    138         }
    139     }
    140     if (config->filter != NULL) {
    141         psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
    142             config->filter);
    143     }
    144     if (config->exp_id != NULL) {
    145         psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
    146             config->exp_id);
    147     }
    148     if (config->class != NULL) {
    149         psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
    150             config->class);
    151     }
    152     if (config->class_id != NULL) {
    153         psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
    154             config->class_id);
    155     }
    156 
    157     if (where->list->n < 1) {
    158         psFree(where);
    159         where = NULL;
    160     }
    161 
    162     psArray *exps = p2PendingExpSelectRowObjects(config->database, where,
     60    psArray *exps = p2PendingExpSelectRowObjects(config->database,
     61        config->where,
    16362        MAX_ROWS);
    164     psFree(where);
    16563    if (!exps) {
    16664        psError(PS_ERR_UNKNOWN, false, "no p2PendingExp rows found");
Note: See TracChangeset for help on using the changeset viewer.