Changeset 25792
- Timestamp:
- Oct 7, 2009, 12:40:12 PM (17 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
magicdstool.c (modified) (6 diffs)
-
magicdstoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magicdstool.c
r25513 r25792 44 44 static bool completedrevertMode(pxConfig *config); 45 45 46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state);46 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psMetadata *where, const char *state); 47 47 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 48 48 … … 381 381 382 382 // required 383 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false); 384 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 385 386 if (state) { 387 // set detRun.state to state 388 return setmagicDSRunState(config, magic_ds_id, state); 389 } 390 391 return true; 383 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 384 385 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", false, false); 386 if (magic_ds_id) { 387 388 return setmagicDSRunState(config, magic_ds_id, NULL, state); 389 390 } else if (!strcmp(state, "full")) { 391 psError(PS_ERR_UNKNOWN, true, "magic_ds_id is required to update run state to full"); 392 return false; 393 } 394 // we can transition by query as well 395 396 psMetadata *where = psMetadataAlloc(); 397 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 398 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 399 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 400 401 402 if (psListLength(where->list) < 2) { 403 psError(PS_ERR_UNKNOWN, true, "at least 2 search arguments are required"); 404 return false; 405 } 406 407 408 PXOPT_LOOKUP_BOOL(noreplace, config->args, "-noreplace", false); 409 if (!noreplace) { 410 psMetadataAddS32(where, PS_LIST_TAIL, "re_place", 0, ">", 0); 411 } 412 bool result = setmagicDSRunState(config, magic_ds_id, where, state); 413 psFree(where); 414 415 return result; 392 416 } 393 417 … … 796 820 797 821 // set magicDSRun.state to 'full' 798 if (!setmagicDSRunState(config, magic_ds_id, "full")) {822 if (!setmagicDSRunState(config, magic_ds_id, NULL, "full")) { 799 823 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 800 824 magic_ds_id); … … 994 1018 } 995 1019 996 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, const char *state) 997 { 998 PS_ASSERT_PTR_NON_NULL(state, false); 999 1000 // check that state is a valid string value 1020 static bool validDSRunState(const char *state) 1021 { 1001 1022 if (!((strcmp(state, "new") == 0) || 1002 1023 (strcmp(state, "full") == 0) || … … 1008 1029 (strcmp(state, "goto_purged") == 0)) 1009 1030 ) { 1031 return false; 1032 } else { 1033 return true; 1034 } 1035 } 1036 1037 static bool setmagicDSRunState(pxConfig *config, psS64 magic_ds_id, psMetadata *where, const char *state) 1038 { 1039 PS_ASSERT_PTR_NON_NULL(state, false); 1040 1041 if (!validDSRunState(state)) { 1010 1042 psError(PS_ERR_UNKNOWN, false, 1011 1043 "invalid magicDSRun state: %s", state); … … 1013 1045 } 1014 1046 1015 char *query = "UPDATE magicDSRun SET state = '%s' WHERE magic_ds_id = %" PRId64; 1016 if (!p_psDBRunQueryF(config->dbh, query, state, magic_ds_id)) { 1047 psString query = psStringCopy("UPDATE magicDSRun SET state = '%s'"); 1048 if (magic_ds_id) { 1049 psStringAppend(&query, " WHERE magic_ds_id = %" PRId64, magic_ds_id); 1050 } else if (where && psListLength(where->list)) { 1051 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1052 psStringAppend(&query, " WHERE %s", whereClause); 1053 psFree(whereClause); 1054 } else { 1055 psError(PS_ERR_UNKNOWN, true, "search arugments are required"); 1056 return false; 1057 } 1058 1059 if (!p_psDBRunQueryF(config->dbh, query, state)) { 1017 1060 psError(PS_ERR_UNKNOWN, false, 1018 1061 "failed to change state for magic_id %" PRId64, magic_ds_id); -
trunk/ippTools/src/magicdstoolConfig.c
r25492 r25792 82 82 // -updaterun 83 83 psMetadata *updaterunArgs = psMetadataAlloc(); 84 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magictool ID (required)", 0); 85 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 84 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state (required)", NULL); 85 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magictool ID", 0); 86 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-stage", 0, "define stage", NULL); 87 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id", 0); 88 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 89 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-noreplace", 0, "only update runs with replace not set", false); 86 90 87 91 // -addinputskyfile
Note:
See TracChangeset
for help on using the changeset viewer.
