IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6214


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

factor out 'where' query from parameter generation

Location:
trunk/ippTools/src
Files:
5 edited

Legend:

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

    r6210 r6214  
    116116    EMPTY_TO_NULL_STRING(config->url);
    117117
     118    psMetadata *where = psMetadataAlloc();
     119
     120    if (config->camera_name != NULL) {
     121        if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
     122            config->camera_name)) {
     123            psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
     124            psFree(where);
     125            return NULL;
     126        }
     127    }
     128    if (config->filter != NULL) {
     129        psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
     130            config->filter);
     131    }
     132    if (config->exp_id != NULL) {
     133        psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
     134            config->exp_id);
     135    }
     136    if (config->class != NULL) {
     137        psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
     138            config->class);
     139    }
     140    if (config->class_id != NULL) {
     141        psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
     142             config->class_id);
     143    }
     144
     145    /*
     146    // psMetadataConfig does not support times yet
     147    if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {
     148        psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);
     149        psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);
     150    }
     151    */
     152
     153    if (where->list->n < 1) {
     154        psFree(where);
     155        where = NULL;
     156    }
     157
     158    config->where = where;
     159
     160
    118161    // add the input and output images to the arguments list
    119162    //psMetadataAddStr (config->arguments, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);
  • trunk/ippTools/src/p2searchDoneFrames.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 (where->list->n < 1) {
    19        psFree(where);
    20        where = NULL;
    21     }
    22 
    23     psArray *exposures = p2DoneExpSelectRowObjects(config->database, where,
    24         MAX_ROWS);
    25     psFree (where);
     7    psArray *exposures = p2DoneExpSelectRowObjects(config->database,
     8        config->where, MAX_ROWS);
    269    if (!exposures) {
    2710        psError(PS_ERR_UNKNOWN, false, "no p2DoneExp rows found");
     
    3417    frames->n = 0;
    3518
    36     // 'where' to select each exposure
    37     where = psMetadataAlloc ();
    3819    for (int i = 0; i < exposures->n; i++) {
    3920        p2DoneExpRow *exposure = exposures->data[i];
    4021
     22        // 'where' to select each exposure
     23        psMetadata *where = psMetadataAlloc ();
    4124        psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", PS_META_REPLACE, "==",
    4225            exposure->exp_id);
     
    4427        psArray *images = p2DoneImfileSelectRowObjects(config->database, where,
    4528            MAX_ROWS);
     29        psFree(where);
    4630        if (!images) {
    4731            psError(PS_ERR_UNKNOWN, false, "database access failed");
  • 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");
  • trunk/ippTools/src/p2searchRawFrames.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     // psMetadataConfig does not support times yet
    18     /*
    19     if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {
    20         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);
    21         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);
    22     }
    23     */
    24 
    25     // if no search criteria were added then set where to NULL to search for
    26     // everything
    27     // XXX fix handling of where
    28     if (where->list->n < 1) {
    29         psFree(where);
    30         where = NULL;
    31     }
    32 
    33     psArray *exposures = rawScienceExpSelectRowObjects(config->database, where,
    34         MAX_ROWS);
    35     psFree(where);
     7    psArray *exposures = rawScienceExpSelectRowObjects(config->database,
     8        config->where, MAX_ROWS);
    369    if (!exposures) {
    3710        psError(PS_ERR_UNKNOWN, false, "no rawScienceExp rows found");
     
    4518
    4619    // 'where' to select each exposure
    47     where = psMetadataAlloc ();
     20    psMetadata *where = psMetadataAlloc ();
    4821    for (int i = 0; i < exposures->n; i++) {
    4922        rawScienceExpRow *exposure = exposures->data[i];
  • trunk/ippTools/src/pxtools.h

    r6210 r6214  
    4444    char *class_id;
    4545    char *url;
     46    psMetadata *where;
    4647} pxConfig;
    4748
Note: See TracChangeset for help on using the changeset viewer.