Search in sources :

Example 1 with InvalidFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultFormService method validateAttribute.

private InvalidFormAttributeDto validateAttribute(IdmFormDefinitionDto formDefinition, IdmFormAttributeDto formAttribute, List<IdmFormValueDto> formValues, boolean validateOnlySameOwnerType) {
    Assert.notNull(formAttribute, "Form attribute is required.");
    // 
    InvalidFormAttributeDto result = new InvalidFormAttributeDto(formAttribute);
    result.setDefinitionCode(formDefinition.getCode());
    // 
    if (formAttribute.isRequired()) {
        if (CollectionUtils.isEmpty(formValues) || !formValues.stream().filter(formValue -> !formValue.isEmpty()).findFirst().isPresent()) {
            LOG.debug("Form attribute [{}] validation failed - value is required.", formAttribute.getCode());
            // 
            result.setMissingValue(true);
        }
    }
    if (CollectionUtils.isEmpty(formValues)) {
        // values are not filled => other validations is not needed.
        return result;
    }
    // TODO: redesign to registrable validators
    // TODO: multiple values -> the last validation error is returned. Return invalid attribute for the all values ...
    formValues.stream().filter(formValue -> !formValue.isEmpty()).forEach(formValue -> {
        // minimum value validation
        if (formAttribute.getMin() != null) {
            if (formAttribute.getPersistentType() == PersistentType.SHORTTEXT) {
                String value = formValue.getShortTextValue();
                if (value.length() < formAttribute.getMin().intValue()) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is shorter than min [{}].", formAttribute.getCode(), value.length(), formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.TEXT) {
                String value = formValue.getStringValue();
                if (value.length() < formAttribute.getMin().intValue()) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is shorter than min [{}].", formAttribute.getCode(), value.length(), formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.DATE) {
                LocalDate value = formValue.getDateValue().toLocalDate();
                if (value.isBefore(LocalDate.now().plusDays(formAttribute.getMin().longValue()))) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is before than [{}] days.", formAttribute.getCode(), value, formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.DATETIME) {
                ZonedDateTime value = formValue.getDateValue();
                if (value.isBefore(ZonedDateTime.now().plusDays(formAttribute.getMin().longValue()))) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is before than [{}] days.", formAttribute.getCode(), value, formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
            } else {
                if (formValue.getLongValue() != null && formAttribute.getMin().compareTo(BigDecimal.valueOf(formValue.getLongValue())) > 0) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is lesser than min [{}].", formAttribute.getCode(), formValue.getLongValue(), formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
                if (formValue.getDoubleValue() != null && formAttribute.getMin().compareTo(formValue.getDoubleValue()) > 0) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is lesser than min [{}].", formAttribute.getCode(), formValue.getDoubleValue(), formAttribute.getMin());
                    // 
                    result.setMinValue(formAttribute.getMin());
                }
            }
        }
        // maximum value validation
        if (formAttribute.getMax() != null) {
            if (formAttribute.getPersistentType() == PersistentType.SHORTTEXT) {
                String value = formValue.getShortTextValue();
                if (value.length() > formAttribute.getMax().intValue()) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is shorter than min [{}].", formAttribute.getCode(), value.length(), formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.TEXT) {
                String value = formValue.getStringValue();
                if (value.length() > formAttribute.getMax().intValue()) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is greater than min [{}].", formAttribute.getCode(), value.length(), formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.DATE) {
                LocalDate value = formValue.getDateValue().toLocalDate();
                if (value.isAfter(LocalDate.now().plusDays(formAttribute.getMax().longValue()))) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is after than [{}] days.", formAttribute.getCode(), value, formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
            } else if (formAttribute.getPersistentType() == PersistentType.DATETIME) {
                ZonedDateTime value = formValue.getDateValue();
                if (value.isAfter(ZonedDateTime.now().plusDays(formAttribute.getMax().longValue()))) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is after than [{}] days.", formAttribute.getCode(), value, formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
            } else {
                if (formValue.getLongValue() != null && formAttribute.getMax().compareTo(BigDecimal.valueOf(formValue.getLongValue())) < 0) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is greater than max [{}].", formAttribute.getCode(), formValue.getLongValue(), formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
                if (formValue.getDoubleValue() != null && formAttribute.getMax().compareTo(formValue.getDoubleValue()) < 0) {
                    LOG.debug("Form attribute [{}] validation failed - given value [{}] is greater than max [{}].", formAttribute.getCode(), formValue.getDoubleValue(), formAttribute.getMax());
                    // 
                    result.setMaxValue(formAttribute.getMax());
                }
            }
        }
        String regex = formAttribute.getRegex();
        if (StringUtils.isNotEmpty(regex)) {
            Pattern p = Pattern.compile(regex);
            String stringValue = formValue.getValue().toString();
            // all persistent types are supported on BE, but string values makes the good sense.
            Matcher m = p.matcher(stringValue);
            if (!m.matches()) {
                LOG.debug("Form attribute [{}] validation failed - given value [{}] does not match regex [{}].", formAttribute.getCode(), stringValue, regex);
                // 
                result.setRegexValue(regex);
            }
        }
        if (formAttribute.isUnique()) {
            IdmFormValueFilter<FormableEntity> valueFilter = new IdmFormValueFilter<>();
            valueFilter.setAttributeId(formValue.getFormAttribute());
            valueFilter.setPersistentType(formValue.getPersistentType());
            valueFilter.setStringValue(formValue.getStringValue());
            valueFilter.setShortTextValue(formValue.getShortTextValue());
            valueFilter.setBooleanValue(formValue.getBooleanValue());
            valueFilter.setLongValue(formValue.getLongValue());
            valueFilter.setDoubleValue(formValue.getDoubleValue());
            valueFilter.setDateValue(formValue.getDateValue());
            valueFilter.setUuidValue(formValue.getUuidValue());
            // 
            Identifiable owner = getEmptyOwner(formDefinition);
            Assert.notNull(owner, "Filter - attribute owner is required. Is possible to filter form values by given owner only");
            // 
            FormValueService<FormableEntity> formValueService = getFormValueService(owner.getClass());
            // 
            List<IdmFormValueDto> existValues = formValueService.find(valueFilter, PageRequest.of(0, 2)).getContent();
            // 
            if (existValues.stream().filter(v -> {
                if (validateOnlySameOwnerType) {
                    return v.getOwnerType().equals(formValue.getOwnerType());
                }
                return true;
            }).anyMatch(v -> formValue.getId() == null || !formValue.getId().equals(v.getId()))) {
                LOG.debug("Form attribute [{}] validation failed - given value [{}] is not unigue.", formAttribute.getCode(), formValue.getValue());
                // 
                result.setUniqueValue(formValue.getValue().toString());
            }
        }
    });
    // 
    return result;
}
Also used : AbstractFormValue_(eu.bcvsolutions.idm.core.eav.entity.AbstractFormValue_) Order(org.springframework.data.domain.Sort.Order) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) PluginRegistry(org.springframework.plugin.core.PluginRegistry) FormProjectionManager(eu.bcvsolutions.idm.core.eav.api.service.FormProjectionManager) Autowired(org.springframework.beans.factory.annotation.Autowired) FormDefinitionCache(eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) BigDecimal(java.math.BigDecimal) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) Matcher(java.util.regex.Matcher) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) FormableFilter(eu.bcvsolutions.idm.core.api.dto.filter.FormableFilter) Method(java.lang.reflect.Method) ImmutableMap(com.google.common.collect.ImmutableMap) ConfigurationClassProperty(eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) UUID(java.util.UUID) IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) IntrospectionException(java.beans.IntrospectionException) Serializable(java.io.Serializable) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) PermissionUtils(eu.bcvsolutions.idm.core.security.api.utils.PermissionUtils) PropertyDescriptor(java.beans.PropertyDescriptor) LocalDate(java.time.LocalDate) Entry(java.util.Map.Entry) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) Lazy(org.springframework.context.annotation.Lazy) Pattern(java.util.regex.Pattern) PageImpl(org.springframework.data.domain.PageImpl) FormableDto(eu.bcvsolutions.idm.core.api.dto.FormableDto) IdmFormAttribute_(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute_) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) FormAttributeRendererDto(eu.bcvsolutions.idm.core.eav.api.dto.FormAttributeRendererDto) OrderAwarePluginRegistry(org.springframework.plugin.core.OrderAwarePluginRegistry) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) HashMap(java.util.HashMap) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter) Introspector(java.beans.Introspector) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) CollectionUtils(org.apache.commons.collections.CollectionUtils) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) ConfigurationClass(eu.bcvsolutions.idm.core.api.domain.ConfigurationClass) IdmFormDefinition_(eu.bcvsolutions.idm.core.eav.entity.IdmFormDefinition_) FormAttributeRenderer(eu.bcvsolutions.idm.core.eav.api.service.FormAttributeRenderer) IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter) CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) ObjectUtils(org.springframework.util.ObjectUtils) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) EnabledEvaluator(eu.bcvsolutions.idm.core.security.api.service.EnabledEvaluator) ApplicationContext(org.springframework.context.ApplicationContext) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) ExportDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) FormValueService(eu.bcvsolutions.idm.core.eav.api.service.FormValueService) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) IdmForm(eu.bcvsolutions.idm.core.eav.entity.IdmForm) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) Comparator(java.util.Comparator) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) LocalDate(java.time.LocalDate) FormableEntity(eu.bcvsolutions.idm.core.eav.api.entity.FormableEntity) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) ZonedDateTime(java.time.ZonedDateTime) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter)

