IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 9, 2006, 7:39:42 PM (20 years ago)
Author:
jhoblitt
Message:

fix -updateimfile so that the entry in newImfile is removed
partial implement ion of -updateexp

File:
1 edited

Legend:

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

    r8250 r8268  
    167167    PS_ASSERT_PTR_NON_NULL(config, false);
    168168
    169     // make sure that the exp_id(s) are ready to be updated based on the same
    170     // critera used in pendingexpMode
    171     char *query =
    172         "SELECT newImfile.* FROM newImfile"
    173         " LEFT JOIN newExp USING(exp_id)"
    174         " LEFT JOIN rawScienceExp USING(exp_id)"
    175         " LEFT JOIN rawDetrendExp USING (exp_id)"
    176         " WHERE newExp.exp_id is NOT NULL"
    177         " AND rawScienceExp.exp_id IS NULL"
    178         " AND rawDetrendExp.exp_id IS NULL";
    179 
     169    // make sure that the exp_id(s) are ready to be updated based on:
     170    // exp_id is not in rawScienceExp
     171    // exp_id is not in rawDetrendExp
     172    // exp_id is not in newImfile
     173    // that the correct count of imfiles is in rawImfile
     174    psString query = psStringCopy("SELECT newExp.* FROM newExp LEFT JOIN newImfile USING(exp_id) LEFT JOIN rawScienceExp USING(exp_id) LEFT JOIN rawDetrendExp USING(exp_id) WHERE newExp.exp_id IS NOT NULL AND newImfile.exp_id IS NULL AND rawScienceExp.exp_id IS NULL AND newExp.imfiles = (SELECT COUNT(exp_id) FROM rawImfile GROUP BY exp_id)");
     175
     176    {       
     177        bool status = false;
     178        psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     179        if (!status) {
     180            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
     181            return false;
     182        }
     183        if (exp_id) {
     184            psStringAppend(&query, " AND newExp.exp_id = '%s'", exp_id);
     185        }
     186    }
     187   
    180188    if (!p_psDBRunQuery(config->dbh, query)) {
    181189        psError(PS_ERR_UNKNOWN, false, "database error");
     
    293301            newImfileRow *object = newImfileObjectFromMetadata(newImfiles->data[i]);
    294302            rawImfileRow *imfile = newToRawImfile(config, object);
    295             psFree(object);
    296303            if (!imfile) {
    297304                // rollback
     
    300307                }
    301308                psError(PS_ERR_UNKNOWN, false, "failed to create a new rawImfile row");
     309                psFree(object);
    302310                psFree(newImfiles);
    303311                return false;
     
    310318                psError(PS_ERR_UNKNOWN, false, "failed to insert row into the database");
    311319                psFree(imfile);
     320                psFree(object);
    312321                psFree(newImfiles);
    313322                return false;
    314323            }
    315324            psFree(imfile);
     325            if (!newImfileDeleteObject(config->dbh, object)) {
     326                // rollback
     327                if (!psDBRollback(config->dbh)) {
     328                    psError(PS_ERR_UNKNOWN, false, "database error");
     329                }
     330                psError(PS_ERR_UNKNOWN, false, "failed to delete row from the database");
     331                psFree(object);
     332                psFree(newImfiles);
     333                return false;
     334            }
     335            psFree(object);
    316336        }
    317337
Note: See TracChangeset for help on using the changeset viewer.