/**
 * This file is part of the Meeds project (https://meeds.io/).
 *
 * Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
package org.exoplatform.commons.notification.impl.jpa.web.entity;

import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import jakarta.persistence.*;

@Entity(name = "NotificationsWebNotifEntity")
@Table(name = "NTF_WEB_NOTIFS")
public class WebNotifEntity {
  @Id
  @Column(name = "WEB_NOTIF_ID")
  @SequenceGenerator(name="SEQ_NTF_WEB_NOTIFS", sequenceName="SEQ_NTF_WEB_NOTIFS", allocationSize = 1)
  @GeneratedValue(strategy=GenerationType.AUTO, generator="SEQ_NTF_WEB_NOTIFS")
  private long id;

  @Column(name = "SENDER")
  private String sender;

  @Column(name = "TYPE")
  private String type;

  @Column(name = "CREATION_DATE")
  private Calendar creationDate;

  @Column(name = "TEXT")
  private String text;

  @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL,  mappedBy = "webNotification")
  private Set<WebParamsEntity> parameters = new HashSet<>();

  @OneToMany(fetch=FetchType.LAZY, mappedBy = "webNotification")
  private Set<WebUsersEntity> receivers = new HashSet<>();

  public long getId() {
    return id;
  }

  public String getSender() {
    return sender;
  }

  public WebNotifEntity setSender(String sender) {
    this.sender = sender;
    return this;
  }

  public String getType() {
    return type;
  }

  public WebNotifEntity setType(String type) {
    this.type = type;
    return this;
  }

  public Calendar getCreationDate() {
    return creationDate;
  }

  public WebNotifEntity setCreationDate(Calendar creationDate) {
    this.creationDate = creationDate;
    return this;
  }

  public String getText() {
    return text;
  }

  public WebNotifEntity setText(String text) {
    this.text = text;
    return this;
  }

  public Set<WebParamsEntity> getParameters() {
    return parameters;
  }

  public void setParameters(Set<WebParamsEntity> parameters) {
    this.parameters = parameters;
  }

  public void addParameter(WebParamsEntity parameter) {
    this.parameters.add(parameter);
  }

  public void addReceiver(WebUsersEntity receiver) {
    this.receivers.add(receiver);
  }

  public Set<WebUsersEntity> getReceivers() {
    return receivers;
  }

  public void setReceivers(Set<WebUsersEntity> receivers) {
    this.receivers = receivers;
  }
}