Example 2 with InvalidFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto in project CzechIdMng by bcvsolutions.

the class FormInstanceValidateProcessor method process.

@Override
public EventResult<IdmFormInstanceDto> process(EntityEvent<IdmFormInstanceDto> event) {
    IdmFormInstanceDto formInstance = event.getContent();
    Assert.notNull(formInstance.getFormDefinition(), "Form definition is required for form instance validation.");
    // 
    // resolve given / configured / overridden / default form definition
    // configured definition is loaded only once and applied twice (optimization)
    IdmFormDefinitionDto configuredFormDefinition = formProjectionManager.getConfiguredFormDefinition(getOwner(formInstance), formInstance.getFormDefinition());
    IdmFormDefinitionDto formDefinition = formProjectionManager.overrideFormDefinition(formService.getDefinition(formInstance.getFormDefinition().getId()), configuredFormDefinition);
    Assert.notNull(formDefinition, "Form definition is required for form instance validation.");
    IdmFormDefinitionDto formInstanceDefinition = formProjectionManager.overrideFormDefinition(formInstance.getFormDefinition(), configuredFormDefinition);
    Assert.notNull(formInstanceDefinition, "Form definition is required for form instance validation.");
    // 
    Map<String, Serializable> properties = event.getProperties();
    // 
    // get distinct attributes from the sent values
    // PATCH is used - only sent attributes are validated
    Set<IdmFormAttributeDto> sentAttributes = formInstance.getValues().stream().map(IdmFormValueDto::getFormAttribute).map(attributeId -> {
        IdmFormAttributeDto mappedAttribute = formInstanceDefinition.getMappedAttribute(attributeId);
        if (mappedAttribute != null) {
            return mappedAttribute;
        }
        return formDefinition.getMappedAttribute(attributeId);
    }).collect(Collectors.toSet());
    // only sent attributes in definition and instance
    formDefinition.setFormAttributes(Lists.newArrayList(sentAttributes));
    formInstance.setFormDefinition(formDefinition);
    // validate
    List<InvalidFormAttributeDto> errors = formService.validate(formInstance);
    // skip <required> validation if contract update is performed from time slice
    if (getBooleanProperty(ContractSliceManager.SKIP_CHECK_FOR_SLICES, properties)) {
        errors = errors.stream().filter(error -> {
            return !error.isMissingValue();
        }).collect(Collectors.toList());
    }
    if (!errors.isEmpty()) {
        throw new InvalidFormException(errors);
    }
    // 
    return new DefaultEventResult<>(event, this);
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) FormProjectionManager(eu.bcvsolutions.idm.core.eav.api.service.FormProjectionManager) Autowired(org.springframework.beans.factory.annotation.Autowired) CoreEventProcessor(eu.bcvsolutions.idm.core.api.event.CoreEventProcessor) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) FormInstanceProcessor(eu.bcvsolutions.idm.core.eav.api.event.processor.FormInstanceProcessor) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Map(java.util.Map) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Description(org.springframework.context.annotation.Description) Set(java.util.Set) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) InvalidFormException(eu.bcvsolutions.idm.core.api.exception.InvalidFormException) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) Component(org.springframework.stereotype.Component) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) ContractSliceManager(eu.bcvsolutions.idm.core.api.service.ContractSliceManager) Assert(org.springframework.util.Assert) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) Serializable(java.io.Serializable) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) InvalidFormException(eu.bcvsolutions.idm.core.api.exception.InvalidFormException) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)

