IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2006, 4:48:56 PM (20 years ago)
Author:
jhoblitt
Message:

initial implementation of -addmaster & -master

File:
1 edited

Legend:

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

    r7373 r7378  
    16251625    PS_ASSERT_PTR_NON_NULL(config, false);
    16261626
     1627    // det_id & iteration are required
     1628    bool status = false;
     1629    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
     1630    if (!status) {
     1631        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
     1632        return false;
     1633    }
     1634    if (!det_id) {
     1635        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
     1636        return false;
     1637    }
     1638    psString iteration = psMetadataLookupStr(&status, config->args, "-iteration");
     1639    if (!status) {
     1640        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
     1641        return false;
     1642    }
     1643    if (!iteration) {
     1644        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
     1645        return false;
     1646    }
     1647    // comment is optional
     1648    psString comment = psMetadataLookupStr(&status, config->args, "-comment");
     1649    if (!status) {
     1650        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -comment");
     1651        return false;
     1652    }
     1653
     1654    // create a new detMasterFrame row and insert it
     1655    detMasterFrameRow *masterFrame = detMasterFrameRowAlloc(
     1656                (psS32)atol(det_id),
     1657                (psS32)atol(iteration),
     1658                comment // may be NULL
     1659            );
     1660
     1661    if (!detMasterFrameInsertObject(config->dbh, masterFrame)) {
     1662        psError(PS_ERR_UNKNOWN, false, "database error");
     1663        psFree(masterFrame);
     1664        return false;
     1665    }
     1666
     1667    psFree(masterFrame);
     1668
    16271669    return true;
    16281670}
     
    16321674    PS_ASSERT_PTR_NON_NULL(config, false);
    16331675
     1676    // no options are required... use the default where statement
     1677    psArray *masterFrames= detMasterFrameSelectRowObjects(config->dbh,
     1678            config->where, 0);
     1679    if (!masterFrames) {
     1680        psError(PS_ERR_UNKNOWN, false, "no detMasterFrame rows found");
     1681        return false;
     1682    }
     1683
     1684    if (psArrayLength(masterFrames)) {
     1685        // print imfile list
     1686        psMetadata *output = psMetadataAlloc();
     1687        for (long i = 0; i < psArrayLength(masterFrames); i++) {
     1688            psMetadata *md = detMasterFrameMetadataFromObject(
     1689                    masterFrames->data[i]);
     1690            psMetadataAddMetadata(
     1691                output, PS_LIST_TAIL, "detMasterFrame",
     1692                PS_META_DUPLICATE_OK, NULL, md
     1693            );
     1694        }
     1695
     1696        psString str = psMetadataConfigFormat(output);
     1697        psFree(output);
     1698        fprintf(stdout, "%s\n", str);
     1699        psFree(str);
     1700    }
     1701
     1702    psFree(masterFrames);
     1703
    16341704    return true;
    16351705}
Note: See TracChangeset for help on using the changeset viewer.