InteractionListForm timerEventInteractionListForm = (InteractionListForm)form;
String idParam = req.getParameter("id");
if (idParam != null) {
req.getSession().setAttribute("interactionListId", new Long(idParam)); // required for command entries
}
TimerEvent event = eventFromSession(req);
req.setAttribute("event", event);
timerEventInteractionListForm.setGroupId(event.getGroup().getId());
String applyTo;
if (event.getRequestingUser() != null){
if (event.getRequestingUser().getUsername() != null){
applyTo = event.getRequestingUser().getUsername();
} else {
applyTo = event.getRequestingUser().getMsisdn() + "";
}
} else if (event.getRequestingUserSet() != null){
applyTo = event.getRequestingUserSet().getName();
} else {
applyTo = event.getGroup().getGroupname();
}
req.setAttribute("applyTo",applyTo);
String repetition = "-";
MessageResources resources = getResources(req);
if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_WEEK) {
long weeks = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_WEEK;
repetition = resources.getMessage(locale,"smssvc.repeatEveryNWeeks", weeks +"");
} else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_DAY){
long days = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_DAY;
repetition = resources.getMessage(locale,"smssvc.repeatEveryNDays", days+"");
} else if (event.getIntervalInMillis() >= TimerEventEnterOrEditForm.MILLIS_PER_HOUR) {
long hours = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_HOUR;
repetition = resources.getMessage(locale,"smssvc.repeatEveryNHours", hours+"");
} else if (event.getIntervalInMillis() >= 1) {
long minutes = event.getIntervalInMillis() / TimerEventEnterOrEditForm.MILLIS_PER_MINUTE;
repetition = resources.getMessage(locale,"smssvc.repeatEveryNMinutes", minutes+"");
}
req.setAttribute("repetition", repetition);
SortedSet<CommandEntry> sortedCommandEntries = sortedCommandEntries(event);
List<DisplayableInteractionContent> interactionList = buildInteractionList(req, event.getGroup(), sortedCommandEntries,false,Boolean.TRUE.equals(timerEventInteractionListForm.getExpandFragments()));
req.setAttribute("interactions",interactionList);
long defaultInsertionPointId = sortedCommandEntries.size() == 0 ? 0L : insertionPointFromRequest(req, sortedCommandEntries.last()).getId();
timerEventInteractionListForm.setInsertCommandEntryId(defaultInsertionPointId);
timerEventInteractionListForm.setInsertionType(2);
req.setAttribute("commandEntries", sortedCommandEntries);