[jbpm-commits] JBoss JBPM SVN: r5733 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/internal/xml and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Oct 12 13:44:34 EDT 2009
Author: koen.aers at jboss.com
Date: 2009-10-12 13:44:34 -0400 (Mon, 12 Oct 2009)
New Revision: 5733
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.2.xsd
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java
Log:
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.2.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.2.xsd 2009-10-12 13:22:58 UTC (rev 5732)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.2.xsd 2009-10-12 17:44:34 UTC (rev 5733)
@@ -1183,4 +1183,26 @@
<annotation><documentation>Reference to the email template</documentation></annotation>
<restriction base="string"></restriction>
</simpleType>
+
+ <element name="migrate-instances">
+ <annotation><documentation>Information to migrate instances of previously deployed process definitions
+ to the new one</documentation></annotation>
+ <complexType>
+ <sequence>
+ <element name="activity-mapping" minOccurs="0" maxOccurs="unbounded">
+ <annotation><documentation>One activity mapping will be present for each activity of which the name changed.</documentation></annotation>
+ <complexType>
+ <attribute name="old-name" type="string" use="required">
+ <annotation><documentation>The name of the activity in the previously deployed process definition.</documentation></annotation>
+ </attribute>
+ <attribute name="new-name" type="string" use="required">
+ <annotation><documentation>The name of the activity in the newly deployed process definition</documentation></annotation>
+ </attribute>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+
+
</schema>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-10-12 13:22:58 UTC (rev 5732)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-10-12 17:44:34 UTC (rev 5733)
@@ -80,6 +80,8 @@
import org.jbpm.pvm.internal.xml.Parser;
import org.jbpm.pvm.internal.xml.ProblemImpl;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @author Tom Baeyens
@@ -287,7 +289,17 @@
migrations = new HashMap<ProcessDefinition, MigrationDescriptor>();
parse.contextMapPut(Parse.CONTEXT_KEY_MIGRATIONS, migrations);
}
- migrations.put(processDefinition, new MigrationDescriptor());
+ MigrationDescriptor migrationDescriptor = new MigrationDescriptor();
+ NodeList activityMappings = migrationElement.getElementsByTagName("activity-mapping");
+ for (int i = 0; i < activityMappings.getLength(); i++) {
+ Node activityMapping = activityMappings.item(i);
+ if (activityMapping instanceof Element) {
+ String oldName = ((Element)activityMapping).getAttribute("old-name");
+ String newName = ((Element)activityMapping).getAttribute("new-name");
+ migrationDescriptor.addMigrationElement(MigrationDescriptor.ACTIVITY_TYPE, oldName, newName);
+ }
+ }
+ migrations.put(processDefinition, migrationDescriptor);
}
public void parseActivities(Element documentElement, Parse parse, CompositeElementImpl compositeElement) {
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java 2009-10-12 13:22:58 UTC (rev 5732)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/migration/InstanceMigratorTest.java 2009-10-12 17:44:34 UTC (rev 5733)
@@ -28,13 +28,19 @@
" <transition to='foo'/>" +
" </start>" +
" <state name='foo'>" +
- " <transition to='bar'/>" +
+ " <transition to='fu'/>" +
" </state>" +
- " <state name='bar'>" +
+ " <state name='fu'>" +
+ " <transition name='to end' to='end'/>" +
+ " <transition name='to baz' to='baz'/>" +
+ " </state>" +
+ " <state name='baz'>" +
" <transition to='end'/>" +
" </state>" +
" <end name='end'/>" +
- " <migrate-instances/>" +
+ " <migrate-instances>" +
+ " <activity-mapping old-name='bar' new-name='fu'/>" +
+ " </migrate-instances>" +
"</process>";
@@ -54,7 +60,8 @@
.createProcessInstanceQuery()
.processDefinitionId(processDefinition1.getId())
.uniqueResult();
- assertNotNull(processInstance1.findActiveExecutionIn("bar"));
+ execution = processInstance1.findActiveExecutionIn("bar");
+ assertNotNull(execution);
String deploymentId2 = repositoryService.createDeployment()
.addResourceFromString("foobar.jpdl.xml", secondVersion)
@@ -67,9 +74,18 @@
.createProcessInstanceQuery()
.processDefinitionId(processDefinition2.getId())
.uniqueResult();
+ execution = processInstance2.findActiveExecutionIn("fu");
+ assertNotNull(execution);
- assertNotNull(processInstance2);
+ executionService.signalExecutionById(execution.getId(), "to baz");
+ processInstance2 = executionService
+ .createProcessInstanceQuery()
+ .processDefinitionId(processDefinition2.getId())
+ .uniqueResult();
+ execution = processInstance2.findActiveExecutionIn("baz");
+ assertNotNull(execution);
+
repositoryService.deleteDeploymentCascade(deploymentId2);
repositoryService.deleteDeploymentCascade(deploymentId1);
More information about the jbpm-commits
mailing list