change description validator with visibility service
This commit is contained in:
parent
e9fa56f5c9
commit
99ae216cf3
|
@ -228,7 +228,7 @@ public class DescriptionPersist {
|
||||||
.iff(() -> item.getStatus() == DescriptionStatus.Finalized)
|
.iff(() -> item.getStatus() == DescriptionStatus.Finalized)
|
||||||
.on(DescriptionPersist._properties)
|
.on(DescriptionPersist._properties)
|
||||||
.over(item.getProperties())
|
.over(item.getProperties())
|
||||||
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition).withRules(definition))
|
.using(() -> this.validatorFactory.validator(PropertyDefinitionPersist.PropertyDefinitionPersistValidator.class).setStatus(item.getStatus()).withDefinition(definition).setVisibilityService(definition, item.getProperties()))
|
||||||
// this.navSpec()
|
// this.navSpec()
|
||||||
// .iff(() -> !this.isNull(item.getTags()))
|
// .iff(() -> !this.isNull(item.getTags()))
|
||||||
// .on(DescriptionPersist._tags)
|
// .on(DescriptionPersist._tags)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.model.persist.ReferencePersist;
|
import eu.eudat.model.persist.ReferencePersist;
|
||||||
|
import eu.eudat.service.visibility.VisibilityService;
|
||||||
import gr.cite.tools.validation.ValidatorFactory;
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
@ -96,8 +97,8 @@ public class FieldPersist {
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private FieldEntity fieldEntity;
|
private FieldEntity fieldEntity;
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
private List<List<RuleEntity>> rules;
|
private VisibilityService visibilityService;
|
||||||
private Boolean fieldSetIsRuleTarget;
|
private Integer ordinal;
|
||||||
|
|
||||||
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
|
@ -114,34 +115,34 @@ public class FieldPersist {
|
||||||
protected List<Specification> specifications(FieldPersist item) {
|
protected List<Specification> specifications(FieldPersist item) {
|
||||||
FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
|
FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
|
||||||
boolean required = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Required) : false;
|
boolean required = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Required) : false;
|
||||||
boolean isRuleTarget = this.checkIfFieldIsRuleTarget();
|
boolean isVisible = this.visibilityService.isVisible(fieldEntity.getId(), ordinal);
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> FieldType.isTextType(fieldType) && !fieldType.equals(FieldType.CHECK_BOX) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required)
|
.iff(()-> FieldType.isTextType(fieldType) && !fieldType.equals(FieldType.CHECK_BOX) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||||
.must(() -> !this.isEmpty(item.getTextValue()))
|
.must(() -> !this.isEmpty(item.getTextValue()))
|
||||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> FieldType.isDateType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required)
|
.iff(()-> FieldType.isDateType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||||
.must(() -> !this.isNull(item.getDateValue()))
|
.must(() -> !this.isNull(item.getDateValue()))
|
||||||
.failOn(FieldPersist._dateValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dateValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._dateValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._dateValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> FieldType.isExternalIdentifierType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required)
|
.iff(()-> FieldType.isExternalIdentifierType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||||
.must(() -> !this.isNull(item.getExternalIdentifier()))
|
.must(() -> !this.isNull(item.getExternalIdentifier()))
|
||||||
.failOn(FieldPersist._externalIdentifier).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._externalIdentifier).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._externalIdentifier}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> FieldType.isTextListType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required && !fieldType.equals(FieldType.TAGS))
|
.iff(()-> FieldType.isTextListType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required && !fieldType.equals(FieldType.TAGS))
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()) || !this.isEmpty(item.getTextValue()))
|
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()) || !this.isEmpty(item.getTextValue()))
|
||||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> fieldType.equals(FieldType.TAGS) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required)
|
.iff(()-> fieldType.equals(FieldType.TAGS) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()))
|
.must(() -> !this.isListNullOrEmpty(item.getTextListValue()))
|
||||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> FieldType.isReferenceType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget && required)
|
.iff(()-> FieldType.isReferenceType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getReferences()) || !this.isNull(item.getReference()))
|
.must(() -> !this.isListNullOrEmpty(item.getReferences()) || !this.isNull(item.getReference()))
|
||||||
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._textListValue).failWith(messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textListValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(()-> !this.isEmpty(item.getTextValue()) && (fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.BOOLEAN_DECISION)) && this.isListNullOrEmpty(fieldEntity.getVisibilityRules()) && !isRuleTarget && !fieldSetIsRuleTarget)
|
.iff(()-> !this.isEmpty(item.getTextValue()) && (fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.BOOLEAN_DECISION)))
|
||||||
.must(() -> this.isBoolean(item.getTextValue()))
|
.must(() -> this.isBoolean(item.getTextValue()))
|
||||||
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
.failOn(FieldPersist._textValue).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
|
@ -171,30 +172,19 @@ public class FieldPersist {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistValidator withRules(List<List<RuleEntity>> rules) {
|
|
||||||
this.rules = rules;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PersistValidator setStatus(DescriptionStatus status) {
|
public PersistValidator setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistValidator ifFieldSetIsRuleTarget(Boolean fieldSetIsRuleTarget){
|
public PersistValidator withVisibilityService(VisibilityService visibilityService) {
|
||||||
this.fieldSetIsRuleTarget = fieldSetIsRuleTarget;
|
this.visibilityService = visibilityService;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
private boolean checkIfFieldIsRuleTarget(){
|
|
||||||
if (this.isListNullOrEmpty(rules)) return false;
|
public PersistValidator withOrdinal(Integer ordinal) {
|
||||||
for (List<RuleEntity> rulesBySection: rules) {
|
this.ordinal = ordinal;
|
||||||
if (!this.isListNullOrEmpty(rulesBySection)){
|
return this;
|
||||||
for (RuleEntity rule :rulesBySection) {
|
|
||||||
if (rule.getTarget().equals(this.fieldEntity.getId())) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
import eu.eudat.model.persist.DescriptionPersist;
|
import eu.eudat.service.visibility.VisibilityService;
|
||||||
import gr.cite.tools.validation.ValidatorFactory;
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
@ -61,8 +61,8 @@ public class PropertyDefinitionFieldSetItemPersist {
|
||||||
|
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private FieldSetEntity fieldSetEntity;
|
private FieldSetEntity fieldSetEntity;
|
||||||
private List<List<RuleEntity>> rules;
|
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
|
private VisibilityService visibilityService;
|
||||||
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
|
@ -88,7 +88,7 @@ public class PropertyDefinitionFieldSetItemPersist {
|
||||||
.using((itm) ->
|
.using((itm) ->
|
||||||
{
|
{
|
||||||
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById((String)itm.getKey()).stream().findFirst().orElse(null) : null;
|
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getFieldById((String)itm.getKey()).stream().findFirst().orElse(null) : null;
|
||||||
return this.validatorFactory.validator(FieldPersist.PersistValidator.class).withFieldEntity(fieldEntity).withRules(rules).ifFieldSetIsRuleTarget(this.checkIfFieldSetIsRuleTarget()).setStatus(this.status);
|
return this.validatorFactory.validator(FieldPersist.PersistValidator.class).withFieldEntity(fieldEntity).withVisibilityService(visibilityService).withOrdinal(item.getOrdinal()).setStatus(this.status);
|
||||||
})
|
})
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -99,26 +99,14 @@ public class PropertyDefinitionFieldSetItemPersist {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistValidator withRules(List<List<RuleEntity>> rules) {
|
|
||||||
this.rules = rules;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PersistValidator setStatus(DescriptionStatus status) {
|
public PersistValidator setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean checkIfFieldSetIsRuleTarget(){
|
public PersistValidator withVisibilityService(VisibilityService visibilityService) {
|
||||||
if (this.isListNullOrEmpty(rules)) return false;
|
this.visibilityService = visibilityService;
|
||||||
for (List<RuleEntity> rulesBySection: rules) {
|
return this;
|
||||||
if (!this.isListNullOrEmpty(rulesBySection)){
|
|
||||||
for (RuleEntity rule :rulesBySection) {
|
|
||||||
if (rule.getTarget().equals(this.fieldSetEntity.getId())) return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
|
import eu.eudat.service.visibility.VisibilityService;
|
||||||
import gr.cite.tools.validation.ValidatorFactory;
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
@ -36,7 +37,7 @@ public class PropertyDefinitionFieldSetPersist {
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private FieldSetEntity fieldSetEntity;
|
private FieldSetEntity fieldSetEntity;
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
private List<List<RuleEntity>> rules;
|
private VisibilityService visibilityService;
|
||||||
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource, MessageSource messageSource1) {
|
protected PersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, ValidatorFactory validatorFactory, MessageSource messageSource, MessageSource messageSource1) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
|
@ -60,7 +61,7 @@ public class PropertyDefinitionFieldSetPersist {
|
||||||
.iff(() -> !this.isNull(item.getItems()))
|
.iff(() -> !this.isNull(item.getItems()))
|
||||||
.on(PropertyDefinitionFieldSetPersist._items)
|
.on(PropertyDefinitionFieldSetPersist._items)
|
||||||
.over(item.getItems())
|
.over(item.getItems())
|
||||||
.using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).withRules(this.rules).setStatus(this.status)),
|
.using((itm) -> this.validatorFactory.validator(PropertyDefinitionFieldSetItemPersist.PersistValidator.class).withFieldSetEntity(this.fieldSetEntity).withVisibilityService(this.visibilityService).setStatus(this.status)),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && min != null)
|
.iff(() -> DescriptionStatus.Finalized.equals(this.status) && min != null)
|
||||||
.must(() -> !this.isListNullOrEmpty(item.getItems()) && min <= item.getItems().size())
|
.must(() -> !this.isListNullOrEmpty(item.getItems()) && min <= item.getItems().size())
|
||||||
|
@ -77,8 +78,8 @@ public class PropertyDefinitionFieldSetPersist {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersistValidator withRules(List<List<RuleEntity>> rules) {
|
public PersistValidator withVisibilityService(VisibilityService visibilityService) {
|
||||||
this.rules = rules;
|
this.visibilityService = visibilityService;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@ import eu.eudat.commons.enums.FieldValidationType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.RuleEntity;
|
|
||||||
import eu.eudat.commons.validation.BaseValidator;
|
import eu.eudat.commons.validation.BaseValidator;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
import eu.eudat.model.persist.validation.StatusAware;
|
import eu.eudat.model.persist.validation.StatusAware;
|
||||||
|
import eu.eudat.service.visibility.VisibilityService;
|
||||||
|
import eu.eudat.service.visibility.VisibilityServiceImpl;
|
||||||
import gr.cite.tools.validation.ValidatorFactory;
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
@ -47,8 +48,7 @@ public class PropertyDefinitionPersist {
|
||||||
|
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
private DefinitionEntity definition;
|
private DefinitionEntity definition;
|
||||||
|
private VisibilityService visibilityService;
|
||||||
private List<List<RuleEntity>> rules;
|
|
||||||
|
|
||||||
protected PropertyDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
protected PropertyDefinitionPersistValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
super(conventionService, errors);
|
super(conventionService, errors);
|
||||||
|
@ -81,7 +81,7 @@ public class PropertyDefinitionPersist {
|
||||||
.mapKey((k) -> ((String)k))
|
.mapKey((k) -> ((String)k))
|
||||||
.using((itm) -> {
|
.using((itm) -> {
|
||||||
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById((String)itm.getKey()).stream().findFirst().orElse(null) : null;
|
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById((String)itm.getKey()).stream().findFirst().orElse(null) : null;
|
||||||
return this.validatorFactory.validator(PropertyDefinitionFieldSetPersist.PersistValidator.class).withFieldSetEntity(fieldSetEntity).withRules(rules).setStatus(this.status);
|
return this.validatorFactory.validator(PropertyDefinitionFieldSetPersist.PersistValidator.class).withFieldSetEntity(fieldSetEntity).withVisibilityService(visibilityService).setStatus(this.status);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,8 @@ public class PropertyDefinitionPersist {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyDefinitionPersistValidator withRules(DefinitionEntity definition) {
|
public PropertyDefinitionPersistValidator setVisibilityService(DefinitionEntity definition, PropertyDefinitionPersist propertyDefinition) {
|
||||||
List<FieldEntity> fields = definition.getAllField();
|
this.visibilityService = new VisibilityServiceImpl(definition, propertyDefinition);
|
||||||
this.rules = fields.stream().filter(x -> x.getVisibilityRules() != null).map(FieldEntity::getVisibilityRules).collect(Collectors.toList());
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue