Search in sources :

Example 41 with IdmRequestDto

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

the class RequestManagerTest method createRequest.

private IdmRequestDto createRequest(IdmRoleDto changedRole) {
    IdmRequestDto request = requestManager.createRequest(changedRole);
    Assert.assertNotNull(request);
    Assert.assertEquals(request.getOwnerType(), changedRole.getClass().getName());
    Assert.assertEquals(request.getOwnerId(), changedRole.getId());
    // Change role (without save)
    changedRole.setDescription(getHelper().createName());
    changedRole.setPriority(1000);
    // Create request item
    IdmRoleDto requestable = requestManager.post(request.getId(), changedRole);
    Assert.assertNotNull(requestable);
    Assert.assertNotNull(requestable.getRequestItem());
    // Is not same instance
    Assert.assertNotSame(changedRole, requestable);
    // Has same values as new role
    Assert.assertEquals(changedRole.getPriority(), requestable.getPriority());
    Assert.assertEquals(changedRole.getDescription(), requestable.getDescription());
    IdmRoleDto currentRole = roleService.get(changedRole.getId());
    Assert.assertNotEquals(changedRole.getPriority(), currentRole.getPriority());
    Assert.assertNotEquals(changedRole.getDescription(), currentRole.getDescription());
    return request;
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)

Example 42 with IdmRequestDto

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

the class RequestManagerTest method testGetChangesEAV.

@Test
public void testGetChangesEAV() {
    // Create role
    IdmRoleDto role = getHelper().createRole();
    // Get definition
    IdmFormInstanceDto formInstance = formService.getFormInstance(role);
    // None values yet
    Assert.assertEquals(0, formInstance.getValues().size());
    IdmFormDefinitionDto formDefinition = formInstance.getFormDefinition();
    // Create form attributes
    IdmFormAttributeDto attributeShortText = new IdmFormAttributeDto();
    attributeShortText.setCode(getHelper().createName());
    attributeShortText.setName(attributeShortText.getCode());
    attributeShortText.setPersistentType(PersistentType.SHORTTEXT);
    attributeShortText.setFormDefinition(formDefinition.getId());
    attributeShortText = formService.saveAttribute(attributeShortText);
    IdmFormAttributeDto attributeBoolean = new IdmFormAttributeDto();
    attributeBoolean.setCode(getHelper().createName());
    attributeBoolean.setName(attributeBoolean.getCode());
    attributeBoolean.setPersistentType(PersistentType.BOOLEAN);
    attributeBoolean.setFormDefinition(formDefinition.getId());
    attributeBoolean = formService.saveAttribute(attributeBoolean);
    IdmFormAttributeDto attributeConfidential = new IdmFormAttributeDto();
    attributeConfidential.setCode(getHelper().createName());
    attributeConfidential.setName(attributeConfidential.getCode());
    attributeConfidential.setPersistentType(PersistentType.SHORTTEXT);
    attributeConfidential.setConfidential(true);
    attributeConfidential.setFormDefinition(formDefinition.getId());
    attributeConfidential = formService.saveAttribute(attributeConfidential);
    IdmFormAttributeDto attributeInt = new IdmFormAttributeDto();
    attributeInt.setCode(getHelper().createName());
    attributeInt.setName(attributeInt.getCode());
    attributeInt.setPersistentType(PersistentType.INT);
    attributeInt.setFormDefinition(formDefinition.getId());
    attributeInt = formService.saveAttribute(attributeInt);
    // Create request
    IdmRequestDto request = requestManager.createRequest(role);
    Assert.assertNotNull(request);
    IdmFormInstanceDto formInstanceRequest = requestManager.getFormInstance(request.getId(), role, formDefinition);
    // None values yet
    Assert.assertEquals(0, formInstanceRequest.getValues().size());
    IdmFormValueDto valueShortText = new IdmFormValueDto(attributeShortText);
    valueShortText.setValue(getHelper().createName());
    formInstanceRequest.getValues().add(valueShortText);
    IdmFormValueDto valueBoolean = new IdmFormValueDto(attributeBoolean);
    valueBoolean.setValue(true);
    formInstanceRequest.getValues().add(valueBoolean);
    IdmFormValueDto valueConfidential = new IdmFormValueDto(attributeConfidential);
    String confidentialValueString = getHelper().createName();
    valueConfidential.setValue(confidentialValueString);
    formInstanceRequest.getValues().add(valueConfidential);
    IdmFormValueDto valueInt = new IdmFormValueDto(attributeInt);
    valueInt.setValue(111);
    formInstanceRequest.getValues().add(valueInt);
    formDefinition = formService.getDefinition(IdmRoleDto.class);
    requestManager.saveFormInstance(request.getId(), role, formDefinition, formInstanceRequest.getValues());
    formInstanceRequest = requestManager.getFormInstance(request.getId(), role, formDefinition);
    // Four values in request
    Assert.assertEquals(4, formInstanceRequest.getValues().size());
    formInstance = formService.getFormInstance(role);
    // None values via standard service
    Assert.assertEquals(0, formInstance.getValues().size());
    formInstanceRequest.getValues().forEach(value -> {
        IdmRequestItemDto item = DtoUtils.getEmbedded(value, Requestable.REQUEST_ITEM_FIELD, IdmRequestItemDto.class);
        IdmRequestItemChangesDto changes = requestManager.getChanges(item);
        Assert.assertNotNull(changes);
        List<IdmRequestItemAttributeDto> attributes = changes.getAttributes();
        attributes.forEach(attribute -> {
            Assert.assertEquals(RequestOperationType.ADD, attribute.getValue().getChange());
        });
        IdmRequestItemAttributeDto attributeDto = attributes.stream().filter(attribute -> "stringValue".equals(attribute.getName())).findFirst().get();
        Assert.assertEquals(value.getStringValue(), attributeDto.getValue().getValue());
        attributeDto = attributes.stream().filter(attribute -> "booleanValue".equals(attribute.getName())).findFirst().get();
        Assert.assertEquals(value.getBooleanValue(), attributeDto.getValue().getValue());
        attributeDto = attributes.stream().filter(attribute -> "doubleValue".equals(attribute.getName())).findFirst().get();
        Assert.assertEquals(value.getDoubleValue(), attributeDto.getValue().getValue());
        attributeDto = attributes.stream().filter(attribute -> "longValue".equals(attribute.getName())).findFirst().get();
        Assert.assertEquals(value.getLongValue(), attributeDto.getValue().getValue());
        attributeDto = attributes.stream().filter(attribute -> "shortTextValue".equals(attribute.getName())).findFirst().get();
        Assert.assertEquals(value.getShortTextValue(), attributeDto.getValue().getValue());
    });
    request = requestManager.startRequest(request.getId(), true);
    Assert.assertEquals(RequestState.EXECUTED, request.getState());
    formInstance = formService.getFormInstance(role);
    // Four values via standard service
    Assert.assertEquals(4, formInstance.getValues().size());
    // All changes was applied, check on none changes
    formInstanceRequest = requestManager.getFormInstance(request.getId(), role, formDefinition);
    formInstanceRequest.getValues().forEach(value -> {
        IdmRequestItemDto item = DtoUtils.getEmbedded(value, Requestable.REQUEST_ITEM_FIELD, IdmRequestItemDto.class);
        IdmRequestItemChangesDto changes = requestManager.getChanges(item);
        Assert.assertNotNull(changes);
        List<IdmRequestItemAttributeDto> attributes = changes.getAttributes();
        attributes.forEach(attribute -> {
            Assert.assertEquals(attribute.getValue().getOldValue(), attribute.getValue().getValue());
        });
    });
    // Make changes
    final UUID attributeShortTextId = attributeShortText.getId();
    IdmFormValueDto changedValueShortText = new IdmFormValueDto(attributeShortText);
    changedValueShortText.setValue(getHelper().createName());
    // Create new request
    IdmRequestDto requestChange = requestManager.createRequest(role);
    Assert.assertNotNull(requestChange);
    // Create request items
    requestManager.saveFormInstance(requestChange.getId(), role, formDefinition, Lists.newArrayList(changedValueShortText));
    formInstanceRequest = requestManager.getFormInstance(requestChange.getId(), role, formDefinition);
    // One change in the request
    Assert.assertEquals(4, formInstanceRequest.getValues().size());
    IdmFormValueDto changedValueShortTextRequest = formInstanceRequest.getValues().stream().filter(value -> value.getFormAttribute().equals(attributeShortTextId)).findFirst().get();
    IdmRequestItemDto item = DtoUtils.getEmbedded(changedValueShortTextRequest, Requestable.REQUEST_ITEM_FIELD, IdmRequestItemDto.class);
    IdmRequestItemChangesDto changes = requestManager.getChanges(item);
    Assert.assertNotNull(changes);
    List<IdmRequestItemAttributeDto> attributes = changes.getAttributes();
    IdmRequestItemAttributeDto attributeDto = attributes.stream().filter(attribute -> "shortTextValue".equals(attribute.getName())).findFirst().get();
    Assert.assertNotEquals(attributeDto.getValue().getOldValue(), attributeDto.getValue().getValue());
    Assert.assertEquals(changedValueShortText.getShortTextValue(), attributeDto.getValue().getValue());
    // Delete attributes
    formService.deleteValues(role, attributeShortText);
    formService.deleteAttribute(attributeShortText);
    formService.deleteValues(role, attributeBoolean);
    formService.deleteAttribute(attributeBoolean);
    formService.deleteValues(role, attributeConfidential);
    formService.deleteAttribute(attributeConfidential);
    formService.deleteValues(role, attributeInt);
    formService.deleteAttribute(attributeInt);
}
Also used : IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) RequestOperationType(eu.bcvsolutions.idm.core.api.domain.RequestOperationType) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) RequestState(eu.bcvsolutions.idm.core.api.domain.RequestState) IdmRequestItemDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkType(org.activiti.engine.task.IdentityLinkType) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Lists(com.google.common.collect.Lists) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) WorkflowProcessInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowProcessInstanceService) WorkflowTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) Assert.fail(org.junit.Assert.fail) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) Before(org.junit.Before) Requestable(eu.bcvsolutions.idm.core.api.domain.Requestable) IdmRoleGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmRoleGuaranteeService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) RequestManager(eu.bcvsolutions.idm.core.api.service.RequestManager) Test(org.junit.Test) IdmRequestItemChangesDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemChangesDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestItemService(eu.bcvsolutions.idm.core.api.service.IdmRequestItemService) IdmRequestItemAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemAttributeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) Assert(org.junit.Assert) IdmRequestService(eu.bcvsolutions.idm.core.api.service.IdmRequestService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) IdmRequestItemAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemAttributeDto) IdmRequestItemDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) UUID(java.util.UUID) IdmRequestItemChangesDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemChangesDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 43 with IdmRequestDto

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

the class RequestManagerTest method testDeleteRequest.

@Test
public void testDeleteRequest() {
    // Create role
    IdmRoleDto changedRole = getHelper().createRole();
    // Create request
    IdmRequestDto request = requestManager.createRequest(changedRole);
    Assert.assertNotNull(request);
    Assert.assertEquals(request.getOwnerType(), changedRole.getClass().getName());
    Assert.assertEquals(request.getOwnerId(), changedRole.getId());
    // Change role (without save)
    changedRole.setDescription(getHelper().createName());
    changedRole.setPriority(1000);
    // Create request item
    Requestable requestable = requestManager.post(request.getId(), changedRole);
    Assert.assertNotNull(requestable);
    Assert.assertNotNull(requestable.getRequestItem());
    Assert.assertTrue(requestable instanceof IdmRoleDto);
    IdmRoleDto roleFromRequest = (IdmRoleDto) requestable;
    // Is not same instance
    Assert.assertTrue(changedRole != roleFromRequest);
    // Has same values as new role
    Assert.assertEquals(changedRole.getPriority(), roleFromRequest.getPriority());
    Assert.assertEquals(changedRole.getDescription(), roleFromRequest.getDescription());
    IdmRoleDto currentRole = roleService.get(changedRole.getId());
    Assert.assertNotEquals(changedRole.getPriority(), currentRole.getPriority());
    Assert.assertNotEquals(changedRole.getDescription(), currentRole.getDescription());
    Assert.assertNotNull(requestItemService.get(requestable.getRequestItem()));
    // Delete the request
    requestService.delete(request);
    // Request item must be canceled
    IdmRequestItemDto requestItem = requestItemService.get(requestable.getRequestItem());
    Assert.assertNull(requestItem);
    // Request must be canceled
    request = requestService.get(request.getId());
    Assert.assertNull(request);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestItemDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto) Requestable(eu.bcvsolutions.idm.core.api.domain.Requestable) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 44 with IdmRequestDto

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

the class RequestManagerTest method testChangeRoleWithGuaranteeTypeByRole.

@Test
public void testChangeRoleWithGuaranteeTypeByRole() {
    // Guarantee type -> set to null (default value).
    getHelper().setConfigurationValue("idm.sec.core.request.idm-role.approval.guarantee-type", null);
    String guaranteeTypeOne = getHelper().createName();
    String guaranteeTypeTwo = getHelper().createName();
    // Create role with guarantee
    IdmIdentityDto guaranteeOne = getHelper().createIdentity();
    IdmIdentityDto guaranteeTwo = getHelper().createIdentity();
    IdmRoleDto roleOne = getHelper().createRole();
    IdmRoleDto roleTwo = getHelper().createRole();
    getHelper().createIdentityRole(guaranteeOne, roleOne);
    getHelper().createIdentityRole(guaranteeTwo, roleTwo);
    IdmRoleDto changedRole = getHelper().createRole();
    getHelper().createRoleGuaranteeRole(changedRole, roleOne, guaranteeTypeOne);
    getHelper().createRoleGuaranteeRole(changedRole, roleTwo, guaranteeTypeTwo);
    // Create request
    IdmRequestDto request = createRequest(changedRole);
    // Start request
    IdmRequestDto executedRequest = requestManager.startRequest(request.getId(), true);
    Assert.assertNotNull(executedRequest);
    executedRequest = requestService.get(executedRequest.getId());
    // Role has guarantee, approval process must be started
    Assert.assertEquals(RequestState.IN_PROGRESS, executedRequest.getState());
    WorkflowFilterDto taskFilter = new WorkflowFilterDto();
    taskFilter.setProcessInstanceId(executedRequest.getWfProcessId());
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    Assert.assertEquals(1, tasks.size());
    WorkflowTaskInstanceDto workflowTaskInstanceDto = tasks.get(0);
    List<IdentityLinkDto> candidates = workflowTaskInstanceDto.getIdentityLinks().stream().filter(identityLinkDto -> IdentityLinkType.CANDIDATE.equals(identityLinkDto.getType())).collect(Collectors.toList());
    Assert.assertEquals(2, candidates.size());
    Assert.assertTrue(candidates.stream().anyMatch(candidate -> guaranteeOne.getId().toString().equals(candidate.getUserId())));
    Assert.assertTrue(candidates.stream().anyMatch(candidate -> guaranteeTwo.getId().toString().equals(candidate.getUserId())));
    // Guarantee type -> set to guaranteeTypeOne.
    getHelper().setConfigurationValue("idm.sec.core.request.idm-role.approval.guarantee-type", guaranteeTypeOne);
    // Create request for guarantee type ONE.
    request = createRequest(changedRole);
    // Start request
    executedRequest = requestManager.startRequest(request.getId(), true);
    Assert.assertNotNull(executedRequest);
    executedRequest = requestService.get(executedRequest.getId());
    // Role has guarantee, approval process must be started
    Assert.assertEquals(RequestState.IN_PROGRESS, executedRequest.getState());
    taskFilter = new WorkflowFilterDto();
    taskFilter.setProcessInstanceId(executedRequest.getWfProcessId());
    tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    Assert.assertEquals(1, tasks.size());
    workflowTaskInstanceDto = tasks.get(0);
    candidates = workflowTaskInstanceDto.getIdentityLinks().stream().filter(identityLinkDto -> IdentityLinkType.CANDIDATE.equals(identityLinkDto.getType())).collect(Collectors.toList());
    Assert.assertEquals(1, candidates.size());
    Assert.assertTrue(candidates.stream().anyMatch(candidate -> guaranteeOne.getId().toString().equals(candidate.getUserId())));
    // Guarantee type -> set to guaranteeTypeTwo.
    getHelper().setConfigurationValue("idm.sec.core.request.idm-role.approval.guarantee-type", guaranteeTypeTwo);
    // Create request for guarantee type TWO.
    request = createRequest(changedRole);
    // Start request
    executedRequest = requestManager.startRequest(request.getId(), true);
    Assert.assertNotNull(executedRequest);
    executedRequest = requestService.get(executedRequest.getId());
    // Role has guarantee, approval process must be started
    Assert.assertEquals(RequestState.IN_PROGRESS, executedRequest.getState());
    taskFilter = new WorkflowFilterDto();
    requestService.get(executedRequest.getId());
    taskFilter.setProcessInstanceId(executedRequest.getWfProcessId());
    tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    Assert.assertEquals(1, tasks.size());
    workflowTaskInstanceDto = tasks.get(0);
    candidates = workflowTaskInstanceDto.getIdentityLinks().stream().filter(identityLinkDto -> IdentityLinkType.CANDIDATE.equals(identityLinkDto.getType())).collect(Collectors.toList());
    Assert.assertEquals(1, candidates.size());
    Assert.assertTrue(candidates.stream().anyMatch(candidate -> guaranteeTwo.getId().toString().equals(candidate.getUserId())));
    // Clear after test:
    // Guarantee type -> set to null (default value).
    getHelper().setConfigurationValue("idm.sec.core.request.idm-role.approval.guarantee-type", null);
}
Also used : RequestOperationType(eu.bcvsolutions.idm.core.api.domain.RequestOperationType) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) RequestState(eu.bcvsolutions.idm.core.api.domain.RequestState) IdmRequestItemDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) WorkflowProcessInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessInstanceDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkType(org.activiti.engine.task.IdentityLinkType) PersistentType(eu.bcvsolutions.idm.core.eav.api.domain.PersistentType) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Lists(com.google.common.collect.Lists) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) WorkflowProcessInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowProcessInstanceService) WorkflowTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) Assert.fail(org.junit.Assert.fail) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) Before(org.junit.Before) Requestable(eu.bcvsolutions.idm.core.api.domain.Requestable) IdmRoleGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmRoleGuaranteeService) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) RequestManager(eu.bcvsolutions.idm.core.api.service.RequestManager) Test(org.junit.Test) IdmRequestItemChangesDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemChangesDto) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRequestItemService(eu.bcvsolutions.idm.core.api.service.IdmRequestItemService) IdmRequestItemAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestItemAttributeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) Assert(org.junit.Assert) IdmRequestService(eu.bcvsolutions.idm.core.api.service.IdmRequestService) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 45 with IdmRequestDto

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

the class RequestApprovalProcessor method process.

@SuppressWarnings("unchecked")
@Override
public EventResult<IdmRequestDto> process(EntityEvent<IdmRequestDto> event) {
    IdmRequestDto dto = event.getContent();
    boolean checkRight = (boolean) event.getProperties().get(CHECK_RIGHT_PROPERTY);
    // 
    String ownerTyp = dto.getOwnerType();
    Assert.notNull(ownerTyp, "Owner type is rquired for start approval process!");
    Class<Requestable> ownerClass = null;
    try {
        ownerClass = (Class<Requestable>) Class.forName(ownerTyp);
    } catch (ClassNotFoundException e) {
        throw new CoreException(e);
    }
    String wfDefinition = requestConfiguration.getRequestApprovalProcessKey(ownerClass);
    if (Strings.isNullOrEmpty(wfDefinition)) {
        throw new ResultCodeException(CoreResultCode.REQUEST_NO_WF_DEF_FOUND, ImmutableMap.of("entityType", dto.getOwnerType()));
    }
    boolean approved = manager.startApprovalProcess(dto, checkRight, event, wfDefinition);
    DefaultEventResult<IdmRequestDto> result = new DefaultEventResult<>(event, this);
    result.setSuspended(!approved);
    return result;
}
Also used : CoreException(eu.bcvsolutions.idm.core.api.exception.CoreException) Requestable(eu.bcvsolutions.idm.core.api.domain.Requestable) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)

Aggregations

IdmRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestDto)47 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)25 Test (org.junit.Test)24 Requestable (eu.bcvsolutions.idm.core.api.domain.Requestable)23 IdmRequestItemDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestItemDto)23 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)18 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)18 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)13 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)11 UUID (java.util.UUID)11 IdmRequestItemChangesDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestItemChangesDto)9 Transactional (org.springframework.transaction.annotation.Transactional)9 RequestState (eu.bcvsolutions.idm.core.api.domain.RequestState)8 IdmRequestItemAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmRequestItemAttributeDto)8 IdmRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRequestFilter)8 IdmRequestService (eu.bcvsolutions.idm.core.api.service.IdmRequestService)8 IdmFormInstanceDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto)8 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)8 Lists (com.google.common.collect.Lists)7 IdmRequestItemService (eu.bcvsolutions.idm.core.api.service.IdmRequestItemService)7