Example 3 with InvalidFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testRegexValidation.

@Test
public void testRegexValidation() {
    // prepare form definition a test saving form values
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    String attributeName = getHelper().createName();
    // ip address regex (copied from https://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/)
    String ipRegex = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";
    attribute.setCode(attributeName);
    attribute.setName(attributeName);
    attribute.setPersistentType(PersistentType.SHORTTEXT);
    attribute.setRegex(ipRegex);
    String validationMessage = "invalid...";
    attribute.setValidationMessage(validationMessage);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
    attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
    // 
    IdmFormValueDto value = new IdmFormValueDto(attribute);
    value.setValue("one");
    // 
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    formInstance.setFormDefinition(formDefinitionOne);
    formInstance.setValues(Lists.newArrayList(value));
    // 
    List<InvalidFormAttributeDto> validationErrors = formService.validate(formInstance);
    // 
    Assert.assertEquals(1, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getRegexValue().equals(ipRegex)));
    // 
    value.setValue("125.123.255.111");
    validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    value.setValue("1.1.1.1");
    validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    value.setValue("1.1.1.1.");
    validationErrors = formService.validate(formInstance);
    Assert.assertEquals(1, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getRegexValue().equals(ipRegex)));
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getMessage().equals(validationMessage)));
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormDefinitionCache(eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache) IdmRoleFormValue_(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue_) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) BigDecimal(java.math.BigDecimal) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Predicate(javax.persistence.criteria.Predicate) IdmFormDefinition(eu.bcvsolutions.idm.core.eav.entity.IdmFormDefinition) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ChangePersistentTypeException(eu.bcvsolutions.idm.core.eav.api.exception.ChangePersistentTypeException) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdentityEventType(eu.bcvsolutions.idm.core.model.event.IdentityEvent.IdentityEventType) Sort(org.springframework.data.domain.Sort) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractEntity(eu.bcvsolutions.idm.core.api.entity.AbstractEntity) PageRequest(org.springframework.data.domain.PageRequest) UUID(java.util.UUID) IdmRoleRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleRepository) Page(org.springframework.data.domain.Page) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) Serializable(java.io.Serializable) ChangeConfidentialException(eu.bcvsolutions.idm.core.eav.api.exception.ChangeConfidentialException) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) IdmFormAttribute(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute) Specification(org.springframework.data.jpa.domain.Specification) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FormableDto(eu.bcvsolutions.idm.core.api.dto.FormableDto) IdmFormAttribute_(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute_) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) AbstractFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.AbstractFormValueEvaluator) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) DefaultFormableFilter(eu.bcvsolutions.idm.core.api.dto.filter.DefaultFormableFilter) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Direction(org.springframework.data.domain.Sort.Direction) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Root(javax.persistence.criteria.Root) Before(org.junit.Before) IdentityFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.IdentityFormValueEvaluator) Assert.assertNotNull(org.junit.Assert.assertNotNull) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) IdmRoleFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ApplicationContext(org.springframework.context.ApplicationContext) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) InitDemoDataProcessor(eu.bcvsolutions.idm.core.model.event.processor.module.InitDemoDataProcessor) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) Assert.assertNull(org.junit.Assert.assertNull) ChronoUnit(java.time.temporal.ChronoUnit) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) FormValueService(eu.bcvsolutions.idm.core.eav.api.service.FormValueService) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) IdmEntityEvent_(eu.bcvsolutions.idm.core.model.entity.IdmEntityEvent_) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) Subquery(javax.persistence.criteria.Subquery) Assert(org.junit.Assert) FormAttributeValidateProcessor(eu.bcvsolutions.idm.core.eav.processor.FormAttributeValidateProcessor) Assert.assertEquals(org.junit.Assert.assertEquals) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with InvalidFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testUniqueValidation.

