Search in sources :

Example 16 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class ContractSliceSynchronizationExecutor method doDeleteEntity.

/**
 * Delete entity linked with given account
 *
 * @param account
 * @param entityType
 * @param log
 * @param logItem
 * @param actionLogs
 */
protected void doDeleteEntity(AccAccountDto account, SystemEntityType entityType, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
    IdmContractSliceDto dto = this.getDtoByAccount(null, account);
    if (dto == null) {
        addToItemLog(logItem, MessageFormat.format("Warning! - Entity for account [{0}] was not found!", account.getUid()));
        initSyncActionLog(SynchronizationActionType.DELETE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
    String entityIdentification = dto.getId().toString();
    if (dto instanceof Codeable) {
        entityIdentification = ((Codeable) dto).getCode();
    }
    logItem.setDisplayName(entityIdentification);
    // Delete entity
    // Set dirty state during recalculation, the process of recalculation will be
    // solved in ClearDirtyStateForContractSliceTaskExecutor
    // ClearDirtyStateForContractSliceTaskExecutor will be started with HR
    // processes.
    EntityEvent<IdmContractSliceDto> event = new ContractSliceEvent(ContractSliceEventType.DELETE, dto, ImmutableMap.of(IdmContractSliceService.SET_DIRTY_STATE_CONTRACT_SLICE, Boolean.TRUE));
    // We do not want execute HR processes for every contract. We need start
    // them for every identity only once.
    // For this we skip them now. HR processes must be start after whole
    // sync finished (by using dependent scheduled task)!
    event.getProperties().put(IdmIdentityContractService.SKIP_HR_PROCESSES, Boolean.TRUE);
    // 
    // We don't want recalculate automatic role by attribute recalculation for every
    // contract.
    // Recalculation will be started only once.
    event.getProperties().put(AutomaticRoleManager.SKIP_RECALCULATION, Boolean.TRUE);
    getService().publish(event);
}
Also used : ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)

Example 17 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class IdmAuditListener method changeRevisionEntity.

private void changeRevisionEntity(Class<AbstractEntity> entityClass, String entityName, UUID entityId, IdmAudit revisionEntity, RevisionType revisionType) {
    // name of entity class - full name.
    revisionEntity.setType(entityName);
    // revision type - MOD, DEL, ADD
    revisionEntity.setModification(revisionType.name());
    // action executer identity
    AbstractAuthentication authentication = securityService.getAuthentication();
    IdmIdentityDto currentIdentity = authentication == null ? null : authentication.getCurrentIdentity();
    IdmIdentityDto originalIdentity = authentication == null ? null : authentication.getOriginalIdentity();
    // 
    revisionEntity.setModifier(securityService.getUsername());
    revisionEntity.setModifierId(currentIdentity == null ? null : currentIdentity.getId());
    // original action executer identity (before switch)
    revisionEntity.setOriginalModifier(securityService.getOriginalUsername());
    revisionEntity.setOriginalModifierId(originalIdentity == null ? null : originalIdentity.getId());
    // entity id
    revisionEntity.setEntityId((UUID) entityId);
    // 
    AbstractEntity currentEntity = null;
    if (revisionType == RevisionType.DEL) {
        currentEntity = auditService.getActualRemovedEntity(entityClass, entityId);
    } else {
        currentEntity = (AbstractEntity) entityManger.find(entityClass, entityId);
    }
    if (currentEntity instanceof AuditSearchable) {
        AuditSearchable searchableEntity = ((AuditSearchable) currentEntity);
        revisionEntity.setOwnerCode(searchableEntity.getOwnerCode());
        revisionEntity.setOwnerId(searchableEntity.getOwnerId());
        revisionEntity.setOwnerType(searchableEntity.getOwnerType());
        revisionEntity.setSubOwnerCode(searchableEntity.getSubOwnerCode());
        revisionEntity.setSubOwnerId(searchableEntity.getSubOwnerId());
        revisionEntity.setSubOwnerType(searchableEntity.getSubOwnerType());
    } else if (currentEntity instanceof Codeable) {
        revisionEntity.setOwnerCode(((Codeable) currentEntity).getCode());
    }
    // transaction id
    revisionEntity.setTransactionId(TransactionContextHolder.getContext().getTransactionId());
}
Also used : AuditSearchable(eu.bcvsolutions.idm.core.api.domain.AuditSearchable) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) AbstractEntity(eu.bcvsolutions.idm.core.api.entity.AbstractEntity) AbstractAuthentication(eu.bcvsolutions.idm.core.security.api.domain.AbstractAuthentication) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Aggregations

Codeable (eu.bcvsolutions.idm.core.api.domain.Codeable)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 UUID (java.util.UUID)4 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)3 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)2 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)2 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)2 AuditSearchable (eu.bcvsolutions.idm.core.api.domain.AuditSearchable)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)2 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)2 AbstractEntity (eu.bcvsolutions.idm.core.api.entity.AbstractEntity)2 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)2