Started aligning notification service entities with the database, code cleanup

This commit is contained in:
Thomas Georgios Giannos 2024-01-24 14:24:58 +02:00
parent 7d38ab742d
commit ca4a9db3f8
43 changed files with 1857 additions and 1632 deletions

View File

@ -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<String> scope;
public List<String> 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<String, List<String>> 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<String> permissions;
public List<String> getPermissions() {

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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,62 +14,76 @@ 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";
public static final String _id = "id";
@Column(name = "\"queue\"", nullable = false, length = 50)
private String queue;
public final static String _queue = "queue";
public static final String _queue = "queue";
@Column(name = "\"exchange\"", nullable = false, length = 50)
private String exchange;
public final static String _exchange = "exchange";
public static final String _exchange = "exchange";
@Column(name = "\"route\"", nullable = false, length = 50)
private String route;
public final static String _route = "route";
public static final String _route = "route";
@Column(name = "\"application_id\"", nullable = false, length = 100)
private String applicationId;
public final static String _applicationId = "applicationId";
public static final String _applicationId = "applicationId";
@Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false)
private UUID messageId;
public final static String _messageId = "messageId";
public static final String _messageId = "messageId";
@Type(JsonSQLType.class)
@Column(name = "\"message\"", columnDefinition = "json", nullable = false)
private String message;
public final static String _message = "message";
@Column(name = "\"retry_count\"", nullable = true)
public static final String _message = "message";
@Column(name = "\"retry_count\"")
private Integer retryCount;
public final static String _retryCount = "retryCount";
@Column(name = "\"tenant\"", columnDefinition = "uuid", nullable = true)
public static final String _retryCount = "retryCount";
@Column(name = "\"tenant\"", columnDefinition = "uuid")
private UUID tenantId;
public final static String _tenantId = "tenantId";
@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 _tenantId = "tenantId";
@Column(name = "\"status\"", length = 50, nullable = false)
@Enumerated(EnumType.STRING)
private QueueInboxStatus status;
public final static String _status = "status";
public static final String _status = "status";
@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)
@Version
private Instant updatedAt;
public final static String _updatedAt = "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;
@ -81,6 +93,14 @@ public class QueueInboxEntity implements QueueInbox {
this.id = id;
}
public String getQueue() {
return queue;
}
public void setQueue(String queue) {
this.queue = queue;
}
public String getExchange() {
return exchange;
}
@ -97,6 +117,14 @@ public class QueueInboxEntity implements QueueInbox {
this.route = route;
}
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public UUID getMessageId() {
return messageId;
}
@ -113,6 +141,15 @@ public class QueueInboxEntity implements QueueInbox {
this.message = message;
}
@Override
public Integer getRetryCount() {
return retryCount;
}
public void setRetryCount(Integer retryCount) {
this.retryCount = retryCount;
}
public UUID getTenantId() {
return tenantId;
}
@ -121,14 +158,15 @@ public class QueueInboxEntity implements QueueInbox {
this.tenantId = tenantId;
}
public IsActive getIsActive() {
return isActive;
public QueueInboxStatus getStatus() {
return status;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
public void setStatus(QueueInboxStatus status) {
this.status = status;
}
@Override
public Instant getCreatedAt() {
return createdAt;
}
@ -145,37 +183,12 @@ public class QueueInboxEntity implements QueueInbox {
this.updatedAt = updatedAt;
}
public String getQueue() {
return queue;
public IsActive getIsActive() {
return isActive;
}
public void setQueue(String queue) {
this.queue = queue;
}
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
@Override
public Integer getRetryCount() {
return retryCount;
}
public void setRetryCount(Integer retryCount) {
this.retryCount = retryCount;
}
public QueueInboxStatus getStatus() {
return status;
}
public void setStatus(QueueInboxStatus status) {
this.status = status;
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -1,77 +1,92 @@
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";
public static final String _id = "id";
@Column(name = "\"exchange\"", nullable = false, length = 50)
private String exchange;
public final static String _exchange = "exchange";
public static final String _exchange = "exchange";
@Column(name = "\"route\"", length = 50)
private String route;
public final static String _route = "route";
public static final String _route = "route";
@Column(name = "\"message_id\"", columnDefinition = "uuid", nullable = false)
private UUID messageId;
public final static String _messageId = "messageId";
public static final String _messageId = "messageId";
@Column(name = "\"message\"", columnDefinition = "json", nullable = false)
private String message;
public final static String _message = "message";
public static final String _message = "message";
@Column(name = "\"notify_status\"", length = 20, nullable = false)
@Enumerated(EnumType.STRING)
private QueueOutboxNotifyStatus notifyStatus;
public final static String _notifyStatus = "notifyStatus";
public static final String _notifyStatus = "notifyStatus";
@Column(name = "\"retry_count\"", nullable = false)
private int retryCount;
public final static String _retryCount = "retryCount";
private Integer retryCount;
@Column(name = "\"published_at\"", nullable = true)
public static final String _retryCount = "retryCount";
@Column(name = "\"published_at\"")
private Instant publishedAt;
public final static String _publishedAt = "publishedAt";
@Column(name = "\"confirmed_at\"", nullable = true)
public static final String _publishedAt = "publishedAt";
@Column(name = "\"confirmed_at\"")
private Instant confirmedAt;
public final static String _confirmedAt = "confirmedAt";
@Column(name = "\"tenant\"", columnDefinition = "uuid", nullable = true)
public static final String _confirmedAt = "confirmedAt";
@Column(name = "\"tenant\"", columnDefinition = "uuid")
private UUID tenantId;
public final static String _tenantId = "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\"", length = 20, 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";
@Override
public UUID getId() {
return id;
}
@Override
public void setId(UUID id) {
this.id = id;
}
@ -84,38 +99,47 @@ public class QueueOutboxEntity implements QueueOutbox {
this.exchange = exchange;
}
@Override
public String getRoute() {
return route;
}
@Override
public void setRoute(String route) {
this.route = route;
}
@Override
public UUID getMessageId() {
return messageId;
}
@Override
public void setMessageId(UUID messageId) {
this.messageId = messageId;
}
@Override
public String getMessage() {
return message;
}
@Override
public void setMessage(String message) {
this.message = message;
}
@Override
public QueueOutboxNotifyStatus getNotifyStatus() {
return notifyStatus;
}
@Override
public void setNotifyStatus(QueueOutboxNotifyStatus notifyStatus) {
this.notifyStatus = notifyStatus;
}
@Override
public Integer getRetryCount() {
return retryCount;
}
@ -124,18 +148,22 @@ public class QueueOutboxEntity implements QueueOutbox {
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;
}
@ -148,18 +176,12 @@ public class QueueOutboxEntity implements QueueOutbox {
this.tenantId = tenantId;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
@Override
public Instant getCreatedAt() {
return createdAt;
}
@Override
public void setCreatedAt(Instant createdAt) {
this.createdAt = createdAt;
}
@ -171,5 +193,13 @@ public class QueueOutboxEntity implements QueueOutbox {
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -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;
}
}

View File

@ -2,47 +2,41 @@ 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";
public static final String _id = "id";
@Column(name = "code", length = 200, nullable = false)
private String code;
public final static String _code = "code";
@Column(name = "name", length = 500, nullable = false)
private String name;
public final static String _name = "name";
public static final String _code = "code";
@Column(name = "description", nullable = false)
private String description;
public final static String _description = "description";
@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 final static String _isActive = "isActive";
@Column(name = "config")
private String config;
public final static String _config = "config";
@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;
@ -60,38 +54,6 @@ public class TenantEntity {
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 String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
}
public Instant getCreatedAt() {
return createdAt;
}
@ -107,4 +69,13 @@ public class TenantEntity {
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -3,35 +3,41 @@ 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 static final String _id = "id";
@Column(name = "user", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID userId;
public final static String _userId = "userId";
public static final String _userId = "userId";
@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 = 100, 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;
@ -49,14 +55,6 @@ public class TenantUserEntity extends TenantScopedBaseEntity{
this.userId = userId;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
public Instant getCreatedAt() {
return createdAt;
}
@ -72,4 +70,12 @@ public class TenantUserEntity extends TenantScopedBaseEntity{
public void setUpdatedAt(Instant updatedAt) {
this.updatedAt = updatedAt;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -14,13 +14,20 @@ public class UserEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public final static String _id = "id";
@Column(name = "name", length = UserEntity._nameLength, nullable = true)
public static final String _id = "id";
@Column(name = "name", length = UserEntity._nameLength)
private String name = null;
public final static String _name = "name";
public final static int _nameLength = 250;
public static final String _name = "name";
public static final int _nameLength = 250;
@Column(name = "additional_info")
private String additionalInfo;
public static final String _additionalInfo = "additionalInfo";
@Column(name = "created_at", nullable = false)
private Instant createdAt;
@ -35,11 +42,8 @@ public class UserEntity {
@Column(name = "is_active", nullable = false)
@Convert(converter = IsActiveConverter.class)
private IsActive isActive;
public static final String _isActive = "isActive";
@Column(name = "additional_info", nullable = true)
private String additionalInfo;
public final static String _additionalInfo = "additionalInfo";
public static final String _isActive = "isActive";
public UUID getId() {
return id;
@ -57,6 +61,14 @@ public class UserEntity {
this.name = name;
}
public String getAdditionalInfo() {
return additionalInfo;
}
public void setAdditionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
}
public Instant getCreatedAt() {
return createdAt;
}
@ -81,11 +93,4 @@ public class UserEntity {
this.isActive = isActive;
}
public String getAdditionalInfo() {
return additionalInfo;
}
public void setAdditionalInfo(String additionalInfo) {
this.additionalInfo = additionalInfo;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
@ -20,6 +19,7 @@ import java.util.*;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity> {
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
@Autowired
@ -43,14 +43,20 @@ public class LanguageBuilder extends BaseBuilder<Language, LanguageEntity>{
List<Language> 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));

View File

@ -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,41 +23,44 @@ import java.util.*;
public class TenantBuilder extends BaseBuilder<Tenant, TenantEntity> {
private final BuilderFactory builderFactory;
private final XmlHandlingService xmlHandlingService;
private EnumSet<AuthorizationFlags> 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<AuthorizationFlags> values) {
this.authorize = values;
return this;
}
@Override
public List<Tenant> build(FieldSet fields, List<TenantEntity> 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<>();
FieldSet configFields = fields.extractPrefixed(this.asPrefix(Tenant._config));
if (fields == null || data == null || fields.isEmpty())
return new ArrayList<>();
List<Tenant> 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));

View File

@ -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<TenantConfiguration,
List<TenantConfiguration> 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<TenantConfiguration,
logger.error(e.getMessage(), e);
}
}
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA)).isEmpty()) {
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration._defaultUserLocaleData)).isEmpty()) {
try {
DefaultUserLocaleConfigurationDataContainer container = mapper.readValue(d.getValue(), DefaultUserLocaleConfigurationDataContainer.class);
if (container != null) {
m.setDefaultUserLocaleData(new DefaultUserLocaleConfigurationDataContainer());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA, DefaultUserLocaleConfigurationDataContainer.Field.LANGUAGE)))
if (fields.hasField(this.asIndexer(TenantConfiguration._defaultUserLocaleData, DefaultUserLocaleConfigurationDataContainer.Field.LANGUAGE)))
m.getDefaultUserLocaleData().setLanguage(container.getLanguage());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA, DefaultUserLocaleConfigurationDataContainer.Field.TIME_ZONE)))
if (fields.hasField(this.asIndexer(TenantConfiguration._defaultUserLocaleData, DefaultUserLocaleConfigurationDataContainer.Field.TIME_ZONE)))
m.getDefaultUserLocaleData().setTimeZone(container.getTimeZone());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA, DefaultUserLocaleConfigurationDataContainer.Field.CULTURE)))
if (fields.hasField(this.asIndexer(TenantConfiguration._defaultUserLocaleData, DefaultUserLocaleConfigurationDataContainer.Field.CULTURE)))
m.getDefaultUserLocaleData().setCulture(container.getCulture());
}
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA))) {
if(fields.hasField(this.asIndexer(TenantConfiguration._emailClientData))) {
try {
m.setEmailClientData(mapper.readValue(d.getValue(), EmailClientConfigurationDataContainer.class));
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA)).isEmpty()) {
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration._emailClientData)).isEmpty()) {
try {
EmailClientConfigurationDataContainer container = mapper.readValue(d.getValue(), EmailClientConfigurationDataContainer.class);
if (container != null) {
m.setEmailClientData(new EmailClientConfigurationDataContainer());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.ENABLE_SSL)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.ENABLE_SSL)))
m.getEmailClientData().setEnableSSL(container.getEnableSSL());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.REQUIRE_CREDENTIALS)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.REQUIRE_CREDENTIALS)))
m.getEmailClientData().setRequireCredentials(container.getRequireCredentials());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.HOST_SERVER)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.HOST_SERVER)))
m.getEmailClientData().setHostServer(container.getHostServer());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.HOST_PORT_NO)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.HOST_PORT_NO)))
m.getEmailClientData().setHostPortNo(container.getHostPortNo());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.CERTIFICATE_PATH)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.CERTIFICATE_PATH)))
m.getEmailClientData().setCertificatePath(container.getCertificatePath());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.EMAIL_ADDRESS)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.EMAIL_ADDRESS)))
m.getEmailClientData().setEmailAddress(container.getEmailAddress());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.EMAIL_USER_NAME)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.EMAIL_USER_NAME)))
m.getEmailClientData().setEmailUserName(container.getEmailUserName());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.EMAIL_CLIENT_DATA, EmailClientConfigurationDataContainer.Field.EMAIL_PASSWORD)))
if (fields.hasField(this.asIndexer(TenantConfiguration._emailClientData, EmailClientConfigurationDataContainer.Field.EMAIL_PASSWORD)))
m.getEmailClientData().setEmailPassword(container.getEmailPassword());
}
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.NOTIFIER_LIST_DATA))) {
if(fields.hasField(this.asIndexer(TenantConfiguration._notifierListData))) {
try {
m.setNotifierListData(mapper.readValue(d.getValue(), NotifierListConfigurationDataContainer.class));
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration.Field.NOTIFIER_LIST_DATA)).isEmpty()) {
if (!fields.extractPrefixed(this.asIndexer(TenantConfiguration._notifierListData)).isEmpty()) {
try {
NotifierListConfigurationDataContainer container = mapper.readValue(d.getValue(), NotifierListConfigurationDataContainer.class);
if (container != null) {
m.setNotifierListData(new NotifierListConfigurationDataContainer());
if (fields.hasField(this.asIndexer(TenantConfiguration.Field.NOTIFIER_LIST_DATA, NotifierListConfigurationDataContainer.Field.NOTIFIERS)))
if (fields.hasField(this.asIndexer(TenantConfiguration._notifierListData, NotifierListConfigurationDataContainer.Field.NOTIFIERS)))
m.getNotifierListData().setNotifiers(container.getNotifiers());
}
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
}
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.IS_ACTIVE))) m.setIsActive(d.getIsActive());
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.CREATED_AT))) m.setCreatedAt(d.getCreatedAt());
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.UPDATED_AT))) m.setUpdatedAt(d.getUpdatedAt());
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.HASH))) m.setHash(this.hashValue(d.getUpdatedAt()));
if(fields.hasField(this.asIndexer(TenantConfiguration._isActive))) m.setIsActive(d.getIsActive());
if(fields.hasField(this.asIndexer(TenantConfiguration._createdAt))) m.setCreatedAt(d.getCreatedAt());
if(fields.hasField(this.asIndexer(TenantConfiguration._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
if(fields.hasField(this.asIndexer(TenantConfiguration._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
models.add(m);
}
this.logger.debug("build {} items",Optional.of(models).map(List::size).orElse(0));

View File

@ -1,13 +1,8 @@
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.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.data.UserNotificationPreferenceEntity;
import gr.cite.notification.model.TenantConfiguration;
import gr.cite.notification.model.UserNotificationPreference;
@ -52,7 +47,7 @@ public class UserNotificationPreferenceBuilder extends BaseBuilder<UserNotificat
if(fields.hasField(this.asIndexer(UserNotificationPreference.Field.TYPE))) m.setType(d.getType());
if(fields.hasField(this.asIndexer(UserNotificationPreference.Field.CHANNEL))) m.setChannel(d.getChannel());
if(fields.hasField(this.asIndexer(UserNotificationPreference.Field.ORDINAL))) m.setOrdinal(d.getOrdinal());
if(fields.hasField(this.asIndexer(TenantConfiguration.Field.CREATED_AT))) m.setCreatedAt(d.getCreatedAt());
if(fields.hasField(this.asIndexer(TenantConfiguration._createdAt))) m.setCreatedAt(d.getCreatedAt());
models.add(m);
}
this.logger.debug("build {} items",Optional.of(models).map(List::size).orElse(0));

View File

@ -8,13 +8,13 @@ import java.util.Map;
public class FieldOptions {
private List<String> mandatory;
public final static String _mandatory = "mandatory";
public static final String _mandatory = "mandatory";
private List<FieldInfo> optional;
public final static String _optional = "optional";
public static final String _optional = "optional";
private Map<String, String> formatting;
public final static String _formatting = "formatting";
public static final String _formatting = "formatting";
public List<String> getMandatory() {
return mandatory;

View File

@ -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<String> 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<String> 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<String> 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;

View File

@ -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()))
);
}

View File

@ -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() {

View File

@ -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<TenantSource> sources;
public List<TenantSource> getSources() {

View File

@ -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<TenantSource> sources;
public List<TenantSource> getSources() {

View File

@ -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<String> 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() {

View File

@ -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() {

View File

@ -9,30 +9,41 @@ 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<InAppNotificationEntity> {
private String like;
private Collection<UUID> ids;
private List<UUID> excludeIds;
private List<UUID> userId;
private List<UUID> type;
private Collection<IsActive> isActives;
private List<UUID> tenantIds;
private List<NotificationInAppTracking> trackingState;
private Boolean isRead;
private Instant from;
private Instant to;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public InAppNotificationQuery like(String value) {
@ -164,23 +175,23 @@ public class InAppNotificationQuery extends QueryBase<InAppNotificationEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.ids != null) {
predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._id).in(ids));
predicates.add(queryContext.Root.get(InAppNotificationEntity._id).in(ids));
}
if (this.like != null && !this.like.isEmpty()) {
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(InAppNotificationEntity.Field._subject), this.like));
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.Field._id).in(ids)));
predicates.add(queryContext.CriteriaBuilder.not(queryContext.Root.get(InAppNotificationEntity._id).in(ids)));
}
if (this.userId != null) {
predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._userId).in(userId));
predicates.add(queryContext.Root.get(InAppNotificationEntity._userId).in(userId));
}
if (this.isActives != null) {
predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._isActive).in(isActives));
predicates.add(queryContext.Root.get(InAppNotificationEntity._isActive).in(isActives));
}
if (this.tenantIds != null) {
@ -188,26 +199,26 @@ public class InAppNotificationQuery extends QueryBase<InAppNotificationEntity> {
}
if (this.type != null) {
predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._type).in(this.type));
predicates.add(queryContext.Root.get(InAppNotificationEntity._type).in(this.type));
}
if (this.trackingState != null) {
predicates.add(queryContext.Root.get(InAppNotificationEntity.Field._trackingState).in(trackingState));
predicates.add(queryContext.Root.get(InAppNotificationEntity._trackingState).in(trackingState));
}
if (isRead != null) {
predicates.add(isRead ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(InAppNotificationEntity.Field._readTime)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(InAppNotificationEntity.Field._readTime)));
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.Field._createdAt), from));
predicates.add(queryContext.CriteriaBuilder.greaterThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity._createdAt), from));
}
if (to != null) {
predicates.add(queryContext.CriteriaBuilder.lessThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity.Field._createdAt), from));
predicates.add(queryContext.CriteriaBuilder.lessThanOrEqualTo(queryContext.Root.get(InAppNotificationEntity._createdAt), from));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@ -218,37 +229,52 @@ public class InAppNotificationQuery extends QueryBase<InAppNotificationEntity> {
@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 (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<String> 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.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.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));
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;
}
}

View File

@ -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> {
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<LanguageEntity> {
@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;
}
}

View File

@ -8,35 +8,47 @@ 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<NotificationEntity> {
private Collection<UUID> ids;
private Collection<IsActive> isActives;
private List<UUID> tenantIds;
private List<NotificationNotifyState> notifyState;
private List<NotificationContactType> notifiedWith;
private Boolean notifiedWithHasValue;
private Boolean notifiedAtHasValue;
private List<UUID> type;
private List<NotificationContactType> contactType;
private Integer retryThreshold;
private Instant createdAfter;
private List<NotificationTrackingState> trackingState;
private List<NotificationTrackingProcess> trackingProgress;
private Collection<UUID> userIds;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public NotificationQuery ids(UUID value) {
@ -210,64 +222,64 @@ public class NotificationQuery extends QueryBase<NotificationEntity> {
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> predicates = new ArrayList<>();
if (this.ids != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._id).in(ids));
predicates.add(queryContext.Root.get(NotificationEntity._id).in(ids));
}
if (this.isActives != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._isActive).in(isActives));
predicates.add(queryContext.Root.get(NotificationEntity._isActive).in(isActives));
}
if (this.tenantIds != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._tenantId).in(tenantIds));
predicates.add(queryContext.Root.get(NotificationEntity._tenantId).in(tenantIds));
}
if (this.notifyState != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._notifyState).in(notifyState));
predicates.add(queryContext.Root.get(NotificationEntity._notifyState).in(notifyState));
}
if (this.notifiedWith != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._notifiedWith).in(notifiedWith));
predicates.add(queryContext.Root.get(NotificationEntity._notifiedWith).in(notifiedWith));
}
if (notifiedWithHasValue != null) {
Predicate hasValuePredicate = notifiedWithHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity.Field._notifiedWith)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity.Field._notifiedWith));
Predicate hasValuePredicate = notifiedWithHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity._notifiedWith)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity._notifiedWith));
predicates.add(hasValuePredicate);
}
if (notifiedAtHasValue != null) {
Predicate hasValuePredicate = notifiedAtHasValue ? queryContext.CriteriaBuilder.isNotNull(queryContext.Root.get(NotificationEntity.Field._notifiedAt)) : queryContext.CriteriaBuilder.isNull(queryContext.Root.get(NotificationEntity.Field._notifiedAt));
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.Field._type).in(this.type));
predicates.add(queryContext.Root.get(NotificationEntity._type).in(this.type));
}
if (this.contactType != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._contactTypeHint).in(this.contactType));
predicates.add(queryContext.Root.get(NotificationEntity._contactTypeHint).in(this.contactType));
}
if (this.retryThreshold != null) {
predicates.add(queryContext.CriteriaBuilder.le(queryContext.Root.get(NotificationEntity.Field._retryCount), this.retryThreshold));
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.Field._createdAt), this.createdAfter));
predicates.add(queryContext.CriteriaBuilder.greaterThan(queryContext.Root.get(NotificationEntity._createdAt), this.createdAfter));
}
if (this.trackingState != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._trackingState).in(trackingState));
predicates.add(queryContext.Root.get(NotificationEntity._trackingState).in(trackingState));
}
if (this.trackingProgress != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._trackingProcess).in(trackingProgress));
predicates.add(queryContext.Root.get(NotificationEntity._trackingProcess).in(trackingProgress));
}
if (this.userIds != null) {
predicates.add(queryContext.Root.get(NotificationEntity.Field._userId).in(userIds));
predicates.add(queryContext.Root.get(NotificationEntity._userId).in(userIds));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@ -278,43 +290,63 @@ public class NotificationQuery extends QueryBase<NotificationEntity> {
@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 (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;
else
return null;
}
@Override
protected NotificationEntity convert(Tuple tuple, Set<String> 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));
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;
}

