Changeset 12174 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Mar 1, 2007, 4:57:45 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r12131 r12174 111 111 { \ 112 112 bool status = false; \ 113 ps##type var = psMetadataLookup##type(&status, from, "-" #name); \113 ps##type var = psMetadataLookup##type(&status, from, "-" name); \ 114 114 if (!status) { \ 115 115 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \ … … 118 118 if (!isnan(var)) { \ 119 119 if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \ 120 psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \120 psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \ 121 121 psFree(to); \ 122 122 return false; \ … … 153 153 ADDPARAMSTR(config->args, where, "object"); 154 154 155 if ( config->where->list->n < 1) {156 psFree( config->where);157 config->where = NULL;155 if (where->list->n < 1) { 156 psFree(where); 157 where = NULL; 158 158 } 159 159 … … 165 165 } 166 166 167 // XXX this does not work!!! 167 psString recipe = psMetadataLookupStr(&status, config->args, "-set_recipe"); 168 if (!status) { 169 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_recipe"); 170 return false; 171 } 172 173 psString expgroup = psMetadataLookupStr(&status, config->args, "-set_expgroup"); 174 if (!status) { 175 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_expgroup"); 176 return false; 177 } 178 179 psString dvodb = psMetadataLookupStr(&status, config->args, "-set_dvodb"); 180 if (!status) { 181 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_dvodb"); 182 return false; 183 } 184 185 // find the exp_tag of all the exposures that we want to queue up. 168 186 psString query = psStringCopy( 169 "INSERT INTO chipPendingExp\n" 170 " SElECT\n" 171 " 0\n" // chip_id 172 " exp_tag,\n" 173 " 'my recipe',\n" // recipe 174 " 255\n" // guide_version 175 " 255\n" // chip_version 176 " %s\n" 177 " FROM rawExp" 178 " LEFT JOIN chipProcessedExp" 179 " USING(exp_tag)" 180 " WHERE" 181 " rawExp.fault = 0" 182 ); 183 184 if (config->where) { 185 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp"); 187 "SELECT exp_tag FROM rawExp WHERE rawExp.fault = 0"); 188 if (where) { 189 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); 190 psFree(where); 186 191 psStringAppend(&query, " AND %s", whereClause); 187 192 psFree(whereClause); 188 193 } 189 194 190 if (!p_psDBRunQuery(config->dbh, query , label ? label : "NULL")) {195 if (!p_psDBRunQuery(config->dbh, query)) { 191 196 psError(PS_ERR_UNKNOWN, false, "database error"); 192 197 psFree(query); … … 201 206 } 202 207 if (!psArrayLength(output)) { 203 // XXX check psError here 204 psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found"); 205 psFree(output); 208 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 209 psFree(output); 210 return true; 211 } 212 213 // load the SQL to enqueue our exp_tags from disk once 214 psString queuerawexp_query = pxDataGet("chiptool_queuerawexp.sql"); 215 if (!query) { 216 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 217 psFree(output); 218 return false; 219 } 220 221 psString queuerawimfile_query = pxDataGet("chiptool_queuerawimfile.sql"); 222 if (!query) { 223 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 224 psFree(queuerawexp_query); 225 psFree(output); 226 return false; 227 } 228 229 // start a transaction so we don't end up with an exp without any associted 230 // imfiles 231 if (!psDBTransaction(config->dbh)) { 232 psError(PS_ERR_UNKNOWN, false, "database error"); 233 psFree(queuerawimfile_query); 234 psFree(queuerawexp_query); 235 psFree(output); 236 return false; 237 } 238 239 // loop over our list of exp_tags 240 for (long i = 0; i < psArrayLength(output); i++) { 241 psMetadata *md = output->data[i]; 242 243 psString exp_tag = psMetadataLookupStr(&status, md, "exp_tag"); 244 if (!status) { 245 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag"); 246 psFree(queuerawimfile_query); 247 psFree(queuerawexp_query); 248 psFree(output); 249 return false; 250 } 251 252 // queue the exp 253 if (!p_psDBRunQuery(config->dbh, queuerawexp_query, 254 label ? label : "NULL", 255 recipe ? recipe : "NULL", 256 expgroup ? expgroup : "NULL", 257 dvodb ? dvodb : "NULL", 258 exp_tag 259 )) { 260 psError(PS_ERR_UNKNOWN, false, "database error"); 261 psFree(queuerawimfile_query); 262 psFree(queuerawexp_query); 263 psFree(output); 264 return false; 265 } 266 267 // just to be safe, we should have changed at least one row 268 if (psDBAffectedRows(config->dbh) < 1) { 269 if (!psDBRollback(config->dbh)) { 270 psError(PS_ERR_UNKNOWN, false, "database error"); 271 } 272 psError(PS_ERR_UNKNOWN, false, 273 "no rows affected - should have changed at least one row"); 274 psFree(queuerawimfile_query); 275 psFree(queuerawexp_query); 276 psFree(output); 277 return false; 278 } 279 280 // queue the imfiles for the exp we just queued 281 if (!p_psDBRunQuery(config->dbh, queuerawimfile_query)) { 282 psError(PS_ERR_UNKNOWN, false, "database error"); 283 psFree(queuerawimfile_query); 284 psFree(queuerawexp_query); 285 psFree(output); 286 return false; 287 } 288 289 // just to be safe, we should have changed at least one row 290 if (psDBAffectedRows(config->dbh) < 1) { 291 if (!psDBRollback(config->dbh)) { 292 psError(PS_ERR_UNKNOWN, false, "database error"); 293 } 294 psError(PS_ERR_UNKNOWN, false, 295 "no rows affected - should have changed at least one row"); 296 psFree(queuerawimfile_query); 297 psFree(queuerawexp_query); 298 psFree(output); 299 return false; 300 } 301 } 302 psFree(queuerawimfile_query); 303 psFree(queuerawexp_query); 304 psFree(output); 305 306 if (!psDBCommit(config->dbh)) { 307 psError(PS_ERR_UNKNOWN, false, "database error"); 206 308 return false; 207 309 } … … 776 878 } 777 879 778 psString recipe = psMetadataLookupStr(&status, config->args, "-recip");779 if (!status) {780 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip");781 return false;782 }783 if (!recipe) {784 psError(PS_ERR_UNKNOWN, true, "-recip is required");785 return false;786 }787 788 880 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 789 881 if (!status) { … … 820 912 return chipProcessedImfileRowAlloc( 821 913 imfile->chip_id, 822 imfile->exp_tag,823 imfile->guide_id,824 914 imfile->class_id, 825 recipe,826 915 uri, 827 916 bg,
Note:
See TracChangeset
for help on using the changeset viewer.
