support for behaviorModel not abstract
This commit is contained in:
parent
a6901e5fe9
commit
1d29792225
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "batch")
|
||||
|
@ -12,7 +11,7 @@ public class BatchModel {
|
|||
private int Id;
|
||||
private int parentId;
|
||||
private int childId;
|
||||
private List<BehaviorBaseModel> behaviors;
|
||||
private List<BehaviorModel> behaviors;
|
||||
|
||||
@XmlElement
|
||||
public int getId() {
|
||||
|
@ -42,14 +41,12 @@ public class BatchModel {
|
|||
}
|
||||
|
||||
@XmlElementWrapper(name = "behaviors")
|
||||
@XmlElements(value = {
|
||||
@XmlElement(name = "userBehavior", type = UserBehaviorModel.class),
|
||||
@XmlElement(name = "timerBehavior", type = TimerBehaviorModel.class) })
|
||||
public List<BehaviorBaseModel> getBehaviors() {
|
||||
@XmlElement(name = "behaviorModel")
|
||||
public List<BehaviorModel> getBehaviors() {
|
||||
return behaviors;
|
||||
}
|
||||
|
||||
public void setBehaviors(List<BehaviorBaseModel> behaviors) {
|
||||
public void setBehaviors(List<BehaviorModel> behaviors) {
|
||||
this.behaviors = behaviors;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
package org.bench4q.share.models.agent.scriptrecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import org.bench4q.share.models.agent.ParameterModel;
|
||||
|
||||
public abstract class BehaviorBaseModel {
|
||||
private int id;
|
||||
private String use;
|
||||
private String name;
|
||||
private List<ParameterModel> parameters;
|
||||
|
||||
@XmlElement
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getUse() {
|
||||
return use;
|
||||
}
|
||||
|
||||
public void setUse(String use) {
|
||||
this.use = use;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "parameters")
|
||||
@XmlElement(name = "parameter")
|
||||
public List<ParameterModel> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(List<ParameterModel> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package org.bench4q.share.models.agent.scriptrecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.bench4q.share.models.agent.ParameterModel;
|
||||
|
||||
@XmlRootElement(name = "behaviorModel")
|
||||
public class BehaviorModel {
|
||||
private int id;
|
||||
private String use;
|
||||
private String name;
|
||||
private String type;
|
||||
private List<ParameterModel> parameters;
|
||||
|
||||
@XmlElement
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getUse() {
|
||||
return use;
|
||||
}
|
||||
|
||||
public void setUse(String use) {
|
||||
this.use = use;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "parameters")
|
||||
@XmlElement(name = "parameter")
|
||||
public List<ParameterModel> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(List<ParameterModel> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
private BehaviorModel() {
|
||||
}
|
||||
|
||||
public static BehaviorModel TimerBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> parameters) {
|
||||
BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(id,
|
||||
name, use, parameters);
|
||||
behaviorBaseModel.setType("TIMERBEHAVIOR");
|
||||
return behaviorBaseModel;
|
||||
}
|
||||
|
||||
private static BehaviorModel buildBehaviorModelWithoutType(int id,
|
||||
String name, String use, List<ParameterModel> parameters) {
|
||||
BehaviorModel behaviorBaseModel = new BehaviorModel();
|
||||
behaviorBaseModel.setId(id);
|
||||
behaviorBaseModel.setName(name);
|
||||
behaviorBaseModel.setUse(use);
|
||||
behaviorBaseModel.setParameters(parameters);
|
||||
return behaviorBaseModel;
|
||||
}
|
||||
|
||||
public static BehaviorModel UserBehaviorBuilder(int id, String name,
|
||||
String use, List<ParameterModel> parameters) {
|
||||
BehaviorModel behaviorBaseModel = buildBehaviorModelWithoutType(id,
|
||||
name, use, parameters);
|
||||
behaviorBaseModel.setType("USERBEHAVIOR");
|
||||
return behaviorBaseModel;
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package org.bench4q.share.models.agent.scriptrecord;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "timerBehavior")
|
||||
public class TimerBehaviorModel extends BehaviorBaseModel {
|
||||
|
||||
public String getModelString() {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try {
|
||||
Marshaller marshaller = JAXBContext.newInstance(this.getClass())
|
||||
.createMarshaller();
|
||||
marshaller.marshal(this, os);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return os.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package org.bench4q.share.models.agent.scriptrecord;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "userBehavior")
|
||||
public class UserBehaviorModel extends BehaviorBaseModel {
|
||||
public String getModelString() throws JAXBException {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
Marshaller marshaller = JAXBContext.newInstance(this.getClass())
|
||||
.createMarshaller();
|
||||
marshaller.marshal(this, os);
|
||||
return os.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue