IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8378


Ignore:
Timestamp:
Aug 15, 2006, 6:11:18 PM (20 years ago)
Author:
jhoblitt
Message:

complete new implementation of -addnormalized

Location:
trunk/ippTools/src
Files:
2 edited

Legend:

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

    r8376 r8378  
    4242static bool mapPositionToDetRun(psArray *mds);
    4343static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile);
     44static  detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile);
    4445static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);
    4546static psArray *searchInputImfiles(pxConfig *config, const char *det_id);
     
    20392040    // where det_id, iteration, class_id is not in detNormalizedImfile
    20402041    psString query = psStringCopy(
    2041         "SELECT DISTINCT"
     2042        "SELECT"
    20422043        "   detNormalizedStatImfile.*"
    20432044        " FROM detNormalizedStatImfile"
    2044         " LEFT JOIN detNormalizedStatImfile"
     2045        " LEFT JOIN detNormalizedImfile"
    20452046        "   USING(det_id, iteration, class_id)"
    20462047        " WHERE"
     
    20502051        );
    20512052
    2052 # if 0
    2053     if (config->where) {
    2054         psString whereClaus = psDBGenerateWhereConditionSQL(config->where, "detStackedImfile");
    2055         psStringAppend(&query, " AND %s", whereClaus);
    2056         psFree(whereClaus);
    2057     }
    2058 #endif
     2053    {
     2054        // build a query to search by det_id, iteration, class_id
     2055        psMetadata *where = psMetadataAlloc();
     2056        bool status = false;
     2057        psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     2058        if (!status) {
     2059            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     2060            psFree(where);
     2061            psFree(query);
     2062            return false;
     2063        }
     2064        if (det_id) {
     2065            if (!psMetadataAddStr(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) {
     2066                psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
     2067                psFree(where);
     2068                psFree(query);
     2069                return false;
     2070            }
     2071        }
     2072        psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
     2073        if (!status) {
     2074            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
     2075            psFree(where);
     2076            psFree(query);
     2077            return false;
     2078        }
     2079        // always set iteration
     2080        if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) {
     2081            psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
     2082            psFree(where);
     2083            psFree(query);
     2084            return false;
     2085        }
     2086        psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     2087        if (!status) {
     2088            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
     2089            psFree(where);
     2090            psFree(query);
     2091            return false;
     2092        }
     2093        if (class_id) {
     2094            if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) {
     2095                psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     2096                psFree(where);
     2097                psFree(query);
     2098                return false;
     2099            }
     2100        }
     2101
     2102        // there's not
     2103        psString whereClaus = psDBGenerateWhereConditionSQL(where, "detNormalizedStatImfile");
     2104        psFree(where);
     2105        if (whereClaus) {
     2106            psStringAppend(&query, " AND %s", whereClaus);
     2107            psFree(whereClaus);
     2108        }
     2109    }
    20592110
    20602111    if (!p_psDBRunQuery(config->dbh, query)) {
     
    20792130    }
    20802131
    2081 #if 0
    20822132    for (long i = 0; i < psArrayLength(output); i++) {
    20832133        psMetadata *row = output->data[i];
    2084         // convert metadata into a detStackedImfile object
    2085         detStackedImfileRow *stackedImfile = detStackedImfileObjectFromMetadata(row);
    2086         // convert detStackedImfile object into a detNormalizedStat object
    2087         detNormalizedStatImfileRow *stat = detStackedToDetNormalizedStatImfile(config, stackedImfile);
    2088         psFree(stackedImfile);
    2089         if (!stat) {
     2134        // convert metadata into a detNormalizedStatImfile object
     2135        detNormalizedStatImfileRow *statImfile = detNormalizedStatImfileObjectFromMetadata(row);
     2136        // convert detNormalizedStatImfile object into a detNormalizedImfile
     2137        detNormalizedImfileRow *normalizedImfile  = detNormalizedStatToDetNormalizedmfile(config, statImfile);
     2138        psFree(statImfile);
     2139        if (!normalizedImfile) {
    20902140            if (!psDBRollback(config->dbh)) {
    20912141                psError(PS_ERR_UNKNOWN, false, "database error");
     
    20962146        }
    20972147        // insert detNormlized Stat object into the database
    2098         if (!detNormalizedStatImfileInsertObject(config->dbh, stat)) {
     2148        if (!detNormalizedImfileInsertObject(config->dbh, normalizedImfile)) {
    20992149            if (!psDBRollback(config->dbh)) {
    21002150                psError(PS_ERR_UNKNOWN, false, "database error");
    21012151            }
    21022152            psError(PS_ERR_UNKNOWN, false, "database error");
    2103             psFree(stat);
     2153            psFree(normalizedImfile);
    21042154            psFree(output);
    21052155        }
    2106         psFree(stat);
     2156        psFree(normalizedImfile);
    21072157    }
    21082158
     
    21152165
    21162166    return true;
    2117 #endif
    2118 
    2119     return true;
     2167}
     2168
     2169static  detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile)
     2170{
     2171    PS_ASSERT_PTR_NON_NULL(config, NULL);
     2172    PS_ASSERT_PTR_NON_NULL(statImfile, NULL);
     2173
     2174    bool status = false;
     2175    psString uri = psMetadataLookupStr(&status, config->args, "-uri");
     2176    if (!status) {
     2177        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
     2178        return false;
     2179    }
     2180    if (!uri) {
     2181        psError(PS_ERR_UNKNOWN, true, "-uri is required");
     2182        return false;
     2183    }
     2184
     2185    return detNormalizedImfileRowAlloc(
     2186        statImfile->det_id,
     2187        statImfile->iteration,
     2188        statImfile->class_id,
     2189        uri
     2190    );
    21202191}
    21212192
  • trunk/ippTools/src/dettoolConfig.c

    r8370 r8378  
    231231    psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-uri",  0,
    232232        "define URI (required)", NULL);
    233     psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-recip",  0,
    234         "define recipe (required)", NULL);
    235233
    236234    // -normalized
Note: See TracChangeset for help on using the changeset viewer.