Search in sources :

Example 6 with ReportEmailScheduleEntity

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);
}
Also used : InvalidValueException(com.vaadin.data.Validator.InvalidValueException) ReportEmailRecipient(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailRecipient) ReportEmailScheduleEntity(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity) Date(java.util.Date) HashSet(java.util.HashSet)

Example 7 with ReportEmailScheduleEntity

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);
            }
        }
    }
}
Also used : ReportEmailRecipient(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailRecipient) ReportEmailScheduleEntity(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)

Example 8 with ReportEmailScheduleEntity

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;
        }
    };
}
Also used : EntityTable(au.com.vaadinutils.crud.EntityTable) Table(com.vaadin.ui.Table) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ReportEmailScheduleEntity(au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity) Label(com.vaadin.ui.Label) EntityItem(com.vaadin.addon.jpacontainer.EntityItem)

Aggregations

ReportEmailScheduleEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduleEntity)8 ReportEmailRecipient (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailRecipient)3 ReportEmailSender (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailSender)2 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)2 Date (java.util.Date)2 LinkedList (java.util.LinkedList)2 EntityTable (au.com.vaadinutils.crud.EntityTable)1 FormHelper (au.com.vaadinutils.crud.FormHelper)1 CKEditorEmailField (au.com.vaadinutils.fields.CKEditorEmailField)1 OutputFormat (au.com.vaadinutils.jasper.JasperManager.OutputFormat)1 ExpanderComponent (au.com.vaadinutils.jasper.filter.ExpanderComponent)1 ReportChooser (au.com.vaadinutils.jasper.parameter.ReportChooser)1 JasperReportSchedulerWindow (au.com.vaadinutils.jasper.scheduler.JasperReportSchedulerWindow)1 ScheduleIconBuilder (au.com.vaadinutils.jasper.scheduler.ScheduleIconBuilder)1 DateParameterOffsetType (au.com.vaadinutils.jasper.scheduler.entities.DateParameterOffsetType)1 ReportEmailParameterEntity (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailParameterEntity)1 ReportEmailScheduledDateParameter (au.com.vaadinutils.jasper.scheduler.entities.ReportEmailScheduledDateParameter)1 TimePicker (au.com.vaadinutils.layout.TimePicker)1 TopVerticalLayout (au.com.vaadinutils.layout.TopVerticalLayout)1 ClickEventLogged (au.com.vaadinutils.listener.ClickEventLogged)1