NotificationTask.java

  1. package no.nav.data.team.notify.domain;

  2. import com.fasterxml.jackson.annotation.JsonIgnore;
  3. import lombok.AllArgsConstructor;
  4. import lombok.Builder;
  5. import lombok.Data;
  6. import lombok.NoArgsConstructor;
  7. import no.nav.data.common.auditing.domain.AuditVersion;
  8. import no.nav.data.common.storage.domain.ChangeStamp;
  9. import no.nav.data.common.storage.domain.DomainObject;
  10. import no.nav.data.team.notify.domain.Notification.NotificationChannel;
  11. import no.nav.data.team.notify.domain.Notification.NotificationTime;

  12. import java.util.List;
  13. import java.util.UUID;

  14. @Data
  15. @Builder
  16. @AllArgsConstructor
  17. @NoArgsConstructor
  18. public class NotificationTask implements DomainObject {

  19.     private UUID id;
  20.     private ChangeStamp changeStamp;

  21.     private String ident;
  22.     private NotificationTime time;
  23.     private NotificationChannel channel;
  24.     private List<AuditTarget> targets;

  25.     @Data
  26.     @Builder
  27.     @AllArgsConstructor
  28.     @NoArgsConstructor
  29.     public static class AuditTarget {

  30.         private UUID targetId;
  31.         private String type;
  32.         private UUID prevAuditId;
  33.         private UUID currAuditId;
  34.         private boolean silent;

  35.         @JsonIgnore
  36.         private AuditVersion prevAuditVersion;
  37.         @JsonIgnore
  38.         private AuditVersion currAuditVersion;

  39.         public boolean isCreate() {
  40.             return prevAuditId == null && currAuditId != null;
  41.         }

  42.         public boolean isUpdate() {
  43.             return prevAuditId != null && currAuditId != null;
  44.         }

  45.         public boolean isDelete() {
  46.             return prevAuditId != null && currAuditId == null;
  47.         }

  48.         public boolean isEdit() {
  49.             return prevAuditId != null && currAuditId != null;
  50.         }

  51.         public boolean isTeam() {
  52.             return type.equals(AuditVersion.TEAM_TYPE);
  53.         }
  54.     }

  55. }