1 package org.whatsitcalled.webflange.model;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.List;
6
7 public class LoadTest implements Serializable {
8 private Long id;
9
10 private String name;
11
12 private Project project;
13
14 private Script script;
15
16 private List<Chart> charts = new ArrayList<Chart>();
17
18 private String properties = "";
19
20 private String frequency;
21
22 private String description;
23
24 private Boolean enabled = false;
25
26 private Boolean running = false;
27
28 private List<LoadTestRun> runs = new ArrayList<LoadTestRun>();
29
30 public String getFrequency() {
31 return frequency;
32 }
33
34 public void setFrequency(String frequency) {
35 this.frequency = frequency;
36 }
37
38 public String getName() {
39 return name;
40 }
41
42 public void setName(String name) {
43 this.name = name;
44 }
45
46 public Project getProject() {
47 return project;
48 }
49
50 public void setProject(Project project) {
51 this.project = project;
52 }
53
54 public String getProperties() {
55 if (properties == null) {
56 this.properties = "";
57 }
58 return properties;
59 }
60
61 public void setProperties(String properties) {
62 this.properties = properties;
63 }
64
65 public Long getId() {
66 return id;
67 }
68
69 public void setId(Long id) {
70 this.id = id;
71 }
72
73 @Override
74 public String toString() {
75 StringBuffer b = new StringBuffer();
76 b.append("id:");
77 b.append(this.getId());
78 b.append(" name:");
79 b.append(this.getName());
80
81 if (project != null) {
82 b.append(" project:");
83 b.append(this.getProject().getName());
84 }
85 if (script != null) {
86 b.append(" script:");
87 b.append(this.getScript().getName());
88 }
89 b.append(" properties:");
90 b.append(this.getProperties());
91 b.append(" frequency:");
92 b.append(this.getFrequency());
93 b.append(" description:");
94 b.append(this.getDescription());
95
96 return b.toString();
97 }
98
99 public String getDescription() {
100 return description;
101 }
102
103 public void setDescription(String description) {
104 this.description = description;
105 }
106
107 public String getProjectName() {
108 if (project == null) {
109 return "";
110 }
111
112 return project.getName();
113 }
114
115 public Script getScript() {
116 return script;
117 }
118
119 public void setScript(Script script) {
120 this.script = script;
121
122 }
123
124 public String getScriptName() {
125 if (script == null) {
126 return "";
127 }
128
129 return script.getName();
130 }
131
132 public Boolean getEnabled() {
133 return enabled;
134 }
135
136 public void setEnabled(Boolean enabled) {
137 this.enabled = enabled;
138 }
139
140 public List<Chart> getCharts() {
141 return charts;
142 }
143
144 public void setCharts(List<Chart> charts) {
145 this.charts = charts;
146 }
147
148 public List<LoadTestRun> getRuns() {
149 return runs;
150 }
151
152 public void setRuns(List<LoadTestRun> runs) {
153 this.runs = runs;
154 }
155
156 public LoadTestRun getLastRun() {
157 long time = 0;
158 LoadTestRun lastRun = null;
159 for (Object o: runs) {
160 LoadTestRun run = (LoadTestRun)o;
161 if (run.getTime() > time) {
162 time = run.getTime();
163 lastRun = run;
164 }
165 }
166
167 return lastRun;
168 }
169
170 public int hashCode() {
171 int hash = 1;
172 hash = hash * 31 + id.hashCode();
173 return hash;
174 }
175
176 @Override
177 public boolean equals(Object obj) {
178 return (obj.hashCode() == this.hashCode());
179 }
180
181 public Boolean getRunning() {
182 return running;
183 }
184
185 public void setRunning(Boolean running) {
186 this.running = running;
187 }
188
189 }