small changes in Notification Template
This commit is contained in:
parent
aa648cda1d
commit
35b0d58ec9
|
@ -5,7 +5,7 @@ import gr.cite.notification.data.conventers.DatabaseEnum;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public enum DataType implements DatabaseEnum<Short> {
|
||||
public enum NotificationDataType implements DatabaseEnum<Short> {
|
||||
Integer((short)0),
|
||||
Decimal((short)1),
|
||||
Double((short)2),
|
||||
|
@ -14,7 +14,7 @@ public enum DataType implements DatabaseEnum<Short> {
|
|||
String((short)5);
|
||||
private final Short value;
|
||||
|
||||
DataType(Short value) {
|
||||
NotificationDataType(Short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,9 @@ public enum DataType implements DatabaseEnum<Short> {
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package gr.cite.notification.common.types.notification;
|
||||
|
||||
import gr.cite.notification.common.enums.DataType;
|
||||
import gr.cite.notification.common.enums.NotificationDataType;
|
||||
|
||||
public class FieldInfo {
|
||||
private String key;
|
||||
public final static String _key = "key";
|
||||
private DataType type;
|
||||
private NotificationDataType type;
|
||||
public final static String _type = "type";
|
||||
private String 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.type = type;
|
||||
this.value = value;
|
||||
|
@ -27,11 +27,11 @@ public class FieldInfo {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
public DataType getType() {
|
||||
public NotificationDataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(DataType type) {
|
||||
public void setType(NotificationDataType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package gr.cite.notification.common.types.notificationtemplate;
|
||||
|
||||
import gr.cite.notification.common.enums.DataType;
|
||||
import gr.cite.notification.common.enums.NotificationDataType;
|
||||
|
||||
public class FieldInfoEntity {
|
||||
private String key;
|
||||
private DataType type;
|
||||
private NotificationDataType type;
|
||||
private String value;
|
||||
|
||||
public FieldInfoEntity(String key, DataType type, String value) {
|
||||
public FieldInfoEntity(String key, NotificationDataType type, String value) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
|
@ -24,11 +24,11 @@ public class FieldInfoEntity {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
public DataType getType() {
|
||||
public NotificationDataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(DataType type) {
|
||||
public void setType(NotificationDataType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ public class NotificationTemplatePersist {
|
|||
@ValidEnum
|
||||
private NotificationTemplateChannel channel;
|
||||
|
||||
@NotNull(message = "{validation.empty}")
|
||||
@Valid
|
||||
private UUID notificationType;
|
||||
|
||||
@ValidEnum
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.NotNull;
|
||||
|
@ -13,13 +13,13 @@ public class FieldInfoPersist {
|
|||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private DataType type;
|
||||
private NotificationDataType type;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String value;
|
||||
|
||||
public FieldInfoPersist(String key, DataType type, String value) {
|
||||
public FieldInfoPersist(String key, NotificationDataType type, String value) {
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
|
@ -36,11 +36,11 @@ public class FieldInfoPersist {
|
|||
this.key = key;
|
||||
}
|
||||
|
||||
public DataType getType() {
|
||||
public NotificationDataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(DataType type) {
|
||||
public void setType(NotificationDataType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ public class NotificationTemplateQuery extends QueryBase<NotificationTemplateEnt
|
|||
else if (item.match(NotificationTemplate._createdAt)) return NotificationTemplateEntity._createdAt;
|
||||
else if (item.match(NotificationTemplate._updatedAt)) return NotificationTemplateEntity._updatedAt;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import gr.cite.notification.common.JsonHandlingService;
|
|||
import gr.cite.notification.common.StringUtils;
|
||||
import gr.cite.notification.common.enums.IsActive;
|
||||
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.NotificationFieldData;
|
||||
import gr.cite.notification.common.types.tenantconfiguration.DefaultUserLocaleConfigurationDataContainer;
|
||||
|
@ -73,7 +73,7 @@ public class MessageBuilderServiceImpl implements MessageInfoBuilderService {
|
|||
.map(field -> {
|
||||
FieldInfo fieldInfo = new FieldInfo();
|
||||
fieldInfo.setKey(field.getKey());
|
||||
fieldInfo.setType(DataType.valueOf(field.getType()));
|
||||
fieldInfo.setType(NotificationDataType.valueOf(field.getType()));
|
||||
fieldInfo.setValue(field.getValue());
|
||||
return fieldInfo;
|
||||
}).collect(Collectors.toList()));
|
||||
|
|
|
@ -92,16 +92,19 @@ public class NotificationServiceTemplateImpl implements NotificationTemplateServ
|
|||
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 (!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 {
|
||||
data = new NotificationTemplateEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
data.setIsActive(IsActive.Active);
|
||||
data.setCreatedAt(Instant.now());
|
||||
data.setNotificationType(UUID.randomUUID());
|
||||
}
|
||||
|
||||
data.setChannel(model.getChannel());
|
||||
data.setKind(model.getKind());
|
||||
data.setNotificationType(model.getNotificationType());
|
||||
data.setLanguageId(model.getLanguageId());
|
||||
data.setValue(this.jsonHandlingService.toJsonSafe(this.buildNotificationTemplateValueEntity(model.getValue())));
|
||||
data.setUpdatedAt(Instant.now());
|
||||
|
|
Loading…
Reference in New Issue