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());
}
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());
}
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);
}
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);
}
Aggregations