IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2009, 4:50:37 PM (17 years ago)
Author:
Paul Price
Message:

Making chiptool -importrun work. Defined some useful PXMIRROR macros that can be used to simplify the imports for other tools.

File:
1 edited

Legend:

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

    r23809 r23868  
    204204        bool status;
    205205        char *end_stage = psMetadataLookupStr(&status, md, "end_stage");
    206         if (end_stage && strcasecmp(end_stage, "warp")) continue;
     206        if (end_stage && strcasecmp(end_stage, "warp")) continue;
    207207
    208208        char *raw_tess_id   = psMetadataLookupStr(&status, md, "tess_id");
    209         if (raw_tess_id || tess_id) continue;
     209        if (raw_tess_id || tess_id) continue;
    210210
    211211        char *label  = psMetadataLookupStr(&status, md, "label");
     
    213213
    214214        if (!status) {
    215             psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);
     215            psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);
    216216            psFree(output);
    217217            return false;
     
    263263    PXOPT_COPY_STR(config->args,  where, "-state",   "chipRun.state",   "==");
    264264
    265     if (!psListLength(where->list) && 
    266         !psMetadataLookupBool(NULL, config->args, "-all")) {
     265    if (!psListLength(where->list) &&
     266        !psMetadataLookupBool(NULL, config->args, "-all")) {
    267267        psFree(where);
    268268        where = NULL;
     
    566566    PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "==");
    567567
    568     if (!psListLength(where->list) && 
    569         !psMetadataLookupBool(NULL, config->args, "-all")) {
     568    if (!psListLength(where->list) &&
     569        !psMetadataLookupBool(NULL, config->args, "-all")) {
    570570        psFree(where);
    571571        psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required");
     
    13821382bool importrunMode(pxConfig *config)
    13831383{
    1384   unsigned int nFail;
    1385 
    1386   int numImportTables = 2;
    1387 
    1388   char tables[2] [80] = {"chipImfile", "chipProcessedImfile"};
    1389 
    1390   PS_ASSERT_PTR_NON_NULL(config, NULL);
    1391 
    1392   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
    1393 
    1394   psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false);
    1395 
    1396   fprintf (stdout, "---- input ----\n");
    1397   psMetadataPrint (stderr, input, 1);
    1398 
    1399   psMetadataItem *item = psMetadataLookup (input, "chipRun");
    1400   psAssert (item, "entry not in input?");
    1401   psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    1402 
    1403   psMetadataItem *entry = psListGet (item->data.list, 0);
    1404   assert (entry);
    1405   assert (entry->type == PS_DATA_METADATA);
    1406   chipRunRow *chipRun = chipRunObjectFromMetadata (entry->data.md);
    1407   chipRunInsertObject (config->dbh, chipRun);
    1408 
    1409   // fprintf (stdout, "---- chip run ----\n");
    1410   // psMetadataPrint (stderr, entry->data.md, 1);
    1411 
    1412   for (int i = 0; i < numImportTables; i++) {
    1413     psMetadataItem *item = psMetadataLookup (input, tables[i]);
    1414     psAssert (item, "entry not in input?");
    1415     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    1416 
    1417     switch (i) {
    1418       case 0:
    1419         for (int i = 0; i < item->data.list->n; i++) {
    1420           psMetadataItem *entry = psListGet (item->data.list, i);
    1421           assert (entry);
    1422           assert (entry->type == PS_DATA_METADATA);
    1423           chipImfileRow *chipImfile = chipImfileObjectFromMetadata (entry->data.md);
    1424           chipImfileInsertObject (config->dbh, chipImfile);
    1425 
    1426           // fprintf (stdout, "---- row %d ----\n", i);
    1427           // psMetadataPrint (stderr, entry->data.md, 1);
    1428         }
    1429         break;
    1430 
    1431       case 1:
    1432         for (int i = 0; i < item->data.list->n; i++) {
    1433           psMetadataItem *entry = psListGet (item->data.list, i);
    1434           assert (entry);
    1435           assert (entry->type == PS_DATA_METADATA);
    1436           chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md);
    1437           chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile);
    1438 
    1439           // fprintf (stdout, "---- row %d ----\n", i);
    1440           // psMetadataPrint (stderr, entry->data.md, 1);
    1441         }
    1442         break;
    1443     }
    1444   }
    1445 
    1446   return true;
    1447 }
    1448 
    1449 
     1384    PS_ASSERT_PTR_NON_NULL(config, NULL);
     1385
     1386    PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false);
     1387    unsigned int nFail = 0;               // Number of failed lines
     1388    psMetadata *input = psMetadataConfigRead(NULL, &nFail, infile, false);
     1389    if (nFail) {
     1390        psError(PS_ERR_IO, false, "%d failed lines in input", nFail);
     1391        psFree(input);
     1392        return false;
     1393    }
     1394
     1395    psVector *identifiers = psVectorAllocEmpty(16, PS_TYPE_U64); // Identifiers inserted
     1396
     1397    if (!psDBTransaction(config->dbh)) {
     1398        psError(PS_ERR_UNKNOWN, false, "database error");
     1399        return false;
     1400    }
     1401
     1402    psMetadataIterator *iter = psMetadataIteratorAlloc(input, PS_LIST_HEAD, NULL);       // Iterator
     1403    psMetadataItem *item;               // Item from iteration
     1404    while ((item = psMetadataGetAndIncrement(iter))) {
     1405        PXMIRROR_PRIMARY(item, "chipRun", chipRunRow, chipRunObjectFromMetadata, identifiers, chip_id,
     1406                         chipRunInsertObject, config->dbh,
     1407                         { psFree(iter); psFree(identifiers); psFree(input); });
     1408
     1409        PXMIRROR_OTHER(item, "chipImfile", chipImfileRow, chipImfileObjectFromMetadata, identifiers, chip_id,
     1410                       chipImfileInsertObject, config->dbh,
     1411                       { psFree(iter); psFree(identifiers); psFree(input); });
     1412
     1413        PXMIRROR_OTHER(item, "chipProcessedImfile", chipProcessedImfileRow,
     1414                       chipProcessedImfileObjectFromMetadata, identifiers, chip_id,
     1415                       chipProcessedImfileInsertObject, config->dbh,
     1416                       { psErrorStackPrint(stderr, "Error:"); psMetadataPrint(stderr, item->data.md, 0); psFree(iter); psFree(identifiers); psFree(input); });
     1417    }
     1418    psFree(iter);
     1419    psFree(input);
     1420
     1421    psLogMsg("chiptool", PS_LOG_INFO, "%ld chipRuns added", identifiers->n);
     1422    psFree(identifiers);
     1423
     1424    return true;
     1425}
     1426
     1427
Note: See TracChangeset for help on using the changeset viewer.