fix the bug about save editScript

This commit is contained in:
zhengyingying 2014-04-04 11:31:31 +08:00
parent 5df821b788
commit c7aac992cd
6 changed files with 44 additions and 25 deletions

View File

@ -120,11 +120,6 @@
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -178,11 +178,11 @@ public class ScriptActionController {
@RequestMapping("saveEditScript")
public @ResponseBody
BaseResponseModel saveScript(
BaseResponseModel saveEditScript(
@ModelAttribute("accessToken") String accessToken,
@RequestParam String scriptId, @RequestParam String script)
throws CustomGenericException {
String url = this.getBaseUrl() + "/updateScript";
String url = this.getBaseUrl() + "/updateScript"+"/"+scriptId;
String caller = this.BASECALLER + "saveScript";
Gson gson = new Gson();
RunScenarioModel scriptModel = gson.fromJson(script,
@ -190,15 +190,12 @@ public class ScriptActionController {
try {
String scriptContent = ObjectXmlExchange.toXml(
RunScenarioModel.class, scriptModel);
Map<String, String> params = BaseService.makeParamsMap("scriptId",
scriptId);
params.put("content", scriptContent);
OperateScriptServerResponseModel operateScriptServerResponseModel = (OperateScriptServerResponseModel) this
.getScriptService()
.getCommunicateWithMaster()
.getResponseModel(accessToken, url,
OperateScriptServerResponseModel.class, params,
.getResponseModelByPut(accessToken, url,scriptContent,
OperateScriptServerResponseModel.class,
caller);
if (operateScriptServerResponseModel.isSuccess()) {
return new BaseResponseModel(true);

View File

@ -1 +1 @@
masterAddress=133.133.12.1:7979/
masterAddress=133.133.12.1:8080/

View File

@ -65,6 +65,7 @@ function loadBehaviors() {
function loadFormParameters(plugin_id, behavior_id) {
var plugin = "", method = "";
alert("parameters");
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
if (item.Id == plugin_id) {
@ -74,6 +75,7 @@ function loadFormParameters(plugin_id, behavior_id) {
method = item.name;
$.each(item.parameters, function(i, item) {
parameters.put(item.key, item.value);
alert("key="+item.key+",value="+item.value);
});
}
});
@ -138,7 +140,10 @@ function createForm(behaviorIndex) {
} else if (type == "MultiField sample_frame") {
var key = contents[j].firstChild.firstChild.nodeValue.split(":")[0];
var value = parameters.get(key);
if (!(value == "" || value == null)) {
if(value==null){
addField(20,behaviorIndex);
}
else {
value = value.split(";");
var fieldLength = value.length;
for (var t = 0; t < fieldLength; t++) {
@ -150,7 +155,13 @@ function createForm(behaviorIndex) {
} else if (type == "Table sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue;
/*//参数不统一
if(key=="header"){
key="headers";
}*/
var value = parameters.get(key);
alert("key="+key+",value="+value);
if (value != "" && value != null) {
value = parameters.get(key).split("|;");
var table = $(contents[j]).find("table");
@ -167,6 +178,7 @@ function createForm(behaviorIndex) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
$(colNode).find("input").val(input[n]);
alert("input["+n+"]="+input[n]);
}
}
}
@ -174,6 +186,7 @@ function createForm(behaviorIndex) {
}
}
function saveFormModification() {
alert("saveFormModification");
var div = document.getElementById("showPluginMethodForm").firstChild;
var plugin_method = div.firstChild.firstChild.nodeValue.split(".");
var pluginId = plugin_method[0].split("_")[1];
@ -233,21 +246,31 @@ function saveFormModification() {
}
parameterList.put(key, value);
}
modifyJsonData(pluginId, behaviorId);
}
function modifyJsonData(pluginId, behaviorId) {
for(var i=0;i<parameterList.length();i++){
alert("key="+parameterList.getKeys()[i]+",value="+parameterList.getValues()[i]);
}
alert("modifyJsonData");
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
if (item.Id == pluginId) {
$.each(item.behaviors, function(i, item) {
if (item.id == behaviorId) {
$.each(item.parameters, function(i, item) {
item.value = parameterList.get(item.key);
if(parameterList.exists(item.key)){
item.value = parameterList.get(item.key);
}
});
/*var keyList=parameterList.getKeys();
for(var i=0;i<keyList.length;i++){
alert("keyList is "+keyList[i]);
var parameterModel=new ParameterModel(keyList[i],parameterList.get(keyList[i]));
item.parameters[i] = JSON.stringify(parameterModel);
alert("json is "+item.parameters[i]);
}
alert("item.parameters="+item.parameters);*/
}
});
}

View File

@ -74,6 +74,7 @@ editor.load = function(scriptId) {
codeEditor.set(modelData);
if (codeEditor != null) {
var script = codeEditor.get();
/*alert("script is "+JSON.stringify(script));*/
$.ajax({
url : "saveEditScript",
data : {

View File

@ -216,6 +216,7 @@ var mark;
function showPluginMethod(plugin, method) {
var behaviorData = plugin + "." + method;
var length = pluginMethodList.length;
alert("pluginMehtodList.length="+pluginMethodList.length);
var documentChild = document.getElementById("showPluginMethod").childNodes;
if (place == "before") {
for (var j = length - 1; j >= clickPluginMethodNode; j--) {
@ -223,14 +224,15 @@ function showPluginMethod(plugin, method) {
$(documentChild[j]).attr("id", parseInt(j + 1));
}
mark = clickPluginMethodNode;
clickPluginMethodNode=parseInt(clickPluginMethodNode + 1);
pluginMethodList[mark] = behaviorData;
} else if (place == "after") {
mark = parseInt(clickPluginMethodNode + 1);
if (clickPluginMethodNode == (length - 1)
if (clickPluginMethodNode == parseInt(length - 1)
&& clickPluginMethodNode != -1) {
pluginMethodList.push(behaviorData);
} else {
for (var j = length - 1; j >= clickPluginMethodNode + 1; j--) {
for (var j = parseInt(length - 1); j >= mark; j--) {
pluginMethodList[j + 1] = pluginMethodList[j];
$(documentChild[j]).attr("id", parseInt(j + 1));
}
@ -239,6 +241,7 @@ function showPluginMethod(plugin, method) {
}
$('#insertBefore').attr("class", "show");
$('#myModal_Behavior').modal('hide');
/*loadMethodParams(behaviorData,mark);*/
createPluginMethodLines();
}
@ -247,13 +250,16 @@ function createPluginMethodLines() {
document.getElementById('behaviorArea').innerHTML = "";
for (var j = 0; j < pluginMethodList.length; j++) {
var div = createALine(pluginMethodList[j], j, "pluginMethodList");
if(j==clickPluginMethodNode){
$(div).find("p").attr("class","visited");
}
document.getElementById('behaviorArea').appendChild(div);
loadMethodParams(pluginMethodList[j], j);
}
}
function showMethodDocument(selectedNode) {
clickPluginMethodNode = $(selectedNode).attr("id");
clickPluginMethodNode = parseInt($(selectedNode).attr("id"));
var length = $("#showPluginMethod").children().length;
var behaviorAreaChild = $('#behaviorArea').children();
var div = $("#showPluginMethod").children();
@ -298,7 +304,7 @@ function clearPluginMethodList() {
}
function loadMethodParams(behaviorData, behaviorIndex) {
alert("loadMehtodParams");
var temp = behaviorData.split('.');
var plugin = temp[0].split('_')[0];
var method = temp[1];
@ -364,12 +370,10 @@ function saveBehavior(selectedNode) {
}
} else if ($(node).attr("class") == "MultiField sample_frame") {
key = node.firstChild.firstChild.nodeValue.split(":")[0];
alert("key is "+key);
var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) {
temp = $(fieldNode[j]).find("input").val();
alert("temp is "+temp);
if(temp!=""){
value += temp;
}
@ -377,7 +381,6 @@ function saveBehavior(selectedNode) {
value += ";";
}
}
alert("value is "+value);
} else if ($(node).attr("class") == "Table sample_frame") {
key = node.lastChild.firstChild.nodeValue;
var table = $(node).find("table");