提交 9dec1769 编写于 作者: E Elias Ricken de Medeiros 提交者: salaboy

Allow process deployment from different folder levels (#2086)

Can deploy at the same time processes located under
- /processes
- /any/path/to/processes
上级 7e102619
......@@ -36,7 +36,7 @@ public class ActivitiProperties {
private String databaseSchema;
private boolean isDbHistoryUsed = false;
private HistoryLevel historyLevel = HistoryLevel.NONE;
private String processDefinitionLocationPrefix = "classpath:/processes/";
private String processDefinitionLocationPrefix = "classpath:**/processes/";
private List<String> processDefinitionLocationSuffixes = Arrays.asList("**.bpmn20.xml", "**.bpmn");
private List<String> customMybatisMappers;
private List<String> customMybatisXMLMappers;
......
......@@ -44,22 +44,15 @@ public class ProcessDefinitionResourceFinder {
public List<Resource> discoverProcessDefinitionResources() throws IOException {
List<Resource> resources = new ArrayList<>();
if (activitiProperties.isCheckProcessDefinitions()) {
Resource processFolder = resourceLoader.getResource(activitiProperties.getProcessDefinitionLocationPrefix());
if (processFolder.exists()) {
for (String suffix : activitiProperties.getProcessDefinitionLocationSuffixes()) {
String path = activitiProperties.getProcessDefinitionLocationPrefix() + suffix;
resources.addAll(Arrays.asList(resourceLoader.getResources(path)));
}
if (resources.isEmpty()) {
LOGGER.info("No process definitions were found for auto-deployment in the location `" + activitiProperties.getProcessDefinitionLocationPrefix() + "`");
} else {
List<String> resourcesNames = resources.stream().map(Resource::getFilename).collect(Collectors.toList());
LOGGER.info("The following process definition files will be deployed: " + resourcesNames);
}
for (String suffix : activitiProperties.getProcessDefinitionLocationSuffixes()) {
String path = activitiProperties.getProcessDefinitionLocationPrefix() + suffix;
resources.addAll(Arrays.asList(resourceLoader.getResources(path)));
}
if (resources.isEmpty()) {
LOGGER.info("No process definitions were found for auto-deployment in the location `" + activitiProperties.getProcessDefinitionLocationPrefix() + "`");
} else {
LOGGER.warn("Unable to locate folder `" + activitiProperties.getProcessDefinitionLocationPrefix() +
"`. No process definitions will be auto-deployed");
List<String> resourcesNames = resources.stream().map(Resource::getFilename).collect(Collectors.toList());
LOGGER.info("The following process definition files will be deployed: " + resourcesNames);
}
}
return resources;
......
......@@ -50,13 +50,14 @@ public class ProcessDefinitionResourceFinderIT {
.contains("categorize-human.bpmn20.xml",
"categorize-image.bpmn20.xml",
"gw.bpmn20.xml",
"waiter.bpmn20.xml");
"waiter.bpmn20.xml",
"categorize-human-long-path.bpmn20.xml");//coming from folder long/path/for/processes
}
@Test
public void shouldReturnEmptyListWhenNoProcessDefIsFoundOnSpecifiedFolder() throws Exception {
//given
given(activitiProperties.getProcessDefinitionLocationPrefix()).willReturn("classpath:/processes-empty/");
given(activitiProperties.getProcessDefinitionLocationPrefix()).willReturn("classpath:**/processes-empty/");
//when
List<Resource> resources = resourceFinder.discoverProcessDefinitionResources();
......@@ -68,7 +69,7 @@ public class ProcessDefinitionResourceFinderIT {
@Test
public void shouldReturnEmptyListWhenProcessDefinitionsFolderIsNotFound() throws Exception {
//given
given(activitiProperties.getProcessDefinitionLocationPrefix()).willReturn("classpath:/does-not-exist/");
given(activitiProperties.getProcessDefinitionLocationPrefix()).willReturn("classpath:**/does-not-exist/");
//when
List<Resource> resources = resourceFinder.discoverProcessDefinitionResources();
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Alfresco, Inc. and/or its affiliates.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0v7t65f" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="categorizeHumanLongPathLocationProcess" name="categorizeHumanLongPathLocationProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_14mnde3</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:exclusiveGateway id="ExclusiveGateway_0c36qc6" name="Image Accepted?">
<bpmn:incoming>SequenceFlow_0tpcd7z</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0tsc63v</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_049fuit</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="SequenceFlow_0tsc63v" name="yes" sourceRef="ExclusiveGateway_0c36qc6" targetRef="Task_0snvh02">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${approved == true}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_049fuit" name="no" sourceRef="ExclusiveGateway_0c36qc6" targetRef="Task_1asxw87">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${approved == false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:endEvent id="EndEvent_13bsqqd">
<bpmn:incoming>SequenceFlow_0upfncf</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0upfncf" sourceRef="Task_1asxw87" targetRef="EndEvent_13bsqqd" />
<bpmn:endEvent id="EndEvent_1ogwwp9">
<bpmn:incoming>SequenceFlow_1nn2llw</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1nn2llw" sourceRef="Task_0snvh02" targetRef="EndEvent_1ogwwp9" />
<bpmn:serviceTask id="Task_0snvh02" name="Tag categorized Image" implementation="tagImageConnector">
<bpmn:incoming>SequenceFlow_0tsc63v</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1nn2llw</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="Task_1asxw87" name="Discard and Notify user" implementation="discardImageConnector">
<bpmn:incoming>SequenceFlow_049fuit</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0upfncf</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_14mnde3" sourceRef="StartEvent_1" targetRef="Task_0igeuk7" />
<bpmn:sequenceFlow id="SequenceFlow_0tpcd7z" sourceRef="Task_0igeuk7" targetRef="ExclusiveGateway_0c36qc6" />
<bpmn:userTask id="Task_0igeuk7" name="Review Image">
<bpmn:incoming>SequenceFlow_14mnde3</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0tpcd7z</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="categorizeHumanLongPathLocationProcess">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ExclusiveGateway_0c36qc6_di" bpmnElement="ExclusiveGateway_0c36qc6" isMarkerVisible="true">
<dc:Bounds x="409" y="95" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="391" y="65" width="86" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0tsc63v_di" bpmnElement="SequenceFlow_0tsc63v">
<di:waypoint x="459" y="120" />
<di:waypoint x="509" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="475" y="102" width="18" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_049fuit_di" bpmnElement="SequenceFlow_049fuit">
<di:waypoint x="434" y="145" />
<di:waypoint x="434" y="230" />
<di:waypoint x="509" y="230" />
<bpmndi:BPMNLabel>
<dc:Bounds x="443" y="185" width="13" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_13bsqqd_di" bpmnElement="EndEvent_13bsqqd">
<dc:Bounds x="659" y="212" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0upfncf_di" bpmnElement="SequenceFlow_0upfncf">
<di:waypoint x="609" y="230" />
<di:waypoint x="659" y="230" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1ogwwp9_di" bpmnElement="EndEvent_1ogwwp9">
<dc:Bounds x="659" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1nn2llw_di" bpmnElement="SequenceFlow_1nn2llw">
<di:waypoint x="609" y="120" />
<di:waypoint x="659" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0z16f74_di" bpmnElement="Task_0snvh02">
<dc:Bounds x="509" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_14mct68_di" bpmnElement="Task_1asxw87">
<dc:Bounds x="509" y="190" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_14mnde3_di" bpmnElement="SequenceFlow_14mnde3">
<di:waypoint x="209" y="120" />
<di:waypoint x="259" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0tpcd7z_di" bpmnElement="SequenceFlow_0tpcd7z">
<di:waypoint x="359" y="120" />
<di:waypoint x="409" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1516b3d_di" bpmnElement="Task_0igeuk7">
<dc:Bounds x="259" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册