I'm trying to figure out how I can go about finding members of a list - but only ones that haven't past their expired date - which is one of the properties of the model.
Right now I have:
public static Result getAllNotifications() {
List<Notification> notifications = Notification.getAllNotifications();
for (Notification i: notifications) {
List<Attachments> attachments = Attachments.findAllById(i.id);
i.attached = attachments;
}
return ok(toJson(notifications));
}
Somewhere in there I need to check the expiration date of an individual notification and not return it if today is past that date.
Right now that model for a notificatin looks like this:
public class Notification extends Model {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@NonEmpty
public Long id;
@Constraints.Required
public String title;
@Formats.DateTime(pattern = "dd/MM/yyyy")
public Date created = new Date();
@Constraints.Required
@Column(columnDefinition="TEXT")
public String text;
@Formats.DateTime(pattern = "dd/MM/yyyy")
public Date updated = new Date();
public Boolean status;
public Date expires;
public String author;
public List<Attachments> attached;
public Notification() {
}
public Notification(Long id, String title, String text) {
this.created = new Date();
this.title = title;
this.text = text;
this.id = id;
}
public static Model.Finder<String, Notification> find = new Model.Finder<String, Notification>(String.class, Notification.class);
This is my first ever Stackoverflow post so go easy on me! And thank you, in advance, for the help!