use of au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity 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);
}
use of au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity in project VaadinUtils by rlsutton1.
the class JasperReportScheduleLayout method emailRecipientsHandleRowChange.
private void emailRecipientsHandleRowChange(EntityItem<ReportEmailScheduleEntity> item) {
int ctr = 0;
emailTargetLayout.clear();
if (item != null) {
ReportEmailScheduleEntity entity = item.getEntity();
if (entity != null) {
for (ReportEmailRecipient recip : entity.getRecipients()) {
ctr++;
emailTargetLayout.add(recip);
}
if (ctr == 0) {
emailTargetLayout.add(null);
}
}
}
}
use of au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity in project VaadinUtils by rlsutton1.
the class JasperReportScheduleLayout method getStatusColumnGenerator.
private ColumnGenerator getStatusColumnGenerator() {
return new ColumnGenerator() {
private static final long serialVersionUID = -1873561613938103218L;
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
@SuppressWarnings("unchecked") EntityItem<ReportEmailScheduleEntity> item = (EntityItem<ReportEmailScheduleEntity>) source.getItem(itemId);
ReportEmailScheduleEntity schedule = item.getEntity();
final Label label = new Label("<font color='green'>Scheduled</font>");
label.setContentMode(ContentMode.HTML);
if (schedule.getReportLog() != null && schedule.getReportLog().length() > 0 && !schedule.getReportLog().equals(Scheduler.REPORT_SUCCESSFULLY_RUN)) {
label.setValue("<font color='red'><b>Error</b></font>");
} else {
if (!schedule.isEnabled()) {
label.setValue("<font color='orange'><b>Disabled</b></font>");
}
}
return label;
}
};
}
Aggregations