fix enums with database enum short logic

This commit is contained in:
amentis 2023-12-18 14:22:48 +02:00
parent 18a1d43f01
commit ab68a0bd4d
14 changed files with 73 additions and 90 deletions

View File

@ -0,0 +1,31 @@
package gr.cite.notification.common.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import gr.cite.notification.data.conventers.DatabaseEnum;
import java.util.Map;
public enum DataType implements DatabaseEnum<Short> {
Integer((short)0),
Decimal((short)1),
Double((short)2),
DateTime((short)3),
//TimeSpan(4),
String((short)5);
private final Short value;
DataType(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DataType> map = EnumUtils.getEnumValueMap(DataType.class);
public static DataType of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,29 @@
package gr.cite.notification.common.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import gr.cite.notification.data.conventers.DatabaseEnum;
import java.util.Map;
public enum EmailOverrideMode implements DatabaseEnum<Short> {
NotOverride((short)0),
Additive((short)1),
Replace((short)2);
private final Short value;
EmailOverrideMode(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, EmailOverrideMode> map = EnumUtils.getEnumValueMap(EmailOverrideMode.class);
public static EmailOverrideMode of(Short i) {
return map.get(i);
}
}

View File

@ -8,7 +8,9 @@ import java.util.Map;
public enum NotificationTemplateKind implements DatabaseEnum<Short> {
Draft((short)0),
Primary((short)1);
Secondary((short)1),
Primary((short)2),
Default((short)3);
private final Short value;

View File

@ -1,42 +0,0 @@
package gr.cite.notification.common.types.notification;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
public enum DataType {
Integer(0),
Decimal(1),
Double(2),
DateTime(3),
//TimeSpan(4),
String(5);
private static final Map<Integer, DataType> values = new HashMap<>();
private final Integer mappedName;
//For jackson parsing (used by MVC)
@JsonValue
public Integer getMappedName() {
return mappedName;
}
static {
for (DataType e : values()) {
values.put(e.asInt(), e);
}
}
private DataType(int mappedName) {
this.mappedName = mappedName;
}
public Integer asInt() {
return this.mappedName;
}
public static DataType fromString(Integer value) {
return values.getOrDefault(value, Integer);
}
}

View File

@ -1,39 +0,0 @@
package gr.cite.notification.common.types.notification;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.HashMap;
import java.util.Map;
public enum EmailOverrideMode {
NotOverride(0),
Additive(1),
Replace(2);
private static final Map<Integer, EmailOverrideMode> values = new HashMap<>();
private final Integer mappedName;
//For jackson parsing (used by MVC)
@JsonValue
public Integer getMappedName() {
return mappedName;
}
static {
for (EmailOverrideMode e : values()) {
values.put(e.asInt(), e);
}
}
private EmailOverrideMode(int mappedName) {
this.mappedName = mappedName;
}
public Integer asInt() {
return this.mappedName;
}
public static EmailOverrideMode fromString(Integer value) {
return values.getOrDefault(value, NotOverride);
}
}

View File

@ -1,5 +1,7 @@
package gr.cite.notification.common.types.notification;
import gr.cite.notification.common.enums.DataType;
public class FieldInfo {
private String key;
public final static String _key = "key";

View File

@ -1,6 +1,6 @@
package gr.cite.notification.common.types.notificationtemplate;
import gr.cite.notification.common.types.notification.DataType;
import gr.cite.notification.common.enums.DataType;
public class FieldInfoEntity {
private String key;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.common.types.notificationtemplate;
import gr.cite.notification.common.types.notification.EmailOverrideMode;
import gr.cite.notification.common.enums.EmailOverrideMode;
import java.util.List;

View File

@ -1,7 +1,7 @@
package gr.cite.notification.config.notification;
import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.common.types.notification.EmailOverrideMode;
import gr.cite.notification.common.enums.EmailOverrideMode;
import gr.cite.notification.common.types.notification.FieldInfo;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.model.notificationtemplate;
import gr.cite.notification.common.types.notification.EmailOverrideMode;
import gr.cite.notification.common.enums.EmailOverrideMode;
import java.util.List;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.types.notification.DataType;
import gr.cite.notification.common.enums.DataType;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

View File

@ -1,6 +1,6 @@
package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.types.notification.EmailOverrideMode;
import gr.cite.notification.common.enums.EmailOverrideMode;
import gr.cite.notification.common.validation.ValidEnum;
import javax.validation.Valid;

View File

@ -6,7 +6,7 @@ import gr.cite.notification.common.enums.ContactInfoType;
import gr.cite.notification.common.enums.IsActive;
import gr.cite.notification.common.enums.NotificationContactType;
import gr.cite.notification.common.types.notification.ContactPair;
import gr.cite.notification.common.types.notification.EmailOverrideMode;
import gr.cite.notification.common.enums.EmailOverrideMode;
import gr.cite.notification.common.types.notification.NotificationContactData;
import gr.cite.notification.config.notification.NotificationConfig;
import gr.cite.notification.config.notification.NotificationProperties;

View File

@ -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.types.notification.DataType;
import gr.cite.notification.common.enums.DataType;
import gr.cite.notification.common.types.notification.FieldInfo;
import gr.cite.notification.common.types.notification.NotificationFieldData;
import gr.cite.notification.common.types.tenantconfiguration.DefaultUserLocaleConfigurationDataContainer;