Search in sources :

Example 6 with IdmFormDefinitionFilter

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

the class FormDefinitionDeleteBulkActionIntegrationTest method processBulkActionByIds.

@Test
public void processBulkActionByIds() {
    String type = getHelper().createName();
    // creates Main definition which won't be deleted
    getHelper().createFormDefinition(type, true);
    List<IdmFormDefinitionDto> defDtos = new ArrayList<IdmFormDefinitionDto>();
    for (int i = 0; i < TEST_COUNT; ++i) {
        getHelper().createFormDefinition(type);
    }
    IdmFormDefinitionFilter filter = new IdmFormDefinitionFilter();
    filter.setType(type);
    filter.setMain(false);
    defDtos = formDefService.find(filter, null).getContent();
    Set<UUID> defIds = defDtos.stream().map(IdmFormDefinitionDto::getId).collect(Collectors.toSet());
    Assert.assertTrue(defIds.size() == TEST_COUNT);
    IdmBulkActionDto bulkAction = findBulkAction(IdmFormDefinition.class, FormDefinitionDeleteBulkAction.NAME);
    bulkAction.setIdentifiers(defIds);
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, Long.valueOf(TEST_COUNT), null, null);
    filter.setMain(null);
    List<IdmFormDefinitionDto> defsRemain = formDefService.find(filter, null).getContent();
    Assert.assertEquals(1, defsRemain.size());
    Set<UUID> result = defsRemain.stream().map(IdmFormDefinitionDto::getId).collect(Collectors.toSet());
    result.retainAll(defIds);
    Assert.assertTrue(result.isEmpty());
}
Also used : IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) ArrayList(java.util.ArrayList) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 7 with IdmFormDefinitionFilter

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

the class DefaultFormService method findFormInstances.

@Override
@Transactional(readOnly = true)
public List<IdmFormInstanceDto> findFormInstances(Identifiable owner, FormableFilter filter, BasePermission... permission) {
    Assert.notNull(owner, "Form values owner is required.");
    // 
    // filter form definitions and form attributes, if given
    List<IdmFormDefinitionDto> formDefinitions;
    if (filter == null || CollectionUtils.isEmpty(filter.getFormDefinitionAttributes())) {
        // filter is not set => all form definitions
        formDefinitions = getDefinitions(owner, !PermissionUtils.isEmpty(permission) ? IdmBasePermission.AUTOCOMPLETE : null);
    } else {
        // used filter definitions only.
        IdmFormDefinitionFilter definitionFilter = new IdmFormDefinitionFilter();
        definitionFilter.setType(getDefaultDefinitionType(owner.getClass()));
        definitionFilter.setIds(filter.getFormDefinitionAttributes().stream().map(FormDefinitionAttributes::getDefinition).collect(Collectors.toList()));
        // 
        formDefinitions = formDefinitionService.find(definitionFilter, getDefinitionPageable(), !PermissionUtils.isEmpty(permission) ? IdmBasePermission.AUTOCOMPLETE : null).getContent();
    }
    // 
    return formDefinitions.stream().map(definition -> {
        return findFormInstance(owner, definition, filter, permission);
    }).collect(Collectors.toList());
}
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) IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) FormDefinitionAttributes(eu.bcvsolutions.idm.core.eav.api.dto.FormDefinitionAttributes) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with IdmFormDefinitionFilter

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

the class IdmFormDefinitionController method getDefinitions.

/**
 * Returns all definitions for given ownerClass.
 *
 * @param ownerType
 * @param permission base permissions to evaluate (AND)
 * @return
 */
public ResponseEntity<?> getDefinitions(Class<? extends Identifiable> ownerType, BasePermission permission) {
    IdmFormDefinitionFilter filter = new IdmFormDefinitionFilter();
    filter.setType(formService.getDefaultDefinitionType(ownerType));
    // 
    // find definitions + sorted
    Page<IdmFormDefinitionDto> definitions = find(filter, formService.getDefinitionPageable(), permission);
    // 
    return new ResponseEntity<>(toResources(definitions, getDtoClass()), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)

Example 9 with IdmFormDefinitionFilter

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

the class IdmFormDefinitionController method getDefinitions.

/**
 * Returns definition by given ID
 *
 * @param definitionId
 * @return
 */
public ResponseEntity<?> getDefinitions(UUID definitionId) {
    IdmFormDefinitionFilter filter = new IdmFormDefinitionFilter();
    filter.setId(definitionId);
    // 
    return new ResponseEntity<>(toResources(find(filter, null, null), getDtoClass()), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter)

Aggregations

IdmFormDefinitionFilter (eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter)9 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)7 ArrayList (java.util.ArrayList)4 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)3 IdmFormAttributeFilter (eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter)3 UUID (java.util.UUID)3 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)2 ValueWrapper (eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper)2 FormDefinitionCache (eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache)2 Test (org.junit.Test)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 ConfigurationClass (eu.bcvsolutions.idm.core.api.domain.ConfigurationClass)1 ConfigurationClassProperty (eu.bcvsolutions.idm.core.api.domain.ConfigurationClassProperty)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)1 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 ExportDescriptorDto (eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto)1 FormableDto (eu.bcvsolutions.idm.core.api.dto.FormableDto)1