@DefaultHandler
@DontValidate
@SuppressWarnings("unchecked")
public Resolution form() {
if (noteId != null) {
Note n = notesService.getNote(noteId);
if (n == null || !n.getUser().equals(getContext().getUser()))
return new ErrorResolution(403);
this.color = n.getColor().toString();
this.enableScheduling = n.getSchedulingExpression() != null;
this.note = new Note();
this.schedulingVariant = n.getSchedulingVariant();
this.note.setTitle(n.getTitle());
this.note.setText(n.getText());
this.note.setActivated(n.isActivated());
this.note.setSendActivationNotifications(n.isSendActivationNotifications());
if (n.getAttachments() != null) {
selectedAttachments = new ArrayList<Long>();
for (Attachment a : n.getAttachments()) selectedAttachments.add(a.getId());
}
if (this.enableScheduling) {
switch (this.schedulingVariant) {
case VARIANT_1:
Map<String, Object> m1 = SchedulingStringParsingHelper.reverseConversion(n.getSchedulingExpression(), SchedulingVariant.VARIANT_1);
this.hoursAndMinutes = (String) m1.get("hoursAndMinutes");
this.varOneMonths = (List<Integer>) m1.get("months");
this.varOneDaysOfMonth = (List<Integer>) m1.get("daysOfMonth");
break;
case VARIANT_2:
Map<String, Object> m2 = SchedulingStringParsingHelper.reverseConversion(n.getSchedulingExpression(), SchedulingVariant.VARIANT_2);
this.hoursAndMinutes = (String) m2.get("hoursAndMinutes");
this.varTwoDaysOfWeek = (List<Integer>) m2.get("daysOfWeek");
this.varTwoMonths = (List<Integer>) m2.get("months");
break;
case VARIANT_3:
Map<String, Object> m3 = SchedulingStringParsingHelper.reverseConversion(n.getSchedulingExpression(), SchedulingVariant.VARIANT_3);
this.hoursAndMinutes = (String) m3.get("hoursAndMinutes");
this.varThreeMonths = (List<Integer>) m3.get("months");
this.varThreeDayOfWeek = (Integer) m3.get("dayOfWeek");
this.varThreeFirstOrLast = (FirstOrLast) m3.get("firstOrLast");
break;
case VARIANT_4:
this.varFourSchedulingExpression = n.getSchedulingExpression();
break;
}
}
}
return new ForwardResolution("/WEB-INF/pages/secure/addNoteForm.jsp");