195 lines
5.9 KiB
Java
195 lines
5.9 KiB
Java
package gr.cite.notification.integrationevent.inbox.usertouched;
|
|
|
|
import gr.cite.notification.common.enums.ContactInfoType;
|
|
import gr.cite.notification.common.validation.BaseValidator;
|
|
import gr.cite.notification.convention.ConventionService;
|
|
import gr.cite.notification.errorcode.ErrorThesaurusProperties;
|
|
import gr.cite.notification.integrationevent.TrackedEvent;
|
|
import gr.cite.notification.model.persist.UserTouchedIntegrationEventPersist;
|
|
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;
|
|
import java.util.UUID;
|
|
|
|
public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|
|
|
private UUID id;
|
|
|
|
public static final String _id = "id";
|
|
|
|
private UUID tenant;
|
|
|
|
private String name;
|
|
|
|
public static final String _name = "name";
|
|
|
|
public static final int _nameLength = 200;
|
|
|
|
private String subjectId;
|
|
|
|
public static final String _subjectId = "subjectId";
|
|
|
|
private UserProfile profile;
|
|
|
|
private List<UserContactInfo> userContactInfo;
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public UUID getTenant() {
|
|
return tenant;
|
|
}
|
|
|
|
public void setTenant(UUID tenant) {
|
|
this.tenant = tenant;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getSubjectId() {
|
|
return subjectId;
|
|
}
|
|
|
|
public void setSubjectId(String subjectId) {
|
|
this.subjectId = subjectId;
|
|
}
|
|
|
|
public UserProfile getProfile() {
|
|
return profile;
|
|
}
|
|
|
|
public void setProfile(UserProfile profile) {
|
|
this.profile = profile;
|
|
}
|
|
|
|
public List<UserContactInfo> getUserContactInfo() {
|
|
return userContactInfo;
|
|
}
|
|
|
|
public void setUserContactInfo(List<UserContactInfo> userContactInfo) {
|
|
this.userContactInfo = userContactInfo;
|
|
}
|
|
|
|
public static class UserProfile {
|
|
|
|
private String timezone;
|
|
|
|
private String culture;
|
|
|
|
private String 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 getLanguage() {
|
|
return language;
|
|
}
|
|
|
|
public void setLanguage(String language) {
|
|
this.language = language;
|
|
}
|
|
}
|
|
|
|
public static class UserContactInfo {
|
|
|
|
private ContactInfoType type;
|
|
|
|
private String value;
|
|
|
|
private int ordinal;
|
|
|
|
public ContactInfoType getType() {
|
|
return type;
|
|
}
|
|
|
|
public void setType(ContactInfoType type) {
|
|
this.type = type;
|
|
}
|
|
|
|
public String getValue() {
|
|
return value;
|
|
}
|
|
|
|
public void setValue(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public int getOrdinal() {
|
|
return ordinal;
|
|
}
|
|
|
|
public void setOrdinal(int ordinal) {
|
|
this.ordinal = ordinal;
|
|
}
|
|
}
|
|
|
|
@Component(UserTouchedIntegrationEvent.UserTouchedIntegrationEventValidator.ValidatorName)
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
public static class UserTouchedIntegrationEventValidator extends BaseValidator<UserTouchedIntegrationEvent> {
|
|
|
|
public static final String ValidatorName = "UserTouchedIntegrationEventValidator";
|
|
|
|
private final MessageSource messageSource;
|
|
|
|
protected UserTouchedIntegrationEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
|
super(conventionService, errors);
|
|
this.messageSource = messageSource;
|
|
}
|
|
|
|
@Override
|
|
protected Class<UserTouchedIntegrationEvent> modelClass() {
|
|
return UserTouchedIntegrationEvent.class;
|
|
}
|
|
|
|
@Override
|
|
protected List<Specification> specifications(UserTouchedIntegrationEvent item) {
|
|
return Arrays.asList(
|
|
this.spec()
|
|
.iff(() -> !this.isNull(item.getId()))
|
|
.must(() -> this.isValidGuid(item.getId()))
|
|
.failOn(UserTouchedIntegrationEvent._id).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserTouchedIntegrationEvent._id}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getName()))
|
|
.failOn(UserTouchedIntegrationEvent._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserTouchedIntegrationEvent._name}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.iff(() -> !this.isEmpty(item.getName()))
|
|
.must(() -> this.lessEqualLength(item.getName(), UserTouchedIntegrationEventPersist._nameLength))
|
|
.failOn(UserTouchedIntegrationEvent._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{UserTouchedIntegrationEvent._name}, LocaleContextHolder.getLocale())),
|
|
this.spec()
|
|
.must(() -> !this.isEmpty(item.getSubjectId()))
|
|
.failOn(UserTouchedIntegrationEvent._subjectId).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserTouchedIntegrationEvent._subjectId}, LocaleContextHolder.getLocale()))
|
|
);
|
|
}
|
|
}
|
|
}
|