Author: jim.ma
Date: 2009-07-31 03:18:01 -0400 (Fri, 31 Jul 2009)
New Revision: 5407
Modified:
jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java
jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
jbpm4/trunk/modules/migration/src/test/resources/businesstrip.xml
Log:
JBPM-2388:Added task reminder and notification conversion support
Modified:
jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java
===================================================================
---
jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java 2009-07-31
07:13:39 UTC (rev 5406)
+++
jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java 2009-07-31
07:18:01 UTC (rev 5407)
@@ -420,32 +420,10 @@
addWarning("Unsupported condition attribute converstion for task : " +
taskElement.asXML());
}
- // parse common subelements
- convertTaskTimers(taskElement, jpdlElement);
- convertEvents(taskElement, jpdlElement);
- convertExceptionHandlers(taskElement, jpdlElement);
-
- String duedateText = taskElement.attributeValue("duedate");
+
+ //The converted the elements in task should be in this sequence
+ //assignment-handler, on, notification, reminder, timer
- if (duedateText != null) {
- addWarning("Unsupported duedateDate attribute converstion for task : " +
taskElement.asXML());
- }
-
- String priorityText = taskElement.attributeValue("priority");
- if (priorityText != null) {
- addWarning("Unsupported priorityText attribute converstion for task : " +
taskElement.asXML());
- }
-
- String blockingText = taskElement.attributeValue("blocking");
- if (blockingText != null) {
- addWarning("Unsupported blocking attribute converstion for task : " +
taskElement.asXML());
- }
-
- String signallingText = taskElement.attributeValue("signalling");
- if (signallingText != null) {
- addWarning("Unsupported signallingText attribute converstion for task : "
+ taskElement.asXML());
- }
-
// assignment
String swimlaneName = taskElement.attributeValue("swimlane");
Element assignmentElement = taskElement.element("assignment");
@@ -485,13 +463,45 @@
// the user has to manage assignment manually, so we better inform him/her.
log.info("process xml information: no swimlane or assignment specified for
task '" + taskElement.asXML() + "'");
}
-
+
+ //event elements
+ convertEvents(taskElement, task4);
+
String notificationsText = taskElement.attributeValue("notify");
if (notificationsText != null &&
("true".equalsIgnoreCase(notificationsText)
|| "on".equalsIgnoreCase(notificationsText) ||
"yes".equalsIgnoreCase(notificationsText))) {
- addWarning("Unsupported notify converstion for task : " +
taskElement.asXML());
+ //TODO:Review if there is "continue" attribute to converted
+ Element notify = task4.addElement("notification");
+ notify.addAttribute("continue", "sync");
}
+ //Reminder elements
+ convertTaskReminders(taskElement, task4);
+ //timer elements
+ convertTaskTimers(taskElement, task4);
+ convertExceptionHandlers(taskElement, task4);
+
+ String duedateText = taskElement.attributeValue("duedate");
+
+ if (duedateText != null) {
+ addWarning("Unsupported duedateDate attribute converstion for task : " +
taskElement.asXML());
+ }
+
+ String priorityText = taskElement.attributeValue("priority");
+ if (priorityText != null) {
+ addWarning("Unsupported priorityText attribute converstion for task : " +
taskElement.asXML());
+ }
+
+ String blockingText = taskElement.attributeValue("blocking");
+ if (blockingText != null) {
+ addWarning("Unsupported blocking attribute converstion for task : " +
taskElement.asXML());
+ }
+
+ String signallingText = taskElement.attributeValue("signalling");
+ if (signallingText != null) {
+ addWarning("Unsupported signallingText attribute converstion for task : "
+ taskElement.asXML());
+ }
+
Element taskControllerElement = taskElement.element("controller");
if (taskControllerElement != null) {
addWarning("Unsupported controller converstion for task : " +
taskElement.asXML());
@@ -601,6 +611,7 @@
CreateTimerAction createTimerAction = new CreateTimerAction();
Element onElement = jpdl4Element.addElement("on");
+ //TODO: Look at how to map the event type : start , end and take
onElement.addAttribute("event", "timeout");
createTimerAction.createConvertedElement(timerElement, onElement);
createTimerAction.read(timerElement, this);
@@ -614,12 +625,28 @@
Iterator<?> iter = taskElement.elementIterator();
while (iter.hasNext()) {
Element element = (Element)iter.next();
- if (("timer".equals(element.getName())) ||
("reminder".equals(element.getName())))
+ if (("timer".equals(element.getName())))
{
convertTaskTimer(element, jdpl4Element);
}
}
}
+
+
+ protected void convertTaskReminders(Element taskElement, Element jdpl4Element) {
+ Iterator<?> iter = taskElement.elementIterator();
+ while (iter.hasNext()) {
+ Element element = (Element)iter.next();
+ if ("reminder".equals(element.getName()))
+ {
+ convertTaskTimer(element, jdpl4Element);
+ }
+ }
+ }
+
+
+
+
protected void convertTaskTimer(Element timerElement, Element jpdl4Element) {
if ("timer".equals(timerElement.getName())) {
@@ -627,8 +654,7 @@
String name = timerElement.attributeValue("name",
timerElement.getName());
if (name == null)
name = generateTimerName();
- Element onEle = jpdl4Element.addElement("on");
- onEle.addAttribute("event", "timeout");
+;
Element timer = jpdl4Element.addElement("timer");
String dueDate = timerElement.attributeValue("duedate");
@@ -653,18 +679,27 @@
repeat = null;
addProblem(new Problem(Problem.LEVEL_WARNING, "ignoring repeat on timer
with transition "+ timerElement.asXML()));
}
-
- timer.addAttribute("duedata", dueDate);
this.convertSingleAction(timerElement, timer);
}
else
{
- //TODO:Create mail node for <task-reminder> element
+ Element reminder = jpdl4Element.addElement("reminder");
+ String dueDate = timerElement.attributeValue("duedate");
+ if (dueDate==null) {
+ addWarning("no duedate specified in reminder element '"+
timerElement.asXML()+"'");
+ } else {
+ reminder.addAttribute("duedate", dueDate);
+ }
+ String repeat = timerElement.attributeValue("repeat");
+ if ( "true".equalsIgnoreCase(repeat)
+ || "yes".equalsIgnoreCase(repeat) ) {
+ repeat = dueDate;
+ }
+ reminder.addAttribute("repeat", repeat);
+ //TODO: review it if there is no "continue" attribute to converted
+
}
-
- //TODO: Revist if we need to handle cancelTimerAction
-
}
public Element convertSingleAction(Element jpdl3NodeElement, Element jpdl4Element) {
Modified:
jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
---
jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-07-31
07:13:39 UTC (rev 5406)
+++
jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-07-31
07:18:01 UTC (rev 5407)
@@ -45,8 +45,9 @@
testConvert("simple.xml");
}
- @Ignore
+ @Test
public void testBusinessTrip() throws Exception {
+ setUpEnviroment();
testConvert("businesstrip.xml");
}
@@ -100,7 +101,6 @@
}
@Test
- //Unsupported super-sate and mail node conversion
public void testSuperStateAndMailNode() throws Exception {
InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream("superstate-mail.xml");
@@ -166,7 +166,7 @@
InputSource ins = new InputSource(inputStream);
Jpdl3Converter converter = new Jpdl3Converter(ins);
Document doc = converter.readAndConvert();
- System.out.println(doc.asXML());
+ //System.out.println(doc.asXML());
return doc;
}
@@ -188,7 +188,13 @@
+ " <to addresses='${addressee}' />"
+ " <subject>rectify ${newspaper}</subject>"
+ " <text>${newspaper} ${date} ${details}</text>"
- + " </mail-template>"
+ + " </mail-template>"
+ + " <mail-template name='task-notification'> "
+ + " <to addresses='${addressee}' />"
+ + " <subject>rectify ${newspaper}</subject>"
+ + " <text>${newspaper} ${date} ${details}</text>"
+ + " </mail-template>"
+
+ " </process-engine-context> </jbpm-configuration>");
environmentFactory.openEnvironment();
Modified: jbpm4/trunk/modules/migration/src/test/resources/businesstrip.xml
===================================================================
--- jbpm4/trunk/modules/migration/src/test/resources/businesstrip.xml 2009-07-31 07:13:39
UTC (rev 5406)
+++ jbpm4/trunk/modules/migration/src/test/resources/businesstrip.xml 2009-07-31 07:18:01
UTC (rev 5407)
@@ -31,21 +31,35 @@
</fork>
<node name="erp update">
- <action
- class="org.jbpm.examples.businesstrip.action.UpdateErpAction">
+ <action class="com.test.NodeEnterAction">
</action>
<transition to="join"></transition>
</node>
<node name="query travel agent db">
- <action
- class="org.jbpm.examples.businesstrip.action.QueryTravelAgentDbAction">
+ <action class="com.test.NodeEnterAction">
</action>
<transition to="join"></transition>
</node>
<task-node name="ticket purchase">
- <task swimlane="accountant" />
+ <task notify="true">
+ <timer duedate="2 business minutes">
+ <action name="timer-action1"
class="com.test.MessageActionHandler" />
+ </timer>
+ <event type="node-enter">
+ <action class="com.test.NodeEnterAction" />
+ </event>
+ <assignment class="com.test.RulesAssignmentHandler">
+ <group>reviewers</group>
+ <objectNames>
+ <element>order</element>
+ </objectNames>
+ <ruleFile>/assignment/Assignment.drl
+ </ruleFile>
+ </assignment>
+ <reminder duedate="3 business day" repeat="true" />
+ </task>
<transition to="query travel agent db"></transition>
</task-node>