View File

@ -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<TenantConfigurationEntity> {
private List<UUID> ids;
private List<IsActive> isActives;
private List<TenantConfigurationType> type;
public TenantConfigurationQuery ids(UUID... ids) {
@ -55,7 +56,6 @@ public class TenantConfigurationQuery extends QueryBase<TenantConfigurationEntit
return this;
}
@Override
protected Boolean isFalseQuery() {
return this.isEmpty(this.ids) || this.isEmpty(this.isActives);
@ -70,17 +70,18 @@ public class TenantConfigurationQuery extends QueryBase<TenantConfigurationEntit
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> 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<TenantConfigurationEntit
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(TenantConfiguration.Field.ID)) return TenantConfigurationEntity.Field.ID;
else if (item.match(TenantConfiguration.Field.TENANT_ID)) return TenantConfigurationEntity.Field.TENANT_ID;
else if (item.match(TenantConfiguration.Field.CREATED_AT)) return TenantConfigurationEntity.Field.CREATED_AT;
else if (item.match(TenantConfiguration.Field.IS_ACTIVE)) return TenantConfigurationEntity.Field.IS_ACTIVE;
else if (item.match(TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA)) return TenantConfiguration.Field.DEFAULT_USER_LOCALE_DATA;
else if (item.match(TenantConfiguration.Field.EMAIL_CLIENT_DATA)) return TenantConfiguration.Field.EMAIL_CLIENT_DATA;
else if (item.match(TenantConfiguration.Field.NOTIFIER_LIST_DATA)) return TenantConfiguration.Field.NOTIFIER_LIST_DATA;
else if (item.match(TenantConfiguration.Field.TYPE)) return TenantConfigurationEntity.Field.TYPE;
else if (item.match(TenantConfiguration.Field.UPDATED_AT)) return TenantConfigurationEntity.Field.UPDATED_AT;
else if (item.match(TenantConfiguration.Field.VALUE)) return TenantConfigurationEntity.Field.VALUE;
else return null;
if (item.match(TenantConfiguration._id))
return TenantConfigurationEntity._id;
else if (item.match(TenantConfiguration._tenantId))
return TenantConfigurationEntity._tenantId;
else if (item.match(TenantConfiguration._defaultUserLocaleData))
return TenantConfiguration._defaultUserLocaleData;
else if (item.match(TenantConfiguration._emailClientData))
return TenantConfiguration._emailClientData;
else if (item.match(TenantConfiguration._notifierListData))
return TenantConfiguration._notifierListData;
else if (item.match(TenantConfiguration._type))
return TenantConfigurationEntity._type;
else if (item.match(TenantConfiguration._value))
return TenantConfigurationEntity._value;
else if (item.match(TenantConfiguration._createdAt))
return TenantConfigurationEntity._createdAt;
else if (item.match(TenantConfiguration._updatedAt))
return TenantConfigurationEntity._updatedAt;
else if (item.match(TenantConfiguration._isActive))
return TenantConfigurationEntity._isActive;
else
return null;
}
@Override
protected TenantConfigurationEntity convert(Tuple tuple, Set<String> 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;
}
}