@Test
public void testUniqueValidation() {
    // prepare form definition a test saving form values
    IdmFormAttributeDto attribute = new IdmFormAttributeDto();
    String attributeName = getHelper().createName();
    attribute.setCode(attributeName);
    attribute.setName(attributeName);
    attribute.setPersistentType(PersistentType.TEXT);
    attribute.setUnique(Boolean.TRUE);
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
    attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
    // 
    IdmIdentityDto owner = getHelper().createIdentity((GuardedString) null);
    IdmFormValueDto value = new IdmFormValueDto(attribute);
    value.setValue("one");
    // 
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto(owner, formDefinitionOne, Lists.newArrayList(value));
    // 
    List<InvalidFormAttributeDto> validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    IdmFormInstanceDto savedFormInstance = formService.saveFormInstance(owner, formDefinitionOne, Lists.newArrayList(value));
    IdmFormValueDto savedValue = savedFormInstance.toValueMap().get(attributeName).get(0);
    // 
    validationErrors = formService.validate(formInstance);
    Assert.assertEquals(1, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getUniqueValue().equals("one")));
    // 
    value.setId(savedValue.getId());
    validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    value.setId(UUID.randomUUID());
    validationErrors = formService.validate(formInstance);
    Assert.assertEquals(1, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getUniqueValue().equals("one")));
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormDefinitionCache(eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache) IdmRoleFormValue_(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue_) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) BigDecimal(java.math.BigDecimal) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Predicate(javax.persistence.criteria.Predicate) IdmFormDefinition(eu.bcvsolutions.idm.core.eav.entity.IdmFormDefinition) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ChangePersistentTypeException(eu.bcvsolutions.idm.core.eav.api.exception.ChangePersistentTypeException) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdentityEventType(eu.bcvsolutions.idm.core.model.event.IdentityEvent.IdentityEventType) Sort(org.springframework.data.domain.Sort) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractEntity(eu.bcvsolutions.idm.core.api.entity.AbstractEntity) PageRequest(org.springframework.data.domain.PageRequest) UUID(java.util.UUID) IdmRoleRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleRepository) Page(org.springframework.data.domain.Page) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) Serializable(java.io.Serializable) ChangeConfidentialException(eu.bcvsolutions.idm.core.eav.api.exception.ChangeConfidentialException) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) IdmFormAttribute(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute) Specification(org.springframework.data.jpa.domain.Specification) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FormableDto(eu.bcvsolutions.idm.core.api.dto.FormableDto) IdmFormAttribute_(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute_) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) AbstractFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.AbstractFormValueEvaluator) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) DefaultFormableFilter(eu.bcvsolutions.idm.core.api.dto.filter.DefaultFormableFilter) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Direction(org.springframework.data.domain.Sort.Direction) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Root(javax.persistence.criteria.Root) Before(org.junit.Before) IdentityFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.IdentityFormValueEvaluator) Assert.assertNotNull(org.junit.Assert.assertNotNull) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) IdmRoleFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ApplicationContext(org.springframework.context.ApplicationContext) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) InitDemoDataProcessor(eu.bcvsolutions.idm.core.model.event.processor.module.InitDemoDataProcessor) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) Assert.assertNull(org.junit.Assert.assertNull) ChronoUnit(java.time.temporal.ChronoUnit) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) FormValueService(eu.bcvsolutions.idm.core.eav.api.service.FormValueService) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) IdmEntityEvent_(eu.bcvsolutions.idm.core.model.entity.IdmEntityEvent_) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) Subquery(javax.persistence.criteria.Subquery) Assert(org.junit.Assert) FormAttributeValidateProcessor(eu.bcvsolutions.idm.core.eav.processor.FormAttributeValidateProcessor) Assert.assertEquals(org.junit.Assert.assertEquals) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with InvalidFormAttributeDto

