IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13967


Ignore:
Timestamp:
Jun 25, 2007, 10:19:18 AM (19 years ago)
Author:
jhoblitt
Message:

overhaul new* -> raw* table transistions to keep the complete history

Location:
branches/backtrack
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/backtrack/dbconfig/tasks.md

    r13617 r13967  
    1 # $Id: tasks.md,v 1.134 2007-06-05 00:24:52 eugene Exp $
     1# $Id: tasks.md,v 1.134.4.1 2007-06-25 20:19:18 jhoblitt Exp $
    22
    33# this table records all exposure ID ever seen from the summit
     
    8585    exp_tag     STR         64      # Primary Key
    8686    exp_id      STR         64      # Key
     87    state       STR         64      # Key
    8788    camera      STR         64      # Key
    8889    telescope   STR         64      # Key
    8990    imfiles     S32         0
    9091    workdir     STR         255     # destination for output files
     92    workdir_state STR       64
    9193END
    9294
     
    9496# from there
    9597newImfile METADATA
    96     exp_tag     STR         64      # Primary Key
    97     class       STR         64      # Primary Key
     98    exp_tag     STR         64      # Primary Key fkey(exp_tag) ref newExp(exp_tag)
    9899    class_id    STR         64      # Primary Key
    99100    uri         STR         255
     
    102103# paired with rawImfile
    103104rawExp METADATA
    104     exp_tag     STR         64      # Primary Key
     105    exp_tag     STR         64      # Primary Key fkey(exp_tag) ref newExp(exp_tag)
    105106    exp_id      STR         64      # Key
    106107    camera      STR         64
     
    135136
    136137rawImfile METADATA
    137     exp_tag     STR         64      # Primary Key
     138    exp_tag     STR         64      # Primary Key fkey(exp_tag, class_id) ref newImfile(exp_tag, class_id)
    138139    class_id    STR         64      # Primary Key
    139140    uri         STR         255
  • branches/backtrack/ippTools/src/Makefile.am

    r12190 r13967  
    1515        pztool
    1616
    17 include_HEADERS = \
     17pkginclude_HEADERS = \
    1818        pxtoolsErrorCodes.h \
     19        pxadmin.h \
     20        pxdata.h \
     21        pxio.h \
     22        pxtag.h \
     23        pxregister.h \
     24        pxconfig.h \
    1925        pxtools.h
    2026
     
    2935        difftool.h \
    3036        stacktool.h \
    31         pxadmin.h \
    3237        pxinject.h \
    33         pxdata.h \
    34         pxio.h \
    35         pxtag.h \
    3638        pzgetexp.h \
    3739        pzgetimfiles.h \
     
    5153        pxio.c \
    5254        pxtag.c \
     55        pxregister.c \
    5356        chipqueue.c \
    5457        camqueue.c
  • branches/backtrack/ippTools/src/pxinject.c

    r11854 r13967  
    2424#include <stdlib.h>
    2525#include <ippdb.h>
     26#include <string.h>
    2627
    2728#include "pxtools.h"
    28 #include "pxtag.h"
    2929#include "pxinject.h"
    3030
    3131static bool newExpMode(pxConfig *config);
    3232static bool newImfileMode(pxConfig *config);
     33static bool updatenewExpMode(pxConfig *config);
    3334
    3435# define MODECASE(caseName, func) \
     
    5253        MODECASE(PXINJECT_MODE_NEWEXP, newExpMode);
    5354        MODECASE(PXINJECT_MODE_NEWIMFILE, newImfileMode);
     55        MODECASE(PXINJECT_MODE_UPDATENEWEXP, updatenewExpMode);
    5456        default:
    5557            psAbort("invalid option (this should not happen)");
     
    134136                exp_tag,
    135137                exp_id,
     138                "reg", // state
    136139                camera,
    137140                telescope,
    138141                imfiles,
    139                 workdir
     142                workdir,
     143                "dirty"
    140144            )
    141145        ) {
     
    191195        return false;
    192196    }
     197#if 0
    193198    psString class = psMetadataLookupStr(&status, config->args, "-class");
    194199    if (!status) {
     
    200205        return false;
    201206    }
     207#endif
    202208    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
    203209    if (!status) {
     
    220226
    221227    // insert with error flag state set to 0 (no errors)
    222     if (!newImfileInsert(config->dbh, exp_tag, class, class_id, uri)) {
     228    if (!newImfileInsert(config->dbh, exp_tag, class_id, uri)) {
    223229        psError(PS_ERR_UNKNOWN, false, "database error");
    224230        return false;
     
    227233    return true;
    228234}
     235
     236
     237static bool updatenewExpMode(pxConfig *config)
     238{
     239    PS_ASSERT_PTR_NON_NULL(config, false);
     240
     241    bool status = false;
     242    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
     243    if (!status) {
     244        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
     245        return false;
     246    }
     247    if (!exp_tag) {
     248        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
     249        return false;
     250    }
     251
     252    psString state = psMetadataLookupStr(&status, config->args, "-state");
     253    if (!status) {
     254        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
     255        return false;
     256    }
     257    if (!state) {
     258        psError(PS_ERR_UNKNOWN, true, "-state is required");
     259        return false;
     260    }
     261
     262    if (state) {
     263        // set detRun.state to state
     264        return pxnewExpSetState(config, exp_tag, state);
     265    }
     266
     267    return true;
     268}
  • branches/backtrack/ippTools/src/pxinject.h

    r9392 r13967  
    2626    PXINJECT_MODE_NONE           = 0x0,
    2727    PXINJECT_MODE_NEWEXP,
    28     PXINJECT_MODE_NEWIMFILE
     28    PXINJECT_MODE_NEWIMFILE,
     29    PXINJECT_MODE_UPDATENEWEXP
    2930} pxinjectMode;
    3031
  • branches/backtrack/ippTools/src/pxinjectConfig.c

    r13578 r13967  
    4646    psMetadata *newExpArgs = psMetadataAlloc();
    4747    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-exp_id",  0,
    48         "define the exp_id (required)", NULL);
     48            "define the exp_id (required)", NULL);
    4949    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-inst",  0,
    50         "define the camera name (required)", NULL);
     50            "define the camera name (required)", NULL);
    5151    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-telescope",  0,
    52         "define the telescope name (required)", NULL);
     52            "define the telescope name (required)", NULL);
    5353    psMetadataAddS32(newExpArgs, PS_LIST_TAIL, "-imfiles",  0,
    54         "define the number of imfiles in this exp (required)", 0);
     54            "define the number of imfiles in this exp (required)", 0);
    5555    psMetadataAddStr(newExpArgs, PS_LIST_TAIL, "-workdir",  0,
    56         "define workdir (required)", 0);
     56            "define workdir (required)", 0);
    5757    psMetadataAddBool(newExpArgs, PS_LIST_TAIL, "-simple",  0,
    58         "use the simple output format", false);
     58            "use the simple output format", false);
    5959
    6060    // -newImfile
    6161    psMetadata *newImfileArgs = psMetadataAlloc();
    6262    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-exp_tag",  0,
    63         "define the exp_tag (required)", NULL);
     63            "define the exp_tag (required)", NULL);
     64#if 0
    6465    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-class",  0,
    65         "define the class (required)", NULL);
     66            "define the class (required)", NULL);
     67#endif
    6668    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-class_id",  0,
    67         "define the class ID (required)", NULL);
     69            "define the class ID (required)", NULL);
    6870    psMetadataAddStr(newImfileArgs, PS_LIST_TAIL, "-uri",  0,
    69         "define the URI (required)", NULL);
     71            "define the URI (required)", NULL);
     72
     73    // -updatenewExp
     74    psMetadata *updatenewExpArgs = psMetadataAlloc();
     75    psMetadataAddStr(updatenewExpArgs, PS_LIST_TAIL, "-exp_tag",  0,
     76            "define the exp_tag (required)", NULL);
     77    psMetadataAddStr(updatenewExpArgs, PS_LIST_TAIL, "-state", 0,
     78            "set state (required)", NULL);
     79
    7080
    7181    psMetadata *argSets = psMetadataAlloc();
     
    7484    PXTOOL_ADD_MODE("-newExp",      "", PXINJECT_MODE_NEWEXP,       newExpArgs);
    7585    PXTOOL_ADD_MODE("-newImfile",   "", PXINJECT_MODE_NEWIMFILE,    newImfileArgs);
     86    PXTOOL_ADD_MODE("-updatenewExp",   "", PXINJECT_MODE_UPDATENEWEXP,    updatenewExpArgs);
    7687
    7788    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
  • branches/backtrack/ippTools/src/pxtag.h

    r10114 r13967  
    2121#define PXTAG_H 1
    2222
    23 #include "pxtools.h"
     23#include <pslib.h>
     24
     25#include "pxconfig.h"
    2426
    2527psString pxGenExpTag(pxConfig *config, const char *exp_id);
  • branches/backtrack/ippTools/src/pxtools.h

    r13583 r13967  
    2121#define PXTOOLS_H 1
    2222
    23 # include <stdio.h>
    24 # include <strings.h>  // for strcasecmp
    25 # include <unistd.h>   // for unlink
    26 # include <pslib.h>
    27 # include <psmodules.h>
    28 # include <ippdb.h>
     23#include <stdio.h>
     24#include <strings.h>  // for strcasecmp
     25#include <unistd.h>   // for unlink
     26#include <pslib.h>
     27#include <psmodules.h>
     28#include <ippdb.h>
    2929
    30 # include "pxtoolsErrorCodes.h"
    31 # include "pxio.h"
    32 # include "pxdata.h"
     30#include "pxtoolsErrorCodes.h"
     31#include "pxio.h"
     32#include "pxdata.h"
     33#include "pxtag.h"
     34#include "pxregister.h"
     35#include "pxconfig.h"
    3336
    3437# define MAX_ROWS 10e9
    3538# define PXTOOL_MODE_NONE 0x0
    3639
    37 typedef struct {
    38     char *modeName;
    39     int mode;
    40     pmConfig *modules;
    41     psDB *dbh;
    42     psMetadata *args;
    43     psMetadata *where;
    44     int argc;
    45     char **argv;
    46 } pxConfig;
    47 
    48 pxConfig *pxConfigAlloc(void);
    4940bool pxCreateTables (pxConfig *config);
    5041bool pxDeleteTables (pxConfig *config);
  • branches/backtrack/ippTools/src/regtool.c

    r13617 r13967  
    282282                return false;
    283283            }
     284            psFree(object);
    284285            // insert the rawImfile object into the database
    285286            if (!rawImfileInsertObject(config->dbh, imfile)) {
     
    290291                psError(PS_ERR_UNKNOWN, false, "failed to insert row into the database");
    291292                psFree(imfile);
    292                 psFree(object);
    293293                psFree(output);
    294294                return false;
    295295            }
    296296            psFree(imfile);
    297             // remove the neImfile object from the database
    298             if (!newImfileDeleteObject(config->dbh, object)) {
    299                 // rollback
    300                 if (!psDBRollback(config->dbh)) {
    301                     psError(PS_ERR_UNKNOWN, false, "database error");
    302                 }
    303                 psError(PS_ERR_UNKNOWN, false, "failed to delete row from the database");
    304                 psFree(object);
    305                 psFree(output);
    306                 return false;
    307             }
    308             psFree(object);
    309297        }
    310298
     
    573561    }
    574562    if (!psArrayLength(output)) {
    575         psTrace("regtool", PS_LOG_INFO, "no rows found");
     563        psError(PS_ERR_UNKNOWN, false, "no pending newExp rows found");
    576564        psFree(output);
    577         return true;
    578     }
    579 
    580     // start a transaction so we don't end up with an exp in both rawExp &
    581     // newExp
     565        return false;
     566    }
     567
    582568    if (!psDBTransaction(config->dbh)) {
    583569        psError(PS_ERR_UNKNOWN, false, "database error");
     
    603589            return false;
    604590        }
     591        psFree(newExp);
    605592
    606593        // insert the rawExp object into the database
     
    612599            psError(PS_ERR_UNKNOWN, false, "database error");
    613600            psFree(rawExp);
    614             psFree(newExp);
    615601            psFree(output);
    616602            return false;
    617603        }
    618604        psFree(rawExp);
    619 
    620         // delete the newExp object from the database
    621         if (!newExpDeleteObject(config->dbh, newExp)) {
    622             // rollback
    623             if (!psDBRollback(config->dbh)) {
    624                 psError(PS_ERR_UNKNOWN, false, "database error");
    625             }
    626             psError(PS_ERR_UNKNOWN, false, "database error");
    627             psFree(newExp);
    628             psFree(output);
    629             return false;
    630         }
    631 
    632         psFree(newExp);
    633605
    634606        // if this is a detrend image don't put it in the chip queue (and we're
    635607        // done)
    636608        if (detrend) {
     609            // set the state for the newExp to stop
     610            if (!pxnewExpSetState(config, exp_tag, "stop")) {
     611                // rollback
     612                if (!psDBRollback(config->dbh)) {
     613                    psError(PS_ERR_UNKNOWN, false, "database error");
     614                }
     615                psError(PS_ERR_UNKNOWN, false, "failed to change newExp.state for exp_tag: %s", exp_tag);
     616                psFree(output);
     617                return false;
     618            }
    637619            continue;
    638620        }
     
    648630            return false;
    649631        }
    650     }
    651 
     632
     633        // set the state for the newExp to stop
     634        if (!pxnewExpSetState(config, exp_tag, "stop")) {
     635            // rollback
     636            if (!psDBRollback(config->dbh)) {
     637                psError(PS_ERR_UNKNOWN, false, "database error");
     638            }
     639            psError(PS_ERR_UNKNOWN, false, "failed to change newExp.state for exp_tag: %s", exp_tag);
     640            psFree(output);
     641            return false;
     642        }
     643    }
    652644    psFree(output);
    653645
Note: See TracChangeset for help on using the changeset viewer.