From ca4a9db3f80adf311c9fb8274c8d4a644c56bf6b Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Wed, 24 Jan 2024 14:24:58 +0200 Subject: [PATCH] Started aligning notification service entities with the database, code cleanup --- .../cite/notification/web/model/Account.java | 26 +- .../common/types/notification/FieldInfo.java | 6 +- .../data/InAppNotificationEntity.java | 42 +- .../notification/data/LanguageEntity.java | 36 +- .../notification/data/NotificationEntity.java | 157 +++--- .../data/NotificationTemplateEntity.java | 64 ++- .../notification/data/QueueInboxEntity.java | 263 ++++----- .../notification/data/QueueOutboxEntity.java | 274 +++++---- .../data/TenantConfigurationEntity.java | 58 +- .../cite/notification/data/TenantEntity.java | 127 ++--- .../notification/data/TenantUserEntity.java | 104 ++-- .../data/UserContactInfoEntity.java | 14 +- .../data/UserCredentialEntity.java | 8 +- .../gr/cite/notification/data/UserEntity.java | 121 ++-- .../UserNotificationPreferenceEntity.java | 20 +- .../gr/cite/notification/model/Language.java | 32 +- .../cite/notification/model/Notification.java | 73 ++- .../model/NotificationTemplate.java | 22 +- .../gr/cite/notification/model/Tenant.java | 71 +-- .../model/TenantConfiguration.java | 45 +- .../java/gr/cite/notification/model/User.java | 4 +- .../model/builder/LanguageBuilder.java | 26 +- .../model/builder/TenantBuilder.java | 53 +- .../builder/TenantConfigurationBuilder.java | 54 +- .../UserNotificationPreferenceBuilder.java | 7 +- .../notificationtemplate/FieldOptions.java | 6 +- .../NotificationTemplateValue.java | 26 +- .../model/persist/NotificationPersist.java | 20 +- .../model/tenantconfig/TenantConfig.java | 4 +- .../tenantconfig/TenantDepositConfig.java | 2 +- .../TenantFileTransformersConfig.java | 2 +- .../model/tenantconfig/TenantSource.java | 12 +- .../notification/model/user/PublicUser.java | 4 +- .../query/InAppNotificationQuery.java | 412 +++++++------- .../notification/query/LanguageQuery.java | 32 +- .../notification/query/NotificationQuery.java | 522 ++++++++++-------- .../query/TenantConfigurationQuery.java | 66 ++- .../cite/notification/query/TenantQuery.java | 184 +++--- .../query/UserContactInfoQuery.java | 430 ++++++++------- .../UserNotificationPreferenceQuery.java | 28 +- .../InAppNotificationServiceImpl.java | 23 +- .../NotificationSchedulingServiceImpl.java | 2 +- .../TenantConfigurationServiceImpl.java | 7 +- 43 files changed, 1857 insertions(+), 1632 deletions(-) diff --git a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/model/Account.java b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/model/Account.java index f8bbe0902..601dc19b0 100644 --- a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/model/Account.java +++ b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/model/Account.java @@ -11,7 +11,7 @@ public class Account { public static class PrincipalInfo { - public final static String _userId = "userId"; + public static final String _userId = "userId"; public UUID userId; public UUID getUserId() { @@ -22,7 +22,7 @@ public class Account { this.userId = userId; } - public final static String _subject = "subject"; + public static final String _subject = "subject"; public UUID subject; public UUID getSubject() { @@ -33,7 +33,7 @@ public class Account { this.subject = subject; } - public final static String _name = "name"; + public static final String _name = "name"; @LogSensitive public String name; @@ -45,7 +45,7 @@ public class Account { this.name = name; } - public final static String _scope = "scope"; + public static final String _scope = "scope"; public List scope; public List getScope() { @@ -56,7 +56,7 @@ public class Account { this.scope = scope; } - public final static String _client = "client"; + public static final String _client = "client"; public String client; public String getClient() { @@ -67,7 +67,7 @@ public class Account { this.client = client; } - public final static String _notBefore = "notBefore"; + public static final String _notBefore = "notBefore"; public Instant notBefore; public Instant getNotBefore() { @@ -78,7 +78,7 @@ public class Account { this.notBefore = notBefore; } - public final static String _issuedAt = "issuedAt"; + public static final String _issuedAt = "issuedAt"; public Instant issuedAt; public Instant getIssuedAt() { @@ -89,7 +89,7 @@ public class Account { this.issuedAt = issuedAt; } - public final static String _authenticatedAt = "authenticatedAt"; + public static final String _authenticatedAt = "authenticatedAt"; public Instant authenticatedAt; public Instant getAuthenticatedAt() { @@ -100,7 +100,7 @@ public class Account { this.authenticatedAt = authenticatedAt; } - public final static String _expiresAt = "expiresAt"; + public static final String _expiresAt = "expiresAt"; public Instant expiresAt; public Instant getExpiresAt() { @@ -111,7 +111,7 @@ public class Account { this.expiresAt = expiresAt; } - public final static String _more = "more"; + public static final String _more = "more"; @LogSensitive public Map> more; @@ -125,7 +125,7 @@ public class Account { } - public final static String _isAuthenticated = "isAuthenticated"; + public static final String _isAuthenticated = "isAuthenticated"; private Boolean isAuthenticated; public Boolean getIsAuthenticated() { @@ -136,7 +136,7 @@ public class Account { isAuthenticated = authenticated; } - public final static String _principal = "principal"; + public static final String _principal = "principal"; private PrincipalInfo principal; public PrincipalInfo getPrincipal() { @@ -147,7 +147,7 @@ public class Account { this.principal = principal; } - public final static String _permissions = "permissions"; + public static final String _permissions = "permissions"; private List permissions; public List getPermissions() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/common/types/notification/FieldInfo.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/common/types/notification/FieldInfo.java index b4c0ee47b..2170ae554 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/common/types/notification/FieldInfo.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/common/types/notification/FieldInfo.java @@ -4,11 +4,11 @@ import gr.cite.notification.common.enums.NotificationDataType; public class FieldInfo { private String key; - public final static String _key = "key"; + public static final String _key = "key"; private NotificationDataType type; - public final static String _type = "type"; + public static final String _type = "type"; private String value; - public final static String _value = "value"; + public static final String _value = "value"; public FieldInfo(String key, NotificationDataType type, String value) { this.key = key; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java index 2fdb75a32..0609772df 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/InAppNotificationEntity.java @@ -7,69 +7,80 @@ import gr.cite.notification.data.conventers.InAppNotificationPriorityConverter; import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.NotificationInAppTrackingConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity @Table(name = "\"ntf_InAppNotification\"") public class InAppNotificationEntity extends TenantScopedBaseEntity { - public static class Field { - public static final String _id = "id"; - public static final String _userId = "userId"; - public static final String _isActive = "isActive"; - public static final String _type = "type"; - public static final String _readTime = "readTime"; - public static final String _trackingState = "trackingState"; - public static final String _priority = "priority"; - public static final String _subject = "subject"; - public static final String _body = "body"; - public static final String _extraData = "extraData"; - public static final String _createdAt = "createdAt"; - public static final String _updatedAt = "updatedAt"; - } @Id @Column(name = "\"id\"", columnDefinition = "uuid", nullable = false) private UUID id; + + public static final String _id = "id"; + @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false) private UUID userId; + public static final String _userId = "userId"; + @Column(name = "\"is_active\"", nullable = false) @Convert(converter = IsActiveConverter.class) private IsActive isActive; + public static final String _isActive = "isActive"; + @Column(name = "\"type\"", columnDefinition = "uuid", nullable = false) private UUID type; + public static final String _type = "type"; + @Column(name = "\"read_time\"") private Instant readTime; + public static final String _readTime = "readTime"; + @Column(name = "\"tracking_state\"", nullable = false) @Convert(converter = NotificationInAppTrackingConverter.class) private NotificationInAppTracking trackingState; + public static final String _trackingState = "trackingState"; + @Column(name = "\"priority\"", nullable = false) @Convert(converter = InAppNotificationPriorityConverter.class) private InAppNotificationPriority priority; + public static final String _priority = "priority"; + @Column(name = "\"subject\"") private String subject; + public static final String _subject = "subject"; + @Column(name = "\"body\"") private String body; + public static final String _body = "body"; + @Column(name = "\"extra_data\"") private String extraData; + public static final String _extraData = "extraData"; + @Column(name = "\"created_at\"", nullable = false) private Instant createdAt; + public static final String _createdAt = "createdAt"; + @Column(name = "\"updated_at\"", nullable = false) @Version private Instant updatedAt; + public static final String _updatedAt = "updatedAt"; + public UUID getId() { return id; } @@ -165,4 +176,5 @@ public class InAppNotificationEntity extends TenantScopedBaseEntity { public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java index 3c8d8f4bf..57ec56f3b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/LanguageEntity.java @@ -3,44 +3,46 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"Language\"") +@Table(name = "\"ntf_Language\"") public class LanguageEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; + public static final String _id = "id"; @Column(name = "code", length = 20, nullable = false) private String code; + public static final String _code = "code"; - @Column(name = "payload") - private String payload; - public static final String _payload = "payload"; + @Column(name = "ordinal") + private Integer ordinal; + + public static final String _ordinal = "ordinal"; @Column(name = "\"created_at\"", nullable = false) private Instant createdAt; + public static final String _createdAt = "createdAt"; @Column(name = "\"updated_at\"", nullable = false) private Instant updatedAt; + public static final String _updatedAt = "updatedAt"; @Column(name = "is_active", nullable = false) @Convert(converter = IsActiveConverter.class) private IsActive isActive; - public static final String _isActive = "isActive"; - @Column(name = "ordinal") - private Integer ordinal; - public static final String _ordinal = "ordinal"; + public static final String _isActive = "isActive"; public UUID getId() { return id; @@ -58,12 +60,12 @@ public class LanguageEntity extends TenantScopedBaseEntity { this.code = code; } - public String getPayload() { - return payload; + public Integer getOrdinal() { + return ordinal; } - public void setPayload(String payload) { - this.payload = payload; + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; } public Instant getCreatedAt() { @@ -89,12 +91,4 @@ public class LanguageEntity extends TenantScopedBaseEntity { public void setIsActive(IsActive isActive) { this.isActive = isActive; } - - public Integer getOrdinal() { - return ordinal; - } - - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java index aa398981c..ae910e8bb 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationEntity.java @@ -3,8 +3,8 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.*; import gr.cite.notification.data.conventers.*; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -12,81 +12,100 @@ import java.util.UUID; @Table(name = "\"ntf_Notification\"") public class NotificationEntity extends TenantScopedBaseEntity { - public static class Field { - public final static String _id = "id"; - public static final String _userId = "userId"; - public static final String _type = "type"; - public static final String _contactTypeHint = "contactTypeHint"; - public static final String _contactHint = "contactHint"; - public static final int _contactHintLength = 200; - public final static String _notifiedAt = "notifiedAt"; - public final static String _isActive = "isActive"; - public final static String _createdAt = "createdAt"; - public final static String _updatedAt = "updatedAt"; - public final static String _data = "data"; - public final static String _retryCount = "retryCount"; - public final static String _notifyState = "notifyState"; - public final static String _notifiedWith = "notifiedWith"; - public final static String _tenantId = "tenantId"; - public final static String _trackingState = "trackingState"; - public final static String _trackingProcess = "trackingProcess"; - public final static String _trackingData = "trackingData"; - } - @Id @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; + public static final String _id = "id"; + @Column(name = "\"user\"", columnDefinition = "uuid") private UUID userId; + public static final String _userId = "userId"; + + @Column(name = "\"tenant\"", columnDefinition = "uuid") + private UUID tenantId; + + public static final String _tenantId = "tenantId"; + @Column(name = "\"type\"", columnDefinition = "uuid", nullable = false) private UUID type; + public static final String _type = "type"; + @Column(name = "\"contact_type_hint\"") @Convert(converter = NotificationContactTypeConverter.class) private NotificationContactType contactTypeHint; - @Column(name = "\"contact_hint\"") + public static final String _contactTypeHint = "contactTypeHint"; + + @Column(name = "\"contact_hint\"", length = _contactHintLength) private String contactHint; + public static final String _contactHint = "contactHint"; + + public static final int _contactHintLength = 200; + @Column(name = "\"notify_state\"", nullable = false) @Convert(converter = NotificationNotifyStateConverter.class) private NotificationNotifyState notifyState; + public static final String _notifyState = "notifyState"; + @Column(name = "\"notified_with\"") @Convert(converter = NotificationContactTypeConverter.class) private NotificationContactType notifiedWith; + + public static final String _notifiedWith = "notifiedWith"; + @Column(name = "\"notified_at\"") private Instant notifiedAt; + public static final String _notifiedAt = "notifiedAt"; + @Column(name = "\"data\"") private String data; + public static final String _data = "data"; + @Column(name = "\"retry_count\"") private Integer retryCount; - @Column(name = "\"is_active\"", length = 20, nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - - @Column(name = "\"created_at\"", nullable = false) - private Instant createdAt; - - @Column(name = "\"updated_at\"", nullable = false) - private Instant updatedAt; + public static final String _retryCount = "retryCount"; @Column(name = "\"tracking_state\"", nullable = false) @Convert(converter = NotificationTrackingStateConverter.class) private NotificationTrackingState trackingState; + public static final String _trackingState = "trackingState"; + @Column(name = "\"tracking_process\"", nullable = false) @Convert(converter = NotificationTrackingProcessConverter.class) private NotificationTrackingProcess trackingProcess; + public static final String _trackingProcess = "trackingProcess"; + @Column(name = "\"tracking_data\"") private String trackingData; + public static final String _trackingData = "trackingData"; + + @Column(name = "\"created_at\"", nullable = false) + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + @Column(name = "\"updated_at\"", nullable = false) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + @Column(name = "\"is_active\"", length = 20, nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + public UUID getId() { return id; } @@ -103,6 +122,16 @@ public class NotificationEntity extends TenantScopedBaseEntity { this.userId = userId; } + @Override + public UUID getTenantId() { + return tenantId; + } + + @Override + public void setTenantId(UUID tenantId) { + this.tenantId = tenantId; + } + public UUID getType() { return type; } @@ -127,14 +156,6 @@ public class NotificationEntity extends TenantScopedBaseEntity { this.contactHint = contactHint; } - public NotificationContactType getNotifiedWith() { - return notifiedWith; - } - - public void setNotifiedWith(NotificationContactType notifiedWith) { - this.notifiedWith = notifiedWith; - } - public NotificationNotifyState getNotifyState() { return notifyState; } @@ -143,6 +164,14 @@ public class NotificationEntity extends TenantScopedBaseEntity { this.notifyState = notifyState; } + public NotificationContactType getNotifiedWith() { + return notifiedWith; + } + + public void setNotifiedWith(NotificationContactType notifiedWith) { + this.notifiedWith = notifiedWith; + } + public Instant getNotifiedAt() { return notifiedAt; } @@ -167,30 +196,6 @@ public class NotificationEntity extends TenantScopedBaseEntity { this.retryCount = retryCount; } - public IsActive getIsActive() { - return isActive; - } - - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } - - public Instant getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } - - public Instant getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } - public NotificationTrackingState getTrackingState() { return trackingState; } @@ -214,4 +219,28 @@ public class NotificationEntity extends TenantScopedBaseEntity { public void setTrackingData(String trackingData) { this.trackingData = trackingData; } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java index 6e7db21c1..d356ac9f4 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/NotificationTemplateEntity.java @@ -1,10 +1,14 @@ package gr.cite.notification.data; -import gr.cite.notification.common.enums.*; -import gr.cite.notification.data.conventers.*; +import gr.cite.notification.common.enums.IsActive; +import gr.cite.notification.common.enums.NotificationTemplateChannel; +import gr.cite.notification.common.enums.NotificationTemplateKind; +import gr.cite.notification.data.conventers.IsActiveConverter; +import gr.cite.notification.data.conventers.NotificationTemplateChannelConverter; +import gr.cite.notification.data.conventers.NotificationTemplateKindConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -15,42 +19,51 @@ public class NotificationTemplateEntity extends TenantScopedBaseEntity { @Id @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; - public final static String _id = "id"; + + public static final String _id = "id"; @Column(name = "\"channel\"", nullable = false) @Convert(converter = NotificationTemplateChannelConverter.class) private NotificationTemplateChannel channel; - public final static String _channel = "channel"; + + public static final String _channel = "channel"; @Column(name = "\"notification_type\"", columnDefinition = "uuid", nullable = false) private UUID notificationType; - public final static String _notificationType = "notificationType"; + + public static final String _notificationType = "notificationType"; @Column(name = "\"kind\"", nullable = false) @Convert(converter = NotificationTemplateKindConverter.class) private NotificationTemplateKind kind; - public final static String _kind = "kind"; + + public static final String _kind = "kind"; @Column(name = "\"language\"", columnDefinition = "uuid", nullable = false) private UUID languageId; - public final static String _languageId = "languageId"; + + public static final String _languageId = "languageId"; @Column(name = "\"value\"", nullable = false) private String value; - public final static String _value = "value"; + + public static final String _value = "value"; + + @Column(name = "\"created_at\"", nullable = false) + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + @Column(name = "\"updated_at\"", nullable = false) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; @Column(name = "\"is_active\"", nullable = false) @Convert(converter = IsActiveConverter.class) private IsActive isActive; - public final static String _isActive = "isActive"; - @Column(name = "\"created_at\"", nullable = false) - private Instant createdAt; - public final static String _createdAt = "createdAt"; - - @Column(name = "\"updated_at\"", nullable = false) - private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + public static final String _isActive = "isActive"; public UUID getId() { return id; @@ -100,14 +113,6 @@ public class NotificationTemplateEntity extends TenantScopedBaseEntity { this.value = value; } - public IsActive getIsActive() { - return isActive; - } - - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } - public Instant getCreatedAt() { return createdAt; } @@ -123,4 +128,13 @@ public class NotificationTemplateEntity extends TenantScopedBaseEntity { public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java index bc30bb257..68777aa9a 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueInboxEntity.java @@ -5,10 +5,8 @@ import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.types.JsonSQLType; import gr.cite.queueinbox.entity.QueueInbox; import gr.cite.queueinbox.entity.QueueInboxStatus; - import jakarta.persistence.*; import org.hibernate.annotations.Type; -import org.hibernate.usertype.UserType; import java.time.Instant; import java.util.UUID; @@ -16,166 +14,181 @@ import java.util.UUID; @Entity @Table(name = "\"ntf_QueueInbox\"") public class QueueInboxEntity implements QueueInbox { - @Id - @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public final static String _id = "id"; - @Column(name = "\"queue\"", nullable = false, length = 50) - private String queue; - public final static String _queue = "queue"; + @Id + @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "\"exchange\"", nullable = false, length = 50) - private String exchange; - public final static String _exchange = "exchange"; + public static final String _id = "id"; - @Column(name = "\"route\"", nullable = false, length = 50) - private String route; - public final static String _route = "route"; + @Column(name = "\"queue\"", nullable = false, length = 50) + private String queue; - @Column(name = "\"application_id\"", nullable = false, length = 100) - private String applicationId; - public final static String _applicationId = "applicationId"; + public static final String _queue = "queue"; - @Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false) - private UUID messageId; - public final static String _messageId = "messageId"; + @Column(name = "\"exchange\"", nullable = false, length = 50) + private String exchange; - @Type(JsonSQLType.class) - @Column(name = "\"message\"", columnDefinition = "json", nullable = false) - private String message; - public final static String _message = "message"; + public static final String _exchange = "exchange"; - @Column(name = "\"retry_count\"", nullable = true) - private Integer retryCount; - public final static String _retryCount = "retryCount"; + @Column(name = "\"route\"", nullable = false, length = 50) + private String route; - @Column(name = "\"tenant\"", columnDefinition = "uuid", nullable = true) - private UUID tenantId; - public final static String _tenantId = "tenantId"; + public static final String _route = "route"; - @Column(name = "\"is_active\"", length = 20, nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - public final static String _isActive = "isActive"; + @Column(name = "\"application_id\"", nullable = false, length = 100) + private String applicationId; - @Column(name = "\"status\"", length = 50, nullable = false) - @Enumerated(EnumType.STRING) - private QueueInboxStatus status; - public final static String _status = "status"; + public static final String _applicationId = "applicationId"; - @Column(name = "\"created_at\"", nullable = false) - private Instant createdAt; - public final static String _createdAt = "createdAt"; + @Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false) + private UUID messageId; - @Column(name = "\"updated_at\"", nullable = false) - @Version - private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + public static final String _messageId = "messageId"; - public UUID getId() { - return id; - } + @Type(JsonSQLType.class) + @Column(name = "\"message\"", columnDefinition = "json", nullable = false) + private String message; - public void setId(UUID id) { - this.id = id; - } + public static final String _message = "message"; - public String getExchange() { - return exchange; - } + @Column(name = "\"retry_count\"") + private Integer retryCount; - public void setExchange(String exchange) { - this.exchange = exchange; - } + public static final String _retryCount = "retryCount"; - public String getRoute() { - return route; - } + @Column(name = "\"tenant\"", columnDefinition = "uuid") + private UUID tenantId; - public void setRoute(String route) { - this.route = route; - } + public static final String _tenantId = "tenantId"; - public UUID getMessageId() { - return messageId; - } + @Column(name = "\"status\"", length = 50, nullable = false) + @Enumerated(EnumType.STRING) + private QueueInboxStatus status; - public void setMessageId(UUID messageId) { - this.messageId = messageId; - } + public static final String _status = "status"; - public String getMessage() { - return message; - } + @Column(name = "\"created_at\"", nullable = false) + private Instant createdAt; - public void setMessage(String message) { - this.message = message; - } + public static final String _createdAt = "createdAt"; - public UUID getTenantId() { - return tenantId; - } + @Column(name = "\"updated_at\"", nullable = false) + @Version + private Instant updatedAt; - public void setTenantId(UUID tenantId) { - this.tenantId = tenantId; - } + public static final String _updatedAt = "updatedAt"; - public IsActive getIsActive() { - return isActive; - } + @Column(name = "\"is_active\"", length = 20, nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } + public static final String _isActive = "isActive"; - public Instant getCreatedAt() { - return createdAt; - } + public UUID getId() { + return id; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + public void setId(UUID id) { + this.id = id; + } - public Instant getUpdatedAt() { - return updatedAt; - } + public String getQueue() { + return queue; + } - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } + public void setQueue(String queue) { + this.queue = queue; + } - public String getQueue() { - return queue; - } + public String getExchange() { + return exchange; + } - public void setQueue(String queue) { - this.queue = queue; - } + public void setExchange(String exchange) { + this.exchange = exchange; + } - public String getApplicationId() { - return applicationId; - } + public String getRoute() { + return route; + } - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; - } + public void setRoute(String route) { + this.route = route; + } - @Override - public Integer getRetryCount() { - return retryCount; - } + public String getApplicationId() { + return applicationId; + } - public void setRetryCount(Integer retryCount) { - this.retryCount = retryCount; - } + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } - public QueueInboxStatus getStatus() { - return status; - } + public UUID getMessageId() { + return messageId; + } - public void setStatus(QueueInboxStatus status) { - this.status = status; - } + public void setMessageId(UUID messageId) { + this.messageId = messageId; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public Integer getRetryCount() { + return retryCount; + } + + public void setRetryCount(Integer retryCount) { + this.retryCount = retryCount; + } + + public UUID getTenantId() { + return tenantId; + } + + public void setTenantId(UUID tenantId) { + this.tenantId = tenantId; + } + + public QueueInboxStatus getStatus() { + return status; + } + + public void setStatus(QueueInboxStatus status) { + this.status = status; + } + + @Override + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java index a5dac204d..f12067e49 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/QueueOutboxEntity.java @@ -1,175 +1,205 @@ package gr.cite.notification.data; - import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.queueoutbox.entity.QueueOutbox; import gr.cite.queueoutbox.entity.QueueOutboxNotifyStatus; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity @Table(name = "\"ntf_QueueOutbox\"") public class QueueOutboxEntity implements QueueOutbox { - @Id - @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public final static String _id = "id"; - @Column(name = "\"exchange\"", nullable = false, length = 50) - private String exchange; - public final static String _exchange = "exchange"; + @Id + @Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "\"route\"", length = 50) - private String route; - public final static String _route = "route"; + public static final String _id = "id"; - @Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false) - private UUID messageId; - public final static String _messageId = "messageId"; + @Column(name = "\"exchange\"", nullable = false, length = 50) + private String exchange; - @Column(name = "\"message\"", columnDefinition = "json", nullable = false) - private String message; - public final static String _message = "message"; + public static final String _exchange = "exchange"; - @Column(name = "\"notify_status\"", length = 20, nullable = false) - @Enumerated(EnumType.STRING) - private QueueOutboxNotifyStatus notifyStatus; - public final static String _notifyStatus = "notifyStatus"; + @Column(name = "\"route\"", length = 50) + private String route; - @Column(name = "\"retry_count\"", nullable = false) - private int retryCount; - public final static String _retryCount = "retryCount"; + public static final String _route = "route"; - @Column(name = "\"published_at\"", nullable = true) - private Instant publishedAt; - public final static String _publishedAt = "publishedAt"; + @Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false) + private UUID messageId; - @Column(name = "\"confirmed_at\"", nullable = true) - private Instant confirmedAt; - public final static String _confirmedAt = "confirmedAt"; + public static final String _messageId = "messageId"; - @Column(name = "\"tenant\"", columnDefinition = "uuid", nullable = true) - private UUID tenantId; - public final static String _tenantId = "tenantId"; + @Column(name = "\"message\"", columnDefinition = "json", nullable = false) + private String message; - @Column(name = "\"is_active\"", length = 20, nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - public final static String _isActive = "isActive"; + public static final String _message = "message"; - @Column(name = "\"created_at\"", nullable = false) - private Instant createdAt; - public final static String _createdAt = "createdAt"; + @Column(name = "\"notify_status\"", length = 20, nullable = false) + @Enumerated(EnumType.STRING) + private QueueOutboxNotifyStatus notifyStatus; - @Column(name = "\"updated_at\"", nullable = false) - private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + public static final String _notifyStatus = "notifyStatus"; - public UUID getId() { - return id; - } + @Column(name = "\"retry_count\"", nullable = false) + private Integer retryCount; - public void setId(UUID id) { - this.id = id; - } + public static final String _retryCount = "retryCount"; - public String getExchange() { - return exchange; - } + @Column(name = "\"published_at\"") + private Instant publishedAt; - public void setExchange(String exchange) { - this.exchange = exchange; - } + public static final String _publishedAt = "publishedAt"; - public String getRoute() { - return route; - } + @Column(name = "\"confirmed_at\"") + private Instant confirmedAt; - public void setRoute(String route) { - this.route = route; - } + public static final String _confirmedAt = "confirmedAt"; - public UUID getMessageId() { - return messageId; - } + @Column(name = "\"tenant\"", columnDefinition = "uuid") + private UUID tenantId; - public void setMessageId(UUID messageId) { - this.messageId = messageId; - } + public static final String _tenantId = "tenantId"; - public String getMessage() { - return message; - } + @Column(name = "\"created_at\"", nullable = false) + private Instant createdAt; - public void setMessage(String message) { - this.message = message; - } + public static final String _createdAt = "createdAt"; - public QueueOutboxNotifyStatus getNotifyStatus() { - return notifyStatus; - } + @Column(name = "\"updated_at\"", nullable = false) + private Instant updatedAt; - public void setNotifyStatus(QueueOutboxNotifyStatus notifyStatus) { - this.notifyStatus = notifyStatus; - } + public static final String _updatedAt = "updatedAt"; - public Integer getRetryCount() { - return retryCount; - } + @Column(name = "\"is_active\"", length = 20, nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public void setRetryCount(Integer retryCount) { - this.retryCount = retryCount; - } + public static final String _isActive = "isActive"; - public Instant getPublishedAt() { - return publishedAt; - } + @Override + public UUID getId() { + return id; + } - public void setPublishedAt(Instant publishedAt) { - this.publishedAt = publishedAt; - } + @Override + public void setId(UUID id) { + this.id = id; + } - public Instant getConfirmedAt() { - return confirmedAt; - } + public String getExchange() { + return exchange; + } - public void setConfirmedAt(Instant confirmedAt) { - this.confirmedAt = confirmedAt; - } + public void setExchange(String exchange) { + this.exchange = exchange; + } - public UUID getTenantId() { - return tenantId; - } + @Override + public String getRoute() { + return route; + } - public void setTenantId(UUID tenantId) { - this.tenantId = tenantId; - } + @Override + public void setRoute(String route) { + this.route = route; + } - public IsActive getIsActive() { - return isActive; - } + @Override + public UUID getMessageId() { + return messageId; + } - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } + @Override + public void setMessageId(UUID messageId) { + this.messageId = messageId; + } - public Instant getCreatedAt() { - return createdAt; - } + @Override + public String getMessage() { + return message; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + @Override + public void setMessage(String message) { + this.message = message; + } - public Instant getUpdatedAt() { - return updatedAt; - } + @Override + public QueueOutboxNotifyStatus getNotifyStatus() { + return notifyStatus; + } - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } + @Override + public void setNotifyStatus(QueueOutboxNotifyStatus notifyStatus) { + this.notifyStatus = notifyStatus; + } + + @Override + public Integer getRetryCount() { + return retryCount; + } + + public void setRetryCount(Integer retryCount) { + this.retryCount = retryCount; + } + + @Override + public Instant getPublishedAt() { + return publishedAt; + } + + @Override + public void setPublishedAt(Instant publishedAt) { + this.publishedAt = publishedAt; + } + + @Override + public Instant getConfirmedAt() { + return confirmedAt; + } + + @Override + public void setConfirmedAt(Instant confirmedAt) { + this.confirmedAt = confirmedAt; + } + + public UUID getTenantId() { + return tenantId; + } + + public void setTenantId(UUID tenantId) { + this.tenantId = tenantId; + } + + @Override + public Instant getCreatedAt() { + return createdAt; + } + + @Override + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java index 2377a11d5..6e5b4dfab 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantConfigurationEntity.java @@ -5,8 +5,8 @@ import gr.cite.notification.common.enums.TenantConfigurationType; import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.conventers.TenantConfigurationTypeConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -14,36 +14,43 @@ import java.util.UUID; @Table(name = "\"ntf_TenantConfiguration\"") public class TenantConfigurationEntity extends TenantScopedBaseEntity { - public static class Field { - public static final String ID = "id"; - public static final String TENANT_ID = "tenantId"; - public static final String TYPE = "type"; - public static final String VALUE = "value"; - public static final String IS_ACTIVE = "isActive"; - public static final String CREATED_AT = "createdAt"; - public static final String UPDATED_AT = "updatedAt"; - } - @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; + public static final String _id = "id"; + @Column(name = "type", nullable = false) @Convert(converter = TenantConfigurationTypeConverter.class) private TenantConfigurationType type; + public static final String _type = "type"; + @Column(name = "value", nullable = false) private String value; + public static final String _value = "value"; + + @Column(name = "\"tenant\"", columnDefinition = "uuid") + private UUID tenantId; + + public static final String _tenantId = "tenantId"; + + @Column(name = "created_at", nullable = false) + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + @Column(name = "is_active", nullable = false) @Convert(converter = IsActiveConverter.class) private IsActive isActive; - @Column(name = "created_at", nullable = false) - private Instant createdAt; - - @Column(name = "updated_at", nullable = false) - private Instant updatedAt; + public static final String _isActive = "isActive"; public UUID getId() { return id; @@ -69,12 +76,14 @@ public class TenantConfigurationEntity extends TenantScopedBaseEntity { this.value = value; } - public IsActive getIsActive() { - return isActive; + @Override + public UUID getTenantId() { + return tenantId; } - public void setIsActive(IsActive isActive) { - this.isActive = isActive; + @Override + public void setTenantId(UUID tenantId) { + this.tenantId = tenantId; } public Instant getCreatedAt() { @@ -92,4 +101,13 @@ public class TenantConfigurationEntity extends TenantScopedBaseEntity { public void setUpdatedAt(Instant updatedAt) { this.updatedAt = updatedAt; } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java index 297da6dc1..b20d2d00a 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantEntity.java @@ -2,109 +2,80 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.IsActiveConverter; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity -@Table(name = "\"Tenant\"") +@Table(name = "\"ntf_Tenant\"") public class TenantEntity { - @Id - @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public final static String _id = "id"; - @Column(name = "code", length = 200, nullable = false) - private String code; - public final static String _code = "code"; + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "name", length = 500, nullable = false) - private String name; - public final static String _name = "name"; + public static final String _id = "id"; - @Column(name = "description", nullable = false) - private String description; - public final static String _description = "description"; + @Column(name = "code", length = 200, nullable = false) + private String code; - @Column(name = "is_active", length = 20, nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - public final static String _isActive = "isActive"; + public static final String _code = "code"; - @Column(name = "config") - private String config; - public final static String _config = "config"; + @Column(name = "created_at", nullable = false) + private Instant createdAt; - @Column(name = "created_at", nullable = false) - private Instant createdAt; - public final static String _createdAt = "createdAt"; + public static final String _createdAt = "createdAt"; - @Column(name = "updated_at", nullable = false) - private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; - public UUID getId() { - return id; - } + public static final String _updatedAt = "updatedAt"; - public void setId(UUID id) { - this.id = id; - } + @Column(name = "is_active", length = 20, nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public String getCode() { - return code; - } + public static final String _isActive = "isActive"; - public void setCode(String code) { - this.code = code; - } + public UUID getId() { + return id; + } - public String getName() { - return name; - } + public void setId(UUID id) { + this.id = id; + } - public void setName(String name) { - this.name = name; - } + public String getCode() { + return code; + } - public String getDescription() { - return description; - } + public void setCode(String code) { + this.code = code; + } - public void setDescription(String description) { - this.description = description; - } + public Instant getCreatedAt() { + return createdAt; + } - public IsActive getIsActive() { - return isActive; - } + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } + public Instant getUpdatedAt() { + return updatedAt; + } - public String getConfig() { - return config; - } + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } - public void setConfig(String config) { - this.config = config; - } + public IsActive getIsActive() { + return isActive; + } - public Instant getCreatedAt() { - return createdAt; - } + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } - - public Instant getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java index 257689196..40ea61311 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/TenantUserEntity.java @@ -3,73 +3,79 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.IsActiveConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @Entity @Table(name = "\"TenantUser\"") -public class TenantUserEntity extends TenantScopedBaseEntity{ - @Id - @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public final static String _id = "id"; +public class TenantUserEntity extends TenantScopedBaseEntity { - @Column(name = "user", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID userId; - public final static String _userId = "userId"; + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "is_active", length = 100, nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - public final static String _isActive = "isActive"; + public static final String _id = "id"; - @Column(name = "created_at", nullable = false) - private Instant createdAt; - public final static String _createdAt = "createdAt"; + @Column(name = "user", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID userId; - @Column(name = "updated_at", nullable = false) - private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + public static final String _userId = "userId"; - public UUID getId() { - return id; - } + @Column(name = "created_at", nullable = false) + private Instant createdAt; - public void setId(UUID id) { - this.id = id; - } + public static final String _createdAt = "createdAt"; - public UUID getUserId() { - return userId; - } + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; - public void setUserId(UUID userId) { - this.userId = userId; - } + public static final String _updatedAt = "updatedAt"; - public IsActive getIsActive() { - return isActive; - } + @Column(name = "is_active", length = 100, nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } + public static final String _isActive = "isActive"; - public Instant getCreatedAt() { - return createdAt; - } + public UUID getId() { + return id; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + public void setId(UUID id) { + this.id = id; + } - public Instant getUpdatedAt() { - return updatedAt; - } + public UUID getUserId() { + return userId; + } - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } + public void setUserId(UUID userId) { + this.userId = userId; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java index 08a8da048..75b3fba01 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserContactInfoEntity.java @@ -3,8 +3,8 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.ContactInfoType; import gr.cite.notification.data.conventers.ContactInfoTypeConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -15,30 +15,34 @@ public class UserContactInfoEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; + public static final String _id = "id"; @Column(name = "\"user\"", nullable = false) private UUID userId; + public static final String _userId = "userId"; @Column(name = "\"ordinal\"", nullable = false) private Integer ordinal; - public static final String _ordinal = "ordinal"; + public static final String _ordinal = "ordinal"; @Column(name = "type", length = 100, nullable = false) @Convert(converter = ContactInfoTypeConverter.class) private ContactInfoType type; - public final static String _type = "type"; + + public static final String _type = "type"; @Column(name = "value", nullable = false) private String value; - public final static String _value = "value"; + + public static final String _value = "value"; @Column(name = "created_at", nullable = false) private Instant createdAt; - public final static String _createdAt = "createdAt"; + public static final String _createdAt = "createdAt"; public UUID getUserId() { return userId; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java index ca4053893..015fd1b7f 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserCredentialEntity.java @@ -14,16 +14,16 @@ public class UserCredentialEntity extends TenantScopedBaseEntity { @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; - public final static String _id = "id"; + public static final String _id = "id"; @Column(name = "\"user\"", columnDefinition = "uuid", nullable = false) private UUID userId; - public final static String _userId = "userId"; + public static final String _userId = "userId"; @Column(name = "\"external_id\"", length = UserCredentialEntity._externalIdLength, nullable = false) private String externalId; - public final static String _externalId = "externalId"; - public final static int _externalIdLength = 512; + public static final String _externalId = "externalId"; + public static final int _externalIdLength = 512; @Column(name = "created_at", nullable = false) private Instant createdAt; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java index fd38203ed..477695f65 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserEntity.java @@ -2,8 +2,8 @@ package gr.cite.notification.data; import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.data.conventers.IsActiveConverter; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -11,81 +11,86 @@ import java.util.UUID; @Table(name = "\"User\"") public class UserEntity { - @Id - @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) - private UUID id; - public final static String _id = "id"; + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; - @Column(name = "name", length = UserEntity._nameLength, nullable = true) - private String name = null; - public final static String _name = "name"; - public final static int _nameLength = 250; + public static final String _id = "id"; + @Column(name = "name", length = UserEntity._nameLength) + private String name = null; - @Column(name = "created_at", nullable = false) - private Instant createdAt; + public static final String _name = "name"; - public static final String _createdAt = "createdAt"; + public static final int _nameLength = 250; - @Column(name = "updated_at", nullable = false) - private Instant updatedAt; + @Column(name = "additional_info") + private String additionalInfo; - public static final String _updatedAt = "updatedAt"; + public static final String _additionalInfo = "additionalInfo"; - @Column(name = "is_active", nullable = false) - @Convert(converter = IsActiveConverter.class) - private IsActive isActive; - public static final String _isActive = "isActive"; + @Column(name = "created_at", nullable = false) + private Instant createdAt; - @Column(name = "additional_info", nullable = true) - private String additionalInfo; - public final static String _additionalInfo = "additionalInfo"; + public static final String _createdAt = "createdAt"; - public UUID getId() { - return id; - } + @Column(name = "updated_at", nullable = false) + private Instant updatedAt; - public void setId(UUID id) { - this.id = id; - } + public static final String _updatedAt = "updatedAt"; - public String getName() { - return name; - } + @Column(name = "is_active", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; - public void setName(String name) { - this.name = name; - } + public static final String _isActive = "isActive"; - public Instant getCreatedAt() { - return createdAt; - } + public UUID getId() { + return id; + } - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - } + public void setId(UUID id) { + this.id = id; + } - public Instant getUpdatedAt() { - return updatedAt; - } + public String getName() { + return name; + } - public void setUpdatedAt(Instant updatedAt) { - this.updatedAt = updatedAt; - } + public void setName(String name) { + this.name = name; + } - public IsActive getIsActive() { - return isActive; - } + public String getAdditionalInfo() { + return additionalInfo; + } - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } + public void setAdditionalInfo(String additionalInfo) { + this.additionalInfo = additionalInfo; + } - public String getAdditionalInfo() { - return additionalInfo; - } + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } - public void setAdditionalInfo(String additionalInfo) { - this.additionalInfo = additionalInfo; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java index 331f22523..1841453db 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/data/UserNotificationPreferenceEntity.java @@ -4,8 +4,8 @@ import gr.cite.notification.common.enums.NotificationContactType; import gr.cite.notification.data.composite.CompositeUserNotificationPreferenceId; import gr.cite.notification.data.conventers.NotificationContactTypeConverter; import gr.cite.notification.data.tenant.TenantScopedBaseEntity; - import jakarta.persistence.*; + import java.time.Instant; import java.util.UUID; @@ -14,33 +14,35 @@ import java.util.UUID; @IdClass(CompositeUserNotificationPreferenceId.class) public class UserNotificationPreferenceEntity extends TenantScopedBaseEntity { - public static class Field { - public static final String USER_ID = "userId"; - public static final String TYPE = "type"; - public static final String CHANNEL = "channel"; - public static final String ORDINAL = "ordinal"; - public static final String CREATED_AT = "createdAt"; - } - @Id @Column(name = "user", columnDefinition = "uuid", nullable = false) private UUID userId; + public static final String _userId = "userId"; + @Id @Column(name = "type", columnDefinition = "uuid", nullable = false) private UUID type; + public static final String _type = "type"; + @Id @Column(name = "channel", nullable = false) @Convert(converter = NotificationContactTypeConverter.class) private NotificationContactType channel; + public static final String _channel = "channel"; + @Column(name = "ordinal", nullable = false) private Integer ordinal; + public static final String _ordinal = "ordinal"; + @Column(name = "created_at", nullable = false) private Instant createdAt; + public static final String _createdAt = "createdAt"; + public UUID getUserId() { return userId; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Language.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Language.java index e83e23b6d..a677beb19 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Language.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Language.java @@ -8,28 +8,32 @@ import java.util.UUID; public class Language { private UUID id; + public static final String _id = "id"; private String code; + public static final String _code = "code"; - private String payload; - public static final String _payload = "payload"; + private Integer ordinal; + + public static final String _ordinal = "ordinal"; private Instant createdAt; + public static final String _createdAt = "createdAt"; private Instant updatedAt; + public static final String _updatedAt = "updatedAt"; private IsActive isActive; + public static final String _isActive = "isActive"; - private Integer ordinal; - public static final String _ordinal = "ordinal"; - private String hash; - public final static String _hash = "hash"; + + public static final String _hash = "hash"; public UUID getId() { return id; @@ -47,12 +51,12 @@ public class Language { this.code = code; } - public String getPayload() { - return payload; + public Integer getOrdinal() { + return ordinal; } - public void setPayload(String payload) { - this.payload = payload; + public void setOrdinal(Integer ordinal) { + this.ordinal = ordinal; } public Instant getCreatedAt() { @@ -79,14 +83,6 @@ public class Language { this.isActive = isActive; } - public Integer getOrdinal() { - return ordinal; - } - - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } - public String getHash() { return hash; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Notification.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Notification.java index 4d0d5b8b2..020a23ea7 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Notification.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Notification.java @@ -1,64 +1,83 @@ package gr.cite.notification.model; import gr.cite.notification.common.enums.*; -import gr.cite.notification.data.conventers.IsActiveConverter; -import gr.cite.notification.data.conventers.NotificationTrackingProcessConverter; -import gr.cite.notification.data.conventers.NotificationTrackingStateConverter; -import jakarta.persistence.Column; -import jakarta.persistence.Convert; import java.time.Instant; import java.util.UUID; public class Notification { private UUID id; - public final static String _id = "id"; + + public static final String _id = "id"; private Tenant tenant; - public final static String _tenant = "tenant"; + + public static final String _tenant = "tenant"; private User user; + public static final String _user = "user"; private UUID type; + public static final String _type = "type"; private NotificationContactType contactTypeHint; + public static final String _contactTypeHint = "contactTypeHint"; private String contactHint; + public static final String _contactHint = "contactHint"; private Instant notifiedAt; - public final static String _notifiedAt = "notifiedAt"; + + public static final String _notifiedAt = "notifiedAt"; + + private String data; + + public static final String _data = "data"; private NotificationNotifyState notifyState; - public final static String _notifyState = "notifyState"; + + public static final String _notifyState = "notifyState"; private NotificationContactType notifiedWith; - public final static String _notifiedWith = "notifiedWith"; + + public static final String _notifiedWith = "notifiedWith"; private Integer retryCount; - public final static String _retryCount = "retryCount"; + + public static final String _retryCount = "retryCount"; private NotificationTrackingState trackingState; - public final static String _trackingState = "trackingState"; + + public static final String _trackingState = "trackingState"; private NotificationTrackingProcess trackingProcess; - public final static String _trackingProcess = "trackingProcess"; + + public static final String _trackingProcess = "trackingProcess"; + + private String trackingData; + + public static final String _trackingData = "trackingData"; private String hash; - public final static String _hash = "hash"; + + public static final String _hash = "hash"; private IsActive isActive; - public final static String _isActive = "isActive"; + + public static final String _isActive = "isActive"; private Instant createdAt; - public final static String _createdAt = "createdAt"; + + public static final String _createdAt = "createdAt"; private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + + public static final String _updatedAt = "updatedAt"; public UUID getId() { return id; @@ -92,11 +111,11 @@ public class Notification { this.type = type; } - public gr.cite.notification.common.enums.NotificationContactType getContactTypeHint() { + public NotificationContactType getContactTypeHint() { return contactTypeHint; } - public void setContactTypeHint(gr.cite.notification.common.enums.NotificationContactType contactTypeHint) { + public void setContactTypeHint(NotificationContactType contactTypeHint) { this.contactTypeHint = contactTypeHint; } @@ -116,6 +135,14 @@ public class Notification { this.notifiedAt = notifiedAt; } + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + public NotificationNotifyState getNotifyState() { return notifyState; } @@ -156,6 +183,14 @@ public class Notification { this.trackingProcess = trackingProcess; } + public String getTrackingData() { + return trackingData; + } + + public void setTrackingData(String trackingData) { + this.trackingData = trackingData; + } + public String getHash() { return hash; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/NotificationTemplate.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/NotificationTemplate.java index fa6cc6221..81be59bab 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/NotificationTemplate.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/NotificationTemplate.java @@ -12,37 +12,37 @@ import java.util.UUID; public class NotificationTemplate { private UUID id; - public final static String _id = "id"; + public static final String _id = "id"; private NotificationTemplateChannel channel; - public final static String _channel = "channel"; + public static final String _channel = "channel"; private UUID notificationType; - public final static String _notificationType = "notificationType"; + public static final String _notificationType = "notificationType"; private NotificationTemplateKind kind; - public final static String _kind = "kind"; + public static final String _kind = "kind"; private Language language; - public final static String _language = "language"; + public static final String _language = "language"; private NotificationTemplateValue value; - public final static String _value = "value"; + public static final String _value = "value"; private IsActive isActive; - public final static String _isActive = "isActive"; + public static final String _isActive = "isActive"; private Instant createdAt; - public final static String _createdAt = "createdAt"; + public static final String _createdAt = "createdAt"; private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; + public static final String _updatedAt = "updatedAt"; private Tenant tenant; - public final static String _tenant = "tenant"; + public static final String _tenant = "tenant"; private String hash; - public final static String _hash = "hash"; + public static final String _hash = "hash"; public UUID getId() { return id; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Tenant.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Tenant.java index 1d86f9ebe..ab585cf72 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Tenant.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/Tenant.java @@ -1,7 +1,6 @@ package gr.cite.notification.model; import gr.cite.notification.common.enums.IsActive; -import gr.cite.notification.model.tenantconfig.TenantConfig; import java.time.Instant; import java.util.UUID; @@ -9,32 +8,29 @@ import java.util.UUID; public class Tenant { private UUID id; - public final static String _id = "id"; + + public static final String _id = "id"; private String code; - public final static String _code = "code"; - private String name; - public final static String _name = "name"; - - private String description; - public final static String _description = "description"; - - private IsActive isActive; - public final static String _isActive = "isActive"; - - private TenantConfig config; - public final static String _config = "config"; + public static final String _code = "code"; private Instant createdAt; - public final static String _createdAt = "createdAt"; + + public static final String _createdAt = "createdAt"; private Instant updatedAt; - public final static String _updatedAt = "updatedAt"; - public final static String _hash = "hash"; + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } @@ -51,38 +47,6 @@ public class Tenant { this.code = code; } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public IsActive getIsActive() { - return isActive; - } - - public void setIsActive(IsActive isActive) { - this.isActive = isActive; - } - - public TenantConfig getConfig() { - return config; - } - - public void setConfig(TenantConfig config) { - this.config = config; - } - public Instant getCreatedAt() { return createdAt; } @@ -99,6 +63,14 @@ public class Tenant { this.updatedAt = updatedAt; } + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + public String getHash() { return hash; } @@ -106,4 +78,5 @@ public class Tenant { public void setHash(String hash) { this.hash = hash; } + } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/TenantConfiguration.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/TenantConfiguration.java index 62b678ca6..2484cd45e 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/TenantConfiguration.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/TenantConfiguration.java @@ -11,31 +11,50 @@ import java.util.UUID; public class TenantConfiguration { - public static class Field { - public static final String ID = "id"; - public static final String TENANT_ID = "tenantId"; - public static final String TYPE = "type"; - public static final String VALUE = "value"; - public static final String EMAIL_CLIENT_DATA = "emailClientData"; - public static final String DEFAULT_USER_LOCALE_DATA = "defaultUserLocaleData"; - public static final String NOTIFIER_LIST_DATA = "notifierListData"; - public static final String IS_ACTIVE = "isActive"; - public static final String CREATED_AT = "createdAt"; - public static final String UPDATED_AT = "updatedAt"; - public static final String HASH = "hash"; - } private UUID id; + + public static final String _id = "id"; + private UUID tenantId; + + public static final String _tenantId = "tenantId"; + private TenantConfigurationType type; + + public static final String _type = "type"; + private String value; + + public static final String _value = "value"; + private EmailClientConfigurationDataContainer emailClientData; + + public static final String _emailClientData = "emailClientData"; + private DefaultUserLocaleConfigurationDataContainer defaultUserLocaleData; + + public static final String _defaultUserLocaleData = "defaultUserLocaleData"; + private NotifierListConfigurationDataContainer notifierListData; + + public static final String _notifierListData = "notifierListData"; + private IsActive isActive; + + public static final String _isActive = "isActive"; + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + private String hash; + public static final String _hash = "hash"; + public UUID getId() { return id; } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/User.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/User.java index e232b39cc..3ea51b87c 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/User.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/User.java @@ -26,10 +26,10 @@ public class User { public static final String _isActive = "isActive"; - public final static String _hash = "hash"; + public static final String _hash = "hash"; private String hash; - public final static String _tenantUsers = "tenantUsers"; + public static final String _tenantUsers = "tenantUsers"; public UUID getId() { return id; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/LanguageBuilder.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/LanguageBuilder.java index 940877886..e435a9c3f 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/LanguageBuilder.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/LanguageBuilder.java @@ -1,6 +1,5 @@ package gr.cite.notification.model.builder; - import gr.cite.notification.authorization.AuthorizationFlags; import gr.cite.notification.convention.ConventionService; import gr.cite.notification.data.LanguageEntity; @@ -19,7 +18,8 @@ import java.util.*; @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -public class LanguageBuilder extends BaseBuilder{ +public class LanguageBuilder extends BaseBuilder { + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired @@ -43,14 +43,20 @@ public class LanguageBuilder extends BaseBuilder{ List models = new ArrayList<>(); for (LanguageEntity d : data) { Language m = new Language(); - if (fields.hasField(this.asIndexer(Language._id))) m.setId(d.getId()); - if (fields.hasField(this.asIndexer(Language._code))) m.setCode(d.getCode()); - if (fields.hasField(this.asIndexer(Language._payload))) m.setPayload(d.getPayload()); - if (fields.hasField(this.asIndexer(Language._ordinal))) m.setOrdinal(d.getOrdinal()); - if (fields.hasField(this.asIndexer(Language._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if (fields.hasField(this.asIndexer(Language._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if (fields.hasField(this.asIndexer(Language._isActive))) m.setIsActive(d.getIsActive()); - if (fields.hasField(this.asIndexer(Language._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + if (fields.hasField(this.asIndexer(Language._id))) + m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Language._code))) + m.setCode(d.getCode()); + if (fields.hasField(this.asIndexer(Language._ordinal))) + m.setOrdinal(d.getOrdinal()); + if (fields.hasField(this.asIndexer(Language._createdAt))) + m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(Language._updatedAt))) + m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(Language._isActive))) + m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(Language._hash))) + m.setHash(this.hashValue(d.getUpdatedAt())); models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantBuilder.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantBuilder.java index 19c20508d..b647a54e0 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantBuilder.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantBuilder.java @@ -2,11 +2,9 @@ package gr.cite.notification.model.builder; import gr.cite.notification.authorization.AuthorizationFlags; import gr.cite.notification.common.XmlHandlingService; -import gr.cite.notification.common.types.tenant.TenantConfigEntity; import gr.cite.notification.convention.ConventionService; import gr.cite.notification.data.TenantEntity; import gr.cite.notification.model.Tenant; -import gr.cite.notification.model.builder.tenantconfig.TenantConfigBuilder; import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; @@ -25,44 +23,47 @@ import java.util.*; public class TenantBuilder extends BaseBuilder { private final BuilderFactory builderFactory; - private final XmlHandlingService xmlHandlingService; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + @Autowired - public TenantBuilder(ConventionService conventionService, BuilderFactory builderFactory, XmlHandlingService xmlHandlingService) { + public TenantBuilder( + ConventionService conventionService, + BuilderFactory builderFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(TenantBuilder.class))); this.builderFactory = builderFactory; - this.xmlHandlingService = xmlHandlingService; } - public TenantBuilder authorize(EnumSet values){ + public TenantBuilder authorize(EnumSet values) { this.authorize = values; return this; } + @Override public List build(FieldSet fields, List data) throws MyApplicationException { - this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0),Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size) .orElse(0)); - this.logger.trace(new DataLogEntry("requested fields",fields)); - if(fields == null || data == null || fields.isEmpty()) return new ArrayList<>(); + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); - FieldSet configFields = fields.extractPrefixed(this.asPrefix(Tenant._config)); - - List models = new ArrayList<>(); - for(TenantEntity d : data){ + List models = new ArrayList<>(); + for (TenantEntity d : data) { Tenant m = new Tenant(); - if(fields.hasField(this.asIndexer(Tenant._id))) m.setId(d.getId()); - if(fields.hasField(this.asIndexer(Tenant._code))) m.setCode(d.getCode()); - if(fields.hasField(this.asIndexer(Tenant._name))) m.setName(d.getName()); - if(fields.hasField(this.asIndexer(Tenant._description))) m.setDescription(d.getDescription()); - if(fields.hasField(this.asIndexer(Tenant._isActive))) m.setIsActive(d.getIsActive()); - if (!configFields.isEmpty() && d.getConfig() != null){ - TenantConfigEntity config = this.xmlHandlingService.fromXmlSafe(TenantConfigEntity.class, d.getConfig()); - m.setConfig(this.builderFactory.builder(TenantConfigBuilder.class).authorize(this.authorize).build(configFields, config)); - } if(fields.hasField(this.asIndexer(Tenant._createdAt))) m.setCreatedAt(d.getCreatedAt()); - if(fields.hasField(this.asIndexer(Tenant._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); - if(fields.hasField(this.asIndexer(Tenant._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + if (fields.hasField(this.asIndexer(Tenant._id))) + m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Tenant._code))) + m.setCode(d.getCode()); + if (fields.hasField(this.asIndexer(Tenant._isActive))) + m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(Tenant._createdAt))) + m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(Tenant._updatedAt))) + m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(Tenant._hash))) + m.setHash(this.hashValue(d.getUpdatedAt())); models.add(m); } - this.logger.debug("build {} items",Optional.of(models).map(List::size).orElse(0)); + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); return models; } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantConfigurationBuilder.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantConfigurationBuilder.java index 20281e814..ac79649c6 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantConfigurationBuilder.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/builder/TenantConfigurationBuilder.java @@ -3,13 +3,11 @@ package gr.cite.notification.model.builder; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import gr.cite.notification.authorization.AuthorizationFlags; -import gr.cite.notification.common.enums.TenantConfigurationType; import gr.cite.notification.common.types.tenantconfiguration.DefaultUserLocaleConfigurationDataContainer; import gr.cite.notification.common.types.tenantconfiguration.EmailClientConfigurationDataContainer; import gr.cite.notification.common.types.tenantconfiguration.NotifierListConfigurationDataContainer; import gr.cite.notification.convention.ConventionService; import gr.cite.notification.data.TenantConfigurationEntity; -import gr.cite.notification.model.Tenant; import gr.cite.notification.model.TenantConfiguration; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; @@ -47,11 +45,11 @@ public class TenantConfigurationBuilder extends BaseBuilder models = new ArrayList<>(); for(TenantConfigurationEntity d : data){ TenantConfiguration m = new TenantConfiguration(); - if(fields.hasField(this.asIndexer(TenantConfiguration.Field.ID))) m.setId(d.getId()); - if(fields.hasField(this.asIndexer(TenantConfiguration.Field.TENANT_ID))) m.setTenantId(d.getTenantId()); - if(fields.hasField(this.asIndexer(TenantConfiguration.Field.TYPE))) m.setType(d.getType()); - if(fields.hasField(this.asIndexer(TenantConfiguration.Field.VALUE))) m.setValue(d.getValue()); - if(fields.hasField(this.asIndexer(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA))) { + if(fields.hasField(this.asIndexer(TenantConfiguration._id))) m.setId(d.getId()); + if(fields.hasField(this.asIndexer(TenantConfiguration._tenantId))) m.setTenantId(d.getTenantId()); + if(fields.hasField(this.asIndexer(TenantConfiguration._type))) m.setType(d.getType()); + if(fields.hasField(this.asIndexer(TenantConfiguration._value))) m.setValue(d.getValue()); + if(fields.hasField(this.asIndexer(TenantConfiguration._defaultUserLocaleData))) { try { m.setDefaultUserLocaleData(mapper.readValue(d.getValue(), DefaultUserLocaleConfigurationDataContainer.class)); @@ -59,78 +57,78 @@ public class TenantConfigurationBuilder extends BaseBuilder mandatory; - public final static String _mandatory = "mandatory"; + public static final String _mandatory = "mandatory"; private List optional; - public final static String _optional = "optional"; + public static final String _optional = "optional"; private Map formatting; - public final static String _formatting = "formatting"; + public static final String _formatting = "formatting"; public List getMandatory() { return mandatory; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/notificationtemplate/NotificationTemplateValue.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/notificationtemplate/NotificationTemplateValue.java index 0c096fb12..5abb42ef0 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/notificationtemplate/NotificationTemplateValue.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/notificationtemplate/NotificationTemplateValue.java @@ -7,31 +7,31 @@ import java.util.List; public class NotificationTemplateValue { private String subjectText; - public final static String _subjectText = "subjectText"; + public static final String _subjectText = "subjectText"; private String subjectKey; - public final static String _subjectKey = "subjectKey"; + public static final String _subjectKey = "subjectKey"; private FieldOptions subjectFieldOptions; - public final static String _subjectFieldOptions = "subjectFieldOptions"; + public static final String _subjectFieldOptions = "subjectFieldOptions"; private String bodyText; - public final static String _bodyText = "bodyText"; + public static final String _bodyText = "bodyText"; private String bodyKey; - public final static String _bodyKey = "bodyKey"; + public static final String _bodyKey = "bodyKey"; private String priorityKey; - public final static String _priorityKey = "priorityKey"; + public static final String _priorityKey = "priorityKey"; private Boolean allowAttachments; - public final static String _allowAttachments = "allowAttachments"; + public static final String _allowAttachments = "allowAttachments"; private List cc; - public final static String _cc = "cc"; + public static final String _cc = "cc"; private EmailOverrideMode ccMode; - public final static String _ccMode = "ccMode"; + public static final String _ccMode = "ccMode"; private List bcc; - public final static String _bcc = "bcc"; + public static final String _bcc = "bcc"; private EmailOverrideMode bccMode; - public final static String _bccMode = "bccMode"; + public static final String _bccMode = "bccMode"; private List extraDataKeys; - public final static String _extraDataKeys = "extraDataKeys"; + public static final String _extraDataKeys = "extraDataKeys"; private FieldOptions bodyFieldOptions; - public final static String _bodyFieldOptions = "bodyFieldOptions"; + public static final String _bodyFieldOptions = "bodyFieldOptions"; public String getSubjectText() { return subjectText; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/persist/NotificationPersist.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/persist/NotificationPersist.java index 72af20832..80876abb0 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/persist/NotificationPersist.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/persist/NotificationPersist.java @@ -29,15 +29,15 @@ public class NotificationPersist { public static final String _type = "type"; public static final String _contactTypeHint = "contactTypeHint"; public static final String _contactHint = "contactHint"; - public final static String _notifiedAt = "notifiedAt"; - public final static String _notifyState = "notifyState"; - public final static String _notifiedWith = "notifiedWith"; - public final static String _data = "data"; - public final static String _retryCount = "retryCount"; - public final static String _trackingState = "trackingState"; - public final static String _trackingProcess = "trackingProcess"; - public final static String _trackingData = "trackingData"; - public final static String _provenanceRef = "provenanceRef"; + public static final String _notifiedAt = "notifiedAt"; + public static final String _notifyState = "notifyState"; + public static final String _notifiedWith = "notifiedWith"; + public static final String _data = "data"; + public static final String _retryCount = "retryCount"; + public static final String _trackingState = "trackingState"; + public static final String _trackingProcess = "trackingProcess"; + public static final String _trackingData = "trackingData"; + public static final String _provenanceRef = "provenanceRef"; public static final String _hash = "hash"; } @@ -231,7 +231,7 @@ public class NotificationPersist { .failOn(Field._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{Field._type}, LocaleContextHolder.getLocale())), this.spec() .iff(() -> !this.isEmpty(item.getContactHint())) - .must(() -> this.lessEqualLength(item.getContactHint(), NotificationEntity.Field._contactHintLength)) + .must(() -> this.lessEqualLength(item.getContactHint(), NotificationEntity._contactHintLength)) .failOn(Field._contactHint).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{Field._contactHint}, LocaleContextHolder.getLocale())) ); } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantConfig.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantConfig.java index cbba2d2fc..cd55d9c64 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantConfig.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantConfig.java @@ -3,10 +3,10 @@ package gr.cite.notification.model.tenantconfig; public class TenantConfig { - public final static String _deposit = "deposit"; + public static final String _deposit = "deposit"; private TenantDepositConfig deposit; - public final static String _fileTransformers = "fileTransformers"; + public static final String _fileTransformers = "fileTransformers"; private TenantFileTransformersConfig fileTransformers; public TenantDepositConfig getDeposit() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantDepositConfig.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantDepositConfig.java index 8c468e2fc..2a0517b64 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantDepositConfig.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantDepositConfig.java @@ -4,7 +4,7 @@ import java.util.List; public class TenantDepositConfig { - public final static String _sources = "sources"; + public static final String _sources = "sources"; private List sources; public List getSources() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantFileTransformersConfig.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantFileTransformersConfig.java index ffada6eef..c7b6c0cc2 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantFileTransformersConfig.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantFileTransformersConfig.java @@ -4,7 +4,7 @@ import java.util.List; public class TenantFileTransformersConfig { - public final static String _sources = "sources"; + public static final String _sources = "sources"; private List sources; public List getSources() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantSource.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantSource.java index 4cd422fe1..5003b7781 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantSource.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/tenantconfig/TenantSource.java @@ -5,22 +5,22 @@ import java.util.List; public class TenantSource { - public final static String _url = "url"; + public static final String _url = "url"; private String url; - public final static String _codes = "codes"; + public static final String _codes = "codes"; private List codes; - public final static String _issuerUrl = "issuerUrl"; + public static final String _issuerUrl = "issuerUrl"; private String issuerUrl; - public final static String _clientId = "clientId"; + public static final String _clientId = "clientId"; private String clientId; - public final static String _clientSecret = "clientSecret"; + public static final String _clientSecret = "clientSecret"; private String clientSecret; - public final static String _scope = "scope"; + public static final String _scope = "scope"; private String scope; public String getUrl() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/user/PublicUser.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/user/PublicUser.java index 157203a68..0e683ce0d 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/user/PublicUser.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/user/PublicUser.java @@ -5,10 +5,10 @@ import java.util.UUID; public class PublicUser { - public final static String _id = "id"; + public static final String _id = "id"; private UUID id; - public final static String _name = "name"; + public static final String _name = "name"; private String name = null; public UUID getId() { diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/InAppNotificationQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/InAppNotificationQuery.java index 50970c662..b7c5c1c2c 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/InAppNotificationQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/InAppNotificationQuery.java @@ -9,246 +9,272 @@ import gr.cite.notification.model.InAppNotification; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; - @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class InAppNotificationQuery extends QueryBase { - private String like; - private Collection ids; - private List excludeIds; - private List userId; - private List type; - private Collection isActives; - private List tenantIds; - private List trackingState; - private Boolean isRead; - private Instant from; - private Instant to; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public InAppNotificationQuery like(String value) { - this.like = value; - return this; - } + private String like; - public InAppNotificationQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } + private Collection ids; - public InAppNotificationQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } + private List excludeIds; - public InAppNotificationQuery ids(Collection values) { - this.ids = values; - return this; - } + private List userId; - public InAppNotificationQuery excludeIds(UUID... value) { - this.excludeIds = Arrays.asList(value); - return this; - } + private List type; - public InAppNotificationQuery excludeIds(List values) { - this.excludeIds = values; - return this; - } + private Collection isActives; - public InAppNotificationQuery userId(UUID... value) { - this.userId = Arrays.asList(value); - return this; - } + private List tenantIds; - public InAppNotificationQuery userId(List values) { - this.userId = values; - return this; - } + private List trackingState; - public InAppNotificationQuery type(UUID... value) { - this.type = Arrays.asList(value); - return this; - } + private Boolean isRead; - public InAppNotificationQuery type(List values) { - this.type = values; - return this; - } + private Instant from; - public InAppNotificationQuery isActive(IsActive value) { - this.isActives = List.of(value); - return this; - } + private Instant to; - public InAppNotificationQuery isActive(IsActive... value) { - this.isActives = Arrays.asList(value); - return this; - } + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public InAppNotificationQuery Tenants(List value) { - this.tenantIds = value; - return this; - } + public InAppNotificationQuery like(String value) { + this.like = value; + return this; + } - public InAppNotificationQuery Tenants(UUID... value) { - this.tenantIds = Arrays.asList(value); - return this; - } + public InAppNotificationQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } - public InAppNotificationQuery isActive(Collection values) { - this.isActives = values; - return this; - } + public InAppNotificationQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } - public InAppNotificationQuery trackingState(List values) { - this.trackingState = values; - return this; - } + public InAppNotificationQuery ids(Collection values) { + this.ids = values; + return this; + } - public InAppNotificationQuery trackingState(NotificationInAppTracking... value) { - this.trackingState = List.of(value); - return this; - } + public InAppNotificationQuery excludeIds(UUID... value) { + this.excludeIds = Arrays.asList(value); + return this; + } - public InAppNotificationQuery isRead(Boolean isRead) { - this.isRead = isRead; - return this; - } + public InAppNotificationQuery excludeIds(List values) { + this.excludeIds = values; + return this; + } - public InAppNotificationQuery isRead() { - this.isRead = true; - return this; - } + public InAppNotificationQuery userId(UUID... value) { + this.userId = Arrays.asList(value); + return this; + } - public InAppNotificationQuery from(Instant from) { - this.from = from; - return this; - } + public InAppNotificationQuery userId(List values) { + this.userId = values; + return this; + } - public InAppNotificationQuery to(Instant to) { - this.to = to; - return this; - } + public InAppNotificationQuery type(UUID... value) { + this.type = Arrays.asList(value); + return this; + } - public InAppNotificationQuery authorize(EnumSet values) { - this.authorize = values; - return this; - } + public InAppNotificationQuery type(List values) { + this.type = values; + return this; + } - @Override - protected Boolean isFalseQuery() { - return this.isNullOrEmpty(this.ids) - && this.isNullOrEmpty(this.isActives) - && this.isNullOrEmpty(this.type) - && this.isNullOrEmpty(this.excludeIds) - && this.isNullOrEmpty(this.userId) - && this.isNullOrEmpty(this.trackingState); - } + public InAppNotificationQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } - @Override - protected Class entityClass() { - return InAppNotificationEntity.class; - } + public InAppNotificationQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } - @Override - protected Predicate applyFilters(QueryContext queryContext) { - List predicates = new ArrayList<>(); - if (this.ids != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._id).in(ids)); - } + public InAppNotificationQuery Tenants(List value) { + this.tenantIds = value; + return this; + } - if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(InAppNotificationEntity.Field._subject), this.like)); - } + public InAppNotificationQuery Tenants(UUID... value) { + this.tenantIds = Arrays.asList(value); + return this; + } - if (this.excludeIds != null) { - predicates.add(queryContext.CriteriaBuilder.not(queryContext.Root.get(InAppNotificationEntity.Field._id).in(ids))); - } + public InAppNotificationQuery isActive(Collection values) { + this.isActives = values; + return this; + } - if (this.userId != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._userId).in(userId)); - } + public InAppNotificationQuery trackingState(List values) { + this.trackingState = values; + return this; + } - if (this.isActives != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._isActive).in(isActives)); - } + public InAppNotificationQuery trackingState(NotificationInAppTracking... value) { + this.trackingState = List.of(value); + return this; + } - if (this.tenantIds != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity._tenantId).in(tenantIds)); - } + public InAppNotificationQuery isRead(Boolean isRead) { + this.isRead = isRead; + return this; + } - if (this.type != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._type).in(this.type)); - } + public InAppNotificationQuery isRead() { + this.isRead = true; + return this; + } - if (this.trackingState != null) { - predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._trackingState).in(trackingState)); - } + public InAppNotificationQuery from(Instant from) { + this.from = from; + return this; + } - if (isRead != null) { - predicates.add(isRead ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(InAppNotificationEntity.Field._readTime)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(InAppNotificationEntity.Field._readTime))); - } + public InAppNotificationQuery to(Instant to) { + this.to = to; + return this; + } - if (from != null) { - predicates.add(queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity.Field._createdAt), from)); - } + public InAppNotificationQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } - if (to != null) { - predicates.add(queryContext.CriteriaBuilder.lessThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity.Field._createdAt), from)); - } + @Override + protected Boolean isFalseQuery() { + return this.isNullOrEmpty(this.ids) + && this.isNullOrEmpty(this.isActives) + && this.isNullOrEmpty(this.type) + && this.isNullOrEmpty(this.excludeIds) + && this.isNullOrEmpty(this.userId) + && this.isNullOrEmpty(this.trackingState); + } - if (predicates.size() > 0) { - Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); - return queryContext.CriteriaBuilder.and(predicatesArray); - } else { - return null; - } + @Override + protected Class entityClass() { + return InAppNotificationEntity.class; + } - } + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.ids != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._id).in(ids)); + } - @Override - protected String fieldNameOf(FieldResolver item) { - if (item.match(InAppNotification.Field.ID)) return InAppNotificationEntity.Field._id; - else if (item.match(InAppNotification.Field.CREATED_AT)) return InAppNotificationEntity.Field._createdAt; - else if (item.match(InAppNotification.Field.USER)) return InAppNotificationEntity.Field._userId; - else if (item.match(InAppNotification.Field.IS_ACTIVE)) return InAppNotificationEntity.Field._isActive; - else if (item.match(InAppNotification.Field.READ_TIME)) return InAppNotificationEntity.Field._readTime; - else if (item.match(InAppNotification.Field.TRACKING_STATE)) return InAppNotificationEntity.Field._trackingState; - else if (item.match(InAppNotification.Field.BODY)) return InAppNotificationEntity.Field._body; - else if (item.match(InAppNotification.Field.EXTRA_DATA)) return InAppNotificationEntity.Field._extraData; - else if (item.match(InAppNotification.Field.PRIORITY)) return InAppNotificationEntity.Field._priority; - else if (item.match(InAppNotification.Field.SUBJECT)) return InAppNotificationEntity.Field._subject; - else if (item.match(InAppNotification.Field.TENANT)) return InAppNotificationEntity._tenantId; - else if (item.match(InAppNotification.Field.TYPE)) return InAppNotificationEntity.Field._type; - else if (item.match(InAppNotification.Field.UPDATED_AT)) return InAppNotificationEntity.Field._updatedAt; - else return null; - } + if (this.like != null && !this.like.isEmpty()) { + predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(InAppNotificationEntity._subject), this.like)); + } + + if (this.excludeIds != null) { + predicates.add(queryContext.CriteriaBuilder.not(queryContext.Root.get(InAppNotificationEntity._id).in(ids))); + } + + if (this.userId != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._userId).in(userId)); + } + + if (this.isActives != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._isActive).in(isActives)); + } + + if (this.tenantIds != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._tenantId).in(tenantIds)); + } + + if (this.type != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._type).in(this.type)); + } + + if (this.trackingState != null) { + predicates.add(queryContext.Root.get(InAppNotificationEntity._trackingState).in(trackingState)); + } + + if (isRead != null) { + predicates.add(isRead ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(InAppNotificationEntity._readTime)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(InAppNotificationEntity._readTime))); + } + + if (from != null) { + predicates.add(queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity._createdAt), from)); + } + + if (to != null) { + predicates.add(queryContext.CriteriaBuilder.lessThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity._createdAt), from)); + } + + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(InAppNotification.Field.ID)) + return InAppNotificationEntity._id; + else if (item.match(InAppNotification.Field.CREATED_AT)) + return InAppNotificationEntity._createdAt; + else if (item.match(InAppNotification.Field.USER)) + return InAppNotificationEntity._userId; + else if (item.match(InAppNotification.Field.IS_ACTIVE)) + return InAppNotificationEntity._isActive; + else if (item.match(InAppNotification.Field.READ_TIME)) + return InAppNotificationEntity._readTime; + else if (item.match(InAppNotification.Field.TRACKING_STATE)) + return InAppNotificationEntity._trackingState; + else if (item.match(InAppNotification.Field.BODY)) + return InAppNotificationEntity._body; + else if (item.match(InAppNotification.Field.EXTRA_DATA)) + return InAppNotificationEntity._extraData; + else if (item.match(InAppNotification.Field.PRIORITY)) + return InAppNotificationEntity._priority; + else if (item.match(InAppNotification.Field.SUBJECT)) + return InAppNotificationEntity._subject; + else if (item.match(InAppNotification.Field.TENANT)) + return InAppNotificationEntity._tenantId; + else if (item.match(InAppNotification.Field.TYPE)) + return InAppNotificationEntity._type; + else if (item.match(InAppNotification.Field.UPDATED_AT)) + return InAppNotificationEntity._updatedAt; + else + return null; + } + + @Override + protected InAppNotificationEntity convert(Tuple tuple, Set columns) { + InAppNotificationEntity item = new InAppNotificationEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._id, UUID.class)); + item.setType(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._type, UUID.class)); + item.setUserId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._userId, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._tenantId, UUID.class)); + item.setTrackingState(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._trackingState, NotificationInAppTracking.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._isActive, IsActive.class)); + item.setExtraData(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._extraData, String.class)); + item.setBody(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._body, String.class)); + item.setSubject(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._subject, String.class)); + item.setPriority(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._priority, InAppNotificationPriority.class)); + return item; + } - @Override - protected InAppNotificationEntity convert(Tuple tuple, Set columns) { - InAppNotificationEntity item = new InAppNotificationEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._id, UUID.class)); - item.setType(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._type, UUID.class)); - item.setUserId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._userId, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity._tenantId, UUID.class)); - item.setTrackingState(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._trackingState, NotificationInAppTracking.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._isActive, IsActive.class)); - item.setExtraData(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._extraData, String.class)); - item.setBody(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._body, String.class)); - item.setSubject(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._subject, String.class)); - item.setPriority(QueryBase.convertSafe(tuple, columns, InAppNotificationEntity.Field._priority, InAppNotificationPriority.class)); - return item; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/LanguageQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/LanguageQuery.java index 1aaef85a0..314689e67 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/LanguageQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/LanguageQuery.java @@ -7,13 +7,13 @@ import gr.cite.notification.model.Language; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; @@ -160,7 +160,6 @@ public class LanguageQuery extends QueryBase { LanguageEntity item = new LanguageEntity(); item.setId(QueryBase.convertSafe(tuple, columns, LanguageEntity._id, UUID.class)); item.setCode(QueryBase.convertSafe(tuple, columns, LanguageEntity._code, String.class)); - item.setPayload(QueryBase.convertSafe(tuple, columns, LanguageEntity._payload, String.class)); item.setOrdinal(QueryBase.convertSafe(tuple, columns, LanguageEntity._ordinal, Integer.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._createdAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, LanguageEntity._updatedAt, Instant.class)); @@ -170,15 +169,22 @@ public class LanguageQuery extends QueryBase { @Override protected String fieldNameOf(FieldResolver item) { - if (item.match(Language._id)) return LanguageEntity._id; - else if (item.match(Language._code)) return LanguageEntity._code; - else if (item.match(Language._payload)) return LanguageEntity._payload; - else if (item.match(Language._ordinal)) return LanguageEntity._ordinal; - else if (item.match(Language._createdAt)) return LanguageEntity._createdAt; - else if (item.match(Language._updatedAt)) return LanguageEntity._updatedAt; - else if (item.match(Language._hash)) return LanguageEntity._updatedAt; - else if (item.match(Language._isActive)) return LanguageEntity._isActive; - else return null; + if (item.match(Language._id)) + return LanguageEntity._id; + else if (item.match(Language._code)) + return LanguageEntity._code; + else if (item.match(Language._ordinal)) + return LanguageEntity._ordinal; + else if (item.match(Language._createdAt)) + return LanguageEntity._createdAt; + else if (item.match(Language._updatedAt)) + return LanguageEntity._updatedAt; + else if (item.match(Language._hash)) + return LanguageEntity._updatedAt; + else if (item.match(Language._isActive)) + return LanguageEntity._isActive; + else + return null; } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/NotificationQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/NotificationQuery.java index 461b22c8a..6974721e6 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/NotificationQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/NotificationQuery.java @@ -8,314 +8,346 @@ import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.Ordering; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; - @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class NotificationQuery extends QueryBase { - private Collection ids; - private Collection isActives; - private List tenantIds; - private List notifyState; - private List notifiedWith; - private Boolean notifiedWithHasValue; - private Boolean notifiedAtHasValue; - private List type; - private List contactType; - private Integer retryThreshold; - private Instant createdAfter; - private List trackingState; - private List trackingProgress; + private Collection ids; - private Collection userIds; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + private Collection isActives; - public NotificationQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } + private List tenantIds; - public NotificationQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } + private List notifyState; - public NotificationQuery ids(Collection values) { - this.ids = values; - return this; - } + private List notifiedWith; - public NotificationQuery isActive(IsActive value) { - this.isActives = List.of(value); - return this; - } + private Boolean notifiedWithHasValue; - public NotificationQuery isActive(IsActive... value) { - this.isActives = Arrays.asList(value); - return this; - } + private Boolean notifiedAtHasValue; - public NotificationQuery Tenants(List value) { - this.tenantIds = value; - return this; - } + private List type; - public NotificationQuery Tenants(UUID... value) { - this.tenantIds = Arrays.asList(value); - return this; - } + private List contactType; - public NotificationQuery isActive(Collection values) { - this.isActives = values; - return this; - } + private Integer retryThreshold; - public NotificationQuery notifyState(NotificationNotifyState... notifyState) { - this.notifyState = List.of(notifyState); - return this; - } + private Instant createdAfter; - public NotificationQuery notifyState(List notifyState) { - this.notifyState = notifyState; - return this; - } + private List trackingState; - public NotificationQuery notifiedWith(NotificationContactType... notifiedWith) { - this.notifiedWith = List.of(notifiedWith); - return this; - } + private List trackingProgress; - public NotificationQuery notifiedWith(List notifiedWith) { - this.notifiedWith = notifiedWith; - return this; - } + private Collection userIds; - public NotificationQuery notifiedWithHasValue(Boolean notifiedWithHasValue) { - this.notifiedWithHasValue = notifiedWithHasValue; - return this; - } + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public NotificationQuery notifiedWithHasValue() { - this.notifiedWithHasValue = true; - return this; - } + public NotificationQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } - public NotificationQuery notifiedAtHasValue(Boolean notifiedAtHasValue) { - this.notifiedAtHasValue = notifiedAtHasValue; - return this; - } + public NotificationQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } - public NotificationQuery notifiedAtHasValue() { - this.notifiedAtHasValue = true; - return this; - } + public NotificationQuery ids(Collection values) { + this.ids = values; + return this; + } - public NotificationQuery type(UUID... type) { - this.type = List.of(type); - return this; - } + public NotificationQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } - public NotificationQuery type(List type) { - this.type = type; - return this; - } + public NotificationQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } - public NotificationQuery contactType(NotificationContactType... contactType) { - this.contactType = List.of(contactType); - return this; - } + public NotificationQuery Tenants(List value) { + this.tenantIds = value; + return this; + } - public NotificationQuery contactType(List contactType) { - this.contactType = contactType; - return this; - } + public NotificationQuery Tenants(UUID... value) { + this.tenantIds = Arrays.asList(value); + return this; + } - public NotificationQuery retryThreshold(Integer retryThreshold) { - this.retryThreshold = retryThreshold; - return this; - } + public NotificationQuery isActive(Collection values) { + this.isActives = values; + return this; + } - public NotificationQuery createdAfter(Instant createdAfter) { - this.createdAfter = createdAfter; - return this; - } + public NotificationQuery notifyState(NotificationNotifyState... notifyState) { + this.notifyState = List.of(notifyState); + return this; + } - public NotificationQuery authorize(EnumSet values) { - this.authorize = values; - return this; - } + public NotificationQuery notifyState(List notifyState) { + this.notifyState = notifyState; + return this; + } - public NotificationQuery trackingState(NotificationTrackingState... trackingState) { - this.trackingState = List.of(trackingState); - return this; - } + public NotificationQuery notifiedWith(NotificationContactType... notifiedWith) { + this.notifiedWith = List.of(notifiedWith); + return this; + } - public NotificationQuery trackingState(List trackingState) { - this.trackingState = trackingState; - return this; - } + public NotificationQuery notifiedWith(List notifiedWith) { + this.notifiedWith = notifiedWith; + return this; + } - public NotificationQuery trackingProgress(NotificationTrackingProcess... trackingProgress) { - this.trackingProgress = List.of(trackingProgress); - return this; - } + public NotificationQuery notifiedWithHasValue(Boolean notifiedWithHasValue) { + this.notifiedWithHasValue = notifiedWithHasValue; + return this; + } - public NotificationQuery trackingProgress(List trackingProgress) { - this.trackingProgress = trackingProgress; - return this; - } + public NotificationQuery notifiedWithHasValue() { + this.notifiedWithHasValue = true; + return this; + } - public NotificationQuery userIds(UUID value) { - this.userIds = List.of(value); - return this; - } + public NotificationQuery notifiedAtHasValue(Boolean notifiedAtHasValue) { + this.notifiedAtHasValue = notifiedAtHasValue; + return this; + } - public NotificationQuery userIds(UUID... value) { - this.userIds = Arrays.asList(value); - return this; - } + public NotificationQuery notifiedAtHasValue() { + this.notifiedAtHasValue = true; + return this; + } - public NotificationQuery userIds(Collection values) { - this.userIds = values; - return this; - } + public NotificationQuery type(UUID... type) { + this.type = List.of(type); + return this; + } - public NotificationQuery ordering(Ordering ordering) { - this.setOrder(ordering); - return this; - } + public NotificationQuery type(List type) { + this.type = type; + return this; + } - @Override - protected Boolean isFalseQuery() { - return this.isNullOrEmpty(this.ids) - && this.isNullOrEmpty(this.isActives) - && this.isNullOrEmpty(this.notifyState); - } + public NotificationQuery contactType(NotificationContactType... contactType) { + this.contactType = List.of(contactType); + return this; + } - @Override - protected Class entityClass() { - return NotificationEntity.class; - } + public NotificationQuery contactType(List contactType) { + this.contactType = contactType; + return this; + } - @Override - protected Predicate applyFilters(QueryContext queryContext) { - List predicates = new ArrayList<>(); - if (this.ids != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._id).in(ids)); - } + public NotificationQuery retryThreshold(Integer retryThreshold) { + this.retryThreshold = retryThreshold; + return this; + } - if (this.isActives != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._isActive).in(isActives)); - } + public NotificationQuery createdAfter(Instant createdAfter) { + this.createdAfter = createdAfter; + return this; + } - if (this.tenantIds != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._tenantId).in(tenantIds)); - } + public NotificationQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } - if (this.notifyState != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._notifyState).in(notifyState)); - } + public NotificationQuery trackingState(NotificationTrackingState... trackingState) { + this.trackingState = List.of(trackingState); + return this; + } - if (this.notifiedWith != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._notifiedWith).in(notifiedWith)); - } + public NotificationQuery trackingState(List trackingState) { + this.trackingState = trackingState; + return this; + } - if (notifiedWithHasValue != null) { - Predicate hasValuePredicate = notifiedWithHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity.Field._notifiedWith)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity.Field._notifiedWith)); - predicates.add(hasValuePredicate); - } + public NotificationQuery trackingProgress(NotificationTrackingProcess... trackingProgress) { + this.trackingProgress = List.of(trackingProgress); + return this; + } - if (notifiedAtHasValue != null) { - Predicate hasValuePredicate = notifiedAtHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity.Field._notifiedAt)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity.Field._notifiedAt)); - predicates.add(hasValuePredicate); - } + public NotificationQuery trackingProgress(List trackingProgress) { + this.trackingProgress = trackingProgress; + return this; + } - if (this.type != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._type).in(this.type)); - } + public NotificationQuery userIds(UUID value) { + this.userIds = List.of(value); + return this; + } - if (this.contactType != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._contactTypeHint).in(this.contactType)); - } + public NotificationQuery userIds(UUID... value) { + this.userIds = Arrays.asList(value); + return this; + } - if (this.retryThreshold != null) { - predicates.add(queryContext.CriteriaBuilder.le(queryContext.Root.get(NotificationEntity.Field._retryCount), this.retryThreshold)); - } + public NotificationQuery userIds(Collection values) { + this.userIds = values; + return this; + } - if (this.createdAfter != null) { - predicates.add(queryContext.CriteriaBuilder.greaterThan(queryContext.Root.get(NotificationEntity.Field._createdAt), this.createdAfter)); - } + public NotificationQuery ordering(Ordering ordering) { + this.setOrder(ordering); + return this; + } - if (this.trackingState != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._trackingState).in(trackingState)); - } + @Override + protected Boolean isFalseQuery() { + return this.isNullOrEmpty(this.ids) + && this.isNullOrEmpty(this.isActives) + && this.isNullOrEmpty(this.notifyState); + } - if (this.trackingProgress != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._trackingProcess).in(trackingProgress)); - } + @Override + protected Class entityClass() { + return NotificationEntity.class; + } - if (this.userIds != null) { - predicates.add(queryContext.Root.get(NotificationEntity.Field._userId).in(userIds)); - } + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.ids != null) { + predicates.add(queryContext.Root.get(NotificationEntity._id).in(ids)); + } - if (predicates.size() > 0) { - Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); - return queryContext.CriteriaBuilder.and(predicatesArray); - } else { - return null; - } + if (this.isActives != null) { + predicates.add(queryContext.Root.get(NotificationEntity._isActive).in(isActives)); + } - } + if (this.tenantIds != null) { + predicates.add(queryContext.Root.get(NotificationEntity._tenantId).in(tenantIds)); + } - @Override - protected String fieldNameOf(FieldResolver item) { - if (item.match(Notification._id)) return NotificationEntity.Field._id; - else if (item.match(Notification._contactHint)) return NotificationEntity.Field._contactHint; - else if (item.match(Notification._createdAt)) return NotificationEntity.Field._createdAt; - else if (item.match(Notification._isActive)) return NotificationEntity.Field._isActive; - else if (item.match(Notification._contactTypeHint)) return NotificationEntity.Field._contactTypeHint; - else if (item.match(Notification._updatedAt)) return NotificationEntity.Field._updatedAt; - else if (item.match(Notification._notifiedAt)) return NotificationEntity.Field._notifiedAt; - else if (item.prefix(Notification._tenant)) return NotificationEntity.Field._tenantId; - else if (item.prefix(Notification._user)) return NotificationEntity.Field._userId; - else if (item.match(Notification._type)) return NotificationEntity.Field._type; - else if (item.match(Notification._notifyState)) return NotificationEntity.Field._notifyState; - else if (item.match(Notification._notifiedWith)) return NotificationEntity.Field._notifiedWith; - else if (item.match(Notification._trackingState)) return NotificationEntity.Field._trackingState; - else if (item.match(Notification._trackingProcess)) return NotificationEntity.Field._trackingProcess; - else if (item.match(Notification._retryCount)) return NotificationEntity.Field._retryCount; + if (this.notifyState != null) { + predicates.add(queryContext.Root.get(NotificationEntity._notifyState).in(notifyState)); + } - else return null; - } + if (this.notifiedWith != null) { + predicates.add(queryContext.Root.get(NotificationEntity._notifiedWith).in(notifiedWith)); + } - @Override - protected NotificationEntity convert(Tuple tuple, Set columns) { - NotificationEntity item = new NotificationEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._id, UUID.class)); - item.setContactHint(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._contactHint, String.class)); - item.setContactTypeHint(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._contactTypeHint, NotificationContactType.class)); - item.setNotifiedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._notifiedAt, Instant.class)); - item.setType(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._type, UUID.class)); - item.setUserId(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._userId, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._tenantId, UUID.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._isActive, IsActive.class)); - item.setNotifyState(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._notifyState, NotificationNotifyState.class)); - item.setNotifiedWith(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._notifiedWith, NotificationContactType.class)); - item.setTrackingState(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._trackingState, NotificationTrackingState.class)); - item.setTrackingProcess(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._trackingProcess, NotificationTrackingProcess.class)); - item.setRetryCount(QueryBase.convertSafe(tuple, columns, NotificationEntity.Field._retryCount, Integer.class)); + if (notifiedWithHasValue != null) { + Predicate hasValuePredicate = notifiedWithHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity._notifiedWith)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity._notifiedWith)); + predicates.add(hasValuePredicate); + } - return item; - } + if (notifiedAtHasValue != null) { + Predicate hasValuePredicate = notifiedAtHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity._notifiedAt)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity._notifiedAt)); + predicates.add(hasValuePredicate); + } + + if (this.type != null) { + predicates.add(queryContext.Root.get(NotificationEntity._type).in(this.type)); + } + + if (this.contactType != null) { + predicates.add(queryContext.Root.get(NotificationEntity._contactTypeHint).in(this.contactType)); + } + + if (this.retryThreshold != null) { + predicates.add(queryContext.CriteriaBuilder.le(queryContext.Root.get(NotificationEntity._retryCount), this.retryThreshold)); + } + + if (this.createdAfter != null) { + predicates.add(queryContext.CriteriaBuilder.greaterThan(queryContext.Root.get(NotificationEntity._createdAt), this.createdAfter)); + } + + if (this.trackingState != null) { + predicates.add(queryContext.Root.get(NotificationEntity._trackingState).in(trackingState)); + } + + if (this.trackingProgress != null) { + predicates.add(queryContext.Root.get(NotificationEntity._trackingProcess).in(trackingProgress)); + } + + if (this.userIds != null) { + predicates.add(queryContext.Root.get(NotificationEntity._userId).in(userIds)); + } + + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(Notification._id)) + return NotificationEntity._id; + else if (item.match(Notification._contactHint)) + return NotificationEntity._contactHint; + else if (item.match(Notification._createdAt)) + return NotificationEntity._createdAt; + else if (item.match(Notification._isActive)) + return NotificationEntity._isActive; + else if (item.match(Notification._contactTypeHint)) + return NotificationEntity._contactTypeHint; + else if (item.match(Notification._updatedAt)) + return NotificationEntity._updatedAt; + else if (item.match(Notification._notifiedAt)) + return NotificationEntity._notifiedAt; + else if (item.match(Notification._data)) + return NotificationEntity._data; + else if (item.prefix(Notification._tenant)) + return NotificationEntity._tenantId; + else if (item.prefix(Notification._user)) + return NotificationEntity._userId; + else if (item.match(Notification._type)) + return NotificationEntity._type; + else if (item.match(Notification._notifyState)) + return NotificationEntity._notifyState; + else if (item.match(Notification._notifiedWith)) + return NotificationEntity._notifiedWith; + else if (item.match(Notification._trackingState)) + return NotificationEntity._trackingState; + else if (item.match(Notification._trackingProcess)) + return NotificationEntity._trackingProcess; + else if (item.match(Notification._trackingData)) + return NotificationEntity._trackingData; + else if (item.match(Notification._retryCount)) + return NotificationEntity._retryCount; + + else + return null; + } + + @Override + protected NotificationEntity convert(Tuple tuple, Set columns) { + NotificationEntity item = new NotificationEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, NotificationEntity._id, UUID.class)); + item.setContactHint(QueryBase.convertSafe(tuple, columns, NotificationEntity._contactHint, String.class)); + item.setContactTypeHint(QueryBase.convertSafe(tuple, columns, NotificationEntity._contactTypeHint, NotificationContactType.class)); + item.setNotifiedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity._notifiedAt, Instant.class)); + item.setType(QueryBase.convertSafe(tuple, columns, NotificationEntity._type, UUID.class)); + item.setUserId(QueryBase.convertSafe(tuple, columns, NotificationEntity._userId, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, NotificationEntity._tenantId, UUID.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, NotificationEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, NotificationEntity._isActive, IsActive.class)); + item.setNotifyState(QueryBase.convertSafe(tuple, columns, NotificationEntity._notifyState, NotificationNotifyState.class)); + item.setNotifiedWith(QueryBase.convertSafe(tuple, columns, NotificationEntity._notifiedWith, NotificationContactType.class)); + item.setTrackingState(QueryBase.convertSafe(tuple, columns, NotificationEntity._trackingState, NotificationTrackingState.class)); + item.setTrackingProcess(QueryBase.convertSafe(tuple, columns, NotificationEntity._trackingProcess, NotificationTrackingProcess.class)); + item.setRetryCount(QueryBase.convertSafe(tuple, columns, NotificationEntity._retryCount, Integer.class)); + + return item; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantConfigurationQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantConfigurationQuery.java index c279355ed..2420bc696 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantConfigurationQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantConfigurationQuery.java @@ -3,26 +3,27 @@ package gr.cite.notification.query; import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.TenantConfigurationType; import gr.cite.notification.data.TenantConfigurationEntity; -import gr.cite.notification.data.TenantEntity; import gr.cite.notification.model.TenantConfiguration; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class TenantConfigurationQuery extends QueryBase { + private List ids; + private List isActives; + private List type; public TenantConfigurationQuery ids(UUID... ids) { @@ -55,7 +56,6 @@ public class TenantConfigurationQuery extends QueryBase Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.ids != null) { - predicates.add(queryContext.Root.get(TenantConfigurationEntity.Field.ID).in(ids)); + predicates.add(queryContext.Root.get(TenantConfigurationEntity._id).in(ids)); } if (this.isActives != null) { - predicates.add(queryContext.Root.get(TenantConfigurationEntity.Field.IS_ACTIVE).in(isActives)); + predicates.add(queryContext.Root.get(TenantConfigurationEntity._isActive).in(isActives)); } if (type != null) { - predicates.add(queryContext.Root.get(TenantConfigurationEntity.Field.TYPE).in(type)); + predicates.add(queryContext.Root.get(TenantConfigurationEntity._type).in(type)); } - if (predicates.size() > 0) { + + if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); return queryContext.CriteriaBuilder.and(predicatesArray); } else { @@ -91,29 +92,40 @@ public class TenantConfigurationQuery extends QueryBase columns) { TenantConfigurationEntity item = new TenantConfigurationEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.ID, UUID.class)); - item.setValue(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.VALUE, String.class)); - item.setType(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.TYPE, TenantConfigurationType.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.TENANT_ID, UUID.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.CREATED_AT, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.UPDATED_AT, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity.Field.IS_ACTIVE, IsActive.class)); + item.setId(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._id, UUID.class)); + item.setValue(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._value, String.class)); + item.setType(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._type, TenantConfigurationType.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._tenantId, UUID.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, TenantConfigurationEntity._isActive, IsActive.class)); return item; } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantQuery.java index b97498d12..4ffd3bf0a 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/TenantQuery.java @@ -7,121 +7,125 @@ import gr.cite.notification.model.Tenant; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Predicate; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import jakarta.persistence.Tuple; -import jakarta.persistence.criteria.Predicate; import java.time.Instant; import java.util.*; - @Component @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class TenantQuery extends QueryBase { - private String like; - private Collection ids; - private Collection isActives; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + private String like; - public TenantQuery like(String value) { - this.like = value; - return this; - } + private Collection ids; - public TenantQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } + private Collection isActives; - public TenantQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public TenantQuery ids(Collection values) { - this.ids = values; - return this; - } + public TenantQuery like(String value) { + this.like = value; + return this; + } - public TenantQuery isActive(IsActive value) { - this.isActives = List.of(value); - return this; - } + public TenantQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } - public TenantQuery isActive(IsActive... value) { - this.isActives = Arrays.asList(value); - return this; - } + public TenantQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } - public TenantQuery isActive(Collection values) { - this.isActives = values; - return this; - } + public TenantQuery ids(Collection values) { + this.ids = values; + return this; + } - public TenantQuery authorize(EnumSet values) { - this.authorize = values; - return this; - } + public TenantQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } - @Override - protected Boolean isFalseQuery() { - return this.isEmpty(this.ids) || this.isEmpty(this.isActives); - } + public TenantQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } - @Override - protected Class entityClass() { - return TenantEntity.class; - } + public TenantQuery isActive(Collection values) { + this.isActives = values; + return this; + } - @Override - protected Predicate applyFilters(QueryContext queryContext) { - List predicates = new ArrayList<>(); - if (this.ids != null) { - predicates.add(queryContext.Root.get(TenantEntity._id).in(ids)); - } + public TenantQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } - if (this.like != null && !this.like.isEmpty()) { - predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._isActive), this.like)); - } + @Override + protected Boolean isFalseQuery() { + return this.isEmpty(this.ids) || this.isEmpty(this.isActives); + } - if (this.isActives != null) { - predicates.add(queryContext.Root.get(TenantEntity._isActive).in(isActives)); - } - if (predicates.size() > 0) { - Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); - return queryContext.CriteriaBuilder.and(predicatesArray); - } else { - return null; - } + @Override + protected Class entityClass() { + return TenantEntity.class; + } - } + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.ids != null) { + predicates.add(queryContext.Root.get(TenantEntity._id).in(ids)); + } - @Override - protected String fieldNameOf(FieldResolver item) { - if (item.match(Tenant._id)) return TenantEntity._id; - else if (item.match(Tenant._code)) return TenantEntity._code; - else if (item.match(Tenant._name)) return TenantEntity._name; - else if (item.match(Tenant._description)) return TenantEntity._description; - else if (item.prefix(Tenant._config)) return TenantEntity._config; - else if (item.match(Tenant._createdAt)) return TenantEntity._createdAt; - else if (item.match(Tenant._updatedAt)) return TenantEntity._updatedAt; - else if (item.match(Tenant._isActive)) return TenantEntity._isActive; - else return null; - } + if (this.like != null && !this.like.isEmpty()) { + predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(TenantEntity._isActive), this.like)); + } + + if (this.isActives != null) { + predicates.add(queryContext.Root.get(TenantEntity._isActive).in(isActives)); + } + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(Tenant._id)) + return TenantEntity._id; + else if (item.match(Tenant._code)) + return TenantEntity._code; + else if (item.match(Tenant._createdAt)) + return TenantEntity._createdAt; + else if (item.match(Tenant._updatedAt)) + return TenantEntity._updatedAt; + else if (item.match(Tenant._isActive)) + return TenantEntity._isActive; + else + return null; + } + + @Override + protected TenantEntity convert(Tuple tuple, Set columns) { + TenantEntity item = new TenantEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, TenantEntity._id, UUID.class)); + item.setCode(QueryBase.convertSafe(tuple, columns, TenantEntity._code, String.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, TenantEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, TenantEntity._isActive, IsActive.class)); + return item; + } - @Override - protected TenantEntity convert(Tuple tuple, Set columns) { - TenantEntity item = new TenantEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, TenantEntity._id, UUID.class)); - item.setCode(QueryBase.convertSafe(tuple, columns, TenantEntity._code, String.class)); - item.setName(QueryBase.convertSafe(tuple, columns, TenantEntity._name, String.class)); - item.setConfig(QueryBase.convertSafe(tuple, columns, TenantEntity._config, String.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, TenantEntity._createdAt, Instant.class)); - item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, TenantEntity._updatedAt, Instant.class)); - item.setIsActive(QueryBase.convertSafe(tuple, columns, TenantEntity._isActive, IsActive.class)); - return item; - } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java index d8f8549d0..ddfda844b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserContactInfoQuery.java @@ -13,13 +13,12 @@ import gr.cite.notification.model.UserContactInfo; import gr.cite.tools.data.query.FieldResolver; import gr.cite.tools.data.query.QueryBase; import gr.cite.tools.data.query.QueryContext; -import org.springframework.stereotype.Component; -import org.springframework.web.context.annotation.RequestScope; - import jakarta.persistence.Tuple; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Subquery; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + import java.time.Instant; import java.util.*; @@ -27,238 +26,263 @@ import java.util.*; @RequestScope public class UserContactInfoQuery extends QueryBase { - private Collection ids; - private Collection userIds; - private Collection excludedUserIds; - private Collection tenantIds; - private Collection isActives; - private Collection type; - private Collection values; - private UserQuery userQuery; + private Collection ids; - private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + private Collection userIds; - private final UserScope userScope; - private final AuthorizationService authService; + private Collection excludedUserIds; - public UserContactInfoQuery( - UserScope userScope, - AuthorizationService authService - ) { - this.userScope = userScope; - this.authService = authService; - } + private Collection tenantIds; - public UserContactInfoQuery ids(UUID value) { - this.ids = List.of(value); - return this; - } + private Collection isActives; - public UserContactInfoQuery ids(UUID... value) { - this.ids = Arrays.asList(value); - return this; - } + private Collection type; - public UserContactInfoQuery ids(Collection values) { - this.ids = values; - return this; - } + private Collection values; - public UserContactInfoQuery userIds(UUID value) { - this.userIds = List.of(value); - return this; - } + private UserQuery userQuery; - public UserContactInfoQuery userIds(UUID... value) { - this.userIds = Arrays.asList(value); - return this; - } + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); - public UserContactInfoQuery userIds(Collection values) { - this.userIds = values; - return this; - } + private final UserScope userScope; - public UserContactInfoQuery excludedUserIds(Collection values) { - this.excludedUserIds = values; - return this; - } + private final AuthorizationService authService; - public UserContactInfoQuery excludedUserIds(UUID value) { - this.excludedUserIds = List.of(value); - return this; - } + public UserContactInfoQuery( + UserScope userScope, + AuthorizationService authService + ) { + this.userScope = userScope; + this.authService = authService; + } - public UserContactInfoQuery excludedUserIds(UUID... value) { - this.excludedUserIds = Arrays.asList(value); - return this; - } + public UserContactInfoQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } - public UserContactInfoQuery tenantIds(UUID value) { - this.tenantIds = List.of(value); - return this; - } + public UserContactInfoQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } - public UserContactInfoQuery tenantIds(UUID... value) { - this.tenantIds = Arrays.asList(value); - return this; - } + public UserContactInfoQuery ids(Collection values) { + this.ids = values; + return this; + } - public UserContactInfoQuery tenantIds(Collection values) { - this.tenantIds = values; - return this; - } + public UserContactInfoQuery userIds(UUID value) { + this.userIds = List.of(value); + return this; + } - public UserContactInfoQuery isActive(IsActive value) { - this.isActives = List.of(value); - return this; - } + public UserContactInfoQuery userIds(UUID... value) { + this.userIds = Arrays.asList(value); + return this; + } - public UserContactInfoQuery isActive(IsActive... value) { - this.isActives = Arrays.asList(value); - return this; - } + public UserContactInfoQuery userIds(Collection values) { + this.userIds = values; + return this; + } - public UserContactInfoQuery isActive(Collection values) { - this.isActives = values; - return this; - } + public UserContactInfoQuery excludedUserIds(Collection values) { + this.excludedUserIds = values; + return this; + } - public UserContactInfoQuery type(ContactInfoType value) { - this.type = List.of(value); - return this; - } + public UserContactInfoQuery excludedUserIds(UUID value) { + this.excludedUserIds = List.of(value); + return this; + } - public UserContactInfoQuery type(ContactInfoType... value) { - this.type = Arrays.asList(value); - return this; - } + public UserContactInfoQuery excludedUserIds(UUID... value) { + this.excludedUserIds = Arrays.asList(value); + return this; + } - public UserContactInfoQuery type(Collection values) { - this.type = values; - return this; - } + public UserContactInfoQuery tenantIds(UUID value) { + this.tenantIds = List.of(value); + return this; + } - public UserContactInfoQuery values(String value) { - this.values = List.of(value); - return this; - } + public UserContactInfoQuery tenantIds(UUID... value) { + this.tenantIds = Arrays.asList(value); + return this; + } - public UserContactInfoQuery values(String... value) { - this.values = Arrays.asList(value); - return this; - } + public UserContactInfoQuery tenantIds(Collection values) { + this.tenantIds = values; + return this; + } - public UserContactInfoQuery values(Collection values) { - this.values = values; - return this; - } + public UserContactInfoQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } - public UserContactInfoQuery userSubQuery(UserQuery subQuery) { - this.userQuery = subQuery; - return this; - } + public UserContactInfoQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } - public UserContactInfoQuery authorize(EnumSet values) { - this.authorize = values; - return this; - } + public UserContactInfoQuery isActive(Collection values) { + this.isActives = values; + return this; + } - @Override - protected Boolean isFalseQuery() { - return this.isEmpty(this.userIds) || this.isEmpty(this.excludedUserIds) || this.isEmpty(this.tenantIds) || this.isEmpty(this.isActives) - || this.isEmpty(this.type) || this.isEmpty(this.excludedUserIds) || this.isFalseQuery(this.userQuery); - } + public UserContactInfoQuery type(ContactInfoType value) { + this.type = List.of(value); + return this; + } - @Override - protected Class entityClass() { - return UserContactInfoEntity.class; - } + public UserContactInfoQuery type(ContactInfoType... value) { + this.type = Arrays.asList(value); + return this; + } - @Override - protected Predicate applyAuthZ(QueryContext queryContext) { - if (this.authorize.contains(AuthorizationFlags.None)) return null; - if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUserContactInfo)) return null; - UUID ownerId = null; - if (this.authorize.contains(AuthorizationFlags.Owner)) ownerId = this.userScope.getUserIdSafe(); + public UserContactInfoQuery type(Collection values) { + this.type = values; + return this; + } - List predicates = new ArrayList<>(); - if (ownerId != null) { - predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(UserContactInfoEntity._userId), ownerId)); - } - if (predicates.size() > 0) { - Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); - return queryContext.CriteriaBuilder.and(predicatesArray); - } else { - return queryContext.CriteriaBuilder.or(); //Creates a false query - } - } + public UserContactInfoQuery values(String value) { + this.values = List.of(value); + return this; + } - @Override - protected Predicate applyFilters(QueryContext queryContext) { - List predicates = new ArrayList<>(); - if (this.userIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); - for (UUID item : this.userIds) inClause.value(item); - predicates.add(inClause); - } - if (this.excludedUserIds != null) { - CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); - for (UUID item : this.excludedUserIds) - notInClause.value(item); - predicates.add(notInClause.not()); - } - if (this.tenantIds != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._tenantId)); - for (UUID item : this.tenantIds) inClause.value(item); - predicates.add(inClause); - } - if (this.type != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._type)); - for (ContactInfoType item : this.type) inClause.value(item); - predicates.add(inClause); - } - if (this.values != null) { - CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._value)); - for (String item : this.values) - inClause.value(item); - predicates.add(inClause); - } - if (this.userQuery != null) { - QueryContext subQuery = this.applySubQuery(this.userQuery, queryContext, UUID.class, root -> root.get(UserContactInfoEntity._userId)); - predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(subQuery.Query)); - } + public UserContactInfoQuery values(String... value) { + this.values = Arrays.asList(value); + return this; + } - if (!predicates.isEmpty()) { - Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); - return queryContext.CriteriaBuilder.and(predicatesArray); - } else { - return null; - } - } + public UserContactInfoQuery values(Collection values) { + this.values = values; + return this; + } - @Override - protected String fieldNameOf(FieldResolver item) { - if (item.match(UserContactInfo._id)) return UserContactInfoEntity._id; - else if (item.prefix(UserContactInfo._tenant)) return UserContactInfoEntity._tenantId; - else if (item.match(UserContactInfo._type)) return UserContactInfoEntity._type; - else if (item.match(UserContactInfo._value)) return UserContactInfoEntity._value; - else if (item.match(UserContactInfo._createdAt)) return UserContactInfoEntity._createdAt; - else if (item.match(UserContactInfo._user, User._id)) return UserContactInfoEntity._userId; - else if (item.prefix(UserContactInfo._user)) return UserContactInfoEntity._userId; - else return null; - } + public UserContactInfoQuery userSubQuery(UserQuery subQuery) { + this.userQuery = subQuery; + return this; + } - @Override - protected UserContactInfoEntity convert(Tuple tuple, Set columns) { - UserContactInfoEntity item = new UserContactInfoEntity(); - item.setId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._id, UUID.class)); - item.setType(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._type, ContactInfoType.class)); - item.setValue(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._value, String.class)); - item.setUserId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._userId, UUID.class)); - item.setTenantId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._tenantId, UUID.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._createdAt, Instant.class)); - return item; - } + public UserContactInfoQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + protected Boolean isFalseQuery() { + return this.isEmpty(this.userIds) || this.isEmpty(this.excludedUserIds) || this.isEmpty(this.tenantIds) || this.isEmpty(this.isActives) + || this.isEmpty(this.type) || this.isEmpty(this.excludedUserIds) || this.isFalseQuery(this.userQuery); + } + + @Override + protected Class entityClass() { + return UserContactInfoEntity.class; + } + + @Override + protected Predicate applyAuthZ(QueryContext queryContext) { + if (this.authorize.contains(AuthorizationFlags.None)) + return null; + if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUserContactInfo)) + return null; + UUID ownerId = null; + if (this.authorize.contains(AuthorizationFlags.Owner)) + ownerId = this.userScope.getUserIdSafe(); + + List predicates = new ArrayList<>(); + if (ownerId != null) { + predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(UserContactInfoEntity._userId), ownerId)); + } + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return queryContext.CriteriaBuilder.or(); //Creates a false query + } + } + + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.userIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); + for (UUID item : this.userIds) + inClause.value(item); + predicates.add(inClause); + } + if (this.excludedUserIds != null) { + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)); + for (UUID item : this.excludedUserIds) + notInClause.value(item); + predicates.add(notInClause.not()); + } + if (this.tenantIds != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._tenantId)); + for (UUID item : this.tenantIds) + inClause.value(item); + predicates.add(inClause); + } + if (this.type != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._type)); + for (ContactInfoType item : this.type) + inClause.value(item); + predicates.add(inClause); + } + if (this.values != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._value)); + for (String item : this.values) + inClause.value(item); + predicates.add(inClause); + } + if (this.userQuery != null) { + QueryContext subQuery = this.applySubQuery(this.userQuery, queryContext, UUID.class, root -> root.get(UserContactInfoEntity._userId)); + predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId)).value(subQuery.Query)); + } + + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(UserContactInfo._id)) + return UserContactInfoEntity._id; + else if (item.prefix(UserContactInfo._tenant)) + return UserContactInfoEntity._tenantId; + else if (item.match(UserContactInfo._type)) + return UserContactInfoEntity._type; + else if (item.match(UserContactInfo._value)) + return UserContactInfoEntity._value; + else if (item.match(UserContactInfo._ordinal)) + return UserContactInfoEntity._ordinal; + else if (item.match(UserContactInfo._createdAt)) + return UserContactInfoEntity._createdAt; + else if (item.match(UserContactInfo._user, User._id)) + return UserContactInfoEntity._userId; + else if (item.prefix(UserContactInfo._user)) + return UserContactInfoEntity._userId; + else + return null; + } + + @Override + protected UserContactInfoEntity convert(Tuple tuple, Set columns) { + UserContactInfoEntity item = new UserContactInfoEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._id, UUID.class)); + item.setType(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._type, ContactInfoType.class)); + item.setValue(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._value, String.class)); + item.setOrdinal(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._ordinal, Integer.class)); + item.setUserId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._userId, UUID.class)); + item.setTenantId(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._tenantId, UUID.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserContactInfoEntity._createdAt, Instant.class)); + return item; + } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java index 1d7a7d65e..71bbcd172 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/query/UserNotificationPreferenceQuery.java @@ -66,18 +66,18 @@ public class UserNotificationPreferenceQuery extends QueryBase Predicate applyFilters(QueryContext queryContext) { List predicates = new ArrayList<>(); if (this.userId != null) { - predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity.Field.USER_ID).in(this.userId)); + predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._userId).in(this.userId)); } if (this.type != null) { - predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity.Field.TYPE).in(this.type)); + predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._type).in(this.type)); } if (this.channel != null) { - predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity.Field.CHANNEL).in(this.channel)); + predicates.add(queryContext.Root.get(UserNotificationPreferenceEntity._channel).in(this.channel)); } - if (predicates.size() > 0) { + if (!predicates.isEmpty()) { Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); return queryContext.CriteriaBuilder.and(predicatesArray); } else { @@ -88,24 +88,24 @@ public class UserNotificationPreferenceQuery extends QueryBase columns) { UserNotificationPreferenceEntity item = new UserNotificationPreferenceEntity(); - item.setUserId(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field.USER_ID, UUID.class)); - item.setChannel(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field.CHANNEL, NotificationContactType.class)); - item.setType(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field.TYPE, UUID.class)); + item.setUserId(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field._userId, UUID.class)); + item.setChannel(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field._channel, NotificationContactType.class)); + item.setType(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field._type, UUID.class)); item.setTenantId(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity._tenantId, UUID.class)); - item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field.CREATED_AT, Instant.class)); - item.setOrdinal(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field.ORDINAL, Integer.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field._createdAt, Instant.class)); + item.setOrdinal(QueryBase.convertSafe(tuple, columns, UserNotificationPreferenceEntity.Field._ordinal, Integer.class)); return item; } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java index ce310daf6..c6c349d6e 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java @@ -12,25 +12,29 @@ import gr.cite.tools.data.query.QueryFactory; import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; +import jakarta.persistence.Query; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.context.annotation.RequestScope; import javax.management.InvalidApplicationException; -import jakarta.persistence.Column; -import jakarta.persistence.Query; import java.time.Instant; import java.util.List; import java.util.UUID; + @Service @RequestScope -public class InAppNotificationServiceImpl implements InAppNotificationService{ +public class InAppNotificationServiceImpl implements InAppNotificationService { + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(InAppNotificationServiceImpl.class)); private final QueryFactory queryFactory; + private final TenantScopedEntityManager entityManager; + private final AuthorizationService authService; + private final DeleterFactory deleterFactory; @Autowired @@ -41,13 +45,11 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{ this.deleterFactory = deleterFactory; } - public void markAsRead(UUID id) - { + public void markAsRead(UUID id) { this.markAsRead(List.of(id)); } - public void markAsRead(List ids) - { + public void markAsRead(List ids) { try { logger.debug(new DataLogEntry("marking as read in-app notifications", ids)); @@ -71,8 +73,8 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{ public void markAsReadAllUserNotification(UUID userId) { String entity = InAppNotificationEntity.class.getSimpleName(); - String sqlQuery = "UPDATE " + entity + " as e SET "+ InAppNotificationEntity.Field._trackingState +" = :trackingState, "+ InAppNotificationEntity.Field._updatedAt + "= :updatedAt, " + InAppNotificationEntity.Field._readTime + " = :readTime " + - "WHERE e." + InAppNotificationEntity.Field._trackingState + " = :trackingStateCondition AND e."+ InAppNotificationEntity.Field._userId + " = :userId"; + String sqlQuery = "UPDATE " + entity + " as e SET " + InAppNotificationEntity._trackingState + " = :trackingState, " + InAppNotificationEntity._updatedAt + "= :updatedAt, " + InAppNotificationEntity._readTime + " = :readTime " + + "WHERE e." + InAppNotificationEntity._trackingState + " = :trackingStateCondition AND e." + InAppNotificationEntity._userId + " = :userId"; Query query = this.entityManager.createQuery(sqlQuery) .setParameter("trackingState", NotificationInAppTracking.DELIVERED) @@ -84,9 +86,8 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{ int updateCount = query.executeUpdate(); } - public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { - logger.debug("deleting inapp notification: {}", id); + logger.debug("deleting in-app notification: {}", id); this.authService.authorizeForce(Permission.DeleteInAppNotification); this.deleterFactory.deleter(InAppNotificationDeleter.class).deleteAndSaveByIds(List.of(id)); } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notificationscheduling/NotificationSchedulingServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notificationscheduling/NotificationSchedulingServiceImpl.java index b3616e466..9ed9590c4 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notificationscheduling/NotificationSchedulingServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notificationscheduling/NotificationSchedulingServiceImpl.java @@ -79,7 +79,7 @@ public class NotificationSchedulingServiceImpl implements NotificationScheduling .notifyState(NotificationNotifyState.PENDING, NotificationNotifyState.ERROR) .retryThreshold(Math.toIntExact(this.properties.getTask().getProcessor().getOptions().getRetryThreshold())) .createdAfter(lastCandidateNotificationCreationTimestamp) - .ordering(new Ordering().addAscending(NotificationEntity.Field._createdAt)); + .ordering(new Ordering().addAscending(NotificationEntity._createdAt)); candidates = notificationQuery.first(); if (candidates != null) { NotificationNotifyState previousState = candidates.getNotifyState(); diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/tenantconfiguration/TenantConfigurationServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/tenantconfiguration/TenantConfigurationServiceImpl.java index e5fd90cf2..47e49c500 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/tenantconfiguration/TenantConfigurationServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/tenantconfiguration/TenantConfigurationServiceImpl.java @@ -40,7 +40,6 @@ import java.time.Instant; import java.util.List; import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; @Component @RequestScope @@ -176,7 +175,7 @@ public class TenantConfigurationServiceImpl implements TenantConfigurationServic //this._eventBroker.EmitTenantConfigurationTouched(this._scope.Tenant, type); - TenantConfiguration persisted = this.builderFactory.builder(TenantConfigurationBuilder.class).build(fieldSet.merge(new BaseFieldSet(TenantConfiguration.Field.ID, TenantConfiguration.Field.HASH)), data); + TenantConfiguration persisted = this.builderFactory.builder(TenantConfigurationBuilder.class).build(fieldSet.merge(new BaseFieldSet(TenantConfiguration._id, TenantConfiguration._hash)), data); return persisted; } @@ -206,7 +205,7 @@ public class TenantConfigurationServiceImpl implements TenantConfigurationServic Boolean isUpdate = this.conventionService.isValidGuid(modelId); TenantConfigurationQuery tenantConfigurationQuery = applicationContext.getBean(TenantConfigurationQuery.class); - List existingConfigIds = tenantConfigurationQuery.isActive(IsActive.Active).type(type).collectAs(new BaseFieldSet(TenantConfigurationEntity.Field.ID)).stream().map(TenantConfigurationEntity::getId).collect(Collectors.toList()); + List existingConfigIds = tenantConfigurationQuery.isActive(IsActive.Active).type(type).collectAs(new BaseFieldSet(TenantConfigurationEntity._id)).stream().map(TenantConfigurationEntity::getId).toList(); TenantConfigurationEntity data = null; if (isUpdate) { if (!existingConfigIds.contains(modelId)) throw new MyValidationException(this.errors.getSingleTenantConfigurationPerTypeSupported().getCode(), this.errors.getSingleTenantConfigurationPerTypeSupported().getMessage()); @@ -237,7 +236,7 @@ public class TenantConfigurationServiceImpl implements TenantConfigurationServic //this._eventBroker.EmitTenantConfigurationTouched(this._scope.Tenant, type); - TenantConfiguration persisted = this.builderFactory.builder(TenantConfigurationBuilder.class).build(fieldSet.merge(new BaseFieldSet(TenantConfiguration.Field.ID, TenantConfiguration.Field.HASH)), data); + TenantConfiguration persisted = this.builderFactory.builder(TenantConfigurationBuilder.class).build(fieldSet.merge(new BaseFieldSet(TenantConfiguration._id, TenantConfiguration._hash)), data); return persisted; //return null;