Skip to content

[Feature][API] process definition delete api add check process instance is already running. #3581#3582

Merged
qiaozhanwei merged 5 commits intoapache:devfrom
zhuangchong:dev-feature-api-processdefinition-delete
Sep 7, 2020
Merged

[Feature][API] process definition delete api add check process instance is already running. #3581#3582
qiaozhanwei merged 5 commits intoapache:devfrom
zhuangchong:dev-feature-api-processdefinition-delete

Conversation

@zhuangchong
Copy link
Copy Markdown
Contributor

What is the purpose of the pull request

The workflow definition deletion function is added to check whether there are running workflow instances according to the workflow definition ID and running status. If there are running workflow instances, they are not allowed to be deleted, and a friendly prompt will be given. #3581

Brief change log

New running workflow instance check

ProcessDefinitionServiceImpl.deleteProcessDefinitionById

  // check process instances is already running
        List<ProcessInstance> processInstances =  processInstanceMapper.queryByProcessDefineIdAndStatus(processDefinitionId, Constants.NOT_TERMINATED_STATES);
        if(CollectionUtils.isNotEmpty(processInstances)){
            putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
            return result;
        }

Verify this pull request

(Please pick either of the following options)

This pull request is already covered by existing tests, such as (please describe tests).

ProcessDefinitionControllerTest.testDeleteProcessDefinitionById()


##拉取请求的目的是什么

工作流定义删除功能,新增根据工作流定义ID和运行状态,检查是否有正在运行的工作流实例,如果有正在运行的工作流实例,不允许删除,友情提示。

##简要变更日志

新增正在运行工作流实例检查

ProcessDefinitionServiceImpl.deleteProcessDefinitionById

  // check process instances is already running
        List<ProcessInstance> processInstances =  processInstanceMapper.queryByProcessDefineIdAndStatus(processDefinitionId, Constants.NOT_TERMINATED_STATES);
        if(CollectionUtils.isNotEmpty(processInstances)){
            putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
            return result;
        }

##验证此请求

(请选择以下任一选项)

此请求已被现有测试覆盖,例如*(请描述测试)*。

ProcessDefinitionControllerTest.testDeleteProcessDefinitionById()

Copy link
Copy Markdown
Contributor

@qiaozhanwei qiaozhanwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resolve conflicts
+1

@zhuangchong
Copy link
Copy Markdown
Contributor Author

please resolve conflicts
+1

ok,resolved

Comment on lines +492 to +496
List<ProcessInstance> processInstances = processInstanceMapper.queryByProcessDefineIdAndStatus(processDefinitionId, Constants.NOT_TERMINATED_STATES);
if (CollectionUtils.isNotEmpty(processInstances)) {
putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
return result;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
List<ProcessInstance> processInstances = processInstanceMapper.queryByProcessDefineIdAndStatus(processDefinitionId, Constants.NOT_TERMINATED_STATES);
if (CollectionUtils.isNotEmpty(processInstances)) {
putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
return result;
}
List<ProcessInstance> processInstances = processInstanceService.queryByProcessDefineIdAndStatus(processDefinitionId, Constants.NOT_TERMINATED_STATES);
if (CollectionUtils.isNotEmpty(processInstances)) {
putMsg(result, Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
return result;
}

Hi,
In processDefinitionService service layer, it is not recommended straightly use processInstanceMapper dao layer, this part should be in processInstanceService, use processInstanceService here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Processinstanceservice has been used. Processinstanceservice should implement the interface. There are contributors who have submitted branches. I have not changed this.


已使用processInstanceService ,processInstanceService 应该实现接口,已经有贡献者提交分支,这块我没有改.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

50.0% 50.0% Coverage
0.0% 0.0% Duplication

@zhuangchong
Copy link
Copy Markdown
Contributor Author

@dailidong @qiaozhanwei done. Please help to review.

@qiaozhanwei qiaozhanwei merged commit 21a90f2 into apache:dev Sep 7, 2020
@zhuangchong zhuangchong deleted the dev-feature-api-processdefinition-delete branch September 7, 2020 04:26
@zhuangchong zhuangchong restored the dev-feature-api-processdefinition-delete branch September 7, 2020 04:29
@zhuangchong zhuangchong deleted the dev-feature-api-processdefinition-delete branch September 7, 2020 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants