small changes in Notification Template

This commit is contained in:
amentis 2023-12-19 19:05:19 +02:00
parent aa648cda1d
commit 35b0d58ec9
8 changed files with 26 additions and 25 deletions

View File

@ -5,7 +5,7 @@ import gr.cite.notification.data.conventers.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum DataType implements DatabaseEnum<Short> { public enum NotificationDataType implements DatabaseEnum<Short> {
Integer((short)0), Integer((short)0),
Decimal((short)1), Decimal((short)1),
Double((short)2), Double((short)2),
@ -14,7 +14,7 @@ public enum DataType implements DatabaseEnum<Short> {
String((short)5); String((short)5);
private final Short value; private final Short value;
DataType(Short value) { NotificationDataType(Short value) {
this.value = value; this.value = value;
} }
@ -23,9 +23,9 @@ public enum DataType implements DatabaseEnum<Short> {
return value; return value;
} }
private static final Map<Short, DataType> map = EnumUtils.getEnumValueMap(DataType.class); private static final Map<Short, NotificationDataType> map = EnumUtils.getEnumValueMap(NotificationDataType.class);
public static DataType of(Short i) { public static NotificationDataType of(Short i) {
return map.get(i); return map.get(i);
} }
} }

View File

@ -1,16 +1,16 @@
package gr.cite.notification.common.types.notification; package gr.cite.notification.common.types.notification;
import gr.cite.notification.common.enums.DataType; import gr.cite.notification.common.enums.NotificationDataType;
public class FieldInfo { public class FieldInfo {
private String key; private String key;
public final static String _key = "key"; public final static String _key = "key";
private DataType type; private NotificationDataType type;
public final static String _type = "type"; public final static String _type = "type";
private String value; private String value;
public final static String _value = "value"; public final static String _value = "value";
public FieldInfo(String key, DataType type, String value) { public FieldInfo(String key, NotificationDataType type, String value) {
this.key = key; this.key = key;
this.type = type; this.type = type;
this.value = value; this.value = value;
@ -27,11 +27,11 @@ public class FieldInfo {
this.key = key; this.key = key;
} }
public DataType getType() { public NotificationDataType getType() {
return type; return type;
} }
public void setType(DataType type) { public void setType(NotificationDataType type) {
this.type = type; this.type = type;
} }

View File

@ -1,13 +1,13 @@
package gr.cite.notification.common.types.notificationtemplate; package gr.cite.notification.common.types.notificationtemplate;
import gr.cite.notification.common.enums.DataType; import gr.cite.notification.common.enums.NotificationDataType;
public class FieldInfoEntity { public class FieldInfoEntity {
private String key; private String key;
private DataType type; private NotificationDataType type;
private String value; private String value;
public FieldInfoEntity(String key, DataType type, String value) { public FieldInfoEntity(String key, NotificationDataType type, String value) {
this.key = key; this.key = key;
this.type = type; this.type = type;
this.value = value; this.value = value;
@ -24,11 +24,11 @@ public class FieldInfoEntity {
this.key = key; this.key = key;
} }
public DataType getType() { public NotificationDataType getType() {
return type; return type;
} }
public void setType(DataType type) { public void setType(NotificationDataType type) {
this.type = type; this.type = type;
} }

View File

@ -18,8 +18,6 @@ public class NotificationTemplatePersist {
@ValidEnum @ValidEnum
private NotificationTemplateChannel channel; private NotificationTemplateChannel channel;
@NotNull(message = "{validation.empty}")
@Valid
private UUID notificationType; private UUID notificationType;
@ValidEnum @ValidEnum

View File

@ -1,6 +1,6 @@
package gr.cite.notification.model.persist.notificationtemplate; package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.enums.DataType; import gr.cite.notification.common.enums.NotificationDataType;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -13,13 +13,13 @@ public class FieldInfoPersist {
@NotNull @NotNull
@NotEmpty @NotEmpty
private DataType type; private NotificationDataType type;
@NotNull @NotNull
@NotEmpty @NotEmpty
private String value; private String value;
public FieldInfoPersist(String key, DataType type, String value) { public FieldInfoPersist(String key, NotificationDataType type, String value) {
this.key = key; this.key = key;
this.type = type; this.type = type;
this.value = value; this.value = value;
@ -36,11 +36,11 @@ public class FieldInfoPersist {
this.key = key; this.key = key;
} }
public DataType getType() { public NotificationDataType getType() {
return type; return type;
} }
public void setType(DataType type) { public void setType(NotificationDataType type) {
this.type = type; this.type = type;
} }

View File

@ -180,7 +180,7 @@ public class NotificationTemplateQuery extends QueryBase<NotificationTemplateEnt
else if (item.match(NotificationTemplate._createdAt)) return NotificationTemplateEntity._createdAt; else if (item.match(NotificationTemplate._createdAt)) return NotificationTemplateEntity._createdAt;
else if (item.match(NotificationTemplate._updatedAt)) return NotificationTemplateEntity._updatedAt; else if (item.match(NotificationTemplate._updatedAt)) return NotificationTemplateEntity._updatedAt;
else if (item.match(NotificationTemplate._isActive)) return NotificationTemplateEntity._isActive; else if (item.match(NotificationTemplate._isActive)) return NotificationTemplateEntity._isActive;
else if (item.match(NotificationTemplate._tenant)) return NotificationTemplateEntity._tenantId; else if (item.prefix(NotificationTemplate._tenant)) return NotificationTemplateEntity._tenantId;
else return null; else return null;
} }

View File

@ -4,7 +4,7 @@ import gr.cite.notification.common.JsonHandlingService;
import gr.cite.notification.common.StringUtils; import gr.cite.notification.common.StringUtils;
import gr.cite.notification.common.enums.IsActive; import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.scope.tenant.TenantScope; import gr.cite.notification.common.scope.tenant.TenantScope;
import gr.cite.notification.common.enums.DataType; import gr.cite.notification.common.enums.NotificationDataType;
import gr.cite.notification.common.types.notification.FieldInfo; import gr.cite.notification.common.types.notification.FieldInfo;
import gr.cite.notification.common.types.notification.NotificationFieldData; import gr.cite.notification.common.types.notification.NotificationFieldData;
import gr.cite.notification.common.types.tenantconfiguration.DefaultUserLocaleConfigurationDataContainer; import gr.cite.notification.common.types.tenantconfiguration.DefaultUserLocaleConfigurationDataContainer;
@ -73,7 +73,7 @@ public class MessageBuilderServiceImpl implements MessageInfoBuilderService {
.map(field -> { .map(field -> {
FieldInfo fieldInfo = new FieldInfo(); FieldInfo fieldInfo = new FieldInfo();
fieldInfo.setKey(field.getKey()); fieldInfo.setKey(field.getKey());
fieldInfo.setType(DataType.valueOf(field.getType())); fieldInfo.setType(NotificationDataType.valueOf(field.getType()));
fieldInfo.setValue(field.getValue()); fieldInfo.setValue(field.getValue());
return fieldInfo; return fieldInfo;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));

View File

@ -92,16 +92,19 @@ public class NotificationServiceTemplateImpl implements NotificationTemplateServ
data = this.entityManager.find(NotificationTemplateEntity.class, model.getId()); data = this.entityManager.find(NotificationTemplateEntity.class, model.getId());
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), NotificationTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), NotificationTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
if (model.getNotificationType() != null){
data.setNotificationType(model.getNotificationType());
}
} else { } else {
data = new NotificationTemplateEntity(); data = new NotificationTemplateEntity();
data.setId(UUID.randomUUID()); data.setId(UUID.randomUUID());
data.setIsActive(IsActive.Active); data.setIsActive(IsActive.Active);
data.setCreatedAt(Instant.now()); data.setCreatedAt(Instant.now());
data.setNotificationType(UUID.randomUUID());
} }
data.setChannel(model.getChannel()); data.setChannel(model.getChannel());
data.setKind(model.getKind()); data.setKind(model.getKind());
data.setNotificationType(model.getNotificationType());
data.setLanguageId(model.getLanguageId()); data.setLanguageId(model.getLanguageId());
data.setValue(this.jsonHandlingService.toJsonSafe(this.buildNotificationTemplateValueEntity(model.getValue()))); data.setValue(this.jsonHandlingService.toJsonSafe(this.buildNotificationTemplateValueEntity(model.getValue())));
data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());