Changeset 16471 for trunk/ippTools/src/pstamptool.c
- Timestamp:
- Feb 13, 2008, 5:41:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pstamptool.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pstamptool.c
r16361 r16471 33 33 static bool adddatastoreMode(pxConfig *config); 34 34 static bool datastoreMode(pxConfig *config); 35 static bool moddatastoreMode(pxConfig *config); 35 36 static bool addReqMode(pxConfig *config); 36 37 static bool pendingReqMode(pxConfig *config); … … 62 63 MODECASE(PSTAMPTOOL_MODE_ADDDATASTORE, adddatastoreMode); 63 64 MODECASE(PSTAMPTOOL_MODE_DATASTORE, datastoreMode); 65 MODECASE(PSTAMPTOOL_MODE_MODDATASTORE, moddatastoreMode); 64 66 MODECASE(PSTAMPTOOL_MODE_ADDREQ, addReqMode); 65 67 MODECASE(PSTAMPTOOL_MODE_PENDINGREQ, pendingReqMode); … … 92 94 static bool adddatastoreMode(pxConfig *config) 93 95 { 94 psError(PS_ERR_UNKNOWN, true, "-adddatastore not implemented yet");95 return false;96 #ifdef notyet97 96 PS_ASSERT_PTR_NON_NULL(config, false); 98 97 99 98 bool status = false; 100 psString camera = psMetadataLookupStr(&status, config->args, "-inst");101 if (!status) {102 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst");103 return false;104 }105 if (!camera) {106 psError(PS_ERR_UNKNOWN, true, "-inst is required");107 return false;108 }109 110 psString telescope = psMetadataLookupStr(&status, config->args, "-telescope");111 if (!status) {112 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope");113 return false;114 }115 if (!telescope) {116 psError(PS_ERR_UNKNOWN, true, "-telescope is required");117 return false;118 }119 120 99 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 121 100 if (!status) { … … 128 107 } 129 108 130 if (!pzDataStoreInsert(config->dbh, 131 camera, 132 telescope, 133 uri 109 psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset"); 110 111 if (!pstampDataStoreInsert(config->dbh, 112 0, 113 uri, 114 lastFileset 134 115 )) { 135 116 psError(PS_ERR_UNKNOWN, false, "database error"); … … 138 119 139 120 return true; 140 #endif // notyet141 121 } 142 122 143 123 static bool datastoreMode(pxConfig *config) 144 124 { 145 psError(PS_ERR_UNKNOWN, true, "-datastore not implemented yet"); 146 return false; 147 148 #ifdef notyet 149 PS_ASSERT_PTR_NON_NULL(config, false); 150 151 if (!p_psDBRunQuery(config->dbh, "SELECT * FROM pzDataStore")) { 125 PS_ASSERT_PTR_NON_NULL(config, false); 126 127 if (!p_psDBRunQuery(config->dbh, "SELECT * FROM pstampDataStore")) { 152 128 psError(PS_ERR_UNKNOWN, false, "database error"); 153 129 return false; … … 176 152 177 153 // negative simple so the default is true 178 if (!ippdbPrintMetadatas(stdout, output, "p zDataStore", !simple)) {154 if (!ippdbPrintMetadatas(stdout, output, "pstampDataStore", !simple)) { 179 155 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 180 156 psFree(output); … … 185 161 186 162 return true; 187 #endif // notyet 163 } 164 static bool moddatastoreMode(pxConfig *config) 165 { 166 bool status; 167 168 PS_ASSERT_PTR_NON_NULL(config, false); 169 170 psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id"); 171 if (!status) { 172 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id"); 173 return false; 174 } 175 if (!ds_id) { 176 psError(PS_ERR_UNKNOWN, true, "-ds_id is required"); 177 return false; 178 } 179 psString lastFileset = psMetadataLookupStr(&status, config->args, "-last_fileset"); 180 if (!status) { 181 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -last_fileset"); 182 return false; 183 } 184 if (!lastFileset) { 185 psError(PS_ERR_UNKNOWN, true, "-last_fileset is required"); 186 return false; 187 } 188 189 char *query ="UPDATE pstampDataStore" 190 " SET lastFileset = '%s'" 191 " WHERE ds_id = '%s'"; 192 193 if (!p_psDBRunQuery(config->dbh, query, lastFileset, ds_id)) { 194 psError(PS_ERR_UNKNOWN, false, "database error"); 195 psFree(query); 196 return false; 197 } 198 199 psU64 affected = psDBAffectedRows(config->dbh); 200 if (affected != 1) { 201 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 202 PRIu64 " rows were modified", affected); 203 return false; 204 } 205 206 return true; 188 207 } 189 208 … … 204 223 } 205 224 225 // Data Store ID is optional 226 psString ds_id = psMetadataLookupStr(&status, config->args, "-ds_id"); 227 if (!status) { 228 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ds_id"); 229 return false; 230 } 231 if (!ds_id) { 232 ds_id = "0"; 233 } 234 206 235 char *query ="INSERT INTO pstampRequest" 207 " (state, uri )"208 " VALUES( 'new', '%s' )";209 210 if (!p_psDBRunQuery(config->dbh, query, uri )) {236 " (state, uri, ds_id)" 237 " VALUES( 'new', '%s', %s)"; 238 239 if (!p_psDBRunQuery(config->dbh, query, uri, ds_id)) { 211 240 psError(PS_ERR_UNKNOWN, false, "database error"); 212 241 psFree(query); … … 595 624 return false; 596 625 } 597 psString job Status = psMetadataLookupStr(&status, config->args, "-status");598 if (!status) { 599 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for - status");600 return false; 601 } 602 603 psString statusStr = NULL;604 if (!job Status) {605 statusStr = psStringCopy("");626 psString jobResult = psMetadataLookupStr(&status, config->args, "-result"); 627 if (!status) { 628 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -result"); 629 return false; 630 } 631 632 psString resultStr = NULL; 633 if (!jobResult) { 634 resultStr = psStringCopy(""); 606 635 } else { 607 psStringAppend(& statusStr, ", status = '%s'", jobStatus);636 psStringAppend(&resultStr, ", result = '%s'", jobResult); 608 637 } 609 638 … … 615 644 " WHERE job_id = '%s'"; 616 645 617 if (!p_psDBRunQuery(config->dbh, query, state, statusStr, job_id)) {618 psError(PS_ERR_UNKNOWN, false, "database error"); 619 psFree(query); 620 return false; 621 } 622 psFree( statusStr);646 if (!p_psDBRunQuery(config->dbh, query, state, resultStr, job_id)) { 647 psError(PS_ERR_UNKNOWN, false, "database error"); 648 psFree(query); 649 return false; 650 } 651 psFree(resultStr); 623 652 624 653 psU64 affected = psDBAffectedRows(config->dbh);
Note:
See TracChangeset
for help on using the changeset viewer.
