use of io.jmix.core.security.CurrentAuthentication in project jmix by jmix-framework.
the class TimeZoneIndicatorImpl method setApplicationContext.
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) {
super.setApplicationContext(applicationContext);
CurrentAuthentication currentAuthentication = applicationContext.getBean(CurrentAuthentication.class);
TimeZone timeZone = currentAuthentication.getTimeZone();
TimeZoneIndicatorSupport timeZoneSupport = applicationContext.getBean(TimeZoneIndicatorSupport.class);
component.setValue(timeZoneSupport.getDisplayNameShort(timeZone));
}
use of io.jmix.core.security.CurrentAuthentication in project jmix by jmix-framework.
the class IntegerValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
if (value == null) {
return;
}
boolean result;
if (value instanceof String) {
try {
Datatype<Integer> datatype = Datatypes.getNN(Integer.class);
CurrentAuthentication currentAuthentication = AppBeans.get(CurrentAuthentication.class);
Integer num = datatype.parse((String) value, currentAuthentication.getLocale());
result = checkIntegerOnPositive(num);
} catch (ParseException e) {
result = false;
}
} else {
result = value instanceof Integer && checkIntegerOnPositive((Integer) value);
}
if (!result) {
String msg = message != null ? messageTools.loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
use of io.jmix.core.security.CurrentAuthentication in project jmix by jmix-framework.
the class LongValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
if (value == null) {
return;
}
boolean result;
if (value instanceof String) {
try {
Datatype<Long> datatype = Datatypes.getNN(Long.class);
CurrentAuthentication currentAuthentication = AppBeans.get(CurrentAuthentication.class);
Long num = datatype.parse((String) value, currentAuthentication.getLocale());
result = checkPositive(num);
} catch (ParseException e) {
result = false;
}
} else {
result = value instanceof Long && checkPositive((Long) value);
}
if (!result) {
String msg = message != null ? messageTools.loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
use of io.jmix.core.security.CurrentAuthentication in project jmix by jmix-framework.
the class DateValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
if (value == null)
return;
boolean result;
if (value instanceof String) {
try {
Datatype datatype = Datatypes.getNN(java.sql.Date.class);
CurrentAuthentication currentAuthentication = AppBeans.get(CurrentAuthentication.class);
datatype.parse((String) value, currentAuthentication.getLocale());
result = true;
} catch (ParseException e) {
result = false;
}
} else {
result = value instanceof Date;
}
if (!result) {
String msg = message != null ? messageTools.loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
use of io.jmix.core.security.CurrentAuthentication in project jmix by jmix-framework.
the class DoubleValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
if (value == null) {
return;
}
boolean result;
if (value instanceof String) {
try {
Datatype<Double> datatype = Datatypes.getNN(Double.class);
CurrentAuthentication currentAuthentication = AppBeans.get(CurrentAuthentication.class);
Double num = datatype.parse((String) value, currentAuthentication.getLocale());
result = checkDoubleOnPositive(num);
} catch (ParseException e) {
result = false;
}
} else {
result = (value instanceof Double && checkDoubleOnPositive((Double) value)) || (value instanceof BigDecimal && checkBigDecimalOnPositive((BigDecimal) value));
}
if (!result) {
String msg = message != null ? messageTools.loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
Aggregations