diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java index b9c89491..12ae0193 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/api/PluginController.java @@ -7,6 +7,7 @@ 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.helper.MarshalHelper; import org.bench4q.share.models.master.plugin.BehaviorInfoModel; import org.bench4q.share.models.master.plugin.PluginResponseModel; import org.bench4q.share.models.master.plugin.PluginUIModel; @@ -18,7 +19,6 @@ 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 { @@ -107,6 +107,8 @@ public class PluginController extends BaseController { pluginResponseModel.setBehaviorInfoModels(behaviorInfoModels); } + logger.info(MarshalHelper.marshal(PluginResponseModel.class, + pluginResponseModel)); return pluginResponseModel; } catch (Exception e) { logger.error(ExceptionLog.getStackTrace(e)); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java new file mode 100644 index 00000000..6c6192d4 --- /dev/null +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/plugin/FileType.java @@ -0,0 +1,21 @@ +package org.bench4q.master.domain.entity.plugin; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "fieldType") +public class FileType extends ParamType { + private String text; + + @Column(name = "text") + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + +} diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginDomainFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginDomainFactory.java index 18f3b1ca..6fbc776c 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginDomainFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginDomainFactory.java @@ -12,6 +12,7 @@ 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; @@ -25,6 +26,7 @@ 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; @@ -59,12 +61,12 @@ public class PluginDomainFactory { ParamInfoModel paramInfoModel = new ParamInfoModel(); paramInfoModel.setLable(paramInfo.getLable()); paramInfoModel.setName(paramInfo.getName()); - paramInfoModel.setType(paramInfo.getParamType().getType()); try { ParamTypeModelFactory paramTypeModelFactory = new ParamTypeModelFactory(); paramInfoModel.setParamTypeModel(paramTypeModelFactory - .createParamTypeClassAndContnet(paramInfo)); + .createParamModel(paramInfo)); + } catch (JAXBException e) { // TODO Auto-generated catch block logger.info(ExceptionLog.getStackTrace(e)); @@ -110,32 +112,35 @@ public class PluginDomainFactory { @Component class ParamTypeModelFactory { - public ParamTypeModel createParamTypeClassAndContnet(ParamInfo paramInfo) + public ParamTypeModel createParamModel(ParamInfo paramInfo) throws JAXBException { ParamType paramType = paramInfo.getParamType(); + ParamTypeModel paramTypeModel = null; if (paramType instanceof FieldType) { - return createFieldModel((FieldType) paramType); + paramTypeModel = createFieldModel((FieldType) paramType); } else if (paramType instanceof NFieldType) { - return createNFieldModel((NFieldType) paramType); + paramTypeModel = createNFieldModel((NFieldType) paramType); } else if (paramType instanceof TableType) { - return createTableModel((TableType) paramType); + paramTypeModel = createTableModel((TableType) paramType); } else if (paramType instanceof CheckBoxType) { - return createCheckBoxModel((CheckBoxType) paramType); + paramTypeModel = createCheckBoxModel((CheckBoxType) paramType); } else if (paramType instanceof ComboType) { - return createComboModel((ComboType) paramType); + paramTypeModel = createComboModel((ComboType) paramType); } else if (paramType instanceof RadioButtonType) { - return createRadioButton((RadioButtonType) paramType); - } else - return null; + 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; } @@ -177,6 +182,13 @@ class ParamTypeModelFactory { } + private FileModel createFileModel(FileType fileType) { + FileModel fileModel = new FileModel(); + fileModel.setText(fileType.getText()); + return fileModel; + + } + private List createChoiceModels(List choiceTypes) { List choiceModels = new LinkedList(); for (ChoiceType choiceType : choiceTypes) { diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginEntityFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginEntityFactory.java index f98e0189..e32e31a5 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginEntityFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/PluginEntityFactory.java @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; + import org.apache.log4j.Logger; import org.bench4q.master.domain.entity.plugin.BehaviorInfo; import org.bench4q.master.domain.entity.plugin.BehaviorParamInfo; @@ -13,6 +14,7 @@ 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.ParamType; import org.bench4q.master.domain.entity.plugin.PluginInfo; @@ -54,7 +56,6 @@ public class PluginEntityFactory { return behaviorInfos; } - private BehaviorInfo createBehaviorInfoWithOutId(Element element, PluginUI pluginUI) { BehaviorInfo behaviorInfo = new BehaviorInfo(); @@ -67,8 +68,8 @@ public class PluginEntityFactory { XmlParseHelper.getChildElements(paramsElement), behaviorInfo)); return behaviorInfo; } - - //combine this code with the pluginParamInfo + + // combine this code with the pluginParamInfo private Set createBehaviorParamInfos( List elements, BehaviorInfo behaviorInfo) { @@ -84,8 +85,6 @@ public class PluginEntityFactory { return paramInfos; } - - private Document getDocument(String pluginUI) { try { return DocumentHelper.parseText(pluginUI); @@ -121,13 +120,14 @@ public class PluginEntityFactory { paramInfos = null; return paramInfos; } + private BehaviorParamInfo createBehaviorParamInfo(Element element, BehaviorInfo behaviorInfo) { if (XmlParseHelper.getAttribute(element, "name") == null) return null; BehaviorParamInfo behaviorParamInfo = new BehaviorParamInfo(); behaviorParamInfo.setLable(XmlParseHelper - .getAttribute(element, "lable")); + .getAttribute(element, "label")); behaviorParamInfo.setName(XmlParseHelper.getAttribute(element, "name")); ParamTypeFactory paramTypeFactory = new ParamTypeFactory(); behaviorParamInfo.setParamType(paramTypeFactory @@ -137,6 +137,7 @@ public class PluginEntityFactory { System.out.println(behaviorParamInfo.getName()); return behaviorParamInfo; } + private PluginParamInfo createPluginParamInfoWithOutId(Element element, PluginInfo pluginInfo) { if (XmlParseHelper.getAttribute(element, "name") == null) @@ -158,7 +159,7 @@ class ParamTypeFactory { String type = element.getName(); switch (type) { case "field": - return createFileType(element); + return createFieldType(element); case "nfield": return createNFieldType(element); case "table": @@ -169,12 +170,14 @@ class ParamTypeFactory { return createCheckBoxType(element); case "combo": return createComboType(element); + case "file": + return createFileType(element); } return null; } - private FieldType createFileType(Element element) { + private FieldType createFieldType(Element element) { FieldType fieldType = new FieldType(); fieldType.setType("field"); fieldType.setSize(Integer.parseInt(XmlParseHelper.getAttribute(element, @@ -244,6 +247,15 @@ class ParamTypeFactory { return choiceType; } + + private FileType createFileType(Element element) { + + FileType fileType = new FileType(); + fileType.setText(XmlParseHelper.getAttribute(element, "text")); + fileType.setType("file"); + return fileType; + + } } class XmlParseHelper { diff --git a/Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml index c1ba5fb6..a39c503d 100644 --- a/Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml +++ b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/hibernate.cfg.xml @@ -1,46 +1,47 @@ - - - - - com.mysql.jdbc.Driver - jdbc:mysql://localhost:3306/bench4q_master - - root - 123456 - 20 - false - false - true - utf-8 - org.hibernate.dialect.MySQLDialect - update - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/bench4q_master + + root + 123456 + 20 + false + false + true + utf-8 + org.hibernate.dialect.MySQLDialect + update + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java index 1bbdfba5..e4a5394a 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/controller/PluginControllerTest.java @@ -175,10 +175,6 @@ public class PluginControllerTest extends TestBase { pluginResponseModel = (PluginResponseModel) MarshalHelper .unmarshal(PluginResponseModel.class, httpResponse.getContent()); - System.out - .println(pluginResponseModel.getPluginUIModels().get(0) - .getPluginInfoModel().getParamInfoModels().get(0) - .getType()); } catch (Exception e) { logger.info(ExceptionLog.getStackTrace(e)); } diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/FileModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/FileModel.java new file mode 100644 index 00000000..ffd438a4 --- /dev/null +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/FileModel.java @@ -0,0 +1,19 @@ +package org.bench4q.share.models.master.plugin; + +import com.sun.xml.internal.txw2.annotation.XmlElement; + +@XmlElement +public class FileModel extends ParamTypeModel { + + private String text; + + @XmlElement + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + +} diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamInfoModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamInfoModel.java index 1062ee99..7faf5764 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamInfoModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamInfoModel.java @@ -9,7 +9,6 @@ public class ParamInfoModel { private String name; private String lable; - private String type; private ParamTypeModel paramTypeModel; @XmlElement @@ -30,21 +29,13 @@ public class ParamInfoModel { this.lable = lable; } - @XmlElement - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - @XmlElements({ @XmlElement(name = "field", type = FieldModel.class), @XmlElement(name = "table", type = TableModel.class), @XmlElement(name = "checkbox", type = CheckBoxModel.class), @XmlElement(name = "nfield", type = NFieldModel.class), @XmlElement(name = "combo", type = ComboModel.class), - @XmlElement(name = "radio", type = RadioButtonModel.class) }) + @XmlElement(name = "radio", type = RadioButtonModel.class), + @XmlElement(name = "file", type = FileModel.class) }) public ParamTypeModel getParamTypeModel() { return paramTypeModel; } diff --git a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeModel.java b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeModel.java index 4bdbfd10..ecb906ee 100644 --- a/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeModel.java +++ b/Bench4Q-Share/src/main/java/org/bench4q/share/models/master/plugin/ParamTypeModel.java @@ -2,8 +2,20 @@ package org.bench4q.share.models.master.plugin; import javax.xml.bind.annotation.XmlRootElement; +import com.sun.xml.internal.txw2.annotation.XmlElement; @XmlRootElement public class ParamTypeModel { + private String type; + + @XmlElement + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + }