use of eu.bcvsolutions.idm.core.model.event.ContractSliceEvent in project CzechIdMng by bcvsolutions.
the class DefaultContractSliceManager method updateValidTillOnPreviousSlice.
@Override
@Transactional
public void updateValidTillOnPreviousSlice(IdmContractSliceDto slice, List<IdmContractSliceDto> slices) {
Assert.notNull(slice, "Contract slice cannot be null!");
Assert.notNull(slices, "Contract slices are required.");
if (slice.getValidFrom() == null) {
return;
}
IdmContractSliceDto previousSlice = this.findPreviousSlice(slice, slices);
if (previousSlice == null) {
return;
}
// Previous slice will be valid till starts of validity next slice
previousSlice.setValidTill(slice.getValidFrom().minusDays(1));
contractSliceService.publish(new ContractSliceEvent(ContractSliceEventType.UPDATE, previousSlice, ImmutableMap.of(IdmContractSliceService.SKIP_RECALCULATE_CONTRACT_SLICE, Boolean.TRUE)));
}
use of eu.bcvsolutions.idm.core.model.event.ContractSliceEvent in project CzechIdMng by bcvsolutions.
the class DefaultContractSliceManager method setSliceAsCurrentlyUsing.
@Override
@Transactional
public IdmContractSliceDto setSliceAsCurrentlyUsing(IdmContractSliceDto slice, Map<String, Serializable> eventProperties) {
// contract)
if (slice.getParentContract() != null) {
// Find other slices with this contract and marked "is using as contract"
// (usually should be returned only one)
IdmContractSliceFilter sliceFilter = new IdmContractSliceFilter();
sliceFilter.setParentContract(slice.getParentContract());
sliceFilter.setUsingAsContract(Boolean.TRUE);
List<IdmContractSliceDto> otherSlices = contractSliceService.find(sliceFilter, null).getContent();
// To all this slices (exclude itself) set "using as contract" on false
//
otherSlices.stream().filter(//
s -> !s.equals(slice)).forEach(s -> {
//
s.setUsingAsContract(false);
// We want only save data, not update contract by slice
contractSliceService.publish(new ContractSliceEvent(ContractSliceEventType.UPDATE, s, ImmutableMap.of(IdmContractSliceService.SKIP_RECALCULATE_CONTRACT_SLICE, Boolean.TRUE)));
});
}
slice.setUsingAsContract(true);
// attribute 'Is using as contract' to true.
if (eventProperties == null) {
return contractSliceService.save(slice);
}
return contractSliceService.publish(new ContractSliceEvent(ContractSliceEventType.UPDATE, slice, ImmutableMap.copyOf(eventProperties))).getContent();
}
use of eu.bcvsolutions.idm.core.model.event.ContractSliceEvent in project CzechIdMng by bcvsolutions.
the class ContractSliceSynchronizationExecutor method callProvisioningForEntity.
/**
* Call provisioning for given account
*
* @param entity
* @param entityType
* @param logItem
*/
@Override
protected void callProvisioningForEntity(IdmContractSliceDto entity, SystemEntityType entityType, SysSyncItemLogDto logItem) {
addToItemLog(logItem, MessageFormat.format("Call provisioning (process IdmContractSliceDto.UPDATE) for contract ({0}) with position ({1}).", entity.getId(), entity.getPosition()));
ContractSliceEvent event = new ContractSliceEvent(ContractSliceEventType.UPDATE, entity);
// 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);
//
// Skip recalculation, now isn't needed
event.getProperties().put(IdmContractSliceService.SKIP_RECALCULATE_CONTRACT_SLICE, Boolean.TRUE);
entityEventManager.process(event);
}
use of eu.bcvsolutions.idm.core.model.event.ContractSliceEvent 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);
}
Aggregations