Overdue date tip

Hello,

I have an EntityBrowse screen with attribute Date.

@Temporal(TemporalType.DATE)
@Column(name = "DATE_")
protected Date date;

If the date is (let say) 7 days overdue I need the application send an email and/or mark (color line, underline) those overdue date line(s).
What is the best way to do that?
Can you give me a suitable method in order to access “date” attribute from Controller Entity?

Hi,

If the date is (let say) 7 days overdue I need the application send an email

See CUBA Scheduled Tasks

and/or mark (color line, underline) those overdue date line(s).

See Table.setStyleProvider()

Can you give me a suitable method in order to access “date” attribute from Controller Entity?

controller.getDate()?

Thank you very much Konstantin.

I focused to send emails. Everything works fine ( I can send emails like in your example from controller, Sending Emails - CUBA Platform. Developer’s Manual, JMX Emailer) but when I pot the logic in Managed Bean, under core, unfortunately after schedule, the email(s) stay in queue not send (email history). What could it be?

Hi @neutrino
Haven’t you thought about putting a breakpoint to com.haulmont.cuba.core.app.Emailer#processQueuedEmails
and debugging the code?
The logic there is very straightforward, it should not be a problem to understand the reason why the scheduler doesn’t work for you.
It’s the open source for a reason.

Regards,
Alexander.

Hi Alexander,

To be honest I don’t know where I can set a breakpoint. I just have a chronological scheduler that extract some data (jpql query) and put it in the email queue.
I ve set a breakpoint in processQueuedEmails method everything seems to work well.
Moreover a sendByEmail method works fine from controller. The emails are sent.
The problem is some configuration in Managed Bean I think.

You can debug these places in the code:

  • Method com.haulmont.cuba.core.app.Emailer#loadEmailsToSend must return emails which were put in the queue but have not been sent yet.
  • com.haulmont.cuba.core.app.Emailer#returnToQueue returns failed-to-send emails back to queue
  • com.haulmont.cuba.core.app.Emailer#markAsSent - marks successfully sent email (but it’s not your case)

Unfortunately do not get in loadEmailsToSend, after build the list with data, catch a TargetException in AopUtils.java and end in pending (blocked) stage RunnerBean.java.

image

image

image

image