View File

@ -7,23 +7,25 @@ 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<TenantEntity> {
private String like;
private Collection<UUID> ids;
private Collection<IsActive> isActives;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
public TenantQuery like(String value) {
@ -90,7 +92,7 @@ public class TenantQuery extends QueryBase<TenantEntity> {
if (this.isActives != null) {
predicates.add(queryContext.Root.get(TenantEntity._isActive).in(isActives));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@ -101,15 +103,18 @@ public class TenantQuery extends QueryBase<TenantEntity> {
@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 (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
@ -117,11 +122,10 @@ public class TenantQuery extends QueryBase<TenantEntity> {
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;
}
}

View File

@ -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.*;
@ -28,17 +27,25 @@ import java.util.*;
public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
private Collection<UUID> ids;
private Collection<UUID> userIds;
private Collection<UUID> excludedUserIds;
private Collection<UUID> tenantIds;
private Collection<IsActive> isActives;
private Collection<ContactInfoType> type;
private Collection<String> values;
private UserQuery userQuery;
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
private final UserScope userScope;
private final AuthorizationService authService;
public UserContactInfoQuery(
@ -177,16 +184,19 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
@Override
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
if (this.authorize.contains(AuthorizationFlags.None)) return null;
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUserContactInfo)) return null;
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();
if (this.authorize.contains(AuthorizationFlags.Owner))
ownerId = this.userScope.getUserIdSafe();
List<Predicate> predicates = new ArrayList<>();
if (ownerId != null) {
predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(UserContactInfoEntity._userId), ownerId));
}
if (predicates.size() > 0) {
if (!predicates.isEmpty()) {
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
return queryContext.CriteriaBuilder.and(predicatesArray);
} else {
@ -199,7 +209,8 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
List<Predicate> predicates = new ArrayList<>();
if (this.userIds != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._userId));
for (UUID item : this.userIds) inClause.value(item);
for (UUID item : this.userIds)
inClause.value(item);
predicates.add(inClause);
}
if (this.excludedUserIds != null) {
@ -210,12 +221,14 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
}
if (this.tenantIds != null) {
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._tenantId));
for (UUID item : this.tenantIds) inClause.value(item);
for (UUID item : this.tenantIds)
inClause.value(item);
predicates.add(inClause);
}
if (this.type != null) {
CriteriaBuilder.In<ContactInfoType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserContactInfoEntity._type));
for (ContactInfoType item : this.type) inClause.value(item);
for (ContactInfoType item : this.type)
inClause.value(item);
predicates.add(inClause);
}
if (this.values != null) {
@ -239,14 +252,24 @@ public class UserContactInfoQuery extends QueryBase<UserContactInfoEntity> {
@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;
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
@ -255,6 +278,7 @@ public class UserContactInfoQuery extends QueryBase<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));

