change filter script to testplanscript from script

This commit is contained in:
hmm 2014-09-04 13:44:22 +08:00
parent e4bd0ded75
commit 47d4b97131
4 changed files with 18 additions and 18 deletions

View File

@ -180,7 +180,7 @@ public class RunningAgentDB implements RunningAgentInterface {
Script script2 = this.getTestPlanScript().getScript(); Script script2 = this.getTestPlanScript().getScript();
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class, .tryUnmarshal(RunScenarioModel.class,
script2.getFilteredScriptCnt()); this.getTestPlanScript().getFilteredScriptCnt());
runScenarioModel.setPoolSize(getLoadInUse()); runScenarioModel.setPoolSize(getLoadInUse());
RunScenarioResultModel runScenarioResultModel = this RunScenarioResultModel runScenarioResultModel = this
.getAgentMessenger().submitScenrioWithParams(this.getAgent(), .getAgentMessenger().submitScenrioWithParams(this.getAgent(),

View File

@ -27,7 +27,6 @@ public class Script {
private int id; private int id;
private String name; private String name;
private String scriptContent; private String scriptContent;
private String filteredScriptCnt;
private int behaviorCount; private int behaviorCount;
private Date createDateTime; private Date createDateTime;
private User user; private User user;
@ -135,12 +134,4 @@ public class Script {
} }
return Arrays.asList(folder.listFiles()); return Arrays.asList(folder.listFiles());
} }
public String getFilteredScriptCnt() {
return filteredScriptCnt;
}
public void setFilteredScriptCnt(String filteredScriptCnt) {
this.filteredScriptCnt = filteredScriptCnt;
}
} }

View File

@ -50,6 +50,7 @@ public class TestPlanScript implements RunningScriptInterface {
private RunningScriptSampler sampler; private RunningScriptSampler sampler;
private Logger logger = Logger.getLogger(TestPlanScript.class); private Logger logger = Logger.getLogger(TestPlanScript.class);
private static int SECOND_MILISECOND_UNIT_CONVERSION = 1000; private static int SECOND_MILISECOND_UNIT_CONVERSION = 1000;
private String filteredScriptCnt;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -301,4 +302,12 @@ public class TestPlanScript implements RunningScriptInterface {
public Date getStartTime() { public Date getStartTime() {
return this.getTestPlan().getCurrentStartTime(); return this.getTestPlan().getCurrentStartTime();
} }
public String getFilteredScriptCnt() {
return filteredScriptCnt;
}
public void setFilteredScriptCnt(String filteredScriptCnt) {
this.filteredScriptCnt = filteredScriptCnt;
}
} }

View File

@ -156,18 +156,19 @@ public class TestPlanFactory {
TestPlanScript testPlanScript = new TestPlanScript(); TestPlanScript testPlanScript = new TestPlanScript();
testPlanScript.setRequireLoad(requireLoad); testPlanScript.setRequireLoad(requireLoad);
// filter the script // filter the script
testPlanScript.setScript(createAScriptWithFilter( Script script = this.getScriptService().getScript(scriptId);
scriptFilterOptionsModel, testPlanScript.setFilteredScriptCnt(createAScriptWithFilter(
this.getScriptService().getScript(scriptId))); scriptFilterOptionsModel,script.getScriptContent()));
testPlanScript.setScript(script);
testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config)); testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config));
testPlanScript.setTestPlan(testPlanDB); testPlanScript.setTestPlan(testPlanDB);
return testPlanScript; return testPlanScript;
} }
private Script createAScriptWithFilter( private String createAScriptWithFilter(
ScriptFilterOptionsModel scriptFilterOptionsModel, Script script) { ScriptFilterOptionsModel scriptFilterOptionsModel, String scriptContent) {
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class, script.getScriptContent()); .tryUnmarshal(RunScenarioModel.class, scriptContent);
List<String> filterPluginId = new ArrayList<String>(); List<String> filterPluginId = new ArrayList<String>();
if (scriptFilterOptionsModel.isFilterTimer()) { if (scriptFilterOptionsModel.isFilterTimer()) {
for (UsePluginModel pluginModel : runScenarioModel.getUsePlugins()) { for (UsePluginModel pluginModel : runScenarioModel.getUsePlugins()) {
@ -197,8 +198,7 @@ public class TestPlanFactory {
} }
String contentString = MarshalHelper.tryMarshal(runScenarioModel); String contentString = MarshalHelper.tryMarshal(runScenarioModel);
System.out.println(contentString); System.out.println(contentString);
script.setFilteredScriptCnt(contentString); return contentString;
return script;
} }
private boolean isFilterType(String filterTypeMatch, private boolean isFilterType(String filterTypeMatch,