IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 13, 2006, 5:15:56 PM (20 years ago)
Author:
jhoblitt
Message:

VERSION 0.0.55

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippdb/src/ippdb.c

    r9796 r9970  
    234234static void summitExpRowFree(summitExpRow *object);
    235235
    236 summitExpRow *summitExpRowAlloc(const char *exp_id, const char *camera, const char *telescope, const char *exp_type, const char *uri)
     236summitExpRow *summitExpRowAlloc(const char *exp_id, const char *camera, const char *telescope, psTime* time, const char *exp_type, const char *uri)
    237237{
    238238    summitExpRow    *_object;
     
    244244    _object->camera = psStringCopy(camera);
    245245    _object->telescope = psStringCopy(telescope);
     246    _object->time = psTimeCopy(time);
    246247    _object->exp_type = psStringCopy(exp_type);
    247248    _object->uri = psStringCopy(uri);
     
    255256    psFree(object->camera);
    256257    psFree(object->telescope);
     258    psFree(object->time);
    257259    psFree(object->exp_type);
    258260    psFree(object->uri);
     
    277279        return false;
    278280    }
     281    psTime* time = psTimeFromISO("", PS_TIME_UTC);
     282    if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, time)) {
     283        psFree(time);
     284        psError(PS_ERR_UNKNOWN, false, "failed to add item time");
     285        psFree(md);
     286        return false;
     287    }
     288    psFree(time);
    279289    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, "64")) {
    280290        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type");
     
    300310}
    301311
    302 bool summitExpInsert(psDB * dbh, const char *exp_id, const char *camera, const char *telescope, const char *exp_type, const char *uri)
     312bool summitExpInsert(psDB * dbh, const char *exp_id, const char *camera, const char *telescope, psTime* time, const char *exp_type, const char *uri)
    303313{
    304314    psMetadata *md = psMetadataAlloc();
     
    315325    if (!psMetadataAdd(md, PS_LIST_TAIL, "telescope", PS_DATA_STRING, NULL, telescope)) {
    316326        psError(PS_ERR_UNKNOWN, false, "failed to add item telescope");
     327        psFree(md);
     328        return false;
     329    }
     330    if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, time)) {
     331        psError(PS_ERR_UNKNOWN, false, "failed to add item time");
    317332        psFree(md);
    318333        return false;
     
    351366bool summitExpInsertObject(psDB *dbh, summitExpRow *object)
    352367{
    353     return summitExpInsert(dbh, object->exp_id, object->camera, object->telescope, object->exp_type, object->uri);
     368    return summitExpInsert(dbh, object->exp_id, object->camera, object->telescope, object->time, object->exp_type, object->uri);
    354369}
    355370
     
    439454        return false;
    440455    }
     456    if (!psMetadataAdd(md, PS_LIST_TAIL, "time", PS_DATA_TIME, NULL, object->time)) {
     457        psError(PS_ERR_UNKNOWN, false, "failed to add item time");
     458        psFree(md);
     459        return false;
     460    }
    441461    if (!psMetadataAdd(md, PS_LIST_TAIL, "exp_type", PS_DATA_STRING, NULL, object->exp_type)) {
    442462        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type");
     
    473493        return false;
    474494    }
     495    psTime* time = psMetadataLookupPtr(&status, md, "time");
     496    if (!status) {
     497        psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item time");
     498        return false;
     499    }
    475500    char* exp_type = psMetadataLookupPtr(&status, md, "exp_type");
    476501    if (!status) {
     
    484509    }
    485510
    486     return summitExpRowAlloc(exp_id, camera, telescope, exp_type, uri);
     511    return summitExpRowAlloc(exp_id, camera, telescope, time, exp_type, uri);
    487512}
    488513psArray *summitExpSelectRowObjects(psDB *dbh, const psMetadata *where, unsigned long long limit)
Note: See TracChangeset for help on using the changeset viewer.