refactor plugin
This commit is contained in:
parent
4f56536cc4
commit
44846f04cb
|
@ -1,151 +1,151 @@
|
|||
package org.bench4q.master.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.service.PluginService;
|
||||
import org.bench4q.master.domain.service.UserService;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/plugin")
|
||||
public class PluginController extends BaseController {
|
||||
private Logger logger = Logger.getLogger(PluginController.class);
|
||||
private PluginService pluginService;
|
||||
|
||||
public PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginService(PluginService pluginService) {
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/loadPluginList", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel loadPluginUIModels() throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadPluginList");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
try {
|
||||
List<PluginUIModel> pluginUIModels = this.getPluginService()
|
||||
.loadPluginUIs();
|
||||
if (pluginUIModels == null) {
|
||||
pluginResponseModel.setSuccess(false);
|
||||
} else {
|
||||
pluginResponseModel.setSuccess(true);
|
||||
pluginResponseModel.setPluginUIModels(pluginUIModels);
|
||||
}
|
||||
return pluginResponseModel;
|
||||
} catch (Exception e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
pluginResponseModel.setSuccess(false);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/loadPluginNameList")
|
||||
@ResponseBody
|
||||
public PluginResponseModel loadPluginList() throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadPluginNameList");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setPluginList(this.getPluginService()
|
||||
.getPluginNameList());
|
||||
|
||||
pluginResponseModel.setSuccess(true);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/loadBehaviors/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel getBehaviorsInPlugin(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/loadBehaviors/{pluginName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
try {
|
||||
if (!this.getPluginService().isPluginExist(pluginName)) {
|
||||
pluginResponseModel.setSuccess(false);
|
||||
pluginResponseModel.setFailMessage("plugin not exist");
|
||||
return pluginResponseModel;
|
||||
}
|
||||
|
||||
List<BehaviorInfoModel> behaviorInfoModels = this
|
||||
.getPluginService().loadBehaviorInfoModels(pluginName);
|
||||
if (behaviorInfoModels == null) {
|
||||
pluginResponseModel.setFailMessage("no behaviors in plugin");
|
||||
pluginResponseModel.setSuccess(false);
|
||||
}
|
||||
|
||||
else {
|
||||
pluginResponseModel.setSuccess(true);
|
||||
pluginResponseModel.setBehaviorInfoModels(behaviorInfoModels);
|
||||
}
|
||||
|
||||
return pluginResponseModel;
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
pluginResponseModel.setSuccess(false);
|
||||
return pluginResponseModel;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT })
|
||||
@ResponseBody
|
||||
public PluginResponseModel addPlugin(@RequestBody String plugin)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"addPlugin/{pluginName}/{methodName}");
|
||||
}
|
||||
String pluginUIContent = plugin;
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
|
||||
pluginUIContent));
|
||||
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/deletePlugin/{pluginName}", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public PluginResponseModel deletePlugin(
|
||||
@PathVariable("pluginName") String pluginName)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"deletePlugin/{pluginName}");
|
||||
}
|
||||
PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
pluginResponseModel.setSuccess(this.getPluginService().deletePlugin(
|
||||
pluginName));
|
||||
return pluginResponseModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//package org.bench4q.master.api;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.apache.log4j.Logger;
|
||||
//import org.bench4q.master.domain.service.PluginService;
|
||||
//import org.bench4q.master.domain.service.UserService;
|
||||
//import org.bench4q.master.exception.Bench4QException;
|
||||
//import org.bench4q.master.exception.ExceptionLog;
|
||||
//import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
|
||||
//import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
//import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.web.bind.annotation.PathVariable;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//
|
||||
//@Controller
|
||||
//@RequestMapping("/plugin")
|
||||
//public class PluginController extends BaseController {
|
||||
// private Logger logger = Logger.getLogger(PluginController.class);
|
||||
// private PluginService pluginService;
|
||||
//
|
||||
// public PluginService getPluginService() {
|
||||
// return pluginService;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setPluginService(PluginService pluginService) {
|
||||
// this.pluginService = pluginService;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/loadPluginList", method = { RequestMethod.GET,
|
||||
// RequestMethod.POST })
|
||||
// @ResponseBody
|
||||
// public PluginResponseModel loadPluginUIModels() throws Bench4QException {
|
||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
// throw new Bench4QException(400 + "", "not permitted",
|
||||
// "/loadPluginList");
|
||||
// }
|
||||
// PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
// try {
|
||||
// List<PluginUIModel> pluginUIModels = this.getPluginService()
|
||||
// .loadPluginUIs();
|
||||
// if (pluginUIModels == null) {
|
||||
// pluginResponseModel.setSuccess(false);
|
||||
// } else {
|
||||
// pluginResponseModel.setSuccess(true);
|
||||
// pluginResponseModel.setPluginUIModels(pluginUIModels);
|
||||
// }
|
||||
// return pluginResponseModel;
|
||||
// } catch (Exception e) {
|
||||
// logger.info(ExceptionLog.getStackTrace(e));
|
||||
// pluginResponseModel.setSuccess(false);
|
||||
// return pluginResponseModel;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @RequestMapping("/loadPluginNameList")
|
||||
// @ResponseBody
|
||||
// public PluginResponseModel loadPluginList() throws Bench4QException {
|
||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
// throw new Bench4QException(400 + "", "not permitted",
|
||||
// "/loadPluginNameList");
|
||||
// }
|
||||
// PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
// pluginResponseModel.setPluginList(this.getPluginService()
|
||||
// .getPluginNameList());
|
||||
//
|
||||
// pluginResponseModel.setSuccess(true);
|
||||
// return pluginResponseModel;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/loadBehaviors/{pluginName}", method = {
|
||||
// RequestMethod.GET, RequestMethod.POST })
|
||||
// @ResponseBody
|
||||
// public PluginResponseModel getBehaviorsInPlugin(
|
||||
// @PathVariable("pluginName") String pluginName)
|
||||
// throws Bench4QException {
|
||||
//
|
||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
// throw new Bench4QException(400 + "", "not permitted",
|
||||
// "/loadBehaviors/{pluginName}");
|
||||
// }
|
||||
// PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
// try {
|
||||
// if (!this.getPluginService().isPluginExist(pluginName)) {
|
||||
// pluginResponseModel.setSuccess(false);
|
||||
// pluginResponseModel.setFailMessage("plugin not exist");
|
||||
// return pluginResponseModel;
|
||||
// }
|
||||
//
|
||||
// List<BehaviorInfoModel> behaviorInfoModels = this
|
||||
// .getPluginService().loadBehaviorInfoModels(pluginName);
|
||||
// if (behaviorInfoModels == null) {
|
||||
// pluginResponseModel.setFailMessage("no behaviors in plugin");
|
||||
// pluginResponseModel.setSuccess(false);
|
||||
// }
|
||||
//
|
||||
// else {
|
||||
// pluginResponseModel.setSuccess(true);
|
||||
// pluginResponseModel.setBehaviorInfoModels(behaviorInfoModels);
|
||||
// }
|
||||
//
|
||||
// return pluginResponseModel;
|
||||
// } catch (Exception e) {
|
||||
// logger.error(ExceptionLog.getStackTrace(e));
|
||||
// pluginResponseModel.setSuccess(false);
|
||||
// return pluginResponseModel;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/addPlugin", method = { RequestMethod.PUT })
|
||||
// @ResponseBody
|
||||
// public PluginResponseModel addPlugin(@RequestBody String plugin)
|
||||
// throws Bench4QException {
|
||||
// if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
// throw new Bench4QException(400 + "", "not permitted",
|
||||
// "addPlugin/{pluginName}/{methodName}");
|
||||
// }
|
||||
// String pluginUIContent = plugin;
|
||||
// PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
// pluginResponseModel.setSuccess(this.getPluginService().addPlugin(
|
||||
// pluginUIContent));
|
||||
//
|
||||
// return pluginResponseModel;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/deletePlugin/{pluginName}", method = {
|
||||
// RequestMethod.GET, RequestMethod.POST })
|
||||
// @ResponseBody
|
||||
// public PluginResponseModel deletePlugin(
|
||||
// @PathVariable("pluginName") String pluginName)
|
||||
// throws Bench4QException {
|
||||
// if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
// throw new Bench4QException(400 + "", "not permitted",
|
||||
// "deletePlugin/{pluginName}");
|
||||
// }
|
||||
// PluginResponseModel pluginResponseModel = new PluginResponseModel();
|
||||
// pluginResponseModel.setSuccess(this.getPluginService().deletePlugin(
|
||||
// pluginName));
|
||||
// return pluginResponseModel;
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
|
@ -11,6 +14,7 @@ import javax.persistence.Table;
|
|||
public class BehaviorInfo extends ParamsContainer {
|
||||
private String behavoirType;
|
||||
private PluginUI pluginUI;
|
||||
private Set<Group> groups;
|
||||
|
||||
@Column(name = "behavoirType")
|
||||
public String getBehavoirType() {
|
||||
|
@ -20,8 +24,9 @@ public class BehaviorInfo extends ParamsContainer {
|
|||
public void setBehavoirType(String behavoirType) {
|
||||
this.behavoirType = behavoirType;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "pluginId", nullable = false)
|
||||
@JoinColumn(name = "pluginUI", nullable = false)
|
||||
public PluginUI getPluginUI() {
|
||||
return pluginUI;
|
||||
}
|
||||
|
@ -29,4 +34,14 @@ public class BehaviorInfo extends ParamsContainer {
|
|||
public void setPluginUI(PluginUI pluginUI) {
|
||||
this.pluginUI = pluginUI;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "paramsContainer")
|
||||
public Set<Group> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(Set<Group> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
@ -8,11 +10,10 @@ import javax.persistence.Table;
|
|||
@Entity
|
||||
@Table(name = "group")
|
||||
public class Group extends ParamsContainer {
|
||||
|
||||
private ParamsContainer paramsContainer;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "paramsContainerId", nullable = false)
|
||||
@JoinColumn(name = "paramContainer", nullable = false)
|
||||
public ParamsContainer getParamsContainer() {
|
||||
return paramsContainer;
|
||||
}
|
||||
|
|
|
@ -2,16 +2,18 @@ package org.bench4q.master.domain.entity.plugin;
|
|||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@MappedSuperclass
|
||||
@Entity
|
||||
@Table(name = "param")
|
||||
public class ParamInfo {
|
||||
|
||||
private int id;
|
||||
|
@ -19,6 +21,7 @@ public class ParamInfo {
|
|||
private String lable;
|
||||
private ParamType paramType;
|
||||
private ParamsContainer paramsContainer;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
|
@ -58,7 +61,6 @@ public class ParamInfo {
|
|||
this.paramType = paramType;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "paramsContainerId", nullable = false)
|
||||
public ParamsContainer getParamsContainer() {
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.persistence.Table;
|
|||
|
||||
@Entity
|
||||
@Table(name = "paramType")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public abstract class ParamType {
|
||||
private int id;
|
||||
private String type;
|
||||
|
@ -26,7 +26,8 @@ public abstract class ParamType {
|
|||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@Column(name="paramType")
|
||||
|
||||
@Column(name = "editorType")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "paramsContainer")
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
@Table(name = "paramType")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
public abstract class ParamsContainer {
|
||||
private int id;
|
||||
private String name;
|
||||
private Set<ParamInfo> params;
|
||||
private Set<Group> groups;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||
|
@ -51,16 +51,6 @@ public abstract class ParamsContainer {
|
|||
public void setParams(Set<ParamInfo> params) {
|
||||
this.params = params;
|
||||
}
|
||||
@OneToMany(mappedBy = "paramsContainer", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
public Set<Group> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(Set<Group> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package org.bench4q.master.domain.entity.plugin;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "pluginInfo")
|
||||
public class PluginInfo extends ParamsContainer {
|
||||
|
||||
private PluginUI pluginUI;
|
||||
private Set<Group> groups;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "pluginId", nullable = false)
|
||||
@JoinColumn(name = "pluginUI", nullable = false)
|
||||
public PluginUI getPluginUI() {
|
||||
return pluginUI;
|
||||
}
|
||||
|
@ -19,4 +24,13 @@ public class PluginInfo extends ParamsContainer {
|
|||
public void setPluginUI(PluginUI pluginUI) {
|
||||
this.pluginUI = pluginUI;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "paramsContainer")
|
||||
public Set<Group> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(Set<Group> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import jnr.ffi.Struct.int16_t;
|
||||
import jnr.ffi.types.id_t;
|
||||
|
||||
@Entity
|
||||
@Table(name = "pluginUI")
|
||||
public class PluginUI {
|
||||
|
||||
private int id;
|
||||
private PluginInfo pluginInfo;
|
||||
private Set<BehaviorInfo> behaviorInfos;
|
||||
|
@ -36,7 +38,7 @@ public class PluginUI {
|
|||
}
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "pluginUIId", nullable = false)
|
||||
@JoinColumn(name = "pluginUI", nullable = false)
|
||||
public PluginInfo getPluginInfo() {
|
||||
return pluginInfo;
|
||||
}
|
||||
|
|
|
@ -1,207 +0,0 @@
|
|||
package org.bench4q.master.domain.factory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.CheckBoxType;
|
||||
import org.bench4q.master.domain.entity.plugin.ChoiceType;
|
||||
import org.bench4q.master.domain.entity.plugin.ComboType;
|
||||
import org.bench4q.master.domain.entity.plugin.FieldType;
|
||||
import org.bench4q.master.domain.entity.plugin.FileType;
|
||||
import org.bench4q.master.domain.entity.plugin.NFieldType;
|
||||
import org.bench4q.master.domain.entity.plugin.ParamInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.ParamType;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
import org.bench4q.master.domain.entity.plugin.RadioButtonType;
|
||||
import org.bench4q.master.domain.entity.plugin.TableType;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.CheckBoxModel;
|
||||
import org.bench4q.share.models.master.plugin.ChoiceModel;
|
||||
import org.bench4q.share.models.master.plugin.ComboModel;
|
||||
import org.bench4q.share.models.master.plugin.FieldModel;
|
||||
import org.bench4q.share.models.master.plugin.FileModel;
|
||||
import org.bench4q.share.models.master.plugin.NFieldModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.ParamTypeModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
import org.bench4q.share.models.master.plugin.RadioButtonModel;
|
||||
import org.bench4q.share.models.master.plugin.TableModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PluginDomainFactory {
|
||||
|
||||
private Logger logger = Logger.getLogger(PluginDomainFactory.class);
|
||||
|
||||
public PluginUIModel createPluginUIModelwithOutBehaviors(PluginUI pluginUI) {
|
||||
PluginUIModel pluginUIModel = new PluginUIModel();
|
||||
pluginUIModel.setPluginInfoModel(createPluginInfoModel(pluginUI
|
||||
.getPluginInfo()));
|
||||
pluginUIModel.setCreateTimeDate(pluginUI.getCreateDateTime());
|
||||
return pluginUIModel;
|
||||
}
|
||||
|
||||
private PluginInfoModel createPluginInfoModel(PluginInfo pluginInfo) {
|
||||
PluginInfoModel pluginInfoModel = new PluginInfoModel();
|
||||
pluginInfoModel.setName(pluginInfo.getName());
|
||||
pluginInfoModel.setParamInfoModels(createParamInfoModels(pluginInfo
|
||||
.getPluginParamInfos()));
|
||||
return pluginInfoModel;
|
||||
}
|
||||
|
||||
private ParamInfoModel createParamInfoModel(ParamInfo paramInfo) {
|
||||
ParamInfoModel paramInfoModel = new ParamInfoModel();
|
||||
paramInfoModel.setLable(paramInfo.getLable());
|
||||
paramInfoModel.setName(paramInfo.getName());
|
||||
try {
|
||||
|
||||
ParamTypeModelFactory paramTypeModelFactory = new ParamTypeModelFactory();
|
||||
paramInfoModel.setParamTypeModel(paramTypeModelFactory
|
||||
.createParamModel(paramInfo));
|
||||
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
return paramInfoModel;
|
||||
}
|
||||
|
||||
private List<ParamInfoModel> createParamInfoModels(
|
||||
Set<? extends ParamInfo> paramInfos) {
|
||||
List<ParamInfoModel> paramInfoModels = new LinkedList<ParamInfoModel>();
|
||||
for (ParamInfo paramInfo : paramInfos) {
|
||||
ParamInfoModel paramInfoModel = createParamInfoModel(paramInfo);
|
||||
if (paramInfo == null) {
|
||||
return null;
|
||||
}
|
||||
paramInfoModels.add(paramInfoModel);
|
||||
}
|
||||
|
||||
return paramInfoModels;
|
||||
}
|
||||
|
||||
public List<BehaviorInfoModel> createBehaviorInfoModels(
|
||||
Set<BehaviorInfo> behaviorInfos) {
|
||||
List<BehaviorInfoModel> behaviorInfoModels = new LinkedList<BehaviorInfoModel>();
|
||||
for (BehaviorInfo behaviorInfo : behaviorInfos) {
|
||||
behaviorInfoModels.add(createBehaviorInfoModel(behaviorInfo));
|
||||
}
|
||||
return behaviorInfoModels;
|
||||
}
|
||||
|
||||
private BehaviorInfoModel createBehaviorInfoModel(BehaviorInfo behaviorInfo) {
|
||||
BehaviorInfoModel behaviorInfoModel = new BehaviorInfoModel();
|
||||
behaviorInfoModel.setName(behaviorInfo.getName());
|
||||
behaviorInfoModel.setParamInfoModels(createParamInfoModels(behaviorInfo
|
||||
.getParams()));
|
||||
return behaviorInfoModel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
class ParamTypeModelFactory {
|
||||
|
||||
public ParamTypeModel createParamModel(ParamInfo paramInfo)
|
||||
throws JAXBException {
|
||||
ParamType paramType = paramInfo.getParamType();
|
||||
ParamTypeModel paramTypeModel = null;
|
||||
if (paramType instanceof FieldType) {
|
||||
paramTypeModel = createFieldModel((FieldType) paramType);
|
||||
}
|
||||
|
||||
else if (paramType instanceof NFieldType) {
|
||||
paramTypeModel = createNFieldModel((NFieldType) paramType);
|
||||
} else if (paramType instanceof TableType) {
|
||||
paramTypeModel = createTableModel((TableType) paramType);
|
||||
} else if (paramType instanceof CheckBoxType) {
|
||||
paramTypeModel = createCheckBoxModel((CheckBoxType) paramType);
|
||||
} else if (paramType instanceof ComboType) {
|
||||
paramTypeModel = createComboModel((ComboType) paramType);
|
||||
} else if (paramType instanceof RadioButtonType) {
|
||||
paramTypeModel = createRadioButton((RadioButtonType) paramType);
|
||||
} else if (paramType instanceof FileType) {
|
||||
paramTypeModel = createFileModel((FileType) paramType);
|
||||
}
|
||||
paramTypeModel.setType(paramType.getType());
|
||||
return paramTypeModel;
|
||||
}
|
||||
|
||||
private FieldModel createFieldModel(FieldType fieldType) {
|
||||
FieldModel fieldModel = new FieldModel();
|
||||
fieldModel.setSize(fieldType.getSize());
|
||||
fieldModel.setText(fieldType.getText());
|
||||
return fieldModel;
|
||||
|
||||
}
|
||||
|
||||
private NFieldModel createNFieldModel(NFieldType nFieldType) {
|
||||
NFieldModel nFieldModel = new NFieldModel();
|
||||
nFieldModel.setSize(nFieldType.getSize());
|
||||
nFieldModel.setText(nFieldType.getText());
|
||||
return nFieldModel;
|
||||
|
||||
}
|
||||
|
||||
private TableModel createTableModel(TableType tableType) {
|
||||
TableModel tableModel = new TableModel();
|
||||
tableModel.setCols(tableType.getCols());
|
||||
return tableModel;
|
||||
}
|
||||
|
||||
private CheckBoxModel createCheckBoxModel(CheckBoxType checkBoxType) {
|
||||
CheckBoxModel checkBoxModel = new CheckBoxModel();
|
||||
checkBoxModel.setChoiceModels(createChoiceModels(checkBoxType
|
||||
.getChoiceList()));
|
||||
return checkBoxModel;
|
||||
|
||||
}
|
||||
|
||||
private ComboModel createComboModel(ComboType comboType) {
|
||||
ComboModel comboModel = new ComboModel();
|
||||
comboModel
|
||||
.setChoiceModels(createChoiceModels(comboType.getChoiceList()));
|
||||
return comboModel;
|
||||
}
|
||||
|
||||
private RadioButtonModel createRadioButton(RadioButtonType radioButtonType) {
|
||||
RadioButtonModel radioButtonModel = new RadioButtonModel();
|
||||
radioButtonModel.setChoiceModels(createChoiceModels(radioButtonType
|
||||
.getChoices()));
|
||||
return radioButtonModel;
|
||||
|
||||
}
|
||||
|
||||
private FileModel createFileModel(FileType fileType) {
|
||||
FileModel fileModel = new FileModel();
|
||||
fileModel.setText(fileType.getText());
|
||||
return fileModel;
|
||||
|
||||
}
|
||||
|
||||
private List<ChoiceModel> createChoiceModels(List<ChoiceType> choiceTypes) {
|
||||
List<ChoiceModel> choiceModels = new LinkedList<ChoiceModel>();
|
||||
for (ChoiceType choiceType : choiceTypes) {
|
||||
choiceModels.add(createChoiceModel(choiceType));
|
||||
}
|
||||
return choiceModels;
|
||||
}
|
||||
|
||||
private ChoiceModel createChoiceModel(ChoiceType choiceType) {
|
||||
ChoiceModel choiceModel = new ChoiceModel();
|
||||
choiceModel.setDefaultValue(choiceType.isDefaultValue());
|
||||
choiceModel.setValue(choiceType.getValue());
|
||||
return choiceModel;
|
||||
|
||||
}
|
||||
}
|
|
@ -35,16 +35,26 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class PluginEntityFactory {
|
||||
private Logger logger = Logger.getLogger(PluginEntityFactory.class);
|
||||
private final String[] behaviorTypes = { "behavior", "timer", "control" };
|
||||
|
||||
private Document getDocument(String pluginUI) {
|
||||
try {
|
||||
return DocumentHelper.parseText(pluginUI);
|
||||
|
||||
} catch (DocumentException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public PluginUI createPluginUIWithOutId(String pluginUIContent) {
|
||||
Element root = getDocument(pluginUIContent).getRootElement();
|
||||
PluginUI pluginUI = new PluginUI();
|
||||
String[] behaviorNames = { "behavior", "timer", "control" };
|
||||
pluginUI.setPluginInfo(createPluginInfoWithOutId(XmlParseHelper
|
||||
.getOneChildElementByName(root, "plugin")));
|
||||
|
||||
pluginUI.setPluginInfo(createPluginInfoWithOutId(
|
||||
XmlParseHelper.getOneChildElementByName(root, "plugin"),
|
||||
pluginUI));
|
||||
pluginUI.setBehaviorInfos(createBehaviorInfosWithOutId(
|
||||
XmlParseHelper.getChildElements(root, behaviorNames), pluginUI));
|
||||
XmlParseHelper.getChildElements(root, behaviorTypes), pluginUI));
|
||||
pluginUI.setCreateDateTime(new Date());
|
||||
return pluginUI;
|
||||
}
|
||||
|
@ -58,7 +68,7 @@ public class PluginEntityFactory {
|
|||
return behaviorInfos;
|
||||
}
|
||||
|
||||
private ParamsContainer createBehaviorInfoWithOutId(Element element,
|
||||
private BehaviorInfo createBehaviorInfoWithOutId(Element element,
|
||||
PluginUI pluginUI) {
|
||||
BehaviorInfo behaviorInfo = new BehaviorInfo();
|
||||
behaviorInfo.setBehavoirType(element.getName());
|
||||
|
@ -66,63 +76,33 @@ public class PluginEntityFactory {
|
|||
behaviorInfo.setPluginUI(pluginUI);
|
||||
Element paramsElement = XmlParseHelper.getOneChildElementByName(
|
||||
element, "params");
|
||||
behaviorInfo.setParams(createBehaviorParamInfos(
|
||||
XmlParseHelper.getChildElements(paramsElement), behaviorInfo));
|
||||
behaviorInfo.setParams(createParamInfos(
|
||||
XmlParseHelper.getChildElementsByName(paramsElement, "params"),
|
||||
behaviorInfo));
|
||||
behaviorInfo.setGroups(createGroups(
|
||||
XmlParseHelper.getChildElementsByName(paramsElement, "group"),
|
||||
behaviorInfo));
|
||||
return behaviorInfo;
|
||||
}
|
||||
|
||||
// combine this code with the pluginParamInfo
|
||||
|
||||
private Set<BehaviorParamInfo> createBehaviorParamInfos(
|
||||
List<Element> elements, BehaviorInfo behaviorInfo) {
|
||||
Set<BehaviorParamInfo> paramInfos = new HashSet<BehaviorParamInfo>();
|
||||
for (Element element : elements) {
|
||||
BehaviorParamInfo behaviorParamInfo = createBehaviorParamInfo(
|
||||
element, behaviorInfo);
|
||||
if (behaviorParamInfo != null)
|
||||
paramInfos.add(behaviorParamInfo);
|
||||
}
|
||||
if (paramInfos.size() == 0)
|
||||
paramInfos = null;
|
||||
return paramInfos;
|
||||
}
|
||||
|
||||
private Document getDocument(String pluginUI) {
|
||||
try {
|
||||
return DocumentHelper.parseText(pluginUI);
|
||||
|
||||
} catch (DocumentException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private PluginInfo createPluginInfoWithOutId(Element element) {
|
||||
private PluginInfo createPluginInfoWithOutId(Element element,
|
||||
PluginUI pluginUI) {
|
||||
|
||||
PluginInfo pluginInfo = new PluginInfo();
|
||||
pluginInfo.setName(XmlParseHelper.getAttribute(element, "name"));
|
||||
pluginInfo.setPluginUI(pluginUI);
|
||||
Element paramsElement = XmlParseHelper.getOneChildElementByName(
|
||||
element, "params");
|
||||
pluginInfo.setPluginParamInfos(createPluginParamInfos(
|
||||
XmlParseHelper.getChildElements(paramsElement), pluginInfo));
|
||||
pluginInfo.setGroups(createGroups(
|
||||
XmlParseHelper.getChildElementsByName(paramsElement, "group"),
|
||||
pluginInfo));
|
||||
pluginInfo.setParams(createParamInfos(
|
||||
XmlParseHelper.getChildElementsByName(paramsElement, "param"),
|
||||
pluginInfo));
|
||||
return pluginInfo;
|
||||
|
||||
}
|
||||
|
||||
private Set<PluginParamInfo> createPluginParamInfos(List<Element> elements,
|
||||
PluginInfo pluginInfo) {
|
||||
Set<PluginParamInfo> paramInfos = new HashSet<PluginParamInfo>();
|
||||
for (Element element : elements) {
|
||||
PluginParamInfo pluginParamInfo = createPluginParamInfoWithOutId(
|
||||
element, pluginInfo);
|
||||
if (pluginParamInfo != null)
|
||||
paramInfos.add(pluginParamInfo);
|
||||
}
|
||||
if (paramInfos.size() == 0)
|
||||
paramInfos = null;
|
||||
return paramInfos;
|
||||
}
|
||||
|
||||
private ParamInfo createParamInfoWithOutId(Element paramElement,
|
||||
ParamsContainer paramsContainer) {
|
||||
if (!paramElement.getName().equals("param")) {
|
||||
|
@ -142,12 +122,33 @@ public class PluginEntityFactory {
|
|||
return paramInfo;
|
||||
}
|
||||
|
||||
private List<ParamInfo> createParamInfos(List<Element> paramElements,
|
||||
ParamsContainer paramsContainer) {
|
||||
if (paramElements == null) {
|
||||
private Group createGroup(Element groupElement,
|
||||
ParamsContainer fatherParamsContainer) {
|
||||
if (!groupElement.getName().equals("group")) {
|
||||
logger.info("element is not a group:" + groupElement.getName());
|
||||
return null;
|
||||
}
|
||||
List<ParamInfo> paramInfos = new LinkedList<ParamInfo>();
|
||||
Group paramsContainer = new Group();
|
||||
paramsContainer.setName(XmlParseHelper.getAttribute(groupElement,
|
||||
"name"));
|
||||
|
||||
List<Element> paramElements = XmlParseHelper.getChildElementsByName(
|
||||
groupElement, "param");
|
||||
|
||||
if (paramElements.size() > 0) {
|
||||
paramsContainer.setParams(createParamInfos(paramElements,
|
||||
paramsContainer));
|
||||
}
|
||||
paramsContainer.setParamsContainer(paramsContainer);
|
||||
return paramsContainer;
|
||||
}
|
||||
|
||||
private Set<ParamInfo> createParamInfos(List<Element> paramElements,
|
||||
ParamsContainer paramsContainer) {
|
||||
if (paramElements.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Set<ParamInfo> paramInfos = new HashSet<ParamInfo>();
|
||||
for (Element paramElement : paramElements) {
|
||||
paramInfos.add(createParamInfoWithOutId(paramElement,
|
||||
paramsContainer));
|
||||
|
@ -155,21 +156,17 @@ public class PluginEntityFactory {
|
|||
return paramInfos;
|
||||
}
|
||||
|
||||
private Group createGroup(Element groupElement,
|
||||
ParamsContainer paramsContainer) {
|
||||
if (!groupElement.getName().equals("group")) {
|
||||
logger.info("element is not a group:" + groupElement.getName());
|
||||
private Set<Group> createGroups(
|
||||
|
||||
List<Element> groupElements, ParamsContainer baseContainer) {
|
||||
if (groupElements.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Group group = new Group();
|
||||
group.setName(XmlParseHelper.getAttribute(groupElement, "name"));
|
||||
List<Element> groupElements = XmlParseHelper.getChildElementsByName(
|
||||
groupElement, "group");
|
||||
List<Element> paramElements = XmlParseHelper.getChildElementsByName(
|
||||
groupElement, "param");
|
||||
I
|
||||
group.setParamsContainer(paramsContainer);
|
||||
return group;
|
||||
Set<Group> groups = new HashSet<Group>();
|
||||
for (Element element : groupElements) {
|
||||
groups.add(createGroup(element, baseContainer));
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
private static class ParamTypeFactory {
|
||||
|
|
|
@ -261,28 +261,6 @@ public class TestPlanFactory {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: remove this, because it's has no use
|
||||
// public List<RunningAgentDB> createRunningAgentDBsWithoutId(
|
||||
// List<? extends RunningAgentInterface> runningAgents,
|
||||
// TestPlanScript testPlanScript) {
|
||||
// // TODO: see this kind of map RunningAgent to agent, maybe there's a
|
||||
// // problem
|
||||
// List<RunningAgentDB> runningAgentDBs = new ArrayList<RunningAgentDB>();
|
||||
// for (RunningAgentInterface runningAgent : runningAgents) {
|
||||
// RunningAgentDB runningAgentDB = new RunningAgentDB();
|
||||
// runningAgentDB.setAgent(this.getAgentRepository().getAgentBy(
|
||||
// runningAgent.getAgent().getHostName()));
|
||||
// runningAgentDB.setAgentRunId(runningAgent.getAgentRunId());
|
||||
// runningAgentDB.setLoadInUse(runningAgent.getLoadInUse());
|
||||
// runningAgentDB.setAgentMessenger(this.getAgentMessenger());
|
||||
// runningAgentDB.setScript(this.getScriptService().getScript(
|
||||
// runningAgent.getScriptId()));
|
||||
// runningAgentDB.setTestPlanScript(testPlanScript);
|
||||
// runningAgentDBs.add(runningAgentDB);
|
||||
// }
|
||||
// return runningAgentDBs;
|
||||
// }
|
||||
|
||||
private void convertToDomain(Monitor monitor) {
|
||||
monitor.setTestPlanFactory(this);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Set;
|
|||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
import org.bench4q.master.domain.factory.PluginDomainFactory;
|
||||
import org.bench4q.master.domain.factory.PluginEntityFactory;
|
||||
import org.bench4q.share.models.master.plugin.BehaviorInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
|
@ -18,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||
public class PluginService {
|
||||
private PluginRepository pluginRepository;
|
||||
private PluginEntityFactory pluginEntityFactory;
|
||||
private PluginDomainFactory pluginDomainFactory;
|
||||
// private PluginDomainFactory pluginDomainFactory;
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
|
@ -38,14 +37,14 @@ public class PluginService {
|
|||
this.pluginEntityFactory = pluginEntityFactory;
|
||||
}
|
||||
|
||||
public PluginDomainFactory getPluginDomainFactory() {
|
||||
return pluginDomainFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginDomainFactory(PluginDomainFactory pluginDomainFactory) {
|
||||
this.pluginDomainFactory = pluginDomainFactory;
|
||||
}
|
||||
// public PluginDomainFactory getPluginDomainFactory() {
|
||||
// return pluginDomainFactory;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setPluginDomainFactory(PluginDomainFactory pluginDomainFactory) {
|
||||
// this.pluginDomainFactory = pluginDomainFactory;
|
||||
// }
|
||||
|
||||
public boolean addPlugin(String pluginUIContent) {
|
||||
return this.getPluginRepository().attatch(
|
||||
|
@ -57,41 +56,41 @@ public class PluginService {
|
|||
return this.getPluginRepository().detach(pluginName);
|
||||
}
|
||||
|
||||
public List<String> getPluginNameList() {
|
||||
List<PluginUIModel> pluginUIModels = this.loadPluginUIs();
|
||||
if (pluginUIModels == null)
|
||||
return null;
|
||||
List<String> pluginNameList = new LinkedList<String>();
|
||||
for (PluginUIModel pluginUIModel : this.loadPluginUIs()) {
|
||||
pluginNameList.add(pluginUIModel.getPluginInfoModel().getName());
|
||||
}
|
||||
return pluginNameList;
|
||||
// public List<String> getPluginNameList() {
|
||||
// List<PluginUIModel> pluginUIModels = this.loadPluginUIs();
|
||||
// if (pluginUIModels == null)
|
||||
// return null;
|
||||
// List<String> pluginNameList = new LinkedList<String>();
|
||||
// for (PluginUIModel pluginUIModel : this.loadPluginUIs()) {
|
||||
// pluginNameList.add(pluginUIModel.getPluginInfoModel().getName());
|
||||
// }
|
||||
// return pluginNameList;
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public List<PluginUIModel> loadPluginUIs() {
|
||||
List<PluginUI> pluginUIs = this.getPluginRepository().loadPlugins();
|
||||
if (pluginUIs == null)
|
||||
return null;
|
||||
List<PluginUIModel> pluginUIModels = new LinkedList<PluginUIModel>();
|
||||
for (PluginUI pluginUI : pluginUIs) {
|
||||
pluginUIModels.add(this.getPluginDomainFactory()
|
||||
.createPluginUIModelwithOutBehaviors(pluginUI));
|
||||
}
|
||||
|
||||
return pluginUIModels;
|
||||
}
|
||||
|
||||
public List<BehaviorInfoModel> loadBehaviorInfoModels(String pluginName) {
|
||||
|
||||
Set<BehaviorInfo> behaviorInfos = this.getPluginRepository()
|
||||
.loadBehaviorInfos(pluginName);
|
||||
if (behaviorInfos == null)
|
||||
return null;
|
||||
return this.getPluginDomainFactory().createBehaviorInfoModels(
|
||||
this.getPluginRepository().loadBehaviorInfos(pluginName));
|
||||
|
||||
}
|
||||
// public List<PluginUIModel> loadPluginUIs() {
|
||||
// List<PluginUI> pluginUIs = this.getPluginRepository().loadPlugins();
|
||||
// if (pluginUIs == null)
|
||||
// return null;
|
||||
// List<PluginUIModel> pluginUIModels = new LinkedList<PluginUIModel>();
|
||||
// for (PluginUI pluginUI : pluginUIs) {
|
||||
// pluginUIModels.add(this.getPluginDomainFactory()
|
||||
// .createPluginUIModelwithOutBehaviors(pluginUI));
|
||||
// }
|
||||
//
|
||||
// return pluginUIModels;
|
||||
// }
|
||||
//
|
||||
// public List<BehaviorInfoModel> loadBehaviorInfoModels(String pluginName) {
|
||||
//
|
||||
// Set<BehaviorInfo> behaviorInfos = this.getPluginRepository()
|
||||
// .loadBehaviorInfos(pluginName);
|
||||
// if (behaviorInfos == null)
|
||||
// return null;
|
||||
// return this.getPluginDomainFactory().createBehaviorInfoModels(
|
||||
// this.getPluginRepository().loadBehaviorInfos(pluginName));
|
||||
//
|
||||
// }
|
||||
|
||||
public boolean isPluginExist(String pluginName) {
|
||||
return this.getPluginRepository().isExist(pluginName);
|
||||
|
|
|
@ -28,12 +28,13 @@
|
|||
<mapping class="org.bench4q.master.domain.entity.TestPlanScriptResult" />
|
||||
<mapping class="org.bench4q.master.domain.entity.Monitor" />
|
||||
<mapping class="org.bench4q.master.domain.entity.MonitorResult" />
|
||||
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.PluginUI" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.PluginInfo" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.BehaviorInfo" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.ParamsContainer" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.Group" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.ParamType" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.PluginParamInfo" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.BehaviorParamInfo" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.ParamInfo" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.FieldType" />
|
||||
<mapping class="org.bench4q.master.domain.entity.plugin.NFieldType" />
|
||||
|
|
|
@ -83,57 +83,57 @@ public class PluginControllerTest extends TestBase {
|
|||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadPluginNameList() throws JAXBException, IOException {
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
String url = URLSTRING + "/loadPluginNameList";
|
||||
int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
this.test_PluginHelper.addPlugin("ui.xml", pluginService, pluginName);
|
||||
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
makeAccessTockenMap(this.getAccessTocken()));
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
.tryUnmarshal(PluginResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
assertNotNull(pluginResponseModel);
|
||||
Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0);
|
||||
assertEquals(insertBefore + 1, pluginResponseModel.getPluginList()
|
||||
.size());
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadPluginList() throws IOException, JAXBException {
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
this.getTest_PluginHelper().addPlugin(fileName,
|
||||
this.getPluginService(), pluginName);
|
||||
String url = URLSTRING + "/loadPluginList";
|
||||
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
makeAccessTockenMap(this.getAccessTocken()));
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
.tryUnmarshal(PluginResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
assertNotNull(pluginResponseModel);
|
||||
assertEquals(insertBefore + 1, pluginResponseModel.getPluginUIModels()
|
||||
.size());
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePlugin() throws IOException {
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
this.getTest_PluginHelper().addPlugin(fileName,
|
||||
this.getPluginService(), pluginName);
|
||||
String url = URLSTRING + "/deletePlugin" + "/" + this.pluginName;
|
||||
HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
makeAccessTockenMap(this.getAccessTocken()));
|
||||
PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
.tryUnmarshal(PluginResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
assertNotNull(pluginResponseModel);
|
||||
assertTrue(pluginResponseModel.isSuccess());
|
||||
}
|
||||
// @Test
|
||||
// public void testLoadPluginNameList() throws JAXBException, IOException {
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// String url = URLSTRING + "/loadPluginNameList";
|
||||
// int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
// this.test_PluginHelper.addPlugin("ui.xml", pluginService, pluginName);
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
// .tryUnmarshal(PluginResponseModel.class,
|
||||
// httpResponse.getContent());
|
||||
// assertNotNull(pluginResponseModel);
|
||||
// Assert.assertTrue(pluginResponseModel.isSuccess());
|
||||
// Assert.assertTrue(pluginResponseModel.getPluginList().size() > 0);
|
||||
// assertEquals(insertBefore + 1, pluginResponseModel.getPluginList()
|
||||
// .size());
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testLoadPluginList() throws IOException, JAXBException {
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
// this.getTest_PluginHelper().addPlugin(fileName,
|
||||
// this.getPluginService(), pluginName);
|
||||
// String url = URLSTRING + "/loadPluginList";
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
// .tryUnmarshal(PluginResponseModel.class,
|
||||
// httpResponse.getContent());
|
||||
// assertNotNull(pluginResponseModel);
|
||||
// assertEquals(insertBefore + 1, pluginResponseModel.getPluginUIModels()
|
||||
// .size());
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testDeletePlugin() throws IOException {
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// this.getTest_PluginHelper().addPlugin(fileName,
|
||||
// this.getPluginService(), pluginName);
|
||||
// String url = URLSTRING + "/deletePlugin" + "/" + this.pluginName;
|
||||
// HttpResponse httpResponse = this.httpRequester.sendPost(url, null,
|
||||
// makeAccessTockenMap(this.getAccessTocken()));
|
||||
// PluginResponseModel pluginResponseModel = (PluginResponseModel) MarshalHelper
|
||||
// .tryUnmarshal(PluginResponseModel.class,
|
||||
// httpResponse.getContent());
|
||||
// assertNotNull(pluginResponseModel);
|
||||
// assertTrue(pluginResponseModel.isSuccess());
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testGetBehaviors() throws IOException, JAXBException {
|
||||
|
|
|
@ -1,92 +1,92 @@
|
|||
package org.bench4q.master.test.factory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
import org.bench4q.master.domain.factory.PluginDomainFactory;
|
||||
import org.bench4q.master.domain.repository.PluginRepository;
|
||||
import org.bench4q.master.test.testHelper.Test_PluginHelper;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_PluginDomainFactory extends Test_PluginHelper {
|
||||
private PluginDomainFactory pluginDomainFactory;
|
||||
private PluginRepository pluginRepository;
|
||||
private String pluginName;
|
||||
|
||||
public PluginDomainFactory getPluginDomainFactory() {
|
||||
return pluginDomainFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginDomainFactory(PluginDomainFactory pluginDomainFactory) {
|
||||
this.pluginDomainFactory = pluginDomainFactory;
|
||||
}
|
||||
|
||||
public PluginRepository getPluginRepository() {
|
||||
return pluginRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
this.pluginRepository = pluginRepository;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.pluginName = addPlugin("ui.xml", pluginRepository);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_createPluginUIModel() {
|
||||
assertNotNull(pluginName);
|
||||
PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
|
||||
|
||||
PluginUIModel pluginUIModel = this.getPluginDomainFactory()
|
||||
.createPluginUIModelwithOutBehaviors(pluginUI);
|
||||
assertNotNull(pluginUIModel);
|
||||
assertNull(pluginUIModel.getBehaviorInfos());
|
||||
assertEquals(7, pluginUIModel.getPluginInfoModel().getParamInfoModels()
|
||||
.size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_createParamInfoModel() throws JAXBException {
|
||||
assertNotNull(pluginName);
|
||||
PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
|
||||
|
||||
PluginUIModel pluginUIModel = this.getPluginDomainFactory()
|
||||
.createPluginUIModelwithOutBehaviors(pluginUI);
|
||||
assertNotNull(pluginUIModel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_CreateBehaviorModels() {
|
||||
assertNotNull(pluginName);
|
||||
Set<BehaviorInfo> behaviorInfos = this.getPluginRepository()
|
||||
.loadBehaviorInfos(pluginName);
|
||||
assertNotNull(behaviorInfos);
|
||||
assertTrue(behaviorInfos.size() > 0);
|
||||
assertEquals(2, behaviorInfos.size());
|
||||
}
|
||||
|
||||
}
|
||||
//package org.bench4q.master.test.factory;
|
||||
//
|
||||
//import static org.junit.Assert.*;
|
||||
//
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import javax.xml.bind.JAXBException;
|
||||
//import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
//import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
//import org.bench4q.master.domain.factory.PluginDomainFactory;
|
||||
//import org.bench4q.master.domain.repository.PluginRepository;
|
||||
//import org.bench4q.master.test.testHelper.Test_PluginHelper;
|
||||
//import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
//import org.junit.After;
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.test.context.ContextConfiguration;
|
||||
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
//
|
||||
//
|
||||
//@RunWith(SpringJUnit4ClassRunner.class)
|
||||
//@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
//public class Test_PluginDomainFactory extends Test_PluginHelper {
|
||||
// private PluginDomainFactory pluginDomainFactory;
|
||||
// private PluginRepository pluginRepository;
|
||||
// private String pluginName;
|
||||
//
|
||||
// public PluginDomainFactory getPluginDomainFactory() {
|
||||
// return pluginDomainFactory;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setPluginDomainFactory(PluginDomainFactory pluginDomainFactory) {
|
||||
// this.pluginDomainFactory = pluginDomainFactory;
|
||||
// }
|
||||
//
|
||||
// public PluginRepository getPluginRepository() {
|
||||
// return pluginRepository;
|
||||
// }
|
||||
//
|
||||
// @Autowired
|
||||
// public void setPluginRepository(PluginRepository pluginRepository) {
|
||||
// this.pluginRepository = pluginRepository;
|
||||
// }
|
||||
//
|
||||
// @Before
|
||||
// public void setUp() {
|
||||
// this.pluginName = addPlugin("ui.xml", pluginRepository);
|
||||
// }
|
||||
//
|
||||
// @After
|
||||
// public void clear() {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_createPluginUIModel() {
|
||||
// assertNotNull(pluginName);
|
||||
// PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
|
||||
//
|
||||
// PluginUIModel pluginUIModel = this.getPluginDomainFactory()
|
||||
// .createPluginUIModelwithOutBehaviors(pluginUI);
|
||||
// assertNotNull(pluginUIModel);
|
||||
// assertNull(pluginUIModel.getBehaviorInfos());
|
||||
// assertEquals(7, pluginUIModel.getPluginInfoModel().getParamInfoModels()
|
||||
// .size());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_createParamInfoModel() throws JAXBException {
|
||||
// assertNotNull(pluginName);
|
||||
// PluginUI pluginUI = this.getPluginRepository().getPluginUI(pluginName);
|
||||
//
|
||||
// PluginUIModel pluginUIModel = this.getPluginDomainFactory()
|
||||
// .createPluginUIModelwithOutBehaviors(pluginUI);
|
||||
// assertNotNull(pluginUIModel);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_CreateBehaviorModels() {
|
||||
// assertNotNull(pluginName);
|
||||
// Set<BehaviorInfo> behaviorInfos = this.getPluginRepository()
|
||||
// .loadBehaviorInfos(pluginName);
|
||||
// assertNotNull(behaviorInfos);
|
||||
// assertTrue(behaviorInfos.size() > 0);
|
||||
// assertEquals(2, behaviorInfos.size());
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -9,8 +9,8 @@ import java.util.Set;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.bench4q.master.domain.entity.plugin.BehaviorInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.FieldType;
|
||||
import org.bench4q.master.domain.entity.plugin.ParamInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginParamInfo;
|
||||
import org.bench4q.master.domain.entity.plugin.PluginUI;
|
||||
import org.bench4q.master.domain.factory.PluginEntityFactory;
|
||||
import org.junit.Test;
|
||||
|
@ -48,20 +48,20 @@ public class Test_PluginEntityFactory {
|
|||
assertNotNull(pluginUI.getBehaviorInfos());
|
||||
assertNotNull(pluginUI.getPluginInfo());
|
||||
PluginInfo pluginInfo = pluginUI.getPluginInfo();
|
||||
assertNotNull(pluginInfo.getPluginParamInfos());
|
||||
assertEquals(pluginInfo.getPluginParamInfos().size(), 7);
|
||||
Set<PluginParamInfo> pluginParamInfos = pluginInfo
|
||||
.getPluginParamInfos();
|
||||
assertNotNull(pluginInfo.getPluginUI());
|
||||
assertEquals(pluginInfo.getParams().size(), 7);
|
||||
Set<ParamInfo> pluginParamInfos = pluginInfo.getParams();
|
||||
FieldType fieldType = null;
|
||||
for (PluginParamInfo pluginParamInfo : pluginParamInfos) {
|
||||
for (ParamInfo pluginParamInfo : pluginParamInfos) {
|
||||
if (pluginParamInfo.getParamType() instanceof FieldType)
|
||||
fieldType = (FieldType) pluginParamInfo.getParamType();
|
||||
}
|
||||
assertTrue(fieldType.getSize() == 7);
|
||||
assertEquals(2, pluginUI.getBehaviorInfos().size());
|
||||
int timerCount=0;
|
||||
for( BehaviorInfo behaviorInfo:pluginUI.getBehaviorInfos()){
|
||||
if(behaviorInfo.getBehavoirType().equals("timer"))
|
||||
int timerCount = 0;
|
||||
System.out.println(pluginUI.getBehaviorInfos().size());
|
||||
for (BehaviorInfo behaviorInfo : pluginUI.getBehaviorInfos()) {
|
||||
if (behaviorInfo.getBehavoirType().equals("timer"))
|
||||
timerCount++;
|
||||
}
|
||||
assertEquals(1, timerCount);
|
||||
|
|
|
@ -70,22 +70,22 @@ public class Test_PluginService extends Test_PluginHelper {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadPlugins() {
|
||||
int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
addPluginByString();
|
||||
assertEquals(insertBefore + 1, this.getPluginService().loadPluginUIs()
|
||||
.size());
|
||||
this.getPluginService().deletePlugin(pluginName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadBehaviors() {
|
||||
addPluginByString();
|
||||
assertEquals(2,
|
||||
this.getPluginService().loadBehaviorInfoModels(pluginName)
|
||||
.size());
|
||||
}
|
||||
// @Test
|
||||
// public void test_loadPlugins() {
|
||||
// int insertBefore = this.getPluginService().loadPluginUIs().size();
|
||||
// addPluginByString();
|
||||
// assertEquals(insertBefore + 1, this.getPluginService().loadPluginUIs()
|
||||
// .size());
|
||||
// this.getPluginService().deletePlugin(pluginName);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void test_loadBehaviors() {
|
||||
// addPluginByString();
|
||||
// assertEquals(2,
|
||||
// this.getPluginService().loadBehaviorInfoModels(pluginName)
|
||||
// .size());
|
||||
// }
|
||||
|
||||
private void assertTure(boolean deletePlugin) {
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- <?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:task="http://www.springframework.org/schema/task" xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
|
@ -12,3 +12,4 @@
|
|||
<mvc:annotation-driven />
|
||||
<task:annotation-driven />
|
||||
</beans>
|
||||
-->
|
Loading…
Reference in New Issue