93 lines
3.7 KiB
Java
93 lines
3.7 KiB
Java
package gr.cite.annotation.model.persist.tenantconfiguration;
|
|
|
|
import gr.cite.annotation.common.validation.BaseValidator;
|
|
import gr.cite.annotation.convention.ConventionService;
|
|
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
|
import gr.cite.tools.validation.specification.Specification;
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
import org.springframework.context.MessageSource;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
public class TenantConfigurationUserLocaleIntegrationPersist {
|
|
private String language;
|
|
public static final String _language = "language";
|
|
private String timeZone;
|
|
public static final String _timeZone = "timeZone";
|
|
private String culture;
|
|
public static final String _culture = "culture";
|
|
|
|
private String hash;
|
|
|
|
public String getLanguage() {
|
|
return language;
|
|
}
|
|
|
|
public void setLanguage(String language) {
|
|
this.language = language;
|
|
}
|
|
|
|
public String getTimeZone() {
|
|
return timeZone;
|
|
}
|
|
|
|
public void setTimeZone(String timeZone) {
|
|
this.timeZone = timeZone;
|
|
}
|
|
|
|
public String getCulture() {
|
|
return culture;
|
|
}
|
|
|
|
public void setCulture(String culture) {
|
|
this.culture = culture;
|
|
}
|
|
|
|
public String getHash() {
|
|
return hash;
|
|
}
|
|
|
|
public void setHash(String hash) {
|
|
this.hash = hash;
|
|
}
|
|
|
|
@Component(TenantConfigurationUserLocaleIntegrationPersist.TenantConfigurationUserLocaleIntegrationPersistValidator.ValidatorName)
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
public static class TenantConfigurationUserLocaleIntegrationPersistValidator extends BaseValidator<TenantConfigurationUserLocaleIntegrationPersist> {
|
|
|
|
public static final String ValidatorName = "TenantConfigurationUserLocaleIntegrationPersistValidator";
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
protected TenantConfigurationUserLocaleIntegrationPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
super(conventionService, errors);
|
|
this.messageSource = messageSource;
|
|
}
|
|
|
|
@Override
|
|
protected Class<TenantConfigurationUserLocaleIntegrationPersist> modelClass() {
|
|
return TenantConfigurationUserLocaleIntegrationPersist.class;
|
|
}
|
|
|
|
@Override
|
|
protected List<Specification> specifications(TenantConfigurationUserLocaleIntegrationPersist item) {
|
|
return Arrays.asList(
|
|
this.spec()
|
|
.must(() -> !this.isNull(item.getLanguage()))
|
|
.failOn(TenantConfigurationUserLocaleIntegrationPersist._language).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantConfigurationUserLocaleIntegrationPersist._language}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isNull(item.getTimeZone()))
|
|
.failOn(TenantConfigurationUserLocaleIntegrationPersist._timeZone).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantConfigurationUserLocaleIntegrationPersist._timeZone}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isNull(item.getCulture()))
|
|
.failOn(TenantConfigurationUserLocaleIntegrationPersist._culture).failWith(messageSource.getMessage("Validation_Required", new Object[]{TenantConfigurationUserLocaleIntegrationPersist._culture}, LocaleContextHolder.getLocale()))
|
|
|
|
);
|
|
}
|
|
}
|
|
}
|