提交 2968343e 编写于 作者: F frederikheremans

Merged changes from activiti-5.7-alf branch:

 - Fixed bug in ManagementService (manual create schema didn't work)
 - Added method in BPMNParseListener
上级 b7de216c
......@@ -12,6 +12,8 @@
*/
package org.activiti.cdi.impl.event;
import java.util.List;
import org.activiti.cdi.BusinessProcessEventType;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.bpmn.parser.BpmnParseListener;
......@@ -150,6 +152,10 @@ public class CdiEventSupportBpmnParseListener implements BpmnParseListener {
@Override
public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
}
@Override
public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) {
}
@Override
public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) {
......
......@@ -67,7 +67,7 @@ public class ManagementServiceImpl extends ServiceImpl implements ManagementServ
public String databaseSchemaUpgrade(final Connection connection, final String catalog, final String schema) {
return commandExecutor.execute(new Command<String>(){
public String execute(CommandContext commandContext) {
DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSessionFactory.class);
DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSession.class);
DbSqlSession dbSqlSession = new DbSqlSession(dbSqlSessionFactory, connection, catalog, schema);
commandContext.getSessions().put(DbSqlSession.class, dbSqlSession);
return dbSqlSession.dbSchemaUpdate();
......
......@@ -220,6 +220,10 @@ public class BpmnParse extends Parse {
// Diagram interchange parsing must be after parseProcessDefinitions,
// since it depends and sets values on existing process definition objects
parseDiagramInterchangeElements();
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseRootElement(rootElement, getProcessDefinitions());
}
}
protected void parseDefinitionsAttributes() {
......@@ -1697,6 +1701,7 @@ public class BpmnParse extends Parse {
}
}
@SuppressWarnings("unchecked")
private void parseTimerStartEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity, ProcessDefinitionEntity processDefinition) {
timerActivity.setProperty("type", "startTimerEvent");
TimerDeclarationImpl timerDeclaration = parseTimer(timerEventDefinition, timerActivity, TimerStartEventJobHandler.TYPE);
......
......@@ -13,6 +13,8 @@
package org.activiti.engine.impl.bpmn.parser;
import java.util.List;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
......@@ -48,4 +50,5 @@ public interface BpmnParseListener {
void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity);
void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity);
void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity);
void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions);
}
......@@ -13,6 +13,7 @@
package org.activiti.engine.impl.history.handler;
import java.util.List;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.BpmnParseListener;
......@@ -129,11 +130,13 @@ public class HistoryParseListener implements BpmnParseListener {
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
}
public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
// Remove any history parse listeners already attached: the Multi instance
// behavior will
public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) {
}
public void parseMultiInstanceLoopCharacteristics(Element activityElement,
Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
// Remove any history parse listeners already attached: the Multi instance behavior will
// call them for every instance that will be created
}
// helper methods ///////////////////////////////////////////////////////////
......
/* 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.
*/
package org.activiti.standalone.deploy;
import java.io.InputStream;
import org.activiti.engine.impl.test.ResourceActivitiTestCase;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.test.Deployment;
/**
* @author Frederik Heremans
*/
public class BPMNParseListenerTestCase extends ResourceActivitiTestCase {
public BPMNParseListenerTestCase() {
super("org/activiti/standalone/deploy/bpmn.parse.listener.activiti.cfg.xml");
}
@Deployment
public void testAlterProcessDefinitionKeyWhenDeploying() throws Exception {
// Check if process-definition has different key
assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").count());
assertEquals(1, repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess-modified").count());
// Check if process has an automatically-generated diagram
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess-modified").singleResult();
assertNotNull(processDefinition.getDiagramResourceName());
// Get diagram
InputStream diagramStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());
try {
// Validate if retrieving the image resource works
byte[] buffer = new byte[1];
assertEquals(1, diagramStream.read(buffer));
} finally {
if(diagramStream != null) {
diagramStream.close();
}
}
}
}
/* 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.
*/
package org.activiti.standalone.deploy;
import java.util.List;
import org.activiti.engine.impl.bpmn.parser.BpmnParseListener;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.variable.VariableDeclaration;
/**
* @author Frederik Heremans
*/
public class TestBPMNParseListener implements BpmnParseListener {
public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {
}
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
}
public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) {
}
public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
}
public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) {
}
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
}
public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
}
public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) {
}
public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) {
// Change the key of all deployed process-definitions
for(ProcessDefinitionEntity entity : processDefinitions) {
entity.setKey(entity.getKey() + "-modified");
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="oneTaskProcess" name="The One Task Process">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
<userTask id="theTask" name="my task" />
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
<bpmndi:BPMNDiagram id="oneTaskDiagram">
<bpmndi:BPMNPlane bpmnElement="oneTaskProcess" id="BPMNPlane_MyProcess">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_startevent1">
<omgdc:Bounds height="35" width="35" x="164" y="160"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theTask" id="BPMNShape_usertask1">
<omgdc:Bounds height="55" width="105" x="300" y="150"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEnd" id="BPMNShape_endevent1">
<omgdc:Bounds height="35" width="35" x="500" y="160"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="199" y="177"></omgdi:waypoint>
<omgdi:waypoint x="300" y="177"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="405" y="177"></omgdi:waypoint>
<omgdi:waypoint x="500" y="177"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<!-- Database configurations -->
<property name="history" value="audit" />
<property name="databaseSchemaUpdate" value="true" />
<!-- job executor configurations -->
<property name="jobExecutorActivate" value="false" />
<property name="preParseListeners">
<list>
<bean class="org.activiti.standalone.deploy.TestBPMNParseListener" />
</list>
</property>
</bean>
</beans>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册