Changeset 28484 for branches/pap/ippTools/src/pubtool.c
- Timestamp:
- Jun 24, 2010, 2:59:09 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/pubtool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippTools/src
- Property svn:ignore
-
old new 39 39 warptool 40 40 staticskytool 41 42 41 bgtool 42 diffphottool
-
- Property svn:ignore
-
branches/pap/ippTools/src/pubtool.c
r27071 r28484 151 151 PS_ASSERT_PTR_NON_NULL(config, false); 152 152 153 psMetadata *where = psMetadataAlloc(); // WHERE conditions 153 psMetadata *diffWhere = psMetadataAlloc(); // WHERE conditions for diffs 154 psMetadata *camWhere = psMetadataAlloc(); // WHERE conditions for cams 155 psMetadata *diffphotWhere = psMetadataAlloc(); // WHERE conditions for diffphots 154 156 155 157 // required 156 158 157 159 // optional 158 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 159 pxAddLabelSearchArgs(config, where, "-label", "label", "=="); // define using newExp label 160 PXOPT_COPY_S64(config->args, diffWhere, "-client_id", "client_id", "=="); 161 pxAddLabelSearchArgs(config, diffWhere, "-label", "diffRun.label", "=="); 162 pxAddLabelSearchArgs(config, diffWhere, "-data_group", "diffRun.data_group", "LIKE"); 163 PXOPT_COPY_TIME(config->args, diffWhere, "-dateobs_begin", "rawExp.dateobs", ">="); 164 PXOPT_COPY_TIME(config->args, diffWhere, "-dateobs_end", "rawExp.dateobs", "<="); 165 PXOPT_COPY_STR(config->args, diffWhere, "-filter", "rawExp.filter", "LIKE"); 166 PXOPT_COPY_STR(config->args, diffWhere, "-obs_mode", "rawExp.obs_mode", "LIKE"); 167 168 PXOPT_COPY_S64(config->args, camWhere, "-client_id", "client_id", "=="); 169 pxAddLabelSearchArgs(config, camWhere, "-label", "camRun.label", "=="); 170 pxAddLabelSearchArgs(config, camWhere, "-data_group", "camRun.data_group", "LIKE"); 171 PXOPT_COPY_TIME(config->args, camWhere, "-dateobs_begin", "rawExp.dateobs", ">="); 172 PXOPT_COPY_TIME(config->args, camWhere, "-dateobs_end", "rawExp.dateobs", "<="); 173 PXOPT_COPY_STR(config->args, camWhere, "-filter", "rawExp.filter", "LIKE"); 174 PXOPT_COPY_STR(config->args, camWhere, "-obs_mode", "rawExp.obs_mode", "LIKE"); 175 176 PXOPT_COPY_S64(config->args, diffphotWhere, "-client_id", "client_id", "=="); 177 pxAddLabelSearchArgs(config, diffphotWhere, "-label", "diffphotRun.label", "=="); 178 pxAddLabelSearchArgs(config, diffphotWhere, "-data_group", "diffphotRun.data_group", "LIKE"); 179 PXOPT_COPY_TIME(config->args, diffphotWhere, "-dateobs_begin", "rawExp.dateobs", ">="); 180 PXOPT_COPY_TIME(config->args, diffphotWhere, "-dateobs_end", "rawExp.dateobs", "<="); 181 PXOPT_COPY_STR(config->args, diffphotWhere, "-filter", "rawExp.filter", "LIKE"); 182 PXOPT_COPY_STR(config->args, diffphotWhere, "-obs_mode", "rawExp.obs_mode", "LIKE"); 183 184 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 185 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 186 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 187 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 188 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 160 189 161 190 psString query = pxDataGet("pubtool_definerun.sql"); // Query to run 162 191 if (!query) { 163 192 psError(PXTOOLS_ERR_SYS, false, "Failed to retreive SQL statement"); 164 psFree(where); 165 return false; 193 psFree(diffWhere); 194 psFree(camWhere); 195 return false; 196 } 197 198 if (!rerun) { 199 psStringAppend(&query, "\nWHERE publishRun.client_id IS NULL"); 200 } 201 202 if (limit) { 203 psString limitString = psDBGenerateLimitSQL(limit); 204 psStringAppend(&query, "\n%s", limitString); 205 psFree(limitString); 166 206 } 167 207 168 208 if (!psDBTransaction(config->dbh)) { 169 209 psError(PS_ERR_UNKNOWN, false, "Database error"); 170 psFree(where); 171 return false; 172 } 173 174 psString whereClause = psStringCopy(""); // Additional constraints to add to query 175 if (psListLength(where->list)) { 176 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 177 psStringAppend(&whereClause, "\n AND %s", clause); 210 psFree(diffWhere); 211 psFree(camWhere); 212 psFree(diffphotWhere); 213 return false; 214 } 215 216 psString whereDiff = psStringCopy(""); // Additional constraints to add to query 217 if (psListLength(diffWhere->list)) { 218 psString clause = psDBGenerateWhereConditionSQL(diffWhere, NULL); 219 psStringAppend(&whereDiff, "\n AND %s", clause); 178 220 psFree(clause); 179 221 } 180 psFree(where); 181 182 if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause)) { 222 psFree(diffWhere); 223 224 psString whereCam = psStringCopy(""); // Additional constraints to add to query 225 if (psListLength(camWhere->list)) { 226 psString clause = psDBGenerateWhereConditionSQL(camWhere, NULL); 227 psStringAppend(&whereCam, "\n AND %s", clause); 228 psFree(clause); 229 } 230 psFree(camWhere); 231 232 psString whereDiffphot = psStringCopy(""); // Additional constraints to add to query 233 if (psListLength(diffphotWhere->list)) { 234 psString clause = psDBGenerateWhereConditionSQL(diffphotWhere, NULL); 235 psStringAppend(&whereDiffphot, "\n AND %s", clause); 236 psFree(clause); 237 } 238 psFree(diffphotWhere); 239 240 if (!p_psDBRunQueryF(config->dbh, query, whereDiff, whereCam, whereDiffphot)) { 183 241 psError(PS_ERR_UNKNOWN, false, "Database error"); 184 242 psFree(query); 185 psFree(whereClause); 243 psFree(whereDiff); 244 psFree(whereCam); 245 psFree(whereDiffphot); 186 246 if (!psDBRollback(config->dbh)) { 187 247 psError(PS_ERR_UNKNOWN, false, "Database error"); … … 190 250 } 191 251 psFree(query); 192 psFree(whereClause); 252 psFree(whereDiff); 253 psFree(whereCam); 254 psFree(whereDiffphot); 193 255 194 256 psArray *output = p_psDBFetchResult(config->dbh); // Output of SELECT statement … … 206 268 } 207 269 270 if (pretend) { 271 if (!ippdbPrintMetadatas(stdout, output, "publishRun", !simple)) { 272 psError(psErrorCodeLast(), false, "Failed to print array"); 273 psFree(output); 274 return false; 275 } 276 psFree(output); 277 return true; 278 } 279 208 280 for (int i = 0; i < output->n; i++) { 209 281 psMetadata *row = output->data[i]; // Row of interest 210 282 psS64 client = psMetadataLookupS64(NULL, row, "client_id"); // Client identifier 211 283 psS64 stage = psMetadataLookupS64(NULL, row, "stage_id"); // Stage identifier 212 c har *label = psMetadataLookupStr(NULL, row, "src_label"); // label from correct source213 214 if (!publishRunInsert(config->dbh, 0, client, stage, label, "new")) {284 const char *label = psMetadataLookupStr(NULL, row, "src_label"); // label from correct source 285 286 if (!publishRunInsert(config->dbh, 0, client, stage, set_label ? set_label : label, "new")) { 215 287 psError(PS_ERR_UNKNOWN, false, "Unable to add fileset"); 216 288 psFree(output); … … 241 313 PXOPT_COPY_STR(config->args, where, "-stage", "publishClient.stage", "=="); 242 314 PXOPT_COPY_STR(config->args, where, "-comment", "publishClient.comment", "LIKE"); 243 PXOPT_COPY_STR(config->args, where, "-label", "publishRun.label", "==");315 pxAddLabelSearchArgs(config, where, "-label", "publishRun.label", "=="); 244 316 245 317 // optional
Note:
See TracChangeset
for help on using the changeset viewer.
