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