Java Code Examples for org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setName()

The following examples show how to use org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setName() . 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 activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordProcessInstanceNameChange(String processInstanceId, String newName) {
  if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
    HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().findById(processInstanceId);

    if (historicProcessInstance != null) {
      historicProcessInstance.setName(newName);
    }
  }
}
 
Example 2
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordProcessInstanceNameChange(String processInstanceId, String newName) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceManager()
                .findHistoricProcessInstance(processInstanceId);

        if (historicProcessInstance != null) {
            historicProcessInstance.setName(newName);
        }
    }
}
 
Example 3
Source File: UpdateProcessInstanceNameEventListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
protected void onInitialized(ActivitiEvent event) {
    if (!(event instanceof ActivitiEntityEventImpl)) {
        return;
    }

    ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event;
    Object entity = activitiEntityEventImpl.getEntity();

    if (!(entity instanceof ExecutionEntity)) {
        return;
    }

    ActivitiEventType activitiEventType = activitiEntityEventImpl.getType();

    if (activitiEventType != ActivitiEventType.ENTITY_INITIALIZED) {
        return;
    }

    ExecutionEntity executionEntity = (ExecutionEntity) entity;

    if (!executionEntity.isProcessInstanceType()) {
        return;
    }

    String processInstanceId = executionEntity.getId();
    String processDefinitionId = executionEntity.getProcessDefinitionId();
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    // {流程标题:title}-{发起人:startUser}-{发起时间:startTime}
    String processDefinitionName = processDefinition.getName();

    if (processDefinitionName == null) {
        processDefinitionName = processDefinition.getKey();
    }

    String userId = Authentication.getAuthenticatedUserId();
    String displayName = userConnector.findById(userId).getDisplayName();
    String processInstanceName = processDefinitionName + "-" + displayName
            + "-"
            + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
    // runtime
    executionEntity.setName(processInstanceName);

    // history
    HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    historicProcessInstanceEntity.setName(processInstanceName);
}