use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeService method removeAutomaticRoles.
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void removeAutomaticRoles(UUID contractId, Set<AbstractIdmAutomaticRoleDto> automaticRoles) {
for (AbstractIdmAutomaticRoleDto autoRole : automaticRoles) {
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(contractId);
identityRoleFilter.setAutomaticRoleId(autoRole.getId());
// TODO: possible performance update with pageable
for (IdmIdentityRoleDto identityRole : identityRoleService.find(identityRoleFilter, null).getContent()) {
// skip check granted authorities
IdentityRoleEvent event = new IdentityRoleEvent(IdentityRoleEventType.DELETE, identityRole);
event.getProperties().put(IdmIdentityRoleService.SKIP_CHECK_AUTHORITIES, Boolean.TRUE);
identityRoleService.publish(event);
}
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeService method processAutomaticRolesForContract.
@Override
public void processAutomaticRolesForContract(UUID contractId, Set<AbstractIdmAutomaticRoleDto> passedAutomaticRoles, Set<AbstractIdmAutomaticRoleDto> notPassedAutomaticRoles) {
// Assign new passed automatic roles (assign to default contract)
IdmIdentityContractDto contract = identityContractService.get(contractId);
//
if (contract == null) {
LOG.debug(MessageFormat.format("Contract id [{0}] not found.", contractId));
return;
}
// TODO: this behavior can be optimalized by add it into query
if (!contract.isValidNowOrInFuture() || contract.getState() == ContractState.DISABLED) {
// null all new passed automatic roles
passedAutomaticRoles = null;
}
//
// find all automatic roles for identity
IdmIdentityRoleFilter roleIdentityFilter = new IdmIdentityRoleFilter();
roleIdentityFilter.setIdentityContractId(contractId);
roleIdentityFilter.setAutomaticRole(Boolean.TRUE);
//
if (passedAutomaticRoles != null && !passedAutomaticRoles.isEmpty()) {
this.addAutomaticRoles(contract, passedAutomaticRoles);
}
//
if (notPassedAutomaticRoles != null && !notPassedAutomaticRoles.isEmpty()) {
this.removeAutomaticRoles(contract.getId(), notPassedAutomaticRoles);
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityRoleService method findValidRole.
@Override
@Transactional(readOnly = true)
public Page<IdmIdentityRoleDto> findValidRole(UUID identityId, Pageable pageable) {
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setValid(Boolean.TRUE);
identityRoleFilter.setIdentityId(identityId);
return this.find(identityRoleFilter, pageable);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdentityRoleServiceTest method roleCatalogueTest.
@Test
public void roleCatalogueTest() {
IdmIdentityDto person = testHelper.createIdentity();
IdmIdentityDto person2 = testHelper.createIdentity();
IdmRoleCatalogueDto catalogue = testHelper.createRoleCatalogue();
IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
IdmRoleCatalogueRoleDto catalogueRole2 = new IdmRoleCatalogueRoleDto();
IdmIdentityContractDto contract = testHelper.createIdentityContact(person);
IdmIdentityContractDto contract2 = testHelper.createIdentityContact(person2);
IdmRoleDto role = testHelper.createRole();
IdmRoleDto role2 = testHelper.createRole();
catalogueRole.setRoleCatalogue(catalogue.getId());
catalogueRole.setRole(role.getId());
catalogueRole2.setRoleCatalogue(catalogue.getId());
catalogueRole2.setRole(role2.getId());
IdmIdentityRoleDto roleCover = testHelper.createIdentityRole(contract, role);
IdmIdentityRoleDto roleCover2 = testHelper.createIdentityRole(contract2, role2);
idmRoleCatalogueRoleService.save(catalogueRole);
idmRoleCatalogueRoleService.save(catalogueRole2);
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setRoleCatalogueId(catalogue.getId());
Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
assertEquals("Wrong CatalogueRoleId", roleCover.getId(), result.getContent().get(0).getId());
assertEquals("Wrong CatalogueRoleId2", roleCover2.getId(), result.getContent().get(1).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdentityRoleServiceTest method identityIdTest.
@Test
public void identityIdTest() {
IdmRoleDto role = testHelper.createRole();
IdmIdentityDto person = testHelper.createIdentity();
IdmIdentityRoleDto addRole = testHelper.createIdentityRole(person, role);
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setIdentityId(person.getId());
Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
assertEquals("Wrong RoleId", addRole.getId(), result.getContent().get(0).getId());
}
Aggregations