From 3a03b2906ab7f0142f3a48d74e8635ae202fd19d Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Tue, 2 Sep 2014 17:24:28 +0800 Subject: [PATCH] remove warnings remove warnings --- .../domain/factory/TestPlanFactory.java | 55 +++++++++++-------- .../master/domain/service/ScriptService.java | 14 ++--- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java index 45ebdb2b..cc193885 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java @@ -43,7 +43,6 @@ import org.bench4q.share.models.master.TestPlanModel; import org.bench4q.share.models.master.TestScriptConfig; import org.bench4q.share.models.master.statistics.ScriptResultModel; import org.bench4q.share.models.monitor.MonitorMain; -import org.python.antlr.PythonParser.return_stmt_return; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -127,7 +126,8 @@ public class TestPlanFactory { testPlanScripts.add(createATestPlanScriptWithoutId( runningScriptModel.getRequireLoad(), runningScriptModel.getScriptId(), - runningScriptModel.getConfig(), result, runningScriptModel.getScriptFilterOptionsModel())); + runningScriptModel.getConfig(), result, + runningScriptModel.getScriptFilterOptionsModel())); } result.setRequiredLoad(requiredLoad); result.setTestPlanScripts(testPlanScripts); @@ -150,33 +150,43 @@ public class TestPlanFactory { } public TestPlanScript createATestPlanScriptWithoutId(int requireLoad, - int scriptId, TestScriptConfig config, TestPlan testPlanDB, ScriptFilterOptionsModel scriptFilterOptionsModel) { + int scriptId, TestScriptConfig config, TestPlan testPlanDB, + ScriptFilterOptionsModel scriptFilterOptionsModel) { TestPlanScript testPlanScript = new TestPlanScript(); testPlanScript.setRequireLoad(requireLoad); - //filter the script - testPlanScript.setScript(createAScriptWithFilter(scriptFilterOptionsModel, this.getScriptService().getScript(scriptId))); + // filter the script + testPlanScript.setScript(createAScriptWithFilter( + scriptFilterOptionsModel, + this.getScriptService().getScript(scriptId))); testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config)); testPlanScript.setTestPlan(testPlanDB); return testPlanScript; } - private Script createAScriptWithFilter(ScriptFilterOptionsModel scriptFilterOptionsModel, Script script){ + private Script createAScriptWithFilter( + ScriptFilterOptionsModel scriptFilterOptionsModel, Script script) { RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper .tryUnmarshal(RunScenarioModel.class, script.getFilteredScriptCnt()); List filterPluginId = new ArrayList(); - if(scriptFilterOptionsModel.isFilterTimer()){ - for(UsePluginModel pluginModel: runScenarioModel.getUsePlugins()){ - if(pluginModel.getName().equals("ConstantTimer")){ + if (scriptFilterOptionsModel.isFilterTimer()) { + for (UsePluginModel pluginModel : runScenarioModel.getUsePlugins()) { + if (pluginModel.getName().equals("ConstantTimer")) { filterPluginId.add(pluginModel.getId()); } } } - if(scriptFilterOptionsModel.getFilterTypeMatches() != null && !scriptFilterOptionsModel.getFilterTypeMatches().equals("")){ - for(PageModel pageModel: runScenarioModel.getPages()){ - for(BatchModel batchModel : pageModel.getBatches()){ - for(BehaviorModel behaviorModel: batchModel.getBehaviors()){ - if(filterPluginId.contains(behaviorModel.getUse()) || isFilterType(scriptFilterOptionsModel.getFilterTypeMatches(), behaviorModel)){ + if (scriptFilterOptionsModel.getFilterTypeMatches() != null + && !scriptFilterOptionsModel.getFilterTypeMatches().equals("")) { + for (PageModel pageModel : runScenarioModel.getPages()) { + for (BatchModel batchModel : pageModel.getBatches()) { + for (BehaviorModel behaviorModel : batchModel + .getBehaviors()) { + if (filterPluginId.contains(behaviorModel.getUse()) + || isFilterType( + scriptFilterOptionsModel + .getFilterTypeMatches(), + behaviorModel)) { batchModel.getBehaviors().remove(behaviorModel); } } @@ -187,20 +197,21 @@ public class TestPlanFactory { script.setFilteredScriptCnt(contentString); return script; } - - private boolean isFilterType(String filterTypeMatch, BehaviorModel behaviorModel){ - for(ParameterModel parameterModel:behaviorModel.getParameters()){ - if(parameterModel.getKey().equals("expResCnttype")){ - - if(parameterModel.getValue().matches(filterTypeMatch)){ + + private boolean isFilterType(String filterTypeMatch, + BehaviorModel behaviorModel) { + for (ParameterModel parameterModel : behaviorModel.getParameters()) { + if (parameterModel.getKey().equals("expResCnttype")) { + + if (parameterModel.getValue().matches(filterTypeMatch)) { return true; - }else{ + } else { return false; } } } return false; - + } private PlanedConfig createAPlanedConfigWithoutId(TestScriptConfig config) { diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java index 3c9224aa..70c2f1d6 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/ScriptService.java @@ -1,11 +1,7 @@ package org.bench4q.master.domain.service; -import java.io.IOException; -import java.io.InputStream; import java.util.Date; import java.util.List; -import java.util.Properties; - import javax.xml.bind.JAXBException; import org.apache.log4j.Logger; @@ -21,13 +17,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; - @Component public class ScriptService { private ScriptRepositoty scriptRepositoty; private UserRepository userRepository; private Logger logger = Logger.getLogger(ScriptService.class); - + private ScriptRepositoty getScriptRepositoty() { return scriptRepositoty; } @@ -79,7 +74,7 @@ public class ScriptService { public List