Search in sources :

Example 11 with ContractSliceEvent

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)));
}
Also used : ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with ContractSliceEvent

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();
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) ContractSliceEventType(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent.ContractSliceEventType) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ContractGuaranteeEventType(eu.bcvsolutions.idm.core.model.event.ContractGuaranteeEvent.ContractGuaranteeEventType) ContractGuaranteeEvent(eu.bcvsolutions.idm.core.model.event.ContractGuaranteeEvent) ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) AutomaticRoleManager(eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager) Map(java.util.Map) ContractSliceConfiguration(eu.bcvsolutions.idm.core.api.config.domain.ContractSliceConfiguration) Pageable(org.springframework.data.domain.Pageable) Objects(com.google.common.base.Objects) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) ImmutableMap(com.google.common.collect.ImmutableMap) IdentityContractEventType(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent.IdentityContractEventType) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) Serializable(java.io.Serializable) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) List(java.util.List) LocalDate(java.time.LocalDate) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) IdmContractSliceService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceService) HashMap(java.util.HashMap) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) Strings(com.google.common.base.Strings) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) Service(org.springframework.stereotype.Service) IdmContractSliceGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractSliceGuaranteeService) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Logger(org.slf4j.Logger) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) IdmContractGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractGuaranteeService) ApplicationContext(org.springframework.context.ApplicationContext) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) ChronoUnit(java.time.temporal.ChronoUnit) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) Comparator(java.util.Comparator) ContractSliceManager(eu.bcvsolutions.idm.core.api.service.ContractSliceManager) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with ContractSliceEvent

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);
}
Also used : ContractSliceEvent(eu.bcvsolutions.idm.core.model.event.ContractSliceEvent)

Example 14 with ContractSliceEvent

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

Aggregations

ContractSliceEvent (eu.bcvsolutions.idm.core.model.event.ContractSliceEvent)14 IdmContractSliceDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto)13 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)7 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)5 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 Test (org.junit.Test)5 UUID (java.util.UUID)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 IdmContractSliceFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter)3 IdmContractSliceGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter)3 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)3 ContractSliceConfiguration (eu.bcvsolutions.idm.core.api.config.domain.ContractSliceConfiguration)2 Codeable (eu.bcvsolutions.idm.core.api.domain.Codeable)2 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)2 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)2 IdmContractSliceGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto)2 EventContext (eu.bcvsolutions.idm.core.api.event.EventContext)2