parent
bed2979980
commit
3a03b2906a
|
@ -43,7 +43,6 @@ import org.bench4q.share.models.master.TestPlanModel;
|
||||||
import org.bench4q.share.models.master.TestScriptConfig;
|
import org.bench4q.share.models.master.TestScriptConfig;
|
||||||
import org.bench4q.share.models.master.statistics.ScriptResultModel;
|
import org.bench4q.share.models.master.statistics.ScriptResultModel;
|
||||||
import org.bench4q.share.models.monitor.MonitorMain;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -127,7 +126,8 @@ public class TestPlanFactory {
|
||||||
testPlanScripts.add(createATestPlanScriptWithoutId(
|
testPlanScripts.add(createATestPlanScriptWithoutId(
|
||||||
runningScriptModel.getRequireLoad(),
|
runningScriptModel.getRequireLoad(),
|
||||||
runningScriptModel.getScriptId(),
|
runningScriptModel.getScriptId(),
|
||||||
runningScriptModel.getConfig(), result, runningScriptModel.getScriptFilterOptionsModel()));
|
runningScriptModel.getConfig(), result,
|
||||||
|
runningScriptModel.getScriptFilterOptionsModel()));
|
||||||
}
|
}
|
||||||
result.setRequiredLoad(requiredLoad);
|
result.setRequiredLoad(requiredLoad);
|
||||||
result.setTestPlanScripts(testPlanScripts);
|
result.setTestPlanScripts(testPlanScripts);
|
||||||
|
@ -150,33 +150,43 @@ public class TestPlanFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestPlanScript createATestPlanScriptWithoutId(int requireLoad,
|
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 testPlanScript = new TestPlanScript();
|
||||||
testPlanScript.setRequireLoad(requireLoad);
|
testPlanScript.setRequireLoad(requireLoad);
|
||||||
//filter the script
|
// filter the script
|
||||||
testPlanScript.setScript(createAScriptWithFilter(scriptFilterOptionsModel, this.getScriptService().getScript(scriptId)));
|
testPlanScript.setScript(createAScriptWithFilter(
|
||||||
|
scriptFilterOptionsModel,
|
||||||
|
this.getScriptService().getScript(scriptId)));
|
||||||
testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config));
|
testPlanScript.setPlanedConfig(createAPlanedConfigWithoutId(config));
|
||||||
testPlanScript.setTestPlan(testPlanDB);
|
testPlanScript.setTestPlan(testPlanDB);
|
||||||
return testPlanScript;
|
return testPlanScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Script createAScriptWithFilter(ScriptFilterOptionsModel scriptFilterOptionsModel, Script script){
|
private Script createAScriptWithFilter(
|
||||||
|
ScriptFilterOptionsModel scriptFilterOptionsModel, Script script) {
|
||||||
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
||||||
.tryUnmarshal(RunScenarioModel.class,
|
.tryUnmarshal(RunScenarioModel.class,
|
||||||
script.getFilteredScriptCnt());
|
script.getFilteredScriptCnt());
|
||||||
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()) {
|
||||||
if(pluginModel.getName().equals("ConstantTimer")){
|
if (pluginModel.getName().equals("ConstantTimer")) {
|
||||||
filterPluginId.add(pluginModel.getId());
|
filterPluginId.add(pluginModel.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(scriptFilterOptionsModel.getFilterTypeMatches() != null && !scriptFilterOptionsModel.getFilterTypeMatches().equals("")){
|
if (scriptFilterOptionsModel.getFilterTypeMatches() != null
|
||||||
for(PageModel pageModel: runScenarioModel.getPages()){
|
&& !scriptFilterOptionsModel.getFilterTypeMatches().equals("")) {
|
||||||
for(BatchModel batchModel : pageModel.getBatches()){
|
for (PageModel pageModel : runScenarioModel.getPages()) {
|
||||||
for(BehaviorModel behaviorModel: batchModel.getBehaviors()){
|
for (BatchModel batchModel : pageModel.getBatches()) {
|
||||||
if(filterPluginId.contains(behaviorModel.getUse()) || isFilterType(scriptFilterOptionsModel.getFilterTypeMatches(), behaviorModel)){
|
for (BehaviorModel behaviorModel : batchModel
|
||||||
|
.getBehaviors()) {
|
||||||
|
if (filterPluginId.contains(behaviorModel.getUse())
|
||||||
|
|| isFilterType(
|
||||||
|
scriptFilterOptionsModel
|
||||||
|
.getFilterTypeMatches(),
|
||||||
|
behaviorModel)) {
|
||||||
batchModel.getBehaviors().remove(behaviorModel);
|
batchModel.getBehaviors().remove(behaviorModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,13 +198,14 @@ public class TestPlanFactory {
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFilterType(String filterTypeMatch, BehaviorModel behaviorModel){
|
private boolean isFilterType(String filterTypeMatch,
|
||||||
for(ParameterModel parameterModel:behaviorModel.getParameters()){
|
BehaviorModel behaviorModel) {
|
||||||
if(parameterModel.getKey().equals("expResCnttype")){
|
for (ParameterModel parameterModel : behaviorModel.getParameters()) {
|
||||||
|
if (parameterModel.getKey().equals("expResCnttype")) {
|
||||||
|
|
||||||
if(parameterModel.getValue().matches(filterTypeMatch)){
|
if (parameterModel.getValue().matches(filterTypeMatch)) {
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package org.bench4q.master.domain.service;
|
package org.bench4q.master.domain.service;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
@ -21,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ScriptService {
|
public class ScriptService {
|
||||||
private ScriptRepositoty scriptRepositoty;
|
private ScriptRepositoty scriptRepositoty;
|
||||||
|
@ -114,7 +109,8 @@ public class ScriptService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean alterScriptContent(int id, int ownerId, String content, String scriptName) {
|
public boolean alterScriptContent(int id, int ownerId, String content,
|
||||||
|
String scriptName) {
|
||||||
Script script = this.getScriptRepositoty().getEntity(id);
|
Script script = this.getScriptRepositoty().getEntity(id);
|
||||||
if (script.getUser().getId() != ownerId) {
|
if (script.getUser().getId() != ownerId) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue