IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 17, 2006, 3:06:05 PM (20 years ago)
Author:
jhoblitt
Message:

misc changes

File:
1 edited

Legend:

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

    r6670 r6877  
    66static bool pendingMode(pxConfig *config);
    77static bool copydoneMode(pxConfig *config);
    8 bool summitExpPrint(FILE *stream, summitExpRow *summitExp);
    9 psArray *pzsearchPendingImfiles(pxConfig *config);
    10 bool pzsearchFlushPendingExp(pxConfig *config);
     8static bool summitExpPrint(FILE *stream, summitExpRow *summitExp);
     9static psArray *pzsearchPendingExp(pxConfig *config);
     10static psArray *pzsearchPendingImfiles(pxConfig *config);
     11static bool pzsearchFlushPendingExp(pxConfig *config);
    1112
    1213int main(int argc, char **argv)
     
    151152}
    152153
    153 bool summitExpPrint(FILE *stream, summitExpRow *summitExp)
     154static bool summitExpPrint(FILE *stream, summitExpRow *summitExp)
    154155{
    155156    PS_ASSERT_PTR_NON_NULL(stream, false);
     
    167168}
    168169
    169 psArray *pzsearchPendingImfiles(pxConfig *config)
     170static psArray *pzsearchPendingExp(pxConfig *config)
     171{
     172    PS_ASSERT_PTR_NON_NULL(config, NULL);
     173
     174    psArray *exps = pzPendingExpSelectRowObjects(config->dbh,
     175        config->where, MAX_ROWS);
     176    if (!exps) {
     177        psError(PS_ERR_UNKNOWN, false, "no pzPendingExp rows found");
     178        return NULL;
     179    }
     180
     181    return exps;
     182}
     183
     184static psArray *pzsearchPendingImfiles(pxConfig *config)
    170185{
    171186    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    175190    if (!imfiles) {
    176191        psError(PS_ERR_UNKNOWN, false, "no pzPendingImfile rows found");
    177 
    178192        return NULL;
    179193    }
     
    182196}
    183197
    184 bool pzsearchFlushPendingExp(pxConfig *config)
    185 {
    186     PS_ASSERT_PTR_NON_NULL(config, false);
    187 
    188     return true;
    189 }
     198static bool pzsearchFlushPendingExp(pxConfig *config)
     199{
     200    PS_ASSERT_PTR_NON_NULL(config, false);
     201
     202    psArray *pending = pzsearchPendingExp(config);
     203    if (!pending) {
     204        psError(PS_ERR_UNKNOWN, false, "no pzPendingExps found");
     205        return false;
     206    }
     207
     208    for (long i = 0; i < pending->n; i++) {
     209        pzPendingExpRow *pendingExp = pending->data[i];
     210
     211        psMetadata *where = psMetadataAlloc();
     212        psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
     213            pendingExp->exp_id);
     214        psArray *pendingImfiles = pzPendingImfileSelectRowObjects(config->dbh, where, MAX_ROWS);
     215        psFree(where);
     216
     217        if (!pendingImfiles) {
     218            // exp has no coresponding imfiles
     219
     220            // XXX start transaction
     221
     222            psArray *nukeMe = psArrayAlloc(1);
     223            nukeMe->n = 0;
     224            psArrayAdd(nukeMe, 0, pendingExp);
     225            bool status = pzPendingExpDeleteRowObjects(config->dbh, nukeMe, MAX_ROWS);
     226            psFree(nukeMe);
     227            if (!status) {
     228                psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     229                // XXX rollback transaction
     230                return false;
     231            }
     232
     233            // XXX commit transaction
     234        }
     235    }
     236
     237    return true;
     238}
Note: See TracChangeset for help on using the changeset viewer.