Changeset 27838 for branches/tap_branches/ippTools/src/pubtool.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/pubtool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/ippTools/src
- Property svn:ignore
-
old new 16 16 difftool 17 17 disttool 18 dqstatstool 18 19 faketool 19 20 flatcorr
-
- Property svn:ignore
-
branches/tap_branches/ippTools/src/pubtool.c
r25256 r27838 32 32 33 33 static bool defineclientMode(pxConfig *config); 34 static bool updateclientMode(pxConfig *config); 34 35 static bool definerunMode(pxConfig *config); 35 36 static bool pendingMode(pxConfig *config); … … 57 58 switch (config->mode) { 58 59 MODECASE(PUBTOOL_MODE_DEFINECLIENT, defineclientMode); 60 MODECASE(PUBTOOL_MODE_UPDATECLIENT, updateclientMode); 59 61 MODECASE(PUBTOOL_MODE_DEFINERUN, definerunMode); 60 62 MODECASE(PUBTOOL_MODE_PENDING, pendingMode); … … 93 95 // optional 94 96 PXOPT_LOOKUP_STR(comment, config->args, "-comment", false, false); 95 96 if (!publishClientInsert(config->dbh, 0, product, stage, workdir, comment)) { 97 psError(PS_ERR_UNKNOWN, false, "Database error"); 98 return false; 99 } 97 PXOPT_LOOKUP_BOOL(unmagicked, config->args, "-unmagicked", false); 98 99 if (!publishClientInsert(config->dbh, 0, 0, product, stage, !unmagicked, workdir, comment)) { 100 psError(PS_ERR_UNKNOWN, false, "Database error"); 101 return false; 102 } 103 104 return true; 105 } 106 107 static bool updateclientMode(pxConfig *config) 108 { 109 PS_ASSERT_PTR_NON_NULL(config, false); 110 111 psMetadata *where = psMetadataAlloc(); // WHERE conditions 112 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 113 PXOPT_COPY_STR(config->args, where, "-product", "product", "=="); 114 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 115 PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE"); 116 117 PXOPT_LOOKUP_BOOL(active, config->args, "-active", false); 118 PXOPT_LOOKUP_BOOL(inactive, config->args, "-inactive", false); 119 120 if ((!active && !inactive) || (active && inactive)) { 121 psError(PS_ERR_UNKNOWN, false, "Must specify one, and only one, of -active and -inactive."); 122 psFree(where); 123 return false; 124 } 125 126 psString query = NULL; // Query to run 127 psStringAppend(&query, "UPDATE publishClient SET active = %d", active ? 1 : 0); 128 129 if (psListLength(where->list)) { 130 psString clause = psDBGenerateWhereConditionSQL(where, NULL); 131 psStringAppend(&query, "\n WHERE %s", clause); 132 psFree(clause); 133 } 134 psFree(where); 135 136 if (!p_psDBRunQuery(config->dbh, query)) { 137 psError(PS_ERR_UNKNOWN, false, "Database error"); 138 psFree(query); 139 return false; 140 } 141 psFree(query); 142 143 long numUpdated = psDBAffectedRows(config->dbh); 144 psLogMsg("pubtool", PS_LOG_INFO, "%ld rows updated.", numUpdated); 100 145 101 146 return true; … … 112 157 // optional 113 158 PXOPT_COPY_S64(config->args, where, "-client_id", "client_id", "=="); 114 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 115 116 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 159 pxAddLabelSearchArgs(config, where, "-label", "label", "=="); // define using newExp label 117 160 118 161 psString query = pxDataGet("pubtool_definerun.sql"); // Query to run 119 162 if (!query) { 120 psError(PXTOOLS_ERR_ DATA, false, "Failed to retreive SQL statement");163 psError(PXTOOLS_ERR_SYS, false, "Failed to retreive SQL statement"); 121 164 psFree(where); 122 165 return false; … … 167 210 psS64 client = psMetadataLookupS64(NULL, row, "client_id"); // Client identifier 168 211 psS64 stage = psMetadataLookupS64(NULL, row, "stage_id"); // Stage identifier 212 char *label = psMetadataLookupStr(NULL, row, "src_label"); // label from correct source 169 213 170 214 if (!publishRunInsert(config->dbh, 0, client, stage, label, "new")) { … … 205 249 psString query = pxDataGet("pubtool_pending.sql"); 206 250 if (!query) { 207 psError(PXTOOLS_ERR_ DATA, false, "Failed to retreive SQL statement");251 psError(PXTOOLS_ERR_SYS, false, "Failed to retreive SQL statement"); 208 252 psFree(where); 209 253 return false; … … 311 355 PXOPT_COPY_STR(config->args, where, "-client_id", "publishClient.client_id", "=="); 312 356 PXOPT_COPY_STR(config->args, where, "-comment", "publishClient.comment", "LIKE"); 313 PXOPT_COPY_STR(config->args, where, "-label", "publishRun.label", "==");357 pxAddLabelSearchArgs(config, where, "-label", "publishRun.label", "=="); 314 358 315 359 psString query = pxDataGet("pubtool_revert.sql"); 316 360 if (!query) { 317 psError(PXTOOLS_ERR_ DATA, false, "Failed to retreive SQL statement");361 psError(PXTOOLS_ERR_SYS, false, "Failed to retreive SQL statement"); 318 362 psFree(where); 319 363 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
