IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10756


Ignore:
Timestamp:
Dec 15, 2006, 12:43:00 PM (19 years ago)
Author:
jhoblitt
Message:

implement -warpedimfile, -stackedimfile, & -diffimfile

File:
1 edited

Legend:

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

    r10690 r10756  
    254254    PS_ASSERT_PTR_NON_NULL(config, NULL);
    255255
     256    psString query = psStringCopy(
     257        " SELECT DISTINCT"
     258        "   p4WarpedImfile.*"
     259        " FROM p4Run"
     260        " JOIN p4WarpedImfile"
     261        "   USING(p4_id)"
     262        " WHERE"
     263        "   p4Run.state = 'run'"
     264    );
     265
     266    if (config->where) {
     267        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4WarpedImfile");
     268        psStringAppend(&query, " AND %s", whereClause);
     269        psFree(whereClause);
     270    }
     271
     272    if (!p_psDBRunQuery(config->dbh, query)) {
     273        psError(PS_ERR_UNKNOWN, false, "database error");
     274        psFree(query);
     275        return false;
     276    }
     277    psFree(query);
     278
     279    psArray *output = p_psDBFetchResult(config->dbh);
     280    if (!output) {
     281        psError(PS_ERR_UNKNOWN, false, "database error");
     282        return false;
     283    }
     284    if (!psArrayLength(output)) {
     285        // XXX check psError here
     286        psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found");
     287        psFree(output);
     288        return true;
     289    }
     290
     291    bool simple = false;
     292    {
     293        bool status = false;
     294        simple = psMetadataLookupBool(&status, config->args, "-simple");
     295        if (!status) {
     296            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     297            return false;
     298        }
     299    }
     300
     301    // negative simple so the default is true
     302    if (!ippdbPrintMetadatas(stdout, output, "p4WarpedImfile", !simple)) {
     303        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     304        psFree(output);
     305        return false;
     306    }
     307
     308    psFree(output);
     309
    256310    return true;
    257311}
     
    275329    PS_ASSERT_PTR_NON_NULL(config, NULL);
    276330
     331    psString query = psStringCopy(
     332        " SELECT DISTINCT"
     333        "   p4StackedImfile.*"
     334        " FROM p4Run"
     335        " JOIN p4StackedImfile"
     336        "   USING(p4_id)"
     337        " WHERE"
     338        "   p4Run.state = 'run'"
     339    );
     340
     341    if (config->where) {
     342        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4StackedImfile");
     343        psStringAppend(&query, " AND %s", whereClause);
     344        psFree(whereClause);
     345    }
     346
     347    if (!p_psDBRunQuery(config->dbh, query)) {
     348        psError(PS_ERR_UNKNOWN, false, "database error");
     349        psFree(query);
     350        return false;
     351    }
     352    psFree(query);
     353
     354    psArray *output = p_psDBFetchResult(config->dbh);
     355    if (!output) {
     356        psError(PS_ERR_UNKNOWN, false, "database error");
     357        return false;
     358    }
     359    if (!psArrayLength(output)) {
     360        // XXX check psError here
     361        psError(PS_ERR_UNKNOWN, false, "no p4StackedImfile rows found");
     362        psFree(output);
     363        return true;
     364    }
     365
     366    bool simple = false;
     367    {
     368        bool status = false;
     369        simple = psMetadataLookupBool(&status, config->args, "-simple");
     370        if (!status) {
     371            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     372            return false;
     373        }
     374    }
     375
     376    // negative simple so the default is true
     377    if (!ippdbPrintMetadatas(stdout, output, "p4StackedImfile", !simple)) {
     378        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     379        psFree(output);
     380        return false;
     381    }
     382
     383    psFree(output);
     384
    277385    return true;
    278386}
     
    296404    PS_ASSERT_PTR_NON_NULL(config, NULL);
    297405
    298     return true;
    299 }
     406    psString query = psStringCopy(
     407        " SELECT DISTINCT"
     408        "   p4DiffImfile.*"
     409        " FROM p4Run"
     410        " JOIN p4DiffImfile"
     411        "   USING(p4_id)"
     412        " WHERE"
     413        "   p4Run.state = 'run'"
     414    );
     415
     416    if (config->where) {
     417        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4DiffImfile");
     418        psStringAppend(&query, " AND %s", whereClause);
     419        psFree(whereClause);
     420    }
     421
     422    if (!p_psDBRunQuery(config->dbh, query)) {
     423        psError(PS_ERR_UNKNOWN, false, "database error");
     424        psFree(query);
     425        return false;
     426    }
     427    psFree(query);
     428
     429    psArray *output = p_psDBFetchResult(config->dbh);
     430    if (!output) {
     431        psError(PS_ERR_UNKNOWN, false, "database error");
     432        return false;
     433    }
     434    if (!psArrayLength(output)) {
     435        // XXX check psError here
     436        psError(PS_ERR_UNKNOWN, false, "no p4DiffImfile rows found");
     437        psFree(output);
     438        return true;
     439    }
     440
     441    bool simple = false;
     442    {
     443        bool status = false;
     444        simple = psMetadataLookupBool(&status, config->args, "-simple");
     445        if (!status) {
     446            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     447            return false;
     448        }
     449    }
     450
     451    // negative simple so the default is true
     452    if (!ippdbPrintMetadatas(stdout, output, "p4DiffImfile", !simple)) {
     453        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     454        psFree(output);
     455        return false;
     456    }
     457
     458    psFree(output);
     459
     460    return true;
     461}
Note: See TracChangeset for help on using the changeset viewer.