IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 21, 2008, 12:12:59 PM (18 years ago)
Author:
eugene
Message:

adding cleanup mode functions (but not yet sql or cmd-line options); dropping guidetool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/ippTools/src/difftool.c

    r18622 r18643  
    4141static bool definepoprunMode(pxConfig *config);
    4242static bool definebyqueryMode(pxConfig *config);
     43static bool pendingcleanuprunMode(pxConfig *config);
     44static bool pendingcleanupskyfileMode(pxConfig *config);
     45static bool donecleanupMode(pxConfig *config);
    4346
    4447static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state);
     
    6265
    6366    switch (config->mode) {
    64         MODECASE(DIFFTOOL_MODE_DEFINERUN,         definerunMode);
    65         MODECASE(DIFFTOOL_MODE_UPDATERUN,         updaterunMode);
    66         MODECASE(DIFFTOOL_MODE_ADDINPUTSKYFILE,   addinputskyfileMode);
    67         MODECASE(DIFFTOOL_MODE_INPUTSKYFILE,      inputskyfileMode);
    68         MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE,     todiffskyfileMode);
    69         MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE,    adddiffskyfileMode);
    70         MODECASE(DIFFTOOL_MODE_DIFFSKYFILE,       diffskyfileMode);
    71         MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode);
    72         MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN,      definepoprunMode);
    73         MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY,             definebyqueryMode);
     67        MODECASE(DIFFTOOL_MODE_DEFINERUN,             definerunMode);
     68        MODECASE(DIFFTOOL_MODE_UPDATERUN,             updaterunMode);
     69        MODECASE(DIFFTOOL_MODE_ADDINPUTSKYFILE,       addinputskyfileMode);
     70        MODECASE(DIFFTOOL_MODE_INPUTSKYFILE,          inputskyfileMode);
     71        MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE,         todiffskyfileMode);
     72        MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE,        adddiffskyfileMode);
     73        MODECASE(DIFFTOOL_MODE_DIFFSKYFILE,           diffskyfileMode);
     74        MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE,     revertdiffskyfileMode);
     75        MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN,          definepoprunMode);
     76        MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY,         definebyqueryMode);
     77        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
     78        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
     79        MODECASE(DIFFTOOL_MODE_DONECLEANUP,           donecleanupMode);
    7480        default:
    7581            psAbort("invalid option (this should not happen)");
     
    923929    return true;
    924930}
     931
     932static bool pendingcleanuprunMode(pxConfig *config)
     933{
     934    PS_ASSERT_PTR_NON_NULL(config, NULL);
     935
     936    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     937    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     938
     939    psMetadata *where = psMetadataAlloc();
     940    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     941
     942    psString query = pxDataGet("difftool_pendingcleanuprun.sql");
     943    if (!query) {
     944        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     945        return false;
     946    }
     947
     948    if (where && psListLength(where->list)) {
     949        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     950        psStringAppend(&query, " AND %s", whereClause);
     951        psFree(whereClause);
     952    }
     953    psFree(where);
     954
     955    // treat limit == 0 as "no limit"
     956    if (limit) {
     957        psString limitString = psDBGenerateLimitSQL(limit);
     958        psStringAppend(&query, " %s", limitString);
     959        psFree(limitString);
     960    }
     961
     962    if (!p_psDBRunQuery(config->dbh, query)) {
     963        psError(PS_ERR_UNKNOWN, false, "database error");
     964        psFree(query);
     965        return false;
     966    }
     967    psFree(query);
     968
     969    psArray *output = p_psDBFetchResult(config->dbh);
     970    if (!output) {
     971        psError(PS_ERR_UNKNOWN, false, "database error");
     972        return false;
     973    }
     974    if (!psArrayLength(output)) {
     975        psTrace("difftool", PS_LOG_INFO, "no rows found");
     976        psFree(output);
     977        return true;
     978    }
     979
     980    // negative simple so the default is true
     981    if (!ippdbPrintMetadatas(stdout, output, "diffPendingCleanupRun", !simple)) {
     982        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     983        psFree(output);
     984        return false;
     985    }
     986
     987    psFree(output);
     988
     989    return true;
     990}
     991
     992
     993static bool pendingcleanupskyfileMode(pxConfig *config)
     994{
     995    PS_ASSERT_PTR_NON_NULL(config, NULL);
     996
     997    PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false);
     998    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     999    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1000
     1001    psMetadata *where = psMetadataAlloc();
     1002    if (diff_id) {
     1003        PXOPT_COPY_S64(config->args, where, "-diff_id", "diff_id", "==");
     1004    }
     1005    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1006
     1007    psString query = pxDataGet("difftool_pendingcleanupskyfile.sql");
     1008    if (!query) {
     1009        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1010        return false;
     1011    }
     1012
     1013    if (where && psListLength(where->list)) {
     1014        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1015        psStringAppend(&query, " AND %s", whereClause);
     1016        psFree(whereClause);
     1017    }
     1018    psFree(where);
     1019
     1020    // treat limit == 0 as "no limit"
     1021    if (limit) {
     1022        psString limitString = psDBGenerateLimitSQL(limit);
     1023        psStringAppend(&query, " %s", limitString);
     1024        psFree(limitString);
     1025    }
     1026
     1027    if (!p_psDBRunQuery(config->dbh, query)) {
     1028        psError(PS_ERR_UNKNOWN, false, "database error");
     1029        psFree(query);
     1030        return false;
     1031    }
     1032    psFree(query);
     1033
     1034    psArray *output = p_psDBFetchResult(config->dbh);
     1035    if (!output) {
     1036        psError(PS_ERR_UNKNOWN, false, "database error");
     1037        return false;
     1038    }
     1039    if (!psArrayLength(output)) {
     1040        psTrace("difftool", PS_LOG_INFO, "no rows found");
     1041        psFree(output);
     1042        return true;
     1043    }
     1044
     1045    // negative simple so the default is true
     1046    if (!ippdbPrintMetadatas(stdout, output, "diffPendingCleanupSkyfile", !simple)) {
     1047        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1048        psFree(output);
     1049        return false;
     1050    }
     1051
     1052    psFree(output);
     1053
     1054    return true;
     1055}
     1056
     1057
     1058static bool donecleanupMode(pxConfig *config)
     1059{
     1060    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1061
     1062    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1063    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1064
     1065    psMetadata *where = psMetadataAlloc();
     1066    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1067
     1068    psString query = pxDataGet("difftool_donecleanup.sql");
     1069    if (!query) {
     1070        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1071        return false;
     1072    }
     1073
     1074    if (where && psListLength(where->list)) {
     1075        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1076        psStringAppend(&query, " AND %s", whereClause);
     1077        psFree(whereClause);
     1078    }
     1079    psFree(where);
     1080
     1081    // treat limit == 0 as "no limit"
     1082    if (limit) {
     1083        psString limitString = psDBGenerateLimitSQL(limit);
     1084        psStringAppend(&query, " %s", limitString);
     1085        psFree(limitString);
     1086    }
     1087
     1088    if (!p_psDBRunQuery(config->dbh, query)) {
     1089        psError(PS_ERR_UNKNOWN, false, "database error");
     1090        psFree(query);
     1091        return false;
     1092    }
     1093    psFree(query);
     1094
     1095    psArray *output = p_psDBFetchResult(config->dbh);
     1096    if (!output) {
     1097        psError(PS_ERR_UNKNOWN, false, "database error");
     1098        return false;
     1099    }
     1100    if (!psArrayLength(output)) {
     1101        psTrace("difftool", PS_LOG_INFO, "no rows found");
     1102        psFree(output);
     1103        return true;
     1104    }
     1105
     1106    // negative simple so the default is true
     1107    if (!ippdbPrintMetadatas(stdout, output, "diffDoneCleanup", !simple)) {
     1108        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1109        psFree(output);
     1110        return false;
     1111    }
     1112
     1113    psFree(output);
     1114
     1115    return true;
     1116}
Note: See TracChangeset for help on using the changeset viewer.