diff --git a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/email/impl/EmailNotificationServiceFacadeImpl.java b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/email/impl/EmailNotificationServiceFacadeImpl.java index 69e55123..4c8ff55e 100644 --- a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/email/impl/EmailNotificationServiceFacadeImpl.java +++ b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/email/impl/EmailNotificationServiceFacadeImpl.java @@ -9,7 +9,10 @@ import com.sflpro.notifier.api.model.email.request.EmailNotificationFileAttachmentRequest; import com.sflpro.notifier.api.model.email.response.CreateEmailNotificationResponse; import com.sflpro.notifier.api.model.notification.NotificationClientType; +import com.sflpro.notifier.api.model.notification.NotificationLabelModel; import com.sflpro.notifier.api.model.notification.NotificationStateClientType; +import com.sflpro.notifier.api.model.notification.request.NotificationLabelRequest; +import com.sflpro.notifier.db.entities.notification.NotificationLabel; import com.sflpro.notifier.db.entities.notification.NotificationProviderType; import com.sflpro.notifier.db.entities.notification.email.EmailNotification; import com.sflpro.notifier.db.entities.notification.email.EmailNotificationFileAttachment; @@ -72,9 +75,46 @@ private EmailNotificationDto buildDto(final CreateEmailNotificationRequest reque emailNotificationDto.setUserUuid(request.getUserUuId()); emailNotificationDto.setHasSecureProperties(!request.getSecureProperties().isEmpty()); emailNotificationDto.setFileAttachments(mapFileAttachments(request.getFileAttachments())); + emailNotificationDto.setLabels(mapLabels(request.getLabels())); return emailNotificationDto; } + private EmailNotificationModel buildModel(final EmailNotification emailNotification) { + final EmailNotificationModel notificationModel = new EmailNotificationModel(); + notificationModel.setUuId(emailNotification.getUuId()); + notificationModel.setBody(emailNotification.getContent()); + notificationModel.setSubject(emailNotification.getSubject()); + notificationModel.setType(NotificationClientType.valueOf(emailNotification.getType().name())); + notificationModel.setState(NotificationStateClientType.valueOf(emailNotification.getState().name())); + notificationModel.setSenderEmail(emailNotification.getSenderEmail()); + notificationModel.setRecipientEmail(emailNotification.getRecipientEmail()); + notificationModel.setFileAttachments(mapFileAttachmentsModel(emailNotification.getFileAttachments())); + notificationModel.setLabels(mapLabelsModel(emailNotification.getLabels())); + return notificationModel; + } + + private Set mapLabels(final Set labelsResource) { + Set destinationLabels = new HashSet<>(); + + for (NotificationLabelRequest label : labelsResource) { + NotificationLabel item = new NotificationLabel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } + + private Set mapLabelsModel(final Set labelsResource){ + Set destinationLabels = new HashSet<>(); + + for (NotificationLabel label : labelsResource) { + NotificationLabelModel item = new NotificationLabelModel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } + private Set mapFileAttachments(final Set fileAttachmentResource) { Set destinationAttachments = new HashSet<>(); diff --git a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/push/impl/PushNotificationServiceFacadeImpl.java b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/push/impl/PushNotificationServiceFacadeImpl.java index fa58b76f..abe2685d 100644 --- a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/push/impl/PushNotificationServiceFacadeImpl.java +++ b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/push/impl/PushNotificationServiceFacadeImpl.java @@ -4,6 +4,8 @@ import com.sflpro.notifier.api.facade.services.push.PushNotificationServiceFacade; import com.sflpro.notifier.api.model.common.result.ErrorResponseModel; import com.sflpro.notifier.api.model.common.result.ResultResponseModel; +import com.sflpro.notifier.api.model.notification.NotificationLabelModel; +import com.sflpro.notifier.api.model.notification.request.NotificationLabelRequest; import com.sflpro.notifier.api.model.push.PushNotificationModel; import com.sflpro.notifier.api.model.push.PushNotificationRecipientModel; import com.sflpro.notifier.api.model.push.request.CreatePushNotificationRequest; @@ -12,6 +14,7 @@ import com.sflpro.notifier.api.model.push.response.UpdatePushNotificationSubscriptionResponse; import com.sflpro.notifier.db.entities.device.UserDevice; import com.sflpro.notifier.db.entities.device.mobile.DeviceOperatingSystemType; +import com.sflpro.notifier.db.entities.notification.NotificationLabel; import com.sflpro.notifier.db.entities.notification.NotificationProviderType; import com.sflpro.notifier.db.entities.notification.email.NotificationProperty; import com.sflpro.notifier.db.entities.notification.push.PushNotification; @@ -38,6 +41,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.HashSet; +import java.util.Set; import java.util.stream.Collectors; /** @@ -95,6 +100,7 @@ public ResultResponseModel createPushNotificatio pushNotificationDto.setTemplateName(request.getTemplateName()); pushNotificationDto.setLocale(request.getLocale()); pushNotificationDto.setProperties(request.getProperties()); + pushNotificationDto.setLabels(mapLabels(request.getLabels())); // Create push notifications final List pushNotifications = pushNotificationService.createNotificationsForUserActiveRecipients(user.getId(), pushNotificationDto); // Publish events @@ -139,6 +145,7 @@ private static PushNotificationModel createPushNotificationModel(final PushNotif setNotificationCommonProperties(pushNotificationModel, pushNotification); // Create recipient model pushNotificationModel.setRecipient(createPushNotificationRecipientModel(pushNotification.getRecipient())); + pushNotificationModel.setLabels(mapLabelsModel(pushNotification.getLabels())); // Set properties final Map propertyModels = pushNotification.getProperties().stream().collect(Collectors.toMap(NotificationProperty::getPropertyKey, NotificationProperty::getPropertyValue)); @@ -153,5 +160,27 @@ private static PushNotificationRecipientModel createPushNotificationRecipientMod return recipientModel; } + private Set mapLabels(final Set labelsResource) { + Set destinationLabels = new HashSet<>(); + + for (NotificationLabelRequest label : labelsResource) { + NotificationLabel item = new NotificationLabel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } + + private static Set mapLabelsModel(final Set labelsResource){ + Set destinationLabels = new HashSet<>(); + + for (NotificationLabel label : labelsResource) { + NotificationLabelModel item = new NotificationLabelModel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } + //endregion } diff --git a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/sms/impl/SmsNotificationServiceFacadeImpl.java b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/sms/impl/SmsNotificationServiceFacadeImpl.java index f66ba930..f569b2cf 100644 --- a/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/sms/impl/SmsNotificationServiceFacadeImpl.java +++ b/api/api-facade/src/main/java/com/sflpro/notifier/api/facade/services/sms/impl/SmsNotificationServiceFacadeImpl.java @@ -4,9 +4,12 @@ import com.sflpro.notifier.api.facade.services.sms.SmsNotificationServiceFacade; import com.sflpro.notifier.api.model.common.result.ErrorResponseModel; import com.sflpro.notifier.api.model.common.result.ResultResponseModel; +import com.sflpro.notifier.api.model.notification.NotificationLabelModel; +import com.sflpro.notifier.api.model.notification.request.NotificationLabelRequest; import com.sflpro.notifier.api.model.sms.SmsNotificationModel; import com.sflpro.notifier.api.model.sms.request.CreateSmsNotificationRequest; import com.sflpro.notifier.api.model.sms.response.CreateSmsNotificationResponse; +import com.sflpro.notifier.db.entities.notification.NotificationLabel; import com.sflpro.notifier.db.entities.notification.NotificationProviderType; import com.sflpro.notifier.db.entities.notification.sms.SmsNotification; import com.sflpro.notifier.services.notification.dto.sms.SmsNotificationDto; @@ -21,7 +24,9 @@ import org.springframework.util.Assert; import javax.annotation.Nonnull; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * User: Ruben Dilanyan @@ -65,6 +70,7 @@ public ResultResponseModel createSmsNotification( smsNotificationDto.setProperties(request.getProperties()); smsNotificationDto.setHasSecureProperties(!request.getSecureProperties().isEmpty()); smsNotificationDto.setLocale(request.getLocale()); + smsNotificationDto.setLabels(mapLabels(request.getLabels())); final SmsNotification smsNotification = smsNotificationService.createSmsNotification(smsNotificationDto); associateUserWithNotificationIfRequired(request.getUserUuId(), smsNotification); // Publish event @@ -82,6 +88,29 @@ private SmsNotificationModel createSmsNotificationModel(final SmsNotification sm setNotificationCommonProperties(notificationModel, smsNotification); notificationModel.setSubject(smsNotification.getSubject()); notificationModel.setRecipientNumber(smsNotification.getRecipientMobileNumber()); + notificationModel.setLabels(mapLabelsModel(smsNotification.getLabels())); return notificationModel; } + + private Set mapLabels(final Set labelsResource) { + Set destinationLabels = new HashSet<>(); + + for (NotificationLabelRequest label : labelsResource) { + NotificationLabel item = new NotificationLabel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } + + private Set mapLabelsModel(final Set labelsResource){ + Set destinationLabels = new HashSet<>(); + + for (NotificationLabel label : labelsResource) { + NotificationLabelModel item = new NotificationLabelModel(); + item.setLabelName(label.getLabelName()); + destinationLabels.add(item); + } + return destinationLabels; + } } diff --git a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationLabelModel.java b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationLabelModel.java new file mode 100644 index 00000000..d00d4e33 --- /dev/null +++ b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationLabelModel.java @@ -0,0 +1,54 @@ +package com.sflpro.notifier.api.model.notification; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class NotificationLabelModel { + + /* Properties */ + @JsonProperty("labelName") + private String labelName; + + /* Constructors */ + public NotificationLabelModel() { + } + + /* Properties Getters and Setters */ + public String getLabelName() { + return labelName; + } + + public void setLabelName(String labelName) { + this.labelName = labelName; + } + + /* Equals, HashCode and ToString */ + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + NotificationLabelModel that = (NotificationLabelModel) o; + + return new EqualsBuilder() + .append(labelName, that.labelName) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(labelName) + .toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("labelName", labelName) + .toString(); + } +} diff --git a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationModel.java b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationModel.java index f5fa03c6..7424b40b 100644 --- a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationModel.java +++ b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/NotificationModel.java @@ -11,6 +11,8 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; +import java.util.Set; + /** * User: Ruben Dilanyan * Company: SFL LLC @@ -47,6 +49,9 @@ public abstract class NotificationModel extends AbstractApiModel { @JsonProperty("state") private NotificationStateClientType state; + @JsonProperty("labels") + private Set labels; + /* Constructors */ public NotificationModel() { } @@ -100,6 +105,14 @@ public void setState(final NotificationStateClientType state) { this.state = state; } + public Set getLabels() { + return labels; + } + + public void setLabels(Set labels) { + this.labels = labels; + } + /* Equals, HashCode and ToString */ @Override public boolean equals(final Object o) { @@ -117,6 +130,7 @@ public boolean equals(final Object o) { builder.append(this.getSubject(), that.getSubject()); builder.append(this.getType(), that.getType()); builder.append(this.getState(), that.getState()); + builder.append(this.getLabels(), that.getLabels()); return builder.isEquals(); } @@ -128,6 +142,8 @@ public int hashCode() { builder.append(this.getBody()); builder.append(this.getSubject()); builder.append(this.getType()); + builder.append(this.getState()); + builder.append(this.getLabels()); return builder.build(); } @@ -140,6 +156,7 @@ public String toString() { builder.append("subject", this.getSubject()); builder.append("type", this.getType()); builder.append("state", this.getState()); + builder.append("label", this.getLabels()); return builder.build(); } } diff --git a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/AbstractCreateNotificationRequest.java b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/AbstractCreateNotificationRequest.java index ae14a6e9..110663d9 100644 --- a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/AbstractCreateNotificationRequest.java +++ b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/AbstractCreateNotificationRequest.java @@ -32,6 +32,9 @@ public abstract class AbstractCreateNotificationRequest extends AbstractRequestM @JsonProperty("clientIpAddress") private String clientIpAddress; + @JsonProperty("labels") + private Set labels = Collections.emptySet(); + /* Properties getters and setters */ public String getUserUuId() { @@ -58,6 +61,14 @@ public void setClientIpAddress(final String clientIpAddress) { this.clientIpAddress = clientIpAddress; } + public Set getLabels() { + return labels; + } + + public void setLabels(Set labels) { + this.labels = labels; + } + /* Validation methods */ @Nonnull @Override @@ -84,6 +95,7 @@ public boolean equals(final Object o) { builder.append(this.getUserUuId(), that.getUserUuId()); builder.append(this.getBody(), that.getBody()); builder.append(this.getClientIpAddress(), that.getClientIpAddress()); + builder.append(this.getLabels(), that.getLabels()); return builder.isEquals(); } @@ -94,6 +106,7 @@ public int hashCode() { builder.append(this.getUserUuId()); builder.append(this.getBody()); builder.append(this.getClientIpAddress()); + builder.append(this.getLabels()); return builder.build(); } @@ -104,6 +117,7 @@ public String toString() { builder.append("userUuId", this.getUserUuId()); builder.append("body", this.getBody()); builder.append("clientIpAddress", this.getClientIpAddress()); + builder.append("labels", this.getLabels()); return builder.build(); } } diff --git a/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/NotificationLabelRequest.java b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/NotificationLabelRequest.java new file mode 100644 index 00000000..a1d0bb71 --- /dev/null +++ b/api/api-model/src/main/java/com/sflpro/notifier/api/model/notification/request/NotificationLabelRequest.java @@ -0,0 +1,58 @@ +package com.sflpro.notifier.api.model.notification.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.io.Serializable; + +public class NotificationLabelRequest implements Serializable { + + private static final long serialVersionUID = -337850853635048937L; + + /* Properties */ + @JsonProperty("labelName") + private String labelName; + + /* Constructors */ + public NotificationLabelRequest() { + } + + /* Properties Getters and Setters */ + public String getLabelName() { + return this.labelName; + } + + public void setLabelName(final String labelName) { + this.labelName = labelName; + } + + /* Equals, HashCode and ToString */ + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + NotificationLabelRequest that = (NotificationLabelRequest) o; + + return new EqualsBuilder() + .append(labelName, that.labelName) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(labelName) + .toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("labelName", labelName) + .toString(); + } +} \ No newline at end of file diff --git a/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/Notification.java b/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/Notification.java index afd756d0..ebf9d7b7 100644 --- a/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/Notification.java +++ b/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/Notification.java @@ -9,6 +9,7 @@ import javax.persistence.*; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * User: Ruben Dilanyan @@ -58,6 +59,10 @@ public abstract class Notification extends AbstractDomainUuIdAwareEntityModel { @JoinColumn(name = "notification_id", referencedColumnName = "id", updatable = false, nullable = false) private List properties; + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) + @JoinColumn(name = "notification_id", referencedColumnName = "id") + private Set labels; + /* Constructors */ public Notification() { initializeDefaults(); @@ -142,6 +147,14 @@ public void setProperties(final List properties) { this.properties = properties; } + public Set getLabels() { + return labels; + } + + public void setLabels(Set labels) { + this.labels = labels; + } + /* Private utility methods */ private void initializeDefaults() { this.state = NotificationState.CREATED; @@ -167,6 +180,7 @@ public boolean equals(final Object o) { builder.append(this.getSubject(), that.getSubject()); builder.append(this.getProviderExternalUuId(), that.getProviderExternalUuId()); builder.append(this.hasSecureProperties(), that.hasSecureProperties()); + builder.append(this.getLabels(), that.getLabels()); return builder.isEquals(); } @@ -182,6 +196,7 @@ public int hashCode() { builder.append(this.getSubject()); builder.append(this.getProviderExternalUuId()); builder.append(this.hasSecureProperties()); + builder.append(this.getLabels()); return builder.build(); } @@ -198,6 +213,7 @@ public String toString() { builder.append("subject", this.getSubject()); builder.append("providerExternalUuId", this.getProviderExternalUuId()); builder.append("has_secure_properties", this.hasSecureProperties()); + builder.append("labels", this.getLabels()); return builder.build(); } } diff --git a/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/NotificationLabel.java b/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/NotificationLabel.java new file mode 100644 index 00000000..cc855558 --- /dev/null +++ b/core/core-db-entities/src/main/java/com/sflpro/notifier/db/entities/notification/NotificationLabel.java @@ -0,0 +1,67 @@ +package com.sflpro.notifier.db.entities.notification; + +import com.sflpro.notifier.db.entities.AbstractDomainEntityModel; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "notification_label") +public class NotificationLabel extends AbstractDomainEntityModel { + + private static final long serialVersionUID = -1556003343038789691L; + + /* Properties */ + @Column(name = "label_name", nullable = false) + private String labelName; + + /* Constructors */ + public NotificationLabel() { + + } + + public NotificationLabel(String labelName) { + this.labelName = labelName; + } + + public String getLabelName() { + return labelName; + } + + public NotificationLabel setLabelName(String labelName) { + this.labelName = labelName; + return this; + } + + /* Equals, HashCode and ToString */ + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + NotificationLabel that = (NotificationLabel) o; + + return new EqualsBuilder() + .append(labelName, that.labelName) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(labelName) + .toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("labelName", labelName) + .toString(); + } +} diff --git a/core/core-db-repositories/src/main/resources/db/migration/mysql/V1_11__Notification_label.sql b/core/core-db-repositories/src/main/resources/db/migration/mysql/V1_11__Notification_label.sql new file mode 100644 index 00000000..e8b2089e --- /dev/null +++ b/core/core-db-repositories/src/main/resources/db/migration/mysql/V1_11__Notification_label.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS notification_label ( + id BIGINT not null AUTO_INCREMENT PRIMARY KEY, + label_name VARCHAR(255) NOT NULL, + notification_id BIGINT, + CONSTRAINT fk_notification_label_notification FOREIGN KEY (notification_id) REFERENCES notification (id), + created DATETIME NOT NULL, + removed DATETIME, + updated DATETIME NOT NULL +); \ No newline at end of file diff --git a/core/core-db-repositories/src/main/resources/db/migration/postgresql/V1_11__Notification_label.sql b/core/core-db-repositories/src/main/resources/db/migration/postgresql/V1_11__Notification_label.sql new file mode 100644 index 00000000..620de2cd --- /dev/null +++ b/core/core-db-repositories/src/main/resources/db/migration/postgresql/V1_11__Notification_label.sql @@ -0,0 +1,8 @@ +create table if not exists notification_label ( + id bigint not null constraint pk_notification_label primary key, + label_name varchar(255) not null, + notification_id bigint constraint fk_notification_label_notification references notification, + created timestamp not null, + removed timestamp, + updated timestamp not null +); \ No newline at end of file diff --git a/core/core-services/src/main/java/com/sflpro/notifier/services/notification/dto/NotificationDto.java b/core/core-services/src/main/java/com/sflpro/notifier/services/notification/dto/NotificationDto.java index 6e6b08fe..2ff607d5 100644 --- a/core/core-services/src/main/java/com/sflpro/notifier/services/notification/dto/NotificationDto.java +++ b/core/core-services/src/main/java/com/sflpro/notifier/services/notification/dto/NotificationDto.java @@ -1,6 +1,7 @@ package com.sflpro.notifier.services.notification.dto; import com.sflpro.notifier.db.entities.notification.Notification; +import com.sflpro.notifier.db.entities.notification.NotificationLabel; import com.sflpro.notifier.db.entities.notification.NotificationProviderType; import com.sflpro.notifier.db.entities.notification.NotificationType; import com.sflpro.notifier.db.entities.notification.email.NotificationProperty; @@ -13,6 +14,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; /** @@ -36,6 +38,8 @@ public abstract class NotificationDto extends AbstractDo private Map properties; + private Set labels; + private String templateName; private NotificationProviderType providerType; @@ -49,7 +53,7 @@ public NotificationDto(final NotificationType type, final String content, final String subject, final String clientIpAddress, - final NotificationProviderType providerType) { + final NotificationProviderType providerType){ this.type = type; this.content = content; this.clientIpAddress = clientIpAddress; @@ -142,6 +146,14 @@ public void setLocale(Locale locale) { this.locale = locale; } + public Set getLabels() { + return labels; + } + + public void setLabels(Set labels) { + this.labels = labels; + } + /* Public interface methods */ @Override public void updateDomainEntityProperties(final T notification) { @@ -150,6 +162,9 @@ public void updateDomainEntityProperties(final T notification) { notification.setClientIpAddress(getClientIpAddress()); notification.setSubject(getSubject()); notification.setProviderType(providerType); + notification.setLabels(getLabels().stream() + .map(l -> new NotificationLabel(l.getLabelName())) + .collect(Collectors.toSet())); notification.setProperties(getProperties().entrySet() .stream() .map(entry -> new NotificationProperty(entry.getKey(), entry.getValue())) @@ -174,6 +189,7 @@ public boolean equals(final Object o) { builder.append(this.getContent(), that.getContent()); builder.append(this.getSubject(), that.getSubject()); builder.append(this.getProperties(), that.getProperties()); + builder.append(this.getLabels(), that.getLabels()); builder.append(this.getProviderType(), that.getProviderType()); builder.append(this.isHasSecureProperties(), that.isHasSecureProperties()); return builder.isEquals(); @@ -188,6 +204,7 @@ public int hashCode() { builder.append(this.getContent()); builder.append(this.getSubject()); builder.append(this.getProperties()); + builder.append(this.getLabels()); builder.append(this.getProviderType()); builder.append(this.isHasSecureProperties()); return builder.build(); @@ -203,6 +220,7 @@ public String toString() { builder.append("content", this.getContent()); builder.append("subject", this.getSubject()); builder.append("properties", this.getProperties()); + builder.append("labels", this.getLabels()); builder.append("providerType", this.getProviderType()); builder.append("hasSecureProperties", this.isHasSecureProperties()); return builder.build();