NotificationSchedule.java
/*
* Copyright 2026 Global Crop Diversity Trust
* Licensed under the Apache License, Version 2.0
* See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
*/
package org.gringlobal.model.notification;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.custom.validation.javax.CronExpressionValidation;
import org.gringlobal.custom.validation.javax.ZoneIdValidation;
import org.gringlobal.model.CooperatorOwnedModel;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "notification_schedule", uniqueConstraints = { @UniqueConstraint(name = "UQ_notification_schedule", columnNames = { "generator", "method", "cron" }) })
@Getter
@Setter
public class NotificationSchedule extends CooperatorOwnedModel implements Copyable<NotificationSchedule> {
private static final long serialVersionUID = 3866061416397511273L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "notification_schedule_id", columnDefinition = "int")
private Long id;
@Size(max = 256) @Column(name = "generator", length = 256, nullable = false)
@NotNull private String generator;
@Size(max = 128) @Column(name = "method", length = 128, nullable = false)
@NotNull private String method;
@Size(max = 128) @Column(name = "cron", length = 128, nullable = false)
@NotNull @CronExpressionValidation
private String cron;
@Size(max = 20) @Column(name = "timezone", length = 20, nullable = false)
@NotNull @ZoneIdValidation
private String timezone;
@Size(max = 100) @Basic
@Column(length = 100)
private String title;
@Size(max = 200) @Basic
@Column(length = 200)
private String description;
@Basic
@NotBlank @Size(max = 1) @Column(name = "is_active", nullable = false, length = 1)
private String isActive = "Y";
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, mappedBy = "notificationSchedule")
private List<NotificationScheduleSubscriber> subscribers = new ArrayList<>();
@Override
public boolean canEqual(Object other) {
return other instanceof NotificationSchedule;
}
@Override
public Long getId() {
return id;
}
}