fix enums with database enum short logic
This commit is contained in:
parent
18a1d43f01
commit
ab68a0bd4d
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,9 @@ import java.util.Map;
|
||||||
public enum NotificationTemplateKind implements DatabaseEnum<Short> {
|
public enum NotificationTemplateKind implements DatabaseEnum<Short> {
|
||||||
|
|
||||||
Draft((short)0),
|
Draft((short)0),
|
||||||
Primary((short)1);
|
Secondary((short)1),
|
||||||
|
Primary((short)2),
|
||||||
|
Default((short)3);
|
||||||
|
|
||||||
private final Short value;
|
private final Short value;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,7 @@
|
||||||
package gr.cite.notification.common.types.notification;
|
package gr.cite.notification.common.types.notification;
|
||||||
|
|
||||||
|
import gr.cite.notification.common.enums.DataType;
|
||||||
|
|
||||||
public class FieldInfo {
|
public class FieldInfo {
|
||||||
private String key;
|
private String key;
|
||||||
public final static String _key = "key";
|
public final static String _key = "key";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gr.cite.notification.common.types.notificationtemplate;
|
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 {
|
public class FieldInfoEntity {
|
||||||
private String key;
|
private String key;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gr.cite.notification.common.types.notificationtemplate;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package gr.cite.notification.config.notification;
|
package gr.cite.notification.config.notification;
|
||||||
|
|
||||||
import gr.cite.notification.common.enums.NotificationContactType;
|
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 gr.cite.notification.common.types.notification.FieldInfo;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.ConstructorBinding;
|
import org.springframework.boot.context.properties.ConstructorBinding;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gr.cite.notification.model.notificationtemplate;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gr.cite.notification.model.persist.notificationtemplate;
|
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.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package gr.cite.notification.model.persist.notificationtemplate;
|
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 gr.cite.notification.common.validation.ValidEnum;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import gr.cite.notification.common.enums.ContactInfoType;
|
||||||
import gr.cite.notification.common.enums.IsActive;
|
import gr.cite.notification.common.enums.IsActive;
|
||||||
import gr.cite.notification.common.enums.NotificationContactType;
|
import gr.cite.notification.common.enums.NotificationContactType;
|
||||||
import gr.cite.notification.common.types.notification.ContactPair;
|
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.common.types.notification.NotificationContactData;
|
||||||
import gr.cite.notification.config.notification.NotificationConfig;
|
import gr.cite.notification.config.notification.NotificationConfig;
|
||||||
import gr.cite.notification.config.notification.NotificationProperties;
|
import gr.cite.notification.config.notification.NotificationProperties;
|
||||||
|
|
|
@ -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.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.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;
|
||||||
|
|
Loading…
Reference in New Issue