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.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<String> filterPluginId = new ArrayList<String>();
|
||||
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) {
|
||||
|
|
|
@ -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<Script> loadScripts(User user) {
|
||||
return this.getScriptRepositoty().loadEntities(user);
|
||||
}
|
||||
|
||||
|
||||
public List<Script> queryScriptsByCreateTime(Date startDate, Date endDate,
|
||||
User user) {
|
||||
return this.getScriptRepositoty().getWith(
|
||||
|
@ -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);
|
||||
if (script.getUser().getId() != ownerId) {
|
||||
return false;
|
||||
|
@ -123,5 +119,5 @@ public class ScriptService {
|
|||
script.setScriptContent(content);
|
||||
return this.getScriptRepositoty().update(script);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue