|
1 | 1 |
|
2 | 2 | package edu.harvard.iq.dataverse; |
3 | 3 |
|
| 4 | +import edu.harvard.iq.dataverse.util.BundleUtil; |
4 | 5 | import java.io.Serializable; |
5 | 6 | import java.text.SimpleDateFormat; |
6 | 7 | import java.util.ArrayList; |
|
19 | 20 | import javax.persistence.Temporal; |
20 | 21 | import javax.persistence.TemporalType; |
21 | 22 | import javax.persistence.Transient; |
| 23 | +import org.apache.commons.lang.StringEscapeUtils; |
22 | 24 | import org.hibernate.validator.constraints.NotBlank; |
23 | 25 |
|
24 | 26 | /** |
@@ -186,94 +188,63 @@ public boolean isDeletable() { |
186 | 188 |
|
187 | 189 | public void setDeletable(boolean deletable) { |
188 | 190 | this.deletable = deletable; |
189 | | - } |
190 | | - |
191 | | - public String getRequiredCustomQuestionsString(){ |
192 | | - String retVal = ""; |
193 | | - for (CustomQuestion cq : this.getCustomQuestions()){ |
194 | | - if(cq.isRequired()){ |
195 | | - if(retVal.isEmpty()){ |
196 | | - retVal = "Required Custom Questions<br/>  • " + cq.getQuestionString(); |
197 | | - } else { |
198 | | - retVal += "<br/>  • " + cq.getQuestionString(); |
199 | | - } |
200 | | - } |
201 | | - } |
202 | | - return retVal; |
203 | | - } |
204 | | - |
205 | | - public String getOptionalCustomQuestionsString(){ |
206 | | - String retVal = ""; |
207 | | - for (CustomQuestion cq : this.getCustomQuestions()){ |
208 | | - if(!cq.isRequired()){ |
209 | | - if(retVal.isEmpty()){ |
210 | | - retVal = "Optional Custom Questions<br/>  • " + cq.getQuestionString(); |
211 | | - } else { |
212 | | - retVal += "<br/>  • " + cq.getQuestionString(); |
213 | | - } |
214 | | - } |
215 | | - } |
216 | | - return retVal; |
217 | | - } |
| 191 | + } |
218 | 192 |
|
219 | | - public String getRequiredAccountInformationString(){ |
220 | | - String retVal = ""; |
221 | | - if(nameRequired){ |
222 | | - retVal = "Required Account Information<br/>  • Name"; |
| 193 | + public List<String> getRequiredAccountInformation() { |
| 194 | + List<String> retList = new ArrayList(); |
| 195 | + if (nameRequired) { |
| 196 | + retList.add(BundleUtil.getStringFromBundle("name")); |
223 | 197 | } |
224 | | - if(emailRequired){ |
225 | | - if(retVal.isEmpty()){ |
226 | | - retVal = "Required Account Information<br/>  • Email"; |
227 | | - } else { |
228 | | - retVal += "<br/>  • Email"; |
229 | | - } |
| 198 | + if (emailRequired) { |
| 199 | + retList.add(BundleUtil.getStringFromBundle("email")); |
230 | 200 | } |
231 | | - if(institutionRequired){ |
232 | | - if(retVal.isEmpty()){ |
233 | | - retVal = "Required Account Information<br/>  • Institution"; |
234 | | - } else { |
235 | | - retVal += "<br/>  • Institution"; |
236 | | - } |
| 201 | + if (institutionRequired) { |
| 202 | + retList.add(BundleUtil.getStringFromBundle("institution")); |
237 | 203 | } |
238 | | - if(positionRequired){ |
239 | | - if(retVal.isEmpty()){ |
240 | | - retVal = "Required Account Information<br/>  • Position"; |
241 | | - } else { |
242 | | - retVal += "<br/>  • Position"; |
243 | | - } |
| 204 | + if (positionRequired) { |
| 205 | + retList.add(BundleUtil.getStringFromBundle("position")); |
244 | 206 | } |
245 | | - return retVal; |
| 207 | + return retList; |
246 | 208 | } |
247 | 209 |
|
248 | | - public String getOptionalAccountInformationString(){ |
249 | | - String retVal = ""; |
| 210 | + public List<String> getOptionalAccountInformation(){ |
| 211 | + List <String> retList = new ArrayList(); |
250 | 212 | if(!nameRequired){ |
251 | | - retVal = "Optional Account Information<br/>  • Name"; |
| 213 | + retList.add(BundleUtil.getStringFromBundle("name")); |
252 | 214 | } |
253 | 215 | if(!emailRequired){ |
254 | | - if(retVal.isEmpty()){ |
255 | | - retVal = "Optional Account Information<br/>  • Email"; |
256 | | - } else { |
257 | | - retVal += "<br/>  • Email"; |
258 | | - } |
| 216 | + retList.add(BundleUtil.getStringFromBundle("email")); |
259 | 217 | } |
260 | 218 | if(!institutionRequired){ |
261 | | - if(retVal.isEmpty()){ |
262 | | - retVal = "Optional Account Information<br/>  • Institution"; |
263 | | - } else { |
264 | | - retVal += "<br/>  • Institution"; |
265 | | - } |
| 219 | + retList.add(BundleUtil.getStringFromBundle("institution")); |
266 | 220 | } |
267 | 221 | if(!positionRequired){ |
268 | | - if(retVal.isEmpty()){ |
269 | | - retVal = "Optional Account Information<br/>  • Position"; |
270 | | - } else { |
271 | | - retVal += "<br/>  • Position"; |
272 | | - } |
| 222 | + retList.add(BundleUtil.getStringFromBundle("position")); |
273 | 223 | } |
274 | | - return retVal; |
| 224 | + return retList; |
| 225 | + |
| 226 | + } |
| 227 | + |
| 228 | + public List<String> getRequiredQuestionsList(){ |
| 229 | + List <String> retList = new ArrayList(); |
| 230 | + for (CustomQuestion cq : this.getCustomQuestions()){ |
| 231 | + if(cq.isRequired()){ |
| 232 | + retList.add(cq.getQuestionString()); |
| 233 | + } |
| 234 | + } |
| 235 | + return retList; |
275 | 236 | } |
276 | 237 |
|
| 238 | + public List<String> getOptionalQuestionsList(){ |
| 239 | + List <String> retList = new ArrayList(); |
| 240 | + for (CustomQuestion cq : this.getCustomQuestions()){ |
| 241 | + if(!cq.isRequired()){ |
| 242 | + retList.add(cq.getQuestionString()); |
| 243 | + } |
| 244 | + } |
| 245 | + return retList; |
| 246 | + } |
| 247 | + |
277 | 248 | public void removeCustomQuestion(int index){ |
278 | 249 | customQuestions.remove(index); |
279 | 250 | } |
|
0 commit comments