Changeset 7074
- Timestamp:
- May 4, 2006, 5:48:27 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r7058 r7074 14 14 static bool addstacMode(pxConfig *config); 15 15 static bool stacMode(pxConfig *config); 16 17 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id); 16 18 17 19 int main(int argc, char **argv) … … 63 65 static bool defineMode(pxConfig *config) 64 66 { 67 psString str = NULL; 68 bool status = false; 69 65 70 PS_ASSERT_PTR_NON_NULL(config, false); 66 71 72 if (!psDBTransaction(config->dbh)) { 73 psError(PS_ERR_UNKNOWN, false, "database error"); 74 return false; 75 } 76 77 // what type of detRun is this? 78 // XXX make this flag required 79 str = psMetadataLookupStr(&status, config->args, "-det_type"); 80 81 // XXX the value being inserted is junk as we can't yet have an 'empty 82 // table' 83 detRunInsert(config->dbh, str); 84 long det_id = psDBLastInsertID(config->dbh); 85 86 // XXX this needs to fixed to support multipe exp_ids 87 psMetadata *where = psMetadataAlloc(); 88 if ((str = psMetadataLookupStr(&status, config->args, "-exp_id"))) { 89 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", str)) { 90 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 91 // rollback 92 if (!psDBRollback(config->dbh)) { 93 psError(PS_ERR_UNKNOWN, false, "database error"); 94 } 95 psFree(where); 96 return false; 97 } 98 } 99 100 if (where->list->n < 1) { 101 psFree(where); 102 where = NULL; 103 } 104 105 psArray *rawExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0); 106 psFree(where); 107 if (!rawExps) { 108 psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found"); 109 // rollback 110 if (!psDBRollback(config->dbh)) { 111 psError(PS_ERR_UNKNOWN, false, "database error"); 112 } 113 return false; 114 } 115 116 detInputExpRow *detInputExp = rawDetrenTodetInputExpRow( 117 rawExps->data[0], 118 det_id 119 ); 120 121 if (!detInputExpInsertObject(config->dbh, detInputExp)) { 122 psError(PS_ERR_UNKNOWN, false, "database error"); 123 // rollback 124 if (!psDBRollback(config->dbh)) { 125 psError(PS_ERR_UNKNOWN, false, "database error"); 126 } 127 return false; 128 } 129 130 // point of no return for det_id creation 131 if (!psDBCommit(config->dbh)) { 132 psError(PS_ERR_UNKNOWN, false, "database error"); 133 return false; 134 } 135 67 136 return true; 137 } 138 139 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id) 140 { 141 PS_ASSERT_PTR_NON_NULL(rawExp, NULL); 142 143 return detInputExpRowAlloc( 144 det_id, 145 rawExp->exp_id, 146 rawExp->camera, 147 rawExp->telescope, 148 rawExp->exp_type, 149 rawExp->imfiles, 150 rawExp->filter, 151 rawExp->stats 152 ); 68 153 } 69 154
Note:
See TracChangeset
for help on using the changeset viewer.