View File

@ -66,18 +66,18 @@ public class UserNotificationPreferenceQuery extends QueryBase<UserNotificationP
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
List<Predicate> 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<UserNotificationP
@Override
protected String fieldNameOf(FieldResolver item) {
if (item.match(UserNotificationPreference.Field.USER_ID)) return UserNotificationPreferenceEntity.Field.USER_ID;
if (item.match(UserNotificationPreference.Field.USER_ID)) return UserNotificationPreferenceEntity.Field._userId;
else if (item.match(UserNotificationPreference.Field.TENANT_ID)) return UserNotificationPreferenceEntity._tenantId;
else if (item.match(UserNotificationPreference.Field.TYPE)) return UserNotificationPreferenceEntity.Field.TYPE;
else if (item.match(UserNotificationPreference.Field.CHANNEL)) return UserNotificationPreferenceEntity.Field.CHANNEL;
else if (item.match(UserNotificationPreference.Field.ORDINAL)) return UserNotificationPreferenceEntity.Field.ORDINAL;
else if (item.match(UserNotificationPreference.Field.CREATED_AT)) return UserNotificationPreferenceEntity.Field.CREATED_AT;
else if (item.match(UserNotificationPreference.Field.TYPE)) return UserNotificationPreferenceEntity.Field._type;
else if (item.match(UserNotificationPreference.Field.CHANNEL)) return UserNotificationPreferenceEntity.Field._channel;
else if (item.match(UserNotificationPreference.Field.ORDINAL)) return UserNotificationPreferenceEntity.Field._ordinal;
else if (item.match(UserNotificationPreference.Field.CREATED_AT)) return UserNotificationPreferenceEntity.Field._createdAt;
else return null;
}
@Override
protected UserNotificationPreferenceEntity convert(Tuple tuple, Set<String> 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;
}
}

View File

@ -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 {
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<UUID> ids)
{
public void markAsRead(List<UUID> 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));
}

View File

@ -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();

View File

@ -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<UUID> existingConfigIds = tenantConfigurationQuery.isActive(IsActive.Active).type(type).collectAs(new BaseFieldSet(TenantConfigurationEntity.Field.ID)).stream().map(TenantConfigurationEntity::getId).collect(Collectors.toList());
List<UUID> 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;