1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.web.forms;
20
21 import javax.servlet.http.HttpServletRequest;
22
23 import org.apache.log4j.Logger;
24 import org.apache.struts.action.ActionErrors;
25 import org.apache.struts.action.ActionMapping;
26 import org.apache.struts.action.ActionMessage;
27 import org.apache.struts.action.ActionMessages;
28 import org.apache.struts.validator.ValidatorForm;
29 import org.itracker.web.actions.admin.project.EditProjectFormActionUtil;
30 import org.itracker.web.util.ServletContextUtils;
31
32
33
34
35
36
37
38 public class ProjectForm extends ValidatorForm {
39
40
41
42 private static final long serialVersionUID = 1L;
43 private String action;
44 private Integer id;
45 private String name;
46 private Integer status;
47 private String description;
48 private Integer[] owners;
49 private Integer[] users;
50 private Integer[] permissions;
51 private Integer[] options;
52 private Integer[] fields;
53
54 private static final Logger log = Logger.getLogger(ProjectForm.class);
55
56 public void reset(ActionMapping mapping, HttpServletRequest request) {
57 action = null;
58 id = null;
59 name = null;
60 status = null;
61 description = null;
62 owners = null;
63 users = null;
64 permissions = null;
65 options = null;
66 fields = null;
67
68 }
69
70 public ActionErrors validate(ActionMapping mapping,
71 HttpServletRequest request) {
72 ActionErrors errors = super.validate(mapping, request);
73 if (log.isDebugEnabled()) {
74 log.debug("ProjectForm validate called: mapping: " + mapping
75 + ", request: " + request + ", errors: " + errors);
76 }
77 if (ServletContextUtils.getItrackerServices().getProjectService()
78 .isUniqueProjectName(getName(), getId())) {
79 } else {
80 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
81 "itracker.web.error.project.duplicate.name"));
82
83
84 }
85
86 new EditProjectFormActionUtil().init(mapping, request, this);
87 return errors;
88 }
89
90 public String getAction() {
91 return action;
92 }
93
94 public void setAction(String action) {
95 this.action = action;
96 }
97
98 public String getDescription() {
99 return description;
100 }
101
102 public void setDescription(String description) {
103 this.description = description;
104 }
105
106 public Integer[] getFields() {
107 if (null == fields)
108 return null;
109 return fields.clone();
110 }
111
112 public void setFields(Integer[] fields) {
113 if (null == fields)
114 this.fields = null;
115 else
116 this.fields = fields.clone();
117 }
118
119 public Integer getId() {
120 return id;
121 }
122
123 public void setId(Integer id) {
124 this.id = id;
125 }
126
127 public String getName() {
128 return name;
129 }
130
131 public void setName(String name) {
132 this.name = name;
133 }
134
135 public Integer[] getOptions() {
136 if (null == options)
137 return null;
138 return options.clone();
139 }
140
141 public void setOptions(Integer[] options) {
142 if (null == options)
143 this.options = null;
144 else
145 this.options = options.clone();
146 }
147
148 public Integer[] getOwners() {
149 if (null == owners)
150 return null;
151 return owners.clone();
152 }
153
154 public void setOwners(Integer[] owners) {
155 if (null == owners)
156 this.owners = null;
157 else
158 this.owners = owners.clone();
159 }
160
161 public Integer[] getPermissions() {
162 if (null == permissions)
163 return null;
164
165 return permissions.clone();
166
167 }
168
169 public void setPermissions(Integer[] permissions) {
170 if (null == permissions)
171 this.permissions = null;
172 else
173 this.permissions = permissions.clone();
174 }
175
176 public Integer getStatus() {
177 return status;
178 }
179
180 public void setStatus(Integer status) {
181 this.status = status;
182 }
183
184 public Integer[] getUsers() {
185 if (null == users)
186 return null;
187 return users.clone();
188 }
189
190 public void setUsers(Integer[] users) {
191 if (null == users)
192 this.users = null;
193 else
194 this.users = users.clone();
195 }
196
197 }