use of eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto in project CzechIdMng by bcvsolutions.

the class DefaultFormServiceIntegrationTest method testMinMaxDateValidation.

@Test
public void testMinMaxDateValidation() {
    ZonedDateTime now = ZonedDateTime.now();
    // prepare form definition a test saving form values
    IdmFormAttributeDto attributeDate = new IdmFormAttributeDto();
    String attributeDateCode = getHelper().createName();
    attributeDate.setCode(attributeDateCode);
    attributeDate.setName(attributeDateCode);
    attributeDate.setPersistentType(PersistentType.DATE);
    attributeDate.setMin(new BigDecimal("3"));
    attributeDate.setMax(new BigDecimal("5"));
    IdmFormAttributeDto attributeDateTime = new IdmFormAttributeDto();
    String attributeDateTimeCode = getHelper().createName();
    attributeDateTime.setCode(attributeDateTimeCode);
    attributeDateTime.setName(attributeDateTimeCode);
    attributeDateTime.setPersistentType(PersistentType.DATETIME);
    attributeDateTime.setMin(new BigDecimal("6"));
    attributeDateTime.setMax(new BigDecimal("8"));
    IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attributeDate, attributeDateTime));
    attributeDate = formDefinitionOne.getMappedAttributeByCode(attributeDate.getCode());
    attributeDateTime = formDefinitionOne.getMappedAttributeByCode(attributeDateTime.getCode());
    // 
    IdmFormValueDto valueDate = new IdmFormValueDto(attributeDate);
    IdmFormValueDto valueDateTime = new IdmFormValueDto(attributeDateTime);
    // 
    IdmFormInstanceDto formInstance = new IdmFormInstanceDto();
    formInstance.setFormDefinition(formDefinitionOne);
    formInstance.setValues(Lists.newArrayList(valueDate, valueDateTime));
    // 
    List<InvalidFormAttributeDto> validationErrors = formService.validate(formInstance);
    // 
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    valueDate.setDateValue(now.plusDays(2));
    valueDateTime.setDateValue(now.plusDays(5));
    // 
    validationErrors = formService.validate(formInstance);
    Assert.assertEquals(2, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getMinValue() != null));
    Assert.assertTrue(validationErrors.stream().anyMatch(e -> e.getMinValue().equals(new BigDecimal("3")) && e.getAttributeCode().equals(attributeDateCode)));
    Assert.assertTrue(validationErrors.stream().anyMatch(e -> e.getMinValue().equals(new BigDecimal("6")) && e.getAttributeCode().equals(attributeDateTimeCode)));
    // 
    valueDate.setDateValue(now.plusDays(6));
    valueDateTime.setDateValue(now.plusDays(9));
    // 
    validationErrors = formService.validate(formInstance);
    Assert.assertEquals(2, validationErrors.size());
    Assert.assertTrue(validationErrors.stream().allMatch(e -> e.getMaxValue() != null));
    Assert.assertTrue(validationErrors.stream().anyMatch(e -> e.getMaxValue().equals(new BigDecimal("5")) && e.getAttributeCode().equals(attributeDateCode)));
    Assert.assertTrue(validationErrors.stream().anyMatch(e -> e.getMaxValue().equals(new BigDecimal("8")) && e.getAttributeCode().equals(attributeDateTimeCode)));
    // 
    valueDate.setDateValue(now.plusDays(5));
    valueDateTime.setDateValue(now.plusDays(8));
    // 
    validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
    // 
    valueDate.setDateValue(now.plusDays(3));
    valueDateTime.setDateValue(now.plusDays(6).plusMinutes(2));
    // 
    validationErrors = formService.validate(formInstance);
    Assert.assertTrue(validationErrors.isEmpty());
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormDefinitionCache(eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache) IdmRoleFormValue_(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue_) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) BigDecimal(java.math.BigDecimal) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) Predicate(javax.persistence.criteria.Predicate) IdmFormDefinition(eu.bcvsolutions.idm.core.eav.entity.IdmFormDefinition) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Map(java.util.Map) ChangePersistentTypeException(eu.bcvsolutions.idm.core.eav.api.exception.ChangePersistentTypeException) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdmFormAttributeService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormAttributeService) IdentityEventType(eu.bcvsolutions.idm.core.model.event.IdentityEvent.IdentityEventType) Sort(org.springframework.data.domain.Sort) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractEntity(eu.bcvsolutions.idm.core.api.entity.AbstractEntity) PageRequest(org.springframework.data.domain.PageRequest) UUID(java.util.UUID) IdmRoleRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleRepository) Page(org.springframework.data.domain.Page) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) Serializable(java.io.Serializable) ChangeConfidentialException(eu.bcvsolutions.idm.core.eav.api.exception.ChangeConfidentialException) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) IdmFormAttribute(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute) Specification(org.springframework.data.jpa.domain.Specification) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) FormableDto(eu.bcvsolutions.idm.core.api.dto.FormableDto) IdmFormAttribute_(eu.bcvsolutions.idm.core.eav.entity.IdmFormAttribute_) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) ArrayList(java.util.ArrayList) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) IdmFormValueFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormValueFilter) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) AbstractFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.AbstractFormValueEvaluator) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) DefaultFormableFilter(eu.bcvsolutions.idm.core.api.dto.filter.DefaultFormableFilter) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Direction(org.springframework.data.domain.Sort.Direction) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Root(javax.persistence.criteria.Root) Before(org.junit.Before) IdentityFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.IdentityFormValueEvaluator) Assert.assertNotNull(org.junit.Assert.assertNotNull) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) IdmRoleFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmRoleFormValue) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ApplicationContext(org.springframework.context.ApplicationContext) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) InitDemoDataProcessor(eu.bcvsolutions.idm.core.model.event.processor.module.InitDemoDataProcessor) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmTreeNode(eu.bcvsolutions.idm.core.model.entity.IdmTreeNode) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) Assert.assertNull(org.junit.Assert.assertNull) ChronoUnit(java.time.temporal.ChronoUnit) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) FormValueService(eu.bcvsolutions.idm.core.eav.api.service.FormValueService) IdmFormDefinitionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormDefinitionService) IdmEntityEvent_(eu.bcvsolutions.idm.core.model.entity.IdmEntityEvent_) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) AbstractFormableService(eu.bcvsolutions.idm.core.eav.api.service.AbstractFormableService) Subquery(javax.persistence.criteria.Subquery) Assert(org.junit.Assert) FormAttributeValidateProcessor(eu.bcvsolutions.idm.core.eav.processor.FormAttributeValidateProcessor) Assert.assertEquals(org.junit.Assert.assertEquals) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) InvalidFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) BigDecimal(java.math.BigDecimal) DefaultAttachmentManagerIntegrationTest(eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

InvalidFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.InvalidFormAttributeDto)13 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)12 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)11 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)10 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)10 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)10 Lists (com.google.common.collect.Lists)9 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)9 FormableDto (eu.bcvsolutions.idm.core.api.dto.FormableDto)9 CoreEventType (eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType)9 LookupService (eu.bcvsolutions.idm.core.api.service.LookupService)9 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)9 Serializable (java.io.Serializable)9 List (java.util.List)9 Map (java.util.Map)9 UUID (java.util.UUID)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 Transactional (org.springframework.transaction.annotation.Transactional)9 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)8 CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)8