114 lines
3.9 KiB
Java
114 lines
3.9 KiB
Java
package eu.eudat.model.persist.descriptiontemplatedefinition.fielddata;
|
|
|
|
import eu.eudat.commons.validation.BaseValidator;
|
|
import eu.eudat.commons.validation.specification.Specification;
|
|
import eu.eudat.convention.ConventionService;
|
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|
import org.springframework.context.MessageSource;
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
public class AuthAutoCompleteDataPersist {
|
|
|
|
private String url = null;
|
|
|
|
public static final String _uri = "uri";
|
|
|
|
private String method = null;
|
|
|
|
public static final String _method = "method";
|
|
|
|
private String body = null;
|
|
|
|
public static final String _body = "body";
|
|
|
|
private String path = null;
|
|
|
|
public static final String _path = "path";
|
|
|
|
private String type = null;
|
|
|
|
public static final String _type = "type";
|
|
|
|
public String getUrl() {
|
|
return url;
|
|
}
|
|
|
|
public void setUrl(String url) {
|
|
this.url = url;
|
|
}
|
|
|
|
public String getMethod() {
|
|
return method;
|
|
}
|
|
|
|
public void setMethod(String method) {
|
|
this.method = method;
|
|
}
|
|
|
|
public String getBody() {
|
|
return body;
|
|
}
|
|
|
|
public void setBody(String body) {
|
|
this.body = body;
|
|
}
|
|
|
|
public String getPath() {
|
|
return path;
|
|
}
|
|
|
|
public void setPath(String path) {
|
|
this.path = path;
|
|
}
|
|
|
|
public String getType() {
|
|
return type;
|
|
}
|
|
|
|
public void setType(String type) {
|
|
this.type = type;
|
|
}
|
|
|
|
public static class AuthAutoCompleteDataPersistValidator extends BaseValidator<AuthAutoCompleteDataPersist> {
|
|
|
|
public static final String ValidatorName = "DescriptionTemplate.AuthAutoCompleteDataPersistValidator";
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
protected AuthAutoCompleteDataPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
super(conventionService, errors);
|
|
this.messageSource = messageSource;
|
|
}
|
|
|
|
@Override
|
|
protected Class<AuthAutoCompleteDataPersist> modelClass() {
|
|
return AuthAutoCompleteDataPersist.class;
|
|
}
|
|
|
|
@Override
|
|
protected List<Specification> specifications(AuthAutoCompleteDataPersist item) {
|
|
return Arrays.asList(
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getUrl()))
|
|
.failOn(AuthAutoCompleteDataPersist._uri).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._uri}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getMethod()))
|
|
.failOn(AuthAutoCompleteDataPersist._method).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._method}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getBody()))
|
|
.failOn(AuthAutoCompleteDataPersist._body).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._body}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getPath()))
|
|
.failOn(AuthAutoCompleteDataPersist._path).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._path}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getType()))
|
|
.failOn(AuthAutoCompleteDataPersist._type).failWith(messageSource.getMessage("Validation_Required", new Object[]{AuthAutoCompleteDataPersist._type}, LocaleContextHolder.getLocale()))
|
|
);
|
|
}
|
|
}
|
|
|
|
}
|