use of au.com.vaadinutils.jasper.scheduler.entities.ReportEmailRecipient in project VaadinUtils by rlsutton1.
the class JasperReportScheduleLayout method interceptSaveValues.
@Override
protected void interceptSaveValues(EntityItem<ReportEmailScheduleEntity> entityItem) {
ReportEmailScheduleEntity entity = entityItem.getEntity();
entity.setNextScheduledRunTime(entity.getScheduleMode().getNextRuntime(entity, new Date()));
List<ReportEmailRecipient> recips = entity.getRecipients();
Set<ReportEmailRecipient> matchedRecips = new HashSet<ReportEmailRecipient>();
for (EmailTargetLine line : emailTargetLayout.getTargets()) {
// check if the recipient exists
String email = (String) line.targetAddress.getValue();
if (email != null && email.length() > 0) {
// String email = (String)
// item.getItemProperty("id").getValue();
boolean found = false;
for (ReportEmailRecipient recip : recips) {
if (recip.getEmail() != null && recip.getEmail().equalsIgnoreCase(email)) {
found = true;
recip.setVisibility((ReportEmailRecipientVisibility) line.targetTypeCombo.getValue());
matchedRecips.add(recip);
break;
}
}
// if not then add them
if (!found) {
ReportEmailRecipient reportEmailRecipient = new ReportEmailRecipient();
reportEmailRecipient.setEmail(email);
reportEmailRecipient.setVisibility((ReportEmailRecipientVisibility) line.targetTypeCombo.getValue());
recips.add(reportEmailRecipient);
matchedRecips.add(reportEmailRecipient);
}
}
}
recips.clear();
recips.addAll(matchedRecips);
if (recips.size() == 0) {
throw new InvalidValueException("Select at least one Recipient");
}
saveChangesToReportParameters(entity);
}
Aggregations