JBoss JBPM SVN: r4885 - jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-25 09:34:43 -0400 (Mon, 25 May 2009)
New Revision: 4885
Modified:
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml
Log:
event listener process graphics update
Modified: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml 2009-05-25 10:08:37 UTC (rev 4884)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml 2009-05-25 13:34:43 UTC (rev 4885)
@@ -2,7 +2,7 @@
<process name="AsyncEventListener" xmlns="http://jbpm.org/4.0/jpdl">
- <start name="start" g="22,69,80,40">
+ <start name="start" g="27,27,80,40">
<transition to="wait">
<mail continue="async">
<to addresses="you@yourcompany" />
@@ -12,6 +12,6 @@
</transition>
</start>
- <state name="wait"/>
-
+ <state name="wait" g="97,26,82,49"/>
+
</process>
15 years, 1 month
JBoss JBPM SVN: r4884 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/async and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-25 06:08:37 -0400 (Mon, 25 May 2009)
New Revision: 4884
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/eventlistener/
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.mail.properties
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener/
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
Log:
JBPM-2256 async moved event listeners to dev guide
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-05-25 09:14:46 UTC (rev 4883)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-05-25 10:08:37 UTC (rev 4884)
@@ -36,7 +36,7 @@
JobQuery processInstanceId(String processInstanceId);
- JobQuery exception();
+ JobQuery exception(boolean hasException);
JobQuery orderAsc(String property);
JobQuery orderDesc(String property);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-05-25 09:14:46 UTC (rev 4883)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-05-25 10:08:37 UTC (rev 4884)
@@ -42,7 +42,7 @@
protected boolean messagesOnly = false;
protected boolean timersOnly = false;
protected String processInstanceId = null;
- protected boolean exception = false;
+ protected Boolean exception;
public JobQueryImpl(CommandService commandService) {
super(commandService);
@@ -65,10 +65,12 @@
appendWhereClause("j.processInstance.id = '"+processInstanceId+"' ", hql);
}
- if (exception) {
- appendWhereClause("j.exception is not null ", hql);
- } else {
- appendWhereClause("j.exception is null ", hql);
+ if (exception!=null) {
+ if (exception) {
+ appendWhereClause("j.exception is not null ", hql);
+ } else {
+ appendWhereClause("j.exception is null ", hql);
+ }
}
return hql.toString();
@@ -95,8 +97,8 @@
return this;
}
- public JobQuery exception() {
- this.exception = true;
+ public JobQuery exception(boolean hasException) {
+ this.exception = hasException;
return this;
}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/eventlistener (from rev 4879, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener)
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java 2009-05-24 19:24:23 UTC (rev 4879)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java 2009-05-25 10:08:37 UTC (rev 4884)
@@ -21,40 +21,26 @@
*/
package org.jbpm.examples.async.eventlistener;
-import java.io.IOException;
-
-import javax.mail.MessagingException;
-
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.job.Job;
import org.jbpm.test.JbpmTestCase;
-import org.subethamail.wiser.Wiser;
-
/**
* @author Tom Baeyens
*/
public class AsyncEventListenerTest extends JbpmTestCase {
long deploymentDbid;
- Wiser wiser = null;
protected void setUp() throws Exception {
super.setUp();
deploymentDbid = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/examples/async/eventlistener/process.jpdl.xml")
- .deploy();
-
- // start mail server
- wiser = new Wiser();
- wiser.setPort(2525);
- wiser.start();
+ .addResourceFromClasspath("org/jbpm/examples/async/eventlistener/process.jpdl.xml")
+ .deploy();
}
protected void tearDown() throws Exception {
- wiser.stop();
-
repositoryService.deleteDeploymentCascade(deploymentDbid);
super.tearDown();
@@ -64,13 +50,17 @@
ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListener");
String processInstanceId = processInstance.getId();
- assertEquals(0, wiser.getMessages().size());
-
Job job = managementService.createJobQuery()
.processInstanceId(processInstanceId)
.uniqueResult();
managementService.executeJob(job.getDbid());
-
- assertEquals(1, wiser.getMessages().size());
+
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .uniqueResult();
+
+ assertNotNull(job);
+ assertTextPresent("could not send email", job.getException());
+ assertEquals(2, job.getRetries());
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-05-25 09:14:46 UTC (rev 4883)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-05-25 10:08:37 UTC (rev 4884)
@@ -92,7 +92,7 @@
managementService.executeJob(messages.get(0).getDbid());
List<Job> errorJobs = managementService.createJobQuery()
- .exception()
+ .exception(true)
.list();
assertEquals(1, errorJobs.size());
@@ -101,6 +101,7 @@
messages = managementService.createJobQuery()
.messages()
+ .exception(false)
.list();
assertEquals(2, messages.size());
Added: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.mail.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.mail.properties (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.mail.properties 2009-05-25 10:08:37 UTC (rev 4884)
@@ -0,0 +1,3 @@
+mail.smtp.host localhost
+mail.smtp.port 2525
+mail.from noreply(a)jbpm.org
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.mail.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/async/eventlistener (from rev 4879, jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener)
15 years, 1 month
JBoss JBPM SVN: r4883 - projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-05-25 05:14:46 -0400 (Mon, 25 May 2009)
New Revision: 4883
Modified:
projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java
Log:
Date format in personal task list
Modified: projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java
===================================================================
--- projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java 2009-05-25 09:14:29 UTC (rev 4882)
+++ projects/gwt-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/task/AssignedTasksView.java 2009-05-25 09:14:46 UTC (rev 4883)
@@ -35,6 +35,7 @@
import org.jboss.bpm.console.client.ApplicationContext;
import org.jboss.bpm.console.client.icons.ConsoleIconBundle;
import org.jboss.bpm.console.client.model.TaskRef;
+import org.jboss.bpm.console.client.model.util.SimpleDateFormat;
import org.jboss.bpm.console.client.task.events.TaskIdentityEvent;
import org.jboss.bpm.console.client.task.events.DetailViewEvent;
import org.jboss.bpm.console.client.util.WindowUtil;
@@ -58,6 +59,8 @@
private TaskDetailView detailsView;
+ private SimpleDateFormat dateFormat = new SimpleDateFormat();
+
public AssignedTasksView(ApplicationContext appContext, TaskDetailView detailsView)
{
super();
@@ -96,7 +99,8 @@
listBox.setText(row, column, item.getName());
break;
case 2:
- listBox.setText(row, column, String.valueOf( item.getDueDate()));
+ String d = item.getDueDate() != null ? dateFormat.format(item.getDueDate()):"";
+ listBox.setText(row, column, d);
break;
default:
throw new RuntimeException("Unexpected column size");
15 years, 1 month
JBoss JBPM SVN: r4882 - projects/gwt-console/trunk.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-05-25 05:14:29 -0400 (Mon, 25 May 2009)
New Revision: 4882
Modified:
projects/gwt-console/trunk/pom.xml
Log:
Move to mosaic 0.1.10
Modified: projects/gwt-console/trunk/pom.xml
===================================================================
--- projects/gwt-console/trunk/pom.xml 2009-05-25 08:47:00 UTC (rev 4881)
+++ projects/gwt-console/trunk/pom.xml 2009-05-25 09:14:29 UTC (rev 4882)
@@ -24,7 +24,7 @@
<gson.version>1.2.2</gson.version>
<gwt.version>1.5.3</gwt.version>
- <gwt-mosaic.version>0.10.0.CR1</gwt-mosaic.version>
+ <gwt-mosaic.version>0.1.10</gwt-mosaic.version>
<gwt-log.version>2.5.2</gwt-log.version>
<jaf.version>1.1</jaf.version>
<javax.ejb.version>3.0</javax.ejb.version>
15 years, 1 month
JBoss JBPM SVN: r4881 - in jbpm4/branches/idm: modules/distro/src/main/files/jboss and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-05-25 04:47:00 -0400 (Mon, 25 May 2009)
New Revision: 4881
Modified:
jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
jbpm4/branches/idm/pom.xml
Log:
* update the idm to 1.0.0.Alpha7.
* Get IDM from the maven repo.
Modified: jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-25 07:39:20 UTC (rev 4880)
+++ jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-25 08:47:00 UTC (rev 4881)
@@ -21,8 +21,11 @@
<property name="jboss.distro.path" value="${jboss.distro.dir}/${jboss.filename}" />
<property name="jboss.server.configuration" value="default" />
<property name="jboss.server.config.dir" value="${jboss.home}/server/${jboss.server.configuration}" />
-
- <property name="jbossidm.home" value="/local/deploy/jbossidm-1.0.0-SNAPSHOT" />
+
+ <property name="jbossidm.version" value="1.0.0.Alpha7" />
+ <property name="jbossidm.home" value="${jboss.parent.dir}/jbossidm-${jbossidm.version}" />
+ <property name="jbossidm.distro.url" value="http://repository.jboss.com/maven2/org/jboss/identity/idm/idm-assembly/${..." />
+ <property name="jbossidm.distro.path" value="${jboss.distro.dir}/idm-assembly-${jbossidm.version}.zip" />
<!-- JDBC PROPERTIES -->
<property file="${user.home}/.jbpm4/jdbc/${database}.properties" />
@@ -103,6 +106,17 @@
<mkdir dir="${jboss.distro.dir}" />
<get src="${jboss.distro.url}" dest="${jboss.distro.path}" />
</target>
+
+ <!-- ### GET JBOSS IDM ###################################################### -->
+ <condition property="is.jbossidm.distro.available">
+ <available file="${jbossidm.distro.path}" />
+ </condition>
+ <target name="get.jbossidm"
+ unless="is.jbossidm.distro.available"
+ description="downloads jboss idm into ${jbossidm.distro.path}">
+ <mkdir dir="${jboss.distro.dir}" />
+ <get src="${jbossidm.distro.url}" dest="${jbossidm.distro.path}" />
+ </target>
<!-- ### MAIN TARGET TO INSTALL JBPM INTO JBOSS ######################### -->
<target name="install.jbpm.into.jboss"
@@ -195,7 +209,8 @@
</copy>
</target>
- <target name="internal.install.idm.into.jboss" if="jbpm.identity.idm">
+ <target name="internal.install.idm.into.jboss" depends="get.jbossidm" if="jbpm.identity.idm">
+ <unzip src="${jbossidm.distro.path}" dest="${jbossidm.home}/.." />
<ant antfile="${jbossidm.home}/jboss/build.xml" target="install.jbossidm.into.jboss">
<property name="jboss.home" value="${jboss.home}" />
<property name="jboss.server.configuration" value="${jboss.server.configuration}" />
Modified: jbpm4/branches/idm/pom.xml
===================================================================
--- jbpm4/branches/idm/pom.xml 2009-05-25 07:39:20 UTC (rev 4880)
+++ jbpm4/branches/idm/pom.xml 2009-05-25 08:47:00 UTC (rev 4881)
@@ -53,7 +53,7 @@
<slf4j.version>1.5.2</slf4j.version>
<hsqldb.version>1.8.0.7</hsqldb.version>
<izpack.version>4.2.1</izpack.version>
- <jboss.identity.version>1.0.0.Alpha5</jboss.identity.version>
+ <jboss.identity.version>1.0.0.Alpha7</jboss.identity.version>
<jboss.j2ee.version>4.2.2.GA</jboss.j2ee.version>
<jbossesb.version>4.4.0.GA</jbossesb.version>
<jboss.client.version>5.0.1.GA</jboss.client.version>
15 years, 1 month
JBoss JBPM SVN: r4880 - jbpm4/trunk/modules/userguide/src/main/docbook/en/images.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-25 03:39:20 -0400 (Mon, 25 May 2009)
New Revision: 4880
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
Log:
JBPM-2256 async fork image update
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
===================================================================
(Binary files differ)
15 years, 1 month
JBoss JBPM SVN: r4879 - in jbpm4/branches/idm/modules: pvm/src/main/java/org/jbpm/pvm/internal/identity/impl and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-05-24 15:24:23 -0400 (Sun, 24 May 2009)
New Revision: 4879
Modified:
jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java
jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
Log:
* update.
Modified: jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java
===================================================================
--- jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java 2009-05-24 18:41:17 UTC (rev 4878)
+++ jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java 2009-05-24 19:24:23 UTC (rev 4879)
@@ -41,7 +41,7 @@
identityService.createUser("johndoe", "John", "Doe");
redhatGroupId = identityService.createGroup("redhat", Group.TYPE_UNIT, null);
-
+ identityService.createMembership(johndoe, redhatGroupId, "Developer");
}
@@ -73,9 +73,11 @@
}
public void testFindGroupsByUser() throws Exception {
- identityService.createMembership(johndoe, redhatGroupId, "Developer");
- List<Group> groups = identityService.findGroupsByUser(johndoe);
+ identityService.createUser("jeffyu", "Jeff", "Yu");
+ identityService.createMembership("jeffyu", redhatGroupId);
+
+ List<Group> groups = identityService.findGroupsByUser("jeffyu");
assertTrue(groups.size() > 0);
for (Group group : groups) {
@@ -84,11 +86,13 @@
return;
}
}
+
+ identityService.deleteUser("jeffyu");
+
fail("Can't find the group by userid: " + johndoe);
}
public void testFindGroupByUserAndGroupType() throws Exception {
- identityService.createMembership(johndoe, redhatGroupId, "Developer");
List<Group> groups = identityService.findGroupsByUserAndGroupType(johndoe, Group.TYPE_UNIT);
assertTrue(groups.size() > 0);
@@ -102,13 +106,13 @@
}
public void testSingleGroup() throws Exception {
- identityService.createUser("joesmoe", "Joe", "Smoe");
+
+ identityService.createUser("joesmoe", "Joe", "Smoe");
identityService.createUser("jackblack", "Jack", "Black");
String jbossId = identityService.createGroup("jboss", Group.TYPE_UNIT, redhatGroupId);
String jbpmId = identityService.createGroup("jbpm", Group.TYPE_UNIT, jbossId);
- identityService.createMembership("johndoe", jbpmId, "developer");
identityService.createMembership("joesmoe", jbpmId, "developer");
identityService.createMembership("jackblack", jbossId, "manager");
Modified: jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
===================================================================
--- jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-24 18:41:17 UTC (rev 4878)
+++ jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-24 19:24:23 UTC (rev 4879)
@@ -247,8 +247,8 @@
try {
org.jboss.identity.idm.api.User idUser = identitySession.getPersistenceManager().findUser(userName);
- Collection<org.jboss.identity.idm.api.Group> idGroups = identitySession.getRelationshipManager()
- .findAssociatedGroups(idUser, groupType);
+ Collection<org.jboss.identity.idm.api.Group> idGroups = identitySession.getRoleManager()
+ .findGroupsWithRelatedRole(idUser, groupType, null);
List<Group> groups = new ArrayList<Group>();
for (org.jboss.identity.idm.api.Group idGroup : idGroups) {
15 years, 1 month
JBoss JBPM SVN: r4878 - in jbpm4/branches/idm/modules: distro/src/main/files/jboss/jbpm.cfg.idm and 4 other directories.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-05-24 14:41:17 -0400 (Sun, 24 May 2009)
New Revision: 4878
Added:
jbpm4/branches/idm/modules/distro/src/main/files/jboss/jbpm.cfg.idm/jbpm.integration.test.cfg.xml
jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/
jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java
Modified:
jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
jbpm4/branches/idm/modules/examples/src/test/resources/jbpm.cfg.xml
jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
Log:
Update the build.xml, so the integration test can have correct jbpm.cfg.xml.
* Update the identity test case and its impl.
Modified: jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-23 13:48:09 UTC (rev 4877)
+++ jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-24 18:41:17 UTC (rev 4878)
@@ -205,11 +205,9 @@
</target>
<target name="internal.install.jbpm.into.jboss.identity" if="jbpm.identity.idm">
- <copy todir="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" overwrite="true">
- <fileset dir="${jbpm.home}/jboss/jbpm.cfg.idm">
- <include name="jbpm.cfg.xml"/>
- </fileset>
- </copy>
+ <copy file="${jbpm.home}/jboss/jbpm.cfg.idm/jbpm.cfg.xml"
+ tofile="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml"
+ overwrite="true" />
</target>
<!-- ### THE JBOSS INTEGRATION TEST SPECIFICS ####################### -->
@@ -217,11 +215,18 @@
<copy todir="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" overwrite="true">
<fileset dir="${jbpm.home}/jboss/jbpm.cfg.integration.tests" />
</copy>
+ <antcall target="internal.install.idm.into.jboss.integrationtestspecifics" />
<ant antfile="${jbpm.home}/examples/build.xml" target="examples.jar" />
<mkdir dir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
<copy file="${jbpm.home}/examples/target/examples.jar"
todir="${jboss.server.config.dir}/deploy/jbpm/userlibs" />
</target>
+
+ <target name="internal.install.idm.into.jboss.integrationtestspecifics" if="jbpm.identity.idm">
+ <copy file="${jbpm.home}/jboss/jbpm.cfg.idm/jbpm.integration.test.cfg.xml"
+ tofile="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar/jbpm.cfg.xml"
+ overwrite="true" />
+ </target>
<!-- ### THE HSQLDB SPECIFIC PART ####################################### -->
<target name="internal.install.jbpm.into.jboss.db.hsqldb" />
Added: jbpm4/branches/idm/modules/distro/src/main/files/jboss/jbpm.cfg.idm/jbpm.integration.test.cfg.xml
===================================================================
--- jbpm4/branches/idm/modules/distro/src/main/files/jboss/jbpm.cfg.idm/jbpm.integration.test.cfg.xml (rev 0)
+++ jbpm4/branches/idm/modules/distro/src/main/files/jboss/jbpm.cfg.idm/jbpm.integration.test.cfg.xml 2009-05-24 18:41:17 UTC (rev 4878)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.tx.jta.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.jboss.idm.cfg.xml" />
+
+ <import resource="jbpm.mail.templates.examples.xml" />
+
+ <!-- Job executor is excluded for running the example test cases.
+ To enable timers and messages in production use, this should be included.
+ import resource="jbpm.jobexecutor.cfg.xml" / -->
+
+</jbpm-configuration>
Added: jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java
===================================================================
--- jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java (rev 0)
+++ jbpm4/branches/idm/modules/examples/src/test/java/org/jbpm/examples/identity/IdentityTest.java 2009-05-24 18:41:17 UTC (rev 4878)
@@ -0,0 +1,127 @@
+/*
+ * 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.examples.identity;
+
+import java.util.List;
+
+import org.jbpm.api.identity.Group;
+import org.jbpm.api.identity.User;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Jeff Yu
+ */
+public class IdentityTest extends JbpmTestCase {
+
+ private String johndoe = "johndoe";
+ private String redhatGroupId ;
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ identityService.createUser("johndoe", "John", "Doe");
+ redhatGroupId = identityService.createGroup("redhat", Group.TYPE_UNIT, null);
+
+ }
+
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ identityService.deleteUser(johndoe);
+ identityService.deleteGroup(redhatGroupId);
+ }
+
+
+ public void testSingleUser() throws Exception {
+ User user = identityService.findUserById(johndoe);
+
+ assertEquals("johndoe", user.getId());
+ assertEquals("John", user.getGivenName());
+ assertEquals("Doe", user.getFamilyName());
+
+ }
+
+
+ public void testCreateGroup() throws Exception {
+ String testGroupId = identityService.createGroup("testGroup", Group.TYPE_UNIT, null);
+ Group group = identityService.findGroupById(testGroupId);
+ assertEquals("testGroup", group.getName());
+ assertEquals(Group.TYPE_UNIT, group.getType());
+
+ identityService.deleteGroup(testGroupId);
+ }
+
+ public void testFindGroupsByUser() throws Exception {
+ identityService.createMembership(johndoe, redhatGroupId, "Developer");
+
+ List<Group> groups = identityService.findGroupsByUser(johndoe);
+ assertTrue(groups.size() > 0);
+
+ for (Group group : groups) {
+ if (redhatGroupId.equals(group.getId())) {
+ assertTrue(true);
+ return;
+ }
+ }
+ fail("Can't find the group by userid: " + johndoe);
+ }
+
+ public void testFindGroupByUserAndGroupType() throws Exception {
+ identityService.createMembership(johndoe, redhatGroupId, "Developer");
+ List<Group> groups = identityService.findGroupsByUserAndGroupType(johndoe, Group.TYPE_UNIT);
+ assertTrue(groups.size() > 0);
+
+ for (Group group : groups) {
+ if (redhatGroupId.equals(group.getId())) {
+ assertTrue(true);
+ return;
+ }
+ }
+ fail("Can't find the groups by userid " + johndoe + " and group type :" + Group.TYPE_UNIT);
+ }
+
+ public void testSingleGroup() throws Exception {
+ identityService.createUser("joesmoe", "Joe", "Smoe");
+ identityService.createUser("jackblack", "Jack", "Black");
+
+ String jbossId = identityService.createGroup("jboss", Group.TYPE_UNIT, redhatGroupId);
+ String jbpmId = identityService.createGroup("jbpm", Group.TYPE_UNIT, jbossId);
+
+ identityService.createMembership("johndoe", jbpmId, "developer");
+ identityService.createMembership("joesmoe", jbpmId, "developer");
+ identityService.createMembership("jackblack", jbossId, "manager");
+
+ List<Group> groups = identityService.findGroupsByUserAndGroupType("johndoe", Group.TYPE_UNIT);
+
+ assertEquals(1, groups.size());
+ Group group = groups.get(0);
+ System.out.println(group.getName());
+
+ identityService.deleteGroup(jbpmId);
+ identityService.deleteGroup(jbossId);
+
+ identityService.deleteUser("joesmoe");
+ identityService.deleteUser("jackblack");
+ }
+}
Modified: jbpm4/branches/idm/modules/examples/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/branches/idm/modules/examples/src/test/resources/jbpm.cfg.xml 2009-05-23 13:48:09 UTC (rev 4877)
+++ jbpm4/branches/idm/modules/examples/src/test/resources/jbpm.cfg.xml 2009-05-24 18:41:17 UTC (rev 4878)
@@ -5,7 +5,7 @@
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.tx.hibernate.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
- <import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.jboss.idm.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
Modified: jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
===================================================================
--- jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-23 13:48:09 UTC (rev 4877)
+++ jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-24 18:41:17 UTC (rev 4878)
@@ -31,9 +31,8 @@
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.RoleType;
import org.jboss.identity.idm.common.exception.IdentityException;
+import org.jboss.identity.idm.common.p3p.P3PConstants;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
-import org.jboss.identity.idm.impl.api.model.SimpleUser;
-import org.jboss.identity.idm.common.p3p.P3PConstants;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
import org.jbpm.api.identity.Group;
@@ -61,12 +60,19 @@
org.jboss.identity.idm.api.User idUser= identitySession.getPersistenceManager().createUser(userName);
- Attribute[] attributes = new Attribute[] {
- new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, givenName),
- new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, familyName),
- new SimpleAttribute(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, businessEmail)
- };
- identitySession.getAttributesManager().addAttributes(idUser, attributes);
+ List<Attribute> attrs = new ArrayList<Attribute>();
+ if (givenName != null) {
+ attrs.add(new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, givenName));
+ }
+ if (familyName != null) {
+ attrs.add(new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, familyName));
+ }
+ if (businessEmail != null) {
+ attrs.add(new SimpleAttribute(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, businessEmail));
+ }
+
+
+ identitySession.getAttributesManager().addAttributes(idUser, attrs.toArray(new Attribute[attrs.size()]));
return idUser.getId();
} catch (IdentityException e) {
@@ -129,8 +135,9 @@
public List<User> findUsersByGroup(String groupId) {
try {
+ org.jboss.identity.idm.api.Group idGroup = findIdmGroupById(groupId);
Collection<org.jboss.identity.idm.api.User> idusers =
- identitySession.getRelationshipManager().findAssociatedUsers(groupId, false, null);
+ identitySession.getRelationshipManager().findAssociatedUsers(idGroup, false);
List<User> users = new ArrayList<User>();
for (org.jboss.identity.idm.api.User iduser : idusers) {
@@ -155,6 +162,7 @@
public String createGroup(String groupName, String groupType, String parentGroupId) {
try {
+
org.jboss.identity.idm.api.Group group = identitySession.getPersistenceManager().createGroup(groupName, groupType);
String groupId = group.getId();
@@ -175,8 +183,7 @@
public Group findGroupById(String groupId) {
try {
- org.jboss.identity.idm.api.Group idGroup = identitySession.getPersistenceManager().
- findGroupById(groupId);
+ org.jboss.identity.idm.api.Group idGroup = findIdmGroupById(groupId);
GroupImpl group = new GroupImpl();
group.setId(idGroup.getId());
group.setType(idGroup.getGroupType());
@@ -238,7 +245,8 @@
public List<Group> findGroupsByUserAndGroupType(String userName, String groupType) {
try {
- org.jboss.identity.idm.api.User idUser = new SimpleUser(userName);
+ org.jboss.identity.idm.api.User idUser = identitySession.getPersistenceManager().findUser(userName);
+
Collection<org.jboss.identity.idm.api.Group> idGroups = identitySession.getRelationshipManager()
.findAssociatedGroups(idUser, groupType);
List<Group> groups = new ArrayList<Group>();
@@ -309,7 +317,13 @@
protected org.jboss.identity.idm.api.Group findIdmGroupById(String groupId) {
try {
- return identitySession.getPersistenceManager().findGroupById(groupId);
+ Collection<org.jboss.identity.idm.api.Group> groups = identitySession.getPersistenceManager().findGroup(Group.TYPE_UNIT);
+ for (org.jboss.identity.idm.api.Group group : groups) {
+ if (groupId.equals(group.getId())) {
+ return group;
+ }
+ }
+ return null;
} catch (IdentityException e) {
throw new JbpmException("couldn't find the group by groupId: " + groupId, e);
}
15 years, 1 month
JBoss JBPM SVN: r4877 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/task/notification and 7 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-05-23 09:48:09 -0400 (Sat, 23 May 2009)
New Revision: 4877
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
Modified:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
JBPM-2254: task reminder example, plus amendments to JpdlExecution.getExtension
Deleted: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -1,99 +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.examples.task.notification;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.Message.RecipientType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-
-import org.jbpm.examples.task.assignee.Order;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class MailNotificationTest extends JbpmTestCase {
-
- Wiser wiser = new Wiser();
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // deploy process
- long deploymentDbid = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
- .deploy();
- registerDeployment(deploymentDbid);
-
- // create actors
- identityService.createUser("johndoe", "John", "Doe", "john@doe");
-
- // start mail server
- wiser.setPort(2525);
- wiser.start();
- }
-
- protected void tearDown() throws Exception {
- // stop mail server
- wiser.stop();
-
- // delete actors
- identityService.deleteUser("johndoe");
-
- super.tearDown();
- }
-
- public void testTaskNotification() throws MessagingException, IOException {
- Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
- executionService.startProcessInstanceByKey("TaskAssignee", variables);
-
- // examine produced messages
- List<WiserMessage> wiserMessages = wiser.getMessages();
- assertEquals(1, wiserMessages.size());
-
- WiserMessage wiserMessage = wiserMessages.get(0);
- MimeMessage message = wiserMessage.getMimeMessage();
- // from
- Address[] from = message.getFrom();
- assertEquals(1, from.length);
- assertEquals("noreply(a)jbpm.org", from[0].toString());
- // to
- Address[] expectedTo = InternetAddress.parse("john@doe");
- Address[] to = message.getRecipients(RecipientType.TO);
- assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
- // subject
- assertEquals("review", message.getSubject());
- // text
- assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
- }
-}
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java (from rev 4867, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/TaskNotificationTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,104 @@
+/*
+ * 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.examples.task.notification;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+import org.jbpm.examples.task.assignee.Order;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskNotificationTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // deploy process
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
+ .deploy();
+ registerDeployment(deploymentDbid);
+
+ // create actors
+ identityService.createUser("johndoe", "John", "Doe", "john@doe");
+
+ // start mail server
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+
+ // delete actors
+ identityService.deleteUser("johndoe");
+
+ super.tearDown();
+ }
+
+ public void testTaskNotification() throws MessagingException, IOException {
+ Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
+ executionService.startProcessInstanceByKey("TaskNotification", variables);
+
+ // examine produced messages
+ List<WiserMessage> wiserMessages = wiser.getMessages();
+ assertEquals(1, wiserMessages.size());
+
+ // only one message
+ WiserMessage wiserMessage = wiserMessages.get(0);
+ MimeMessage message = wiserMessage.getMimeMessage();
+
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply(a)jbpm.org", from[0].toString());
+
+ // to
+ Address[] expectedTo = InternetAddress.parse("john@doe");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+
+ // subject
+ assertEquals("review", message.getSubject());
+
+ // text
+ assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
+ }
+}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/reminder/TaskReminderTest.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,135 @@
+/*
+ * 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.examples.task.reminder;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.examples.task.assignee.Order;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskReminderTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // deploy process
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/task/reminder/process.jpdl.xml")
+ .deploy();
+ registerDeployment(deploymentDbid);
+
+ // create actors
+ identityService.createUser("johndoe", "John", "Doe", "john@doe");
+
+ // start mail server
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+
+ // delete actors
+ identityService.deleteUser("johndoe");
+
+ super.tearDown();
+ }
+
+ public void testTaskReminder() throws MessagingException, IOException {
+ Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskReminder", variables);
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ // timer was produced, no messages yet
+ assertNotNull("expected job to be non-null", job);
+ assertEquals(0, wiser.getMessages().size());
+
+ managementService.executeJob(job.getDbid());
+
+ // examine produced messages
+ List<WiserMessage> wiserMessages = wiser.getMessages();
+ assertEquals(1, wiserMessages.size());
+
+ // only one message
+ WiserMessage wiserMessage = wiserMessages.get(0);
+ MimeMessage message = wiserMessage.getMimeMessage();
+
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply(a)jbpm.org", from[0].toString());
+
+ // to
+ Address[] expectedTo = InternetAddress.parse("john@doe");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+
+ // subject
+ assertEquals("review", message.getSubject());
+
+ // text
+ assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
+
+ // get task list
+ List<Task> taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(1, taskList.size());
+
+ // only one task
+ Task task = taskList.get(0);
+ assertEquals("review", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+
+ // submit task
+ taskService.completeTask(task.getDbid());
+
+ // timer should be gone
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+ assertNull("expected timer to be null", job);
+ }
+}
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-23 13:48:09 UTC (rev 4877)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="TaskAssignee">
+<process name="TaskNotification">
<start g="20,20,48,48">
<transition to="review"/>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/reminder/process.jpdl.xml 2009-05-23 13:48:09 UTC (rev 4877)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="TaskReminder">
+
+ <start g="20,20,48,48">
+ <transition to="review"/>
+ </start>
+
+ <task name="review"
+ assignee="#{order.owner}"
+ g="96,16,127,52">
+ <reminder duedate="2 days" repeat="1 day"/>
+ <transition to="wait"/>
+ </task>
+
+ <state name="wait" g="255,16,88,52"/>
+
+</process>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -54,16 +54,24 @@
protected Map<String, SwimlaneImpl> swimlanes;
+ @Override
public <T> T getExtension(Class<T> extensionClass) {
if (extensionClass==null) {
throw new JbpmException("extensionClass is null");
}
- if (extensionClass == JpdlExecution.class) {
+ if (JpdlExecution.class.isAssignableFrom(extensionClass)) {
+ if (dbid == 0L) return extensionClass.cast(this);
+
Session session = Environment.getFromCurrent(Session.class);
return extensionClass.cast(session.load(JpdlExecution.class, dbid));
}
throw new JbpmException("unsupported extension "+extensionClass.getName());
}
+
+ @Override
+ protected ExecutionImpl newChildExecution() {
+ return new JpdlExecution();
+ }
// tasks ////////////////////////////////////////////////////////////////////
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-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -493,7 +493,7 @@
Element reminderElement = XmlUtil.element(element, "reminder");
if (reminderElement != null) {
- parseMailEvent(notificationElement, parse, scopeElement, Event.REMIND);
+ parseMailEvent(reminderElement, parse, scopeElement, Event.REMIND);
// associate timer to event
TimerDefinitionImpl timerDefinition = parseTimerDefinition(reminderElement, parse, scopeElement);
timerDefinition.setEventName(Event.REMIND);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-23 13:48:09 UTC (rev 4877)
@@ -997,7 +997,7 @@
if (extensionClass==null) {
throw new JbpmException("extensionClass is null. and this execution doesn't support extensions");
}
- throw new JbpmException("unsuppported extension "+extensionClass.getName());
+ throw new JbpmException("unsupported extension "+extensionClass.getName());
}
/** notification of this execution being deleted. this allows for
15 years, 1 month
JBoss JBPM SVN: r4876 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/session and 7 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-05-23 08:41:04 -0400 (Sat, 23 May 2009)
New Revision: 4876
Added:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailListener.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Event.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Transition.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/PvmDbSession.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
Log:
JBPM-2254: first stab at reminder, refactor notification as event listener
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -24,9 +24,6 @@
import java.util.List;
import java.util.Map;
-import org.jbpm.api.Execution;
-
-
/**
* a activity in a {@link OpenProcessDefinition} graph.
*
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Event.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Event.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Event.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -34,4 +34,8 @@
String START = "start";
/** fired when a process or an activity ends */
String END = "end";
+ /** fired when a task is assigned */
+ String ASSIGN = "assign";
+ /** fired when an assignee is reminded of a task */
+ String REMIND = "remind";
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -26,7 +26,6 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.job.Timer;
/** execution that opens up access to the related
* objects in the execution and process definition
@@ -39,7 +38,7 @@
* an open persistence session. Typically inside of
* an environment block. Navigation over the
* related model objects will load the related objects
- * transparantly with lazy loading.
+ * transparently with lazy loading.
*
* @author Tom Baeyens
*/
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Transition.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Transition.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Transition.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -21,9 +21,6 @@
*/
package org.jbpm.api.model;
-import java.util.Set;
-
-
/**
* a transition in a {@link OpenProcessDefinition} graph.
*
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/PvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/PvmDbSession.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/PvmDbSession.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -23,7 +23,6 @@
import java.util.List;
-import org.jbpm.api.Execution;
import org.jbpm.api.client.ClientExecution;
import org.jbpm.api.client.ClientProcessDefinition;
import org.jbpm.api.job.Job;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -87,7 +87,7 @@
unresolvedTransitions.add(transition, transitionElement);
- jpdlParser.parseOnEvent(transitionElement, transition, Event.TAKE, parse);
+ jpdlParser.parseOnEvent(transitionElement, parse, transition, Event.TAKE);
}
}
}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailListener.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailListener.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailListener.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -0,0 +1,66 @@
+/*
+ * 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.jpdl.internal.activity;
+
+import java.util.Collection;
+
+import javax.mail.Message;
+
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.api.session.TaskDbSession;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.email.spi.MailSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailListener implements EventListener {
+
+ protected transient MailProducer mailProducer;
+
+ private static final long serialVersionUID = 1L;
+ private static final String TASK_VARIABLE_NAME = "task";
+
+ public void notify(EventListenerExecution execution) throws Exception {
+ // find current task
+ Environment environment = Environment.getCurrent();
+ Task task = environment.get(TaskDbSession.class).findTaskByExecution(execution);
+ // make task available to mail templates through execution variable
+ // TODO find a cleaner way
+ execution.setVariable(TASK_VARIABLE_NAME, task);
+ try {
+ Collection<Message> messages = mailProducer.produce(execution);
+ environment.get(MailSession.class).send(messages);
+ }
+ finally {
+// execution.removeVariable(TASK_VARIABLE_NAME);
+ }
+ }
+
+ public void setMailProducer(MailProducer mailProducer) {
+ this.mailProducer = mailProducer;
+ }
+
+}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -52,9 +52,6 @@
TaskHandler taskHandler = task.getTaskHandler();
boolean wait = taskHandler.executionCreateTask(task);
-
- TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
- taskDbSession.save(task);
if (wait) {
execution.waitForSignal();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -22,6 +22,7 @@
package org.jbpm.jpdl.internal.activity;
import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.model.ScopeElementImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -41,7 +42,8 @@
public Object parse(Element element, Parse parse, Parser parser) {
TaskActivity taskActivity = new TaskActivity();
- TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse, parser);
+ ScopeElementImpl scopeElement = parse.findObject(ScopeElementImpl.class);
+ TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse, scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
return taskActivity;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/model/JpdlExecution.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -58,11 +58,11 @@
if (extensionClass==null) {
throw new JbpmException("extensionClass is null");
}
- if (extensionClass.equals(JpdlExecution.class)) {
+ if (extensionClass == JpdlExecution.class) {
Session session = Environment.getFromCurrent(Session.class);
- return (T) session.load(JpdlExecution.class, dbid);
+ return extensionClass.cast(session.load(JpdlExecution.class, dbid));
}
- throw new JbpmException("unsuppported extension "+extensionClass.getName());
+ throw new JbpmException("unsupported extension "+extensionClass.getName());
}
// tasks ////////////////////////////////////////////////////////////////////
@@ -86,6 +86,9 @@
task.setPriority(taskDefinition.getPriority());
task.setForm(taskDefinition.getForm());
+ // save task so that TaskDbSession.findTaskByExecution works for assign event listeners
+ taskDbSession.saveTask(task);
+
SwimlaneDefinitionImpl swimlaneDefinition = taskDefinition.getSwimlaneDefinition();
if (swimlaneDefinition!=null) {
JpdlExecution jpdlProcessInstance = processInstance.getExtension(JpdlExecution.class);
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-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -31,12 +31,15 @@
import java.util.Set;
import java.util.StringTokenizer;
+import org.w3c.dom.Element;
+
import org.jbpm.api.activity.ActivityBehaviour;
import org.jbpm.api.env.Environment;
import org.jbpm.api.listener.EventListener;
import org.jbpm.api.model.Event;
import org.jbpm.internal.log.Log;
import org.jbpm.jpdl.internal.activity.JpdlBinding;
+import org.jbpm.jpdl.internal.activity.MailListener;
import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
import org.jbpm.pvm.internal.email.impl.MailTemplate;
@@ -73,7 +76,6 @@
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.jbpm.pvm.internal.xml.ProblemImpl;
-import org.w3c.dom.Element;
/**
* @author Tom Baeyens
@@ -84,12 +86,14 @@
public static final WireParser wireParser = WireParser.getInstance();
- public static final String[] DEFAULT_ACTIVITIES_RESOURCES = new String[]{
+ // array elements are mutable, even when final
+ // never make a static array public
+ static final String[] DEFAULT_ACTIVITIES_RESOURCES = {
"jbpm.jpdl.activities.xml",
"jbpm.user.activities.xml"
};
- public static final String[] DEFAULT_EVENTLISTENERS_RESOURCES = new String[]{
+ static final String[] DEFAULT_EVENTLISTENERS_RESOURCES = {
"jbpm.jpdl.eventlisteners.xml",
"jbpm.user.eventlisteners.xml"
};
@@ -128,7 +132,6 @@
binding.setCategory(CATEGORY_ACTIVITY);
bindings.addBinding(binding);
}
-
}
} else {
log.trace("skipping unavailable jpdl activities resource: "+activityResource);
@@ -151,7 +154,6 @@
binding.setCategory(CATEGORY_EVENT_LISTENER);
bindings.addBinding(binding);
}
-
}
} else {
log.trace("skipping unavailable jpdl eventlistener resource: "+eventListenerResource);
@@ -217,7 +219,6 @@
} finally {
parse.popObject();
}
-
if (processDefinition.getInitial()==null) {
parse.addProblem("no start activity in process");
@@ -236,65 +237,65 @@
List<Element> elements = XmlUtil.elements(documentElement);
for (Element nestedElement : elements) {
String tagName = XmlUtil.getTagLocalName(nestedElement);
- if ( !"on".equals(tagName)
- && !"timer".equals(tagName)
- && !"swimlane".equals(tagName)
- ) {
- JpdlBinding activityBinding = (JpdlBinding) getBinding(nestedElement, CATEGORY_ACTIVITY);
- if (activityBinding != null) {
- ActivityImpl activity = compositeElement.createActivity();
- parse.pushObject(activity);
- try {
- activity.setType(activityBinding.getTagName());
- activityBinding.parseName(nestedElement, activity, parse);
- parseTransitions(nestedElement, activity, parse);
+ if ("on".equals(tagName)
+ || "timer".equals(tagName)
+ || "swimlane".equals(tagName)) continue;
- String continuationText = XmlUtil.attribute(nestedElement, "continue");
- if (continuationText!=null) {
- if ("async".equals(continuationText)) {
- activity.setContinuation(Continuation.ASYNCHRONOUS);
- } else if ("exclusive".equals(continuationText)) {
- activity.setContinuation(Continuation.EXCLUSIVE);
- }
- }
+ JpdlBinding activityBinding = (JpdlBinding) getBinding(nestedElement, CATEGORY_ACTIVITY);
+ if (activityBinding == null) {
+ log.debug("unrecognized activity: " + tagName);
+ continue;
+ }
- ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
- activity.setBehaviour(activityBehaviour);
+ ActivityImpl activity = compositeElement.createActivity();
+ parse.pushObject(activity);
+ try {
+ activity.setType(activityBinding.getTagName());
+ activityBinding.parseName(nestedElement, activity, parse);
+ parseTransitions(nestedElement, activity, parse);
- parseOnEvents(nestedElement, parse, activity);
+ String continuationText = XmlUtil.attribute(nestedElement, "continue");
+ if (continuationText!=null) {
+ if ("async".equals(continuationText)) {
+ activity.setContinuation(Continuation.ASYNCHRONOUS);
+ } else if ("exclusive".equals(continuationText)) {
+ activity.setContinuation(Continuation.EXCLUSIVE);
+ }
+ }
- String g = XmlUtil.attribute(nestedElement, "g");
- if (g != null) {
- StringTokenizer stringTokenizer = new StringTokenizer(g, ",");
- ActivityCoordinatesImpl coordinates = null;
- if (stringTokenizer.countTokens() == 4) {
- try {
- int x = Integer.parseInt(stringTokenizer.nextToken());
- int y = Integer.parseInt(stringTokenizer.nextToken());
- int width = Integer.parseInt(stringTokenizer.nextToken());
- int height = Integer.parseInt(stringTokenizer.nextToken());
- coordinates = new ActivityCoordinatesImpl(x, y, width, height);
- } catch (NumberFormatException e) {
- coordinates = null;
- }
- }
- if (coordinates != null) {
- activity.setCoordinates(coordinates);
- } else {
- parse.addProblem("invalid coordinates g=\"" + g + "\" in " + activity);
- }
- }
- } finally {
- parse.popObject();
+ ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
+ activity.setBehaviour(activityBehaviour);
+
+ parseOnEvents(nestedElement, parse, activity);
+
+ String g = XmlUtil.attribute(nestedElement, "g");
+ if (g == null) continue;
+
+ StringTokenizer stringTokenizer = new StringTokenizer(g, ",");
+ ActivityCoordinatesImpl coordinates = null;
+ if (stringTokenizer.countTokens() == 4) {
+ try {
+ int x = Integer.parseInt(stringTokenizer.nextToken());
+ int y = Integer.parseInt(stringTokenizer.nextToken());
+ int width = Integer.parseInt(stringTokenizer.nextToken());
+ int height = Integer.parseInt(stringTokenizer.nextToken());
+ coordinates = new ActivityCoordinatesImpl(x, y, width, height);
+ } catch (NumberFormatException e) {
+ coordinates = null;
}
+ }
+ if (coordinates != null) {
+ activity.setCoordinates(coordinates);
} else {
- log.debug("unrecognized activity: " + tagName);
+ parse.addProblem("invalid coordinates g=\"" + g + "\" in " + activity, nestedElement);
}
+ } finally {
+ parse.popObject();
}
}
}
- public TimerDefinitionImpl parseTimerDefinition(Element timerElement, Parse parse, ScopeElementImpl scopeElement) {
+ public static TimerDefinitionImpl parseTimerDefinition(Element timerElement, Parse parse, ScopeElementImpl scopeElement) {
TimerDefinitionImpl timerDefinition = scopeElement.createTimerDefinition();
String duedate = XmlUtil.attribute(timerElement, "duedate");
@@ -330,7 +331,7 @@
List<Element> onElements = XmlUtil.elements(element, "on");
for (Element onElement: onElements) {
String eventName = XmlUtil.attribute(onElement, "event", true, parse);
- parseOnEvent(onElement, scopeElement, eventName, parse);
+ parseOnEvent(onElement, parse, scopeElement, eventName);
Element timerElement = XmlUtil.element(onElement, "timer");
if (timerElement!=null) {
@@ -340,7 +341,7 @@
}
}
- public void parseOnEvent(Element element, ObservableElementImpl observableElement, String eventName, Parse parse) {
+ public void parseOnEvent(Element element, Parse parse, ObservableElementImpl observableElement, String eventName) {
if (eventName!=null) {
EventImpl event = observableElement.getEvent(eventName);
if (event==null) {
@@ -391,7 +392,6 @@
) {
parse.addProblem("unrecognized event listener: "+tagName, null, ProblemImpl.TYPE_WARNING, eventListenerElement);
}
-
}
}
}
@@ -414,7 +414,7 @@
unresolvedTransitions.add(transition, transitionElement);
- parseOnEvent(transitionElement, transition, Event.TAKE, parse);
+ parseOnEvent(transitionElement, parse, transition, Event.TAKE);
}
}
@@ -450,7 +450,7 @@
assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
}
- public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, Parser parser) {
+ public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
String taskName = XmlUtil.attribute(element, "name");
@@ -488,10 +488,17 @@
// parse notification mail producer
Element notificationElement = XmlUtil.element(element, "notification");
if (notificationElement != null) {
- MailProducer mailProducer = parseMailProducer(notificationElement, parse, "task-notification");
- taskDefinition.setNotificationMailProducer(mailProducer);
+ parseMailEvent(notificationElement, parse, scopeElement, Event.ASSIGN);
}
+ Element reminderElement = XmlUtil.element(element, "reminder");
+ if (reminderElement != null) {
+ parseMailEvent(notificationElement, parse, scopeElement, Event.REMIND);
+ // associate timer to event
+ TimerDefinitionImpl timerDefinition = parseTimerDefinition(reminderElement, parse, scopeElement);
+ timerDefinition.setEventName(Event.REMIND);
+ }
+
return taskDefinition;
}
@@ -583,6 +590,29 @@
return variableOutDefinitionSet;
}
+ public static void parseMailEvent(Element element, Parse parse,
+ ObservableElementImpl observableElement, String eventName) {
+ // obtain assign event
+ EventImpl event = observableElement.getEvent(eventName);
+ if (event == null) {
+ event = observableElement.createEvent(eventName);
+ }
+ // register event listener
+ MailListener eventListener = new MailListener();
+ EventListenerReference eventListenerRef = event.createEventListenerReference(eventListener);
+ // set continuation mode
+ String continuationText = XmlUtil.attribute(element, "continue");
+ if ("async".equals(continuationText)) {
+ eventListenerRef.setContinuation(Continuation.ASYNCHRONOUS);
+ }
+ else if ("exclusive".equals(continuationText)) {
+ eventListenerRef.setContinuation(Continuation.EXCLUSIVE);
+ }
+ // associate mail producer to event listener
+ MailProducer mailProducer = parseMailProducer(element, parse, "task-notification");
+ eventListener.setMailProducer(mailProducer);
+ }
+
public static MailProducer parseMailProducer(Element element, Parse parse,
String defaultTemplateName) {
// check whether the element is a generic object descriptor
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -131,14 +131,19 @@
private String evaluateExpression(String expression, Execution execution) {
ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
- return scriptManager.evaluateExpression(expression, execution, template.getLanguage())
- .toString();
+ Object value = scriptManager.evaluateExpression(expression, execution, template.getLanguage());
+ if (!(value instanceof String)) {
+ throw new JbpmException("expected expression '"
+ + expression
+ + "' to return string, but was: "
+ + value);
+ }
+ return (String) value;
}
private String[] tokenizeActors(String recipients, Execution execution) {
String[] actors = evaluateExpression(recipients, execution).split("[,|\\s]+");
- if (actors.length == 0)
- throw new JbpmException("recipient list is empty: " + recipients);
+ if (actors.length == 0) throw new JbpmException("recipient list is empty: " + recipients);
return actors;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -47,7 +47,7 @@
}
public void forceVersionUpdate(Object entity) {
- session.lock(entity, LockMode.NONE);
+ session.lock(entity, LockMode.FORCE);
}
public void lockPessimistically(Object entity) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -21,9 +21,8 @@
*/
package org.jbpm.pvm.internal.hibernate;
-import java.io.Serializable;
-
import org.hibernate.Query;
+
import org.jbpm.api.Execution;
import org.jbpm.api.session.TaskDbSession;
import org.jbpm.api.task.Task;
@@ -52,12 +51,7 @@
taskImpl.setSuperTaskDbid(null);
}
- if (! taskImpl.isPersisted()) {
- Serializable dbid = session.save(taskImpl);
-
- } else {
- session.update(taskImpl);
- }
+ session.saveOrUpdate(task);
}
public Task createTask() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -51,7 +51,7 @@
public List<VariableDefinitionImpl> getVariableDefinitions() {
if (!hasVariableDefinitions()) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return variableDefinitions;
}
@@ -75,7 +75,7 @@
public Set<TimerDefinitionImpl> getTimerDefinitions() {
if (!hasTimerDefinitions()) {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
return timerDefinitions;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.List;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
import org.jbpm.pvm.internal.util.Priority;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -42,8 +41,6 @@
protected SwimlaneDefinitionImpl swimlaneDefinition;
protected Descriptor taskHandlerDescriptor;
- protected transient MailProducer notificationMailProducer;
-
public int getPriority() {
return priority;
}
@@ -80,10 +77,4 @@
public void setTaskHandlerDescriptor(Descriptor taskHandlerDescriptor) {
this.taskHandlerDescriptor = taskHandlerDescriptor;
}
- public MailProducer getNotificationMailProducer() {
- return notificationMailProducer;
- }
- public void setNotificationMailProducer(MailProducer notificationMailProducer) {
- this.notificationMailProducer = notificationMailProducer;
- }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-23 10:38:45 UTC (rev 4875)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-23 12:41:04 UTC (rev 4876)
@@ -23,19 +23,17 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.mail.Message;
-
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
import org.jbpm.api.model.Comment;
+import org.jbpm.api.model.Event;
import org.jbpm.api.session.TaskDbSession;
import org.jbpm.api.task.Assignable;
import org.jbpm.api.task.OpenTask;
@@ -43,8 +41,6 @@
import org.jbpm.api.task.Swimlane;
import org.jbpm.api.task.Task;
import org.jbpm.api.task.TaskHandler;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
-import org.jbpm.pvm.internal.email.spi.MailSession;
import org.jbpm.pvm.internal.history.events.TaskAssign;
import org.jbpm.pvm.internal.history.events.TaskCancel;
import org.jbpm.pvm.internal.history.events.TaskComplete;
@@ -125,27 +121,12 @@
public void setAssignee(String userId, boolean propagateToSwimlane) {
this.assignee = userId;
- notifyAssignee();
if (propagateToSwimlane) {
propagateAssigneeToSwimlane();
}
- }
-
- protected void notifyAssignee() {
- if (taskDefinition == null) return;
-
- MailProducer mailProducer = taskDefinition.getNotificationMailProducer();
- if (mailProducer == null) return;
-
- // TODO how to insert predefined variables cleanly?
- execution.setVariable("task", this);
- try {
- Collection<Message> messages = mailProducer.produce(execution);
- Environment.getFromCurrent(MailSession.class).send(messages);
+ if (execution != null) {
+ execution.fire(Event.ASSIGN, execution.getActivity());
}
- finally {
- execution.removeVariable("task");
- }
}
protected void propagateAssigneeToSwimlane() {
@@ -345,10 +326,6 @@
this.progress = progress;
}
- public boolean isPersisted() {
- return dbid != 0;
- }
-
public void cancelExecution(String signal) {
if (execution != null) {
execution.end("cancel");
15 years, 1 month