Changeset 16471
- Timestamp:
- Feb 13, 2008, 5:41:31 PM (18 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 5 edited
-
configure.ac (modified) (1 diff)
-
src/pstamptool.c (modified) (10 diffs)
-
src/pstamptool.h (modified) (1 diff)
-
src/pstamptoolConfig.c (modified) (3 diffs)
-
src/pxtables.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/configure.ac
r16383 r16471 1 1 AC_PREREQ(2.61) 2 2 3 AC_INIT([ipptools], [1.1. 23], [ipp-support@ifa.hawaii.edu])3 AC_INIT([ipptools], [1.1.30], [ipp-support@ifa.hawaii.edu]) 4 4 AC_CONFIG_SRCDIR([autogen.sh]) 5 5 -
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); -
trunk/ippTools/src/pstamptool.h
r16277 r16471 27 27 PSTAMPTOOL_MODE_ADDDATASTORE, 28 28 PSTAMPTOOL_MODE_DATASTORE, 29 PSTAMPTOOL_MODE_MODDATASTORE, 29 30 PSTAMPTOOL_MODE_ADDREQ, 30 31 PSTAMPTOOL_MODE_PENDINGREQ, -
trunk/ippTools/src/pstamptoolConfig.c
r16277 r16471 47 47 psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-uri", 0, 48 48 "define storage uri", NULL); 49 psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-last_fileset", 0, 50 "define storage uri", NULL); 49 51 50 52 // -datastore … … 53 55 "use the simple output format", false); 54 56 57 // -moddatastore 58 psMetadata *moddatastoreArgs = psMetadataAlloc(); 59 psMetadataAddStr(moddatastoreArgs, PS_LIST_TAIL, "-ds_id", 0, 60 "define ds_id", NULL); 61 psMetadataAddStr(moddatastoreArgs, PS_LIST_TAIL, "-last_fileset", 0, 62 "define storage uri", NULL); 63 64 55 65 // -addreq 56 66 psMetadata *addreqArgs = psMetadataAlloc(); 57 67 psMetadataAddStr(addreqArgs, PS_LIST_TAIL, "-uri", 0, 58 68 "define request file uri", NULL); 69 psMetadataAddStr(addreqArgs, PS_LIST_TAIL, "-ds_id", 0, 70 "define request file ds_id", NULL); 59 71 60 72 // -pendingreq … … 138 150 PXOPT_ADD_MODE("-adddatastore", "", PSTAMPTOOL_MODE_ADDDATASTORE, adddatastoreArgs); 139 151 PXOPT_ADD_MODE("-datastore", "", PSTAMPTOOL_MODE_DATASTORE, datastoreArgs); 152 PXOPT_ADD_MODE("-moddatastore", "", PSTAMPTOOL_MODE_MODDATASTORE, moddatastoreArgs); 140 153 141 154 PXOPT_ADD_MODE("-addreq", "", PSTAMPTOOL_MODE_ADDREQ, addreqArgs); -
trunk/ippTools/src/pxtables.c
r15577 r16471 101 101 CREATE_TABLE(flatcorrRunCreateTable); 102 102 CREATE_TABLE(flatcorrExpCreateTable); 103 CREATE_TABLE(pstampDataStoreCreateTable); 104 CREATE_TABLE(pstampRequestCreateTable); 105 CREATE_TABLE(pstampJobCreateTable); 103 106 104 107 return true; … … 193 196 DROP_TABLE(flatcorrRunDropTable); 194 197 DROP_TABLE(flatcorrExpDropTable); 198 DROP_TABLE(pstampDataStoreDropTable); 199 DROP_TABLE(pstampRequestDropTable); 200 DROP_TABLE(pstampJobDropTable); 195 201 196 202 // re-enable foreign key constrants
Note:
See TracChangeset
for help on using the changeset viewer.
