Class GenericConditionValidator

java.lang.Object
ch.tocco.nice2.persist.core.api.validation.AbstractEntitiesValidator
ch.tocco.nice2.persist.core.api.validation.GenericConditionValidator
All Implemented Interfaces:
EntitiesValidator

@Component public class GenericConditionValidator extends AbstractEntitiesValidator
The validator checks if a condition is valid for a list of entities. The following arguments are configurable:
  • entity (required): entity name on which the validator runs
  • condition (required): field on the entity where the tql condition is defined
  • entityField: field which describes (as a comma separated list) for which entities the condition should be validated Example: "entity_model" or "relConfig.entity"
  • entityStatic: if the condition should be checked on a static (at compile time defined) list of entities (and not be configurable per entity instance as a field)
Either entityField or entityStatic is required! Contribution example: 1. add the validator as an EntityValidators 2. add a contribution to define the condition configuration (as explained above)

 @Bean
 public EntitiesValidatorContribution genericConditionValidatorContribution(GenericConditionValidator validator) {
     EntitiesValidatorContribution bean = new EntitiesValidatorContribution();
     bean.setValidator(validator);
     bean.setFilter("Entity_folder_template");
     return bean;
 }

 @Bean
 public EntityConditionContribution entityFolderTemplateConditionContribution() {
     EntityConditionContribution contribution = new EntityConditionContribution();
     contribution.setEntity("Entity_folder_template");
     contribution.setEntityField("entity_model");
     contribution.setConditionField("condition");
     return contribution;
 }
 
  • Constructor Details

    • GenericConditionValidator

      public GenericConditionValidator(org.slf4j.Logger logger, PersistenceService persistenceService)
  • Method Details