use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class InitOrganizationProcessor method process.
@Override
public EventResult<ModuleDescriptorDto> process(EntityEvent<ModuleDescriptorDto> event) {
//
// create Node type for organization
IdmTreeTypeDto treeType = treeTypeService.getByCode(DEFAULT_TREE_TYPE);
if (treeType == null && treeTypeService.find(PageRequest.of(0, 1)).getTotalElements() == 0) {
treeType = new IdmTreeTypeDto();
treeType.setCode(DEFAULT_TREE_TYPE);
treeType.setName("Organization structure");
treeType = treeTypeService.save(treeType);
treeConfiguration.setDefaultType(treeType.getId());
// create organization root
if (treeNodeService.findRoots(treeType.getId(), PageRequest.of(0, 1)).getTotalElements() == 0) {
IdmTreeNodeDto organizationRoot = new IdmTreeNodeDto();
organizationRoot.setCode("root");
organizationRoot.setName("Root organization");
organizationRoot.setTreeType(treeType.getId());
organizationRoot = treeNodeService.save(organizationRoot);
}
}
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeServiceIntegrationTest method testUpdateWithoutAutomaticRoles.
@Test
public void testUpdateWithoutAutomaticRoles() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity.getId());
IdmRoleDto basicRole = getHelper().createRole();
getHelper().assignRoles(primeContract, basicRole);
IdmTreeTypeDto type = getHelper().createTreeType();
IdmTreeNodeDto node = getHelper().createTreeNode(type, null);
primeContract.setWorkPosition(node.getId());
identity.setDescription(String.valueOf(System.currentTimeMillis()));
identityContractService.save(primeContract);
identityService.save(identity);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method createStructure.
/**
* Creates organization's structure and identity testUser2 as manager
*/
private void createStructure() {
IdmTreeNodeDto rootOrganization = treeNodeService.findRoots((UUID) null, PageRequest.of(0, 1)).getContent().get(0);
IdmRoleDto role2 = new IdmRoleDto();
role2.setCode("TestCustomRole002" + System.currentTimeMillis());
role2 = this.roleService.save(role2);
testUser2 = new IdmIdentityDto();
testUser2.setUsername("Test_user_Manager" + System.currentTimeMillis());
testUser2.setPassword(new GuardedString(InitApplicationData.ADMIN_PASSWORD));
testUser2.setFirstName("Test");
testUser2.setLastName("Second User");
testUser2.setEmail("test2@bscsolutions.eu");
testUser2 = this.identityService.save(testUser2);
IdmTreeTypeDto type = treeTypeService.get(rootOrganization.getTreeType());
organization = new IdmTreeNodeDto();
organization.setCode("test" + System.currentTimeMillis());
organization.setName("Organization Test Notification");
organization.setParent(rootOrganization.getId());
organization.setTreeType(type.getId());
organization = this.treeNodeService.save(organization);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createLotsOfValidRequests.
@Test
public void createLotsOfValidRequests() throws InterruptedException, ExecutionException {
IdmRoleDto role = createAndSaveRole();
createAndSaveRoleSystem(role, system);
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
LocalDate validFrom = LocalDate.now();
// set plus days
validFrom = validFrom.plusDays(5);
// clear request, if any
List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.findAllValid();
for (IdmIdentityRoleValidRequestDto request : list) {
identityRoleValidRequestService.delete(request);
}
List<IdmIdentityDto> identities = new ArrayList<>();
for (int index = 0; index < MAX_CREATE; index++) {
IdmIdentityDto identity = createAndSaveIdentity();
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
// provisioning is not executed, role isn't valid from now
createAndSaveIdentityRole(identityContract, role, null, validFrom);
identities.add(identity);
}
list = identityRoleValidRequestService.findAllValid();
assertEquals(0, list.size());
validFrom = validFrom.minusDays(15);
for (IdmIdentityDto identity : identities) {
List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
assertEquals(1, roles.size());
IdmIdentityRole identityRole = roles.get(0);
identityRole.setValidFrom(validFrom);
identityRoleRepository.save(identityRole);
}
list = identityRoleValidRequestService.findAllValid();
assertEquals(MAX_CREATE, list.size());
IdentityRoleValidRequestTaskExecutor taskExecutor = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask = longRunningTaskManager.execute(taskExecutor);
assertEquals(true, futureTask.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask = longRunningTaskService.get(taskExecutor.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask.getResult().getState());
list = identityRoleValidRequestService.findAllValid();
assertEquals(0, list.size());
for (IdmIdentityDto identity : identities) {
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> accountsList = identityAccountService.find(filter, null).getContent();
assertEquals(false, accountsList.isEmpty());
assertEquals(1, accountsList.size());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createNonValidRoleAndValid.
@Test
public void createNonValidRoleAndValid() throws InterruptedException, ExecutionException {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
createAndSaveRoleSystem(role, system);
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate validFrom = LocalDate.now();
// set plus days
validFrom = validFrom.plusDays(5);
// provisioning is not executed, role isn't valid from now
createAndSaveIdentityRole(identityContract, role, null, validFrom);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> list = identityAccountService.find(filter, null).getContent();
// it must not exists
assertEquals(true, list.isEmpty());
//
IdentityRoleValidRequestTaskExecutor taskExecutor1 = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask1 = longRunningTaskManager.execute(taskExecutor1);
assertEquals(true, futureTask1.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask1 = longRunningTaskService.get(taskExecutor1.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask1.getResult().getState());
list = identityAccountService.find(filter, null).getContent();
// still empty, role isn't valid
assertEquals(true, list.isEmpty());
List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
assertEquals(1, roles.size());
IdmIdentityRole identityRole = roles.get(0);
validFrom = LocalDate.now();
validFrom = validFrom.minusDays(5);
identityRole.setValidFrom(validFrom);
identityRoleRepository.save(identityRole);
// execute again
IdentityRoleValidRequestTaskExecutor taskExecutor2 = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask2 = longRunningTaskManager.execute(taskExecutor2);
assertEquals(true, futureTask2.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask2 = longRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask2.getResult().getState());
list = identityAccountService.find(filter, null).getContent();
assertEquals(false, list.isEmpty());
assertEquals(1, list.size());
// newly created accounts
assertNotNull(list.get(0));
}
Aggregations