Java Code Examples for org.flowable.engine.impl.util.CommandContextUtil#getHistoricIdentityLinkService()

The following examples show how to use org.flowable.engine.impl.util.CommandContextUtil#getHistoricIdentityLinkService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void recordIdentityLinkCreated(IdentityLinkEntity identityLink) {
    String processDefinitionId = getProcessDefinitionId(identityLink);

    // It makes no sense storing historic counterpart for an identity link that is related
    // to a process definition only as this is never kept in history
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT, processDefinitionId) && (identityLink.getProcessInstanceId() != null || identityLink.getTaskId() != null)) {
        HistoricIdentityLinkService historicIdentityLinkService = CommandContextUtil.getHistoricIdentityLinkService();
        HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink();
        historicIdentityLinkEntity.setId(identityLink.getId());
        historicIdentityLinkEntity.setGroupId(identityLink.getGroupId());
        historicIdentityLinkEntity.setProcessInstanceId(identityLink.getProcessInstanceId());
        historicIdentityLinkEntity.setTaskId(identityLink.getTaskId());
        historicIdentityLinkEntity.setType(identityLink.getType());
        historicIdentityLinkEntity.setUserId(identityLink.getUserId());
        historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false);
    }
}
 
Example 2
Source File: IdentityLinkCreatedHistoryJsonTransformer.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) {
    HistoricIdentityLinkService historicIdentityLinkService = CommandContextUtil.getHistoricIdentityLinkService();
    HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink();
    historicIdentityLinkEntity.setId(getStringFromJson(historicalData, HistoryJsonConstants.ID));
    historicIdentityLinkEntity.setGroupId(getStringFromJson(historicalData, HistoryJsonConstants.GROUP_ID));
    historicIdentityLinkEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID));
    historicIdentityLinkEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID));
    historicIdentityLinkEntity.setScopeDefinitionId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_DEFINITION_ID));
    historicIdentityLinkEntity.setScopeId(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_ID));
    historicIdentityLinkEntity.setScopeType(getStringFromJson(historicalData, HistoryJsonConstants.SCOPE_TYPE));
    historicIdentityLinkEntity.setType(getStringFromJson(historicalData, HistoryJsonConstants.IDENTITY_LINK_TYPE));
    historicIdentityLinkEntity.setUserId(getStringFromJson(historicalData, HistoryJsonConstants.USER_ID));
    historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false);
}
 
Example 3
Source File: TaskAssigneeChangedHistoryJsonTransformer.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) {
    String assignee = getStringFromJson(historicalData, HistoryJsonConstants.ASSIGNEE);

    String executionId = getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID);
    String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID);
    String runtimeActivityInstanceId = getStringFromJson(historicalData, HistoryJsonConstants.RUNTIME_ACTIVITY_INSTANCE_ID);
    if (StringUtils.isNotEmpty(executionId) && StringUtils.isNotEmpty(activityId)) {
        
        String activityAssigneeHandled = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ASSIGNEE_HANDLED);
        
        if (activityAssigneeHandled == null || !Boolean.valueOf(activityAssigneeHandled)) {
            HistoricActivityInstanceEntity historicActivityInstanceEntity;
            if (StringUtils.isEmpty(runtimeActivityInstanceId)) {
                historicActivityInstanceEntity = findHistoricActivityInstance(commandContext, executionId, activityId);
            } else {
                historicActivityInstanceEntity = CommandContextUtil.getHistoricActivityInstanceEntityManager(commandContext).findById(runtimeActivityInstanceId);
            }
            
            if (historicActivityInstanceEntity == null) {
                // activity instance not found, ignoring event
                return;
            }
            
            historicActivityInstanceEntity.setAssignee(assignee);
        }
    }
    
    String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID);
    if (StringUtils.isNotEmpty(taskId)) {
        HistoricIdentityLinkService historicIdentityLinkService = CommandContextUtil.getHistoricIdentityLinkService();
        HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink();
        historicIdentityLinkEntity.setTaskId(taskId);
        historicIdentityLinkEntity.setType(IdentityLinkType.ASSIGNEE);
        historicIdentityLinkEntity.setUserId(assignee);
        historicIdentityLinkEntity.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); 
        historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false);
    }
}
 
Example 4
Source File: TaskOwnerChangedHistoryJsonTransformer.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) {
    String owner = getStringFromJson(historicalData, HistoryJsonConstants.OWNER);
    String taskId = getStringFromJson(historicalData, HistoryJsonConstants.ID);
    
    HistoricIdentityLinkService historicIdentityLinkService = CommandContextUtil.getHistoricIdentityLinkService();
    HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink();
    historicIdentityLinkEntity.setTaskId(taskId);
    historicIdentityLinkEntity.setType(IdentityLinkType.OWNER);
    historicIdentityLinkEntity.setUserId(owner);
    historicIdentityLinkEntity.setCreateTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); 
    historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false);
}
 
Example 5
Source File: IdentityLinkDeletedHistoryJsonTransformer.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) {
    HistoricIdentityLinkService historicIdentityLinkService = CommandContextUtil.getHistoricIdentityLinkService();
    historicIdentityLinkService.deleteHistoricIdentityLink(getStringFromJson(historicalData, HistoryJsonConstants.ID));
}