IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 15, 2009, 5:28:09 PM (17 years ago)
Author:
Paul Price
Message:

Adding script to do the actual publishing to DataStore. Decided to bundle all components into the same script (we're working with detections, it's serial, should be fast) to simply things (can remove the 'advance' mode for pubtool). Everything compiles, not tested yet.

Location:
branches/pap_mops/ippTools/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_mops/ippTools/src/pubtool.c

    r24413 r24427  
    3636static bool addMode(pxConfig *config);
    3737static bool revertMode(pxConfig *config);
    38 static bool advanceMode(pxConfig *config);
    3938
    4039# define MODECASE(caseName, func) \
     
    6261        MODECASE(PUBTOOL_MODE_ADD, addMode);
    6362        MODECASE(PUBTOOL_MODE_REVERT, revertMode);
    64         MODECASE(PUBTOOL_MODE_ADVANCE, advanceMode);
    6563      default:
    6664        psAbort("invalid option (this should not happen)");
     
    8987
    9088    // required
     89    PXOPT_LOOKUP_STR(product, config->args, "-product",  true, false);
    9190    PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);
    92     PXOPT_LOOKUP_STR(destination, config->args, "-destination",  true, false);
    9391
    9492    // optional
    95     PXOPT_LOOKUP_STR(format, config->args, "-format",  false, false);
    9693    PXOPT_LOOKUP_STR(comment, config->args, "-comment",  false, false);
    9794
    98     if (!publishClientInsert(config->dbh, 0, stage, destination, format, comment)) {
     95    if (!publishClientInsert(config->dbh, 0, product, stage, comment)) {
    9996        psError(PS_ERR_UNKNOWN, false, "Database error");
    10097        return false;
     
    109106
    110107    psMetadata *where = psMetadataAlloc(); // WHERE conditions
     108
     109    // required
     110    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir",  true, false);
    111111
    112112    // optional
     
    141141        psFree(query);
    142142        psFree(whereClause);
    143         if (!psDBTransaction(config->dbh)) {
     143        if (!psDBRollback(config->dbh)) {
    144144            psError(PS_ERR_UNKNOWN, false, "Database error");
    145145        }
     
    152152    if (!output) {
    153153        psError(PS_ERR_UNKNOWN, false, "Database error");
    154         if (!psDBTransaction(config->dbh)) {
     154        if (!psDBRollback(config->dbh)) {
    155155            psError(PS_ERR_UNKNOWN, false, "Database error");
    156156        }
     
    160160        psTrace("pubtool", PS_LOG_INFO, "No rows found");
    161161        psFree(output);
    162         if (!psDBTransaction(config->dbh)) {
     162        if (!psDBRollback(config->dbh)) {
    163163            psError(PS_ERR_UNKNOWN, false, "Database error");
    164164        }
     
    171171        psS64 stage = psMetadataLookupS64(NULL, row, "stage_id");   // Stage identifier
    172172
    173         if (!publishRunInsert(config->dbh, 0, client, stage, set_label, "new")) {
     173        if (!publishRunInsert(config->dbh, 0, client, stage, workdir, set_label, "new")) {
    174174            psError(PS_ERR_UNKNOWN, false, "Unable to add fileset");
    175175            psFree(output);
    176             if (!psDBTransaction(config->dbh)) {
     176            if (!psDBRollback(config->dbh)) {
    177177                psError(PS_ERR_UNKNOWN, false, "Database error");
    178178            }
     
    182182    psFree(output);
    183183
    184     if (!psDBTransaction(config->dbh)) {
     184    if (!psDBCommit(config->dbh)) {
    185185        psError(PS_ERR_UNKNOWN, false, "Database error");
    186186        return false;
     
    259259    // required
    260260    PXOPT_LOOKUP_S64(pub_id, config->args, "-pub_id", true, false);
    261     PXOPT_LOOKUP_STR(component, config->args, "-component", true, false);
     261    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    262262
    263263    // optional
    264264    PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false);
    265265
    266     if (!publishFileInsert(config->dbh, pub_id, component, fault)) {
     266    if (!psDBTransaction(config->dbh)) {
     267        psError(PS_ERR_UNKNOWN, false, "Database error");
     268        return false;
     269    }
     270
     271    if (!publishDoneInsert(config->dbh, pub_id, path_base, fault)) {
    267272        psError(PS_ERR_UNKNOWN, false, "Unable to add file");
     273        if (!psDBRollback(config->dbh)) {
     274            psError(PS_ERR_UNKNOWN, false, "Database error");
     275        }
     276        return false;
     277    }
     278
     279    if (!p_psDBRunQueryF(config->dbh,
     280                         "UPDATE publishRun SET state = 'full' WHERE pub_id = %" PRId64,
     281                         pub_id)) {
     282        psError(PS_ERR_UNKNOWN, false, "Database error");
     283        if (!psDBRollback(config->dbh)) {
     284            psError(PS_ERR_UNKNOWN, false, "Database error");
     285        }
     286        return false;
     287    }
     288
     289    if (!psDBCommit(config->dbh)) {
     290        psError(PS_ERR_UNKNOWN, false, "Database error");
    268291        return false;
    269292    }
     
    283306    PXOPT_COPY_S32(config->args, where, "-fault", "fault", "==");
    284307    PXOPT_COPY_STR(config->args, where, "-client_id", "client_id", "==");
    285     PXOPT_COPY_STR(config->args, where, "-component", "component", "==");
    286308    PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE");
    287309    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     
    310332    return true;
    311333}
    312 static bool advanceMode(pxConfig *config)
    313 {
    314     PS_ASSERT_PTR_NON_NULL(config, false);
    315 
    316     psString query = pxDataGet("pubtool_advance.sql");
    317     if (!query) {
    318         psError(PXTOOLS_ERR_DATA, false, "Failed to retreive SQL statement");
    319         return false;
    320     }
    321 
    322     if (!p_psDBRunQuery(config->dbh, query)) {
    323         psError(PS_ERR_UNKNOWN, false, "Database error");
    324         psFree(query);
    325         return false;
    326     }
    327     psFree(query);
    328 
    329     return true;
    330 }
     334
  • branches/pap_mops/ippTools/src/pubtool.h

    r24377 r24427  
    3030    PUBTOOL_MODE_ADD,
    3131    PUBTOOL_MODE_REVERT,
    32     PUBTOOL_MODE_ADVANCE,
    3332} pubtoolMode;
    3433
  • branches/pap_mops/ippTools/src/pubtoolConfig.c

    r24413 r24427  
    4646    psMetadata *defineclientArgs = psMetadataAlloc();
    4747    psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-stage", 0, "define stage (required)", NULL);
    48     psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-destination", 0, "define destination (required)", NULL);
    49     psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-format", 0, "define format", NULL);
     48    psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-product", 0, "define product (required)", NULL);
    5049    psMetadataAddStr(defineclientArgs, PS_LIST_TAIL, "-comment", 0, "define comment", NULL);
    5150
    5251    // -definerun
    5352    psMetadata *definerunArgs = psMetadataAlloc();
     53    psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL);
    5454    psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", 0);
    5555    psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-client_id", 0, "search by client_id", 0);
     
    6868    psMetadata *addArgs = psMetadataAlloc();
    6969    psMetadataAddS64(addArgs, PS_LIST_TAIL, "-pub_id", 0, "define pub_id (required)", 0);
    70     psMetadataAddStr(addArgs, PS_LIST_TAIL, "-component", 0, "define component (required)", NULL);
    7170    psMetadataAddS32(addArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0);
    7271
     
    7473    psMetadata *revertArgs = psMetadataAlloc();
    7574    psMetadataAddS64(revertArgs, PS_LIST_TAIL, "-pub_id", 0, "search on pub_id", 0);
    76     psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-component", 0, "search on component", NULL);
    7775    psMetadataAddS32(revertArgs, PS_LIST_TAIL, "-fault", 0, "search on fault code", 0);
    7876    psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-client_id", 0, "search on client_id", NULL);
     
    8078    psMetadataAddStr(revertArgs, PS_LIST_TAIL, "-label", 0, "search on label", NULL);
    8179
    82     // -advance
    83     psMetadata *advanceArgs = psMetadataAlloc();
    8480
    8581    psMetadata *argSets = psMetadataAlloc();
     
    9187    PXOPT_ADD_MODE("-add", "", PUBTOOL_MODE_ADD, addArgs);
    9288    PXOPT_ADD_MODE("-revert", "", PUBTOOL_MODE_REVERT, revertArgs);
    93     PXOPT_ADD_MODE("-advance", "", PUBTOOL_MODE_ADVANCE, advanceArgs);
    9489
    9590    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.