[jbpm-commits] JBoss JBPM SVN: r6124 - in jbpm4/trunk/modules/bpmn/src/main: java/org/jbpm/bpmn/parser and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 25 03:55:31 EST 2010
Author: jbarrez
Date: 2010-01-25 03:55:30 -0500 (Mon, 25 Jan 2010)
New Revision: 6124
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java
Removed:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml
Log:
Work om timer start event
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.bpmn.flownodes;
-
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class EndBinding extends BpmnBinding {
-
- public EndBinding() {
- super("endEvent");
- }
-
- protected EndBinding(String tag) {
- super(tag);
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- EndActivity endActivity = new EndActivity();
-
- Element terminateEventDefinition = XmlUtil.element(element, "terminateEventDefinition");
- if (terminateEventDefinition != null) {
- endActivity.setEndProcessInstance(true);
- } else {
- endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
- }
-
- return endActivity;
- }
-}
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java (from rev 6109, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndEventBinding extends BpmnBinding {
+
+ public EndEventBinding() {
+ super("endEvent");
+ }
+
+ protected EndEventBinding(String tag) {
+ super(tag);
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ EndActivity endActivity = new EndActivity();
+
+ Element terminateEventDefinition = XmlUtil.element(element, "terminateEventDefinition");
+ if (terminateEventDefinition != null) {
+ endActivity.setEndProcessInstance(true);
+ } else {
+ endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
+ }
+
+ return endActivity;
+ }
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -21,13 +21,7 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.jbpm.pvm.internal.cal.CronExpression;
-import org.jbpm.pvm.internal.cal.Duration;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.EventImpl;
import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
@@ -50,7 +44,7 @@
String id = XmlUtil.attribute(element, "id");
Element eventDefinition = XmlUtil.element(element);
if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
- return createIntermediateTimerCatchEvent(id, eventDefinition, parse);
+ return createIntermediateTimerCatchEvent(id, eventDefinition, (BpmnParser) parser, parse);
} else {
parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
}
@@ -59,65 +53,23 @@
}
protected IntermediateCatchTimerEvent createIntermediateTimerCatchEvent(String catchEventId,
- Element eventDefinitionElement, Parse parse) {
+ Element eventDefinitionElement, BpmnParser parser, Parse parse) {
- Element timeDate = XmlUtil.element(eventDefinitionElement, "timeDate");
- Element timeCycle = XmlUtil.element(eventDefinitionElement, "timeCycle");
-
- if ( (timeDate != null && timeCycle != null)
- || (timeDate == null && timeCycle == null) ) {
- parse.addProblem("Intermediate catch event '" + catchEventId +
- "' requires either a timeDate or a timeCycle definition (but not both)");
- return null;
- }
-
IntermediateCatchTimerEvent intermediateCatchTimerEvent = new IntermediateCatchTimerEvent();
+ TimerDefinitionImpl timerDefinition = parser.parseTimerEventDefinition(eventDefinitionElement, parse, catchEventId);
+
+ // Attach the timerDefinition to the current activity.
+ // That way, the PVM will automatically pcik it up when the execution arrives in the activity.
ActivityImpl activity = parse.contextStackFind(ActivityImpl.class);
+ activity.addTimerDefinition(timerDefinition);
- // Create timerDefinition and attach an associated event to the activty
- TimerDefinitionImpl timerDefinition = activity.createTimerDefinition();
+ // The timer will fire an event on which this class will listen.
String eventName = "INTERMEDIATE_TIMER_" + catchEventId;
timerDefinition.setEventName(eventName);
EventImpl timerEvent = activity.createEvent(eventName);
timerEvent.createEventListenerReference(intermediateCatchTimerEvent);
-
- if (timeDate != null) {
- parseTimeDate(catchEventId, parse, timeDate, timerDefinition);
- }
-
- if (timeCycle != null) {
- parseTimeCycle(catchEventId, parse, timeCycle, timerDefinition);
- }
return intermediateCatchTimerEvent;
}
- private void parseTimeCycle(String catchEventId, Parse parse, Element timeCycle, TimerDefinitionImpl timerDefinition) {
- String cycleExpression = timeCycle.getTextContent();
- if (Duration.isValidExpression(cycleExpression)) {
- timerDefinition.setDueDateDescription(cycleExpression);
- } else if (CronExpression.isValidExpression(cycleExpression)) {
- timerDefinition.setCronExpression(cycleExpression);
- } else {
- parse.addProblem("couldn't parse timeDate duration '"+ cycleExpression
- + "' on intermediate catch timer event " + catchEventId);
- }
- }
-
- protected void parseTimeDate(String catchEventId, Parse parse, Element timeDate, TimerDefinitionImpl timerDefinition) {
- String dueDateTime = timeDate.getTextContent();
- String dueDateTimeFormatText = (String) EnvironmentImpl.getFromCurrent("jbpm.duedatetime.format", false);
- if (dueDateTimeFormatText==null) {
- dueDateTimeFormatText = "dd/MM/yyyy HH:mm:ss";
- }
- SimpleDateFormat dateFormat = new SimpleDateFormat(dueDateTimeFormatText);
- try {
- Date duedatetimeDate = dateFormat.parse(dueDateTime);
- timerDefinition.setDueDate(duedatetimeDate);
- } catch (ParseException e) {
- parse.addProblem("couldn't parse timeDate '"+ dueDateTime
- + "' on intermediate catch timer event " + catchEventId, e);
- }
- }
-
}
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.bpmn.flownodes;
-
-import org.jbpm.bpmn.model.BpmnProcessDefinition;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-
-public class StartBinding extends BpmnBinding {
-
- public StartBinding() {
- super("startEvent");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- ActivityImpl startActivity = parse.contextStackFind(ActivityImpl.class);
- BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
-
- if (processDefinition.getInitial()==null) {
- processDefinition.setInitial(startActivity);
-
- } else if (startActivity.getParentActivity()==null) {
- parse.addProblem("multiple start events not yet supported", element);
- }
-
- return new NoneStartEventActivity();
- }
-
- public boolean isNameRequired() {
- return false;
- }
-}
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java (from rev 6109, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+
+public class StartEventBinding extends BpmnBinding {
+
+ public StartEventBinding() {
+ super("startEvent");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ ActivityImpl startActivity = parse.contextStackFind(ActivityImpl.class);
+ BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
+
+ if (processDefinition.getInitial()==null) {
+ processDefinition.setInitial(startActivity);
+
+ } else if (startActivity.getParentActivity()==null) {
+ parse.addProblem("multiple start events not yet supported", element);
+ }
+
+ String id = XmlUtil.attribute(element, "id");
+ Element eventDefinition = XmlUtil.element(element);
+ if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
+ return createTimerStartEvent((BpmnParser) parser, parse, id);
+ } else if (eventDefinition != null){
+ parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
+ }
+
+ return new NoneStartEventActivity(); // default
+ }
+
+ protected TimerStartEvent createTimerStartEvent(BpmnParser parser, Parse parse, String eventId) {
+ TimerStartEvent timerStartEvent = new TimerStartEvent();
+
+ TimerDefinitionImpl timerDefinition = parser.parseTimerEventDefinition(null, parse, eventId);
+
+ // schedule job
+
+ return timerStartEvent;
+ }
+
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -42,7 +42,7 @@
TaskActivity taskActivity = new TaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = ((BpmnParser)parser).parseTaskDefinition(element, parse, scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
taskActivity.setDefault(getDefault());
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class TimerStartEvent extends BpmnActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+
+ }
+
+ public void execute(ExecutionImpl execution) {
+
+ }
+
+
+
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -46,7 +46,7 @@
UserTaskActivity taskActivity = new UserTaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = ((BpmnParser) parser).parseTaskDefinition(element, parse, scopeElement);
addActivityResources(taskDefinition, taskActivity, element, parse);
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -22,7 +22,10 @@
package org.jbpm.bpmn.parser;
import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@@ -37,10 +40,14 @@
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.bpmn.model.SequenceflowCondition;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cal.CronExpression;
+import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.ScopeElementImpl;
+import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
@@ -56,6 +63,7 @@
/**
* @author Tom Baeyens
* @author Bernd Ruecker (bernd.ruecker at camunda.com)
+ * @author Joram Barrez
*/
public class BpmnParser extends Parser {
@@ -308,53 +316,9 @@
}
public void parseDefinition(Element documentElement, Parse parse) {
parseImports(documentElement, parse);
- ///parseItemDefinitions(documentElement, parse);
- //parseMessages(documentElement, parse);
- // parseInterfaces(documentElement, parse);
- // parseResources(documentElement, parse);
}
- // public static void parseAssignmentAttributes(Element element,
- // AssignableDefinitionImpl assignableDefinition, Parse parse) {
- // Element descriptionElement = XmlUtil.element(element, "description");
- // if (descriptionElement!=null) {
- // String description = XmlUtil.getContentText(descriptionElement);
- // assignableDefinition.setDescription(description);
- // }
- //
- // Element assignmentHandlerElement = XmlUtil.element(element,
- // "assignment-handler");
- // if (assignmentHandlerElement!=null) {
- // ObjectDescriptor objectDescriptor =
- // parseObjectDescriptor(assignmentHandlerElement, parse);
- // assignableDefinition.setAssignmentHandlerDescriptor(objectDescriptor);
- // }
- //
- // String assigneeExpression = XmlUtil.attribute(element, "assignee");
- // assignableDefinition.setAssigneeExpression(assigneeExpression);
- //
- // String assigneeExpressionLanguage = XmlUtil.attribute(element,
- // "assignee-lang");
- // assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
- //
- // String candidateUsersExpression = XmlUtil.attribute(element,
- // "candidate-users");
- // assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
- //
- // String candidateUsersExpressionLanguage = XmlUtil.attribute(element,
- // "candidate-users-lang");
- // assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
- //
- // String candidateGroupsExpression = XmlUtil.attribute(element,
- // "candidate-groups");
- // assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
- //
- // String candidateGroupsExpressionLanguage = XmlUtil.attribute(element,
- // "candidate-groups-lang");
- // assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
- // }
-
- public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
+ public TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
String taskName = XmlUtil.attribute(element, "name");
@@ -369,9 +333,66 @@
return taskDefinition;
}
+
+ /**
+ * @param timerEventDefinitionElement The XML element that defines the timer definition
+ * @param activity The activity on which the timer definition must be created
+ * @param eventId The id of the event on which the timer is defined
+ */
+ public TimerDefinitionImpl parseTimerEventDefinition(Element timerEventDefinitionElement, Parse parse, String eventId) {
+
+ Element timeDate = XmlUtil.element(timerEventDefinitionElement, "timeDate");
+ Element timeCycle = XmlUtil.element(timerEventDefinitionElement, "timeCycle");
+
+ if ( (timeDate != null && timeCycle != null)
+ || (timeDate == null && timeCycle == null) ) {
+ parse.addProblem("Intermediate catch event '" + eventId +
+ "' requires either a timeDate or a timeCycle definition (but not both)");
+ return null;
+ }
+
+ TimerDefinitionImpl timerDefinition = new TimerDefinitionImpl();
+
+ if (timeDate != null) {
+ parseTimeDate(eventId, parse, timeDate, timerDefinition);
+ }
+
+ if (timeCycle != null) {
+ parseTimeCycle(eventId, parse, timeCycle, timerDefinition);
+ }
+
+ return timerDefinition;
+ }
+
+ protected void parseTimeCycle(String catchEventId, Parse parse, Element timeCycle, TimerDefinitionImpl timerDefinition) {
+ String cycleExpression = timeCycle.getTextContent();
+ if (Duration.isValidExpression(cycleExpression)) {
+ timerDefinition.setDueDateDescription(cycleExpression);
+ } else if (CronExpression.isValidExpression(cycleExpression)) {
+ timerDefinition.setCronExpression(cycleExpression);
+ } else {
+ parse.addProblem("couldn't parse timeDate duration '"+ cycleExpression
+ + "' on intermediate catch timer event " + catchEventId);
+ }
+ }
+ protected void parseTimeDate(String catchEventId, Parse parse, Element timeDate, TimerDefinitionImpl timerDefinition) {
+ String dueDateTime = timeDate.getTextContent();
+ String dueDateTimeFormatText = (String) EnvironmentImpl.getFromCurrent("jbpm.duedatetime.format", false);
+ if (dueDateTimeFormatText==null) {
+ dueDateTimeFormatText = "dd/MM/yyyy HH:mm:ss";
+ }
+ SimpleDateFormat dateFormat = new SimpleDateFormat(dueDateTimeFormatText);
+ try {
+ Date duedatetimeDate = dateFormat.parse(dueDateTime);
+ timerDefinition.setDueDate(duedatetimeDate);
+ } catch (ParseException e) {
+ parse.addProblem("couldn't parse timeDate '"+ dueDateTime
+ + "' on intermediate catch timer event " + catchEventId, e);
+ }
+ }
- private void parseResources(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseResources(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element resourceElement : XmlUtil.elements(documentElement, "resource")) {
@@ -395,7 +416,7 @@
}
- private void parseInterfaces(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseInterfaces(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element interfaceElement : XmlUtil.elements(documentElement, "interface")) {
for (Element operationElement : XmlUtil.elements(interfaceElement, "operation")) {
@@ -405,14 +426,14 @@
}
}
- private void parseMessages(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseMessages(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element messageElement : XmlUtil.elements(documentElement, "message")) {
processDefinition.getMessages().put(XmlUtil.attribute(messageElement, "id"), messageElement);
}
}
- private void parseItemDefinitions(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseItemDefinitions(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element itemDefinitionElement : XmlUtil.elements(documentElement, "itemDefinition")) {
processDefinition.getItemDefinitions().put(XmlUtil.attribute(itemDefinitionElement, "id"), itemDefinitionElement);
@@ -420,7 +441,7 @@
}
- private void parseImports(Element documentElement, Parse parse) {
+ public void parseImports(Element documentElement, Parse parse) {
}
Modified: jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,8 +1,8 @@
<activities>
<!-- Start / end events -->
- <activity binding="org.jbpm.bpmn.flownodes.StartBinding" />
- <activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.StartEventBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.EndEventBinding" />
<!-- Events -->
<activity binding="org.jbpm.bpmn.flownodes.IntermediateCatchEventBinding" />
More information about the jbpm-commits
mailing list