JBoss JBPM SVN: r3910 - in jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal: execution and 1 other directory.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-02-18 02:32:15 -0500 (Wed, 18 Feb 2009)
New Revision: 3910
Added:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
Log:
added PvmProcessExecutionTest
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java 2009-02-18 07:32:15 UTC (rev 3910)
@@ -0,0 +1,76 @@
+/*
+ * 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.pvm.internal.execution;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.jbpm.Deployment;
+import org.jbpm.Execution;
+import org.jbpm.ExecutionService;
+import org.jbpm.ProcessService;
+import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.pvm.activities.AutomaticActivity;
+import org.jbpm.pvm.activities.WaitState;
+import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
+import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.svc.DeploymentImpl;
+import org.jbpm.pvm.internal.svc.ProcessServiceImpl;
+import org.jbpm.pvm.test.EnvironmentFactoryTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class PvmProcessExecutionTest extends EnvironmentFactoryTestCase {
+
+ public void testDeploy() {
+ JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+ ProcessService processService = environmentFactory.get(ProcessService.class);
+
+ ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("test")
+ .startActivity("start", WaitState.class)
+ .initial()
+ .flow("end", "end")
+ .endActivity()
+ .startActivity("end", AutomaticActivity.class)
+ .endActivity()
+ .endProcess();
+
+ Deployment deployment = new DeploymentImpl();
+ deployment.addObject("testProcesssss", processDefinition);
+
+ ((ProcessServiceImpl) processService).deploy(deployment);
+ }
+
+ public void testStartProcessInstance() {
+ JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+ ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+ Execution execution = executionService.startProcessInstanceById("test:1", "request17");
+ }
+
+ public void testResumeProcessInstance() {
+ JbpmConfiguration environmentFactory = (JbpmConfiguration) getEnvironmentFactory();
+ ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+ Execution execution = executionService.signalExecutionById("test/request17", "end");
+ }
+
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/execution/PvmProcessExecutionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 2 months
JBoss JBPM SVN: r3909 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/job/executor and 8 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-17 22:40:51 -0500 (Tue, 17 Feb 2009)
New Revision: 3909
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableDeleteLog.hbm.xml
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableLog.hbm.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskInstanceDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/log/TaskLogDbTest.java
Log:
JBPM-1812: fix tests that do not cleanup the database
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -28,9 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
-import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
@@ -47,7 +45,6 @@
protected JbpmConfiguration jbpmConfiguration;
protected JbpmContext jbpmContext;
- protected SchemaExport schemaExport;
protected Session session;
protected GraphSession graphSession;
@@ -75,33 +72,35 @@
private void ensureCleanDatabase() {
boolean hasLeftOvers = false;
- DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) getJbpmConfiguration().getServiceFactory("persistence");
- Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
- JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) getJbpmConfiguration().getServiceFactory(
+ "persistence");
+ JbpmSchema jbpmSchema = new JbpmSchema(persistenceServiceFactory.getConfiguration());
+ Map<String, Long> recordCountPerTable = jbpmSchema.getRowsPerTable();
- Map<String, Integer> recordCountPerTable = jbpmSchema.getRecordCountPerTable();
- for (Map.Entry<String, Integer> entry : recordCountPerTable.entrySet()) {
- // String tableName = entry.getKey();
- Integer count = entry.getValue();
-
- if ((count == null) || (count != 0)) {
+ for (Map.Entry<String, Long> entry : recordCountPerTable.entrySet()) {
+ Long count = entry.getValue();
+ if (count != 0) {
hasLeftOvers = true;
// [JBPM-1812] Fix tests that don't cleanup the database
- // Only uncomment this if you intend to fix it. Otherwise it just generates noise.
- // System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left " + count
- // + " records in " + tableName);
+ System.err.println("FIXME: "
+ + getClass().getName()
+ + "."
+ + getName()
+ + " left "
+ + count
+ + " records in "
+ + entry.getKey());
}
}
if (hasLeftOvers) {
- // TODO: JBPM-1781
- // jbpmSchema.cleanSchema();
+ jbpmSchema.cleanSchema();
}
}
protected String getHibernateDialect() {
- DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
- return factory.getConfiguration().getProperty(Environment.DIALECT);
+ DbPersistenceServiceFactory persistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ return persistenceServiceFactory.getConfiguration().getProperty(Environment.DIALECT);
}
protected void beginSessionTransaction() {
@@ -189,12 +188,12 @@
if (System.currentTimeMillis() - startTime > timeout) {
fail("test execution exceeded treshold of " + timeout + " milliseconds");
}
- log.debug("waiting for the job executor to process more jobs");
+ log.debug("waiting for job executor to process more jobs");
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
- // keep going
+ fail("wait for job executor to process more jobs got interrupted");
}
}
}
@@ -250,7 +249,7 @@
jobExecutor.stopAndJoin();
}
catch (InterruptedException e) {
- throw new RuntimeException("waiting for job executor to stop and join got interrupted", e);
+ log.debug("wait for job executor to stop and join got interrupted", e);
}
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -44,9 +44,6 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Settings;
import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.engine.Mapping;
-import org.hibernate.mapping.ForeignKey;
import org.hibernate.mapping.Table;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.TableMetadata;
@@ -66,6 +63,8 @@
ConnectionProvider connectionProvider = null;
Connection connection = null;
+ final List<SQLException> exceptions = new ArrayList<SQLException>();
+
public JbpmSchema(Configuration configuration) {
this.configuration = configuration;
this.settings = configuration.buildSettings();
@@ -80,62 +79,13 @@
}
public String[] getCleanSql() {
- Dialect dialect = settings.getDialect();
- String catalog = settings.getDefaultCatalogName();
- String schema = settings.getDefaultSchemaName();
- Mapping mapping = configuration.buildMapping();
-
- // loop over all foreign key constraints
- List<String> dropForeignKeysSql = new ArrayList<String>();
- List<String> createForeignKeysSql = new ArrayList<String>();
- List<String> deleteSql = new ArrayList<String>();
-
- for (Iterator<?> ti = configuration.getTableMappings(); ti.hasNext();) {
- Table table = (Table) ti.next();
- if (!table.isPhysicalTable()) continue;
-
- for (Iterator<?> fki = table.getForeignKeyIterator(); fki.hasNext();) {
- ForeignKey fk = (ForeignKey) fki.next();
- if (!fk.isPhysicalConstraint()) continue;
-
- // collect the drop foreign key sql
- String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
- dropForeignKeysSql.add(sqlDropString);
-
- // and collect the create foreign key sql
- String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
- createForeignKeysSql.add(sqlCreateString);
- }
- deleteSql.add("DELETE FROM " + table.getName());
- }
-
- // glue
- // - drop foreign key constraints
- // - delete contents of all tables
- // - create foreign key constraints
- // together to form the clean script
- return concat(dropForeignKeysSql, deleteSql, createForeignKeysSql);
+ return concat(getDropSql(), getCreateSql());
}
- private static String[] concat(List<?>... lists) {
- int length = 0;
- for (List<?> list : lists) {
- length += list.size();
- }
- String[] array = new String[length];
- int index = 0;
- for (List<?> list : lists) {
- for (Object element : list) {
- array[index++] = (String) element;
- }
- }
- return array;
- }
-
public List<String> getTableNames() {
List<String> tableNames = new ArrayList<String>();
- for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
- Table table = (Table) iter.next();
+ for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
+ Table table = (Table) i.next();
if (table.isPhysicalTable()) {
tableNames.add(table.getName());
}
@@ -143,16 +93,45 @@
return tableNames;
}
- public Map<String, Integer> getRecordCountPerTable() {
- Map<String, Integer> recordCounts = new HashMap<String, Integer>();
+ public List<String> getAvailableTableNames() {
try {
createConnection();
+ List<String> tableNames = new ArrayList<String>();
+
+ ResultSet resultSet = connection.getMetaData().getTables(settings.getDefaultCatalogName(),
+ settings.getDefaultSchemaName(), "JBPM_%", new String[] { "TABLE" });
+ try {
+ while (resultSet.next()) {
+ tableNames.add(resultSet.getString("TABLE_NAME"));
+ }
+ }
+ finally {
+ resultSet.close();
+ }
+ return tableNames;
+ }
+ catch (SQLException e) {
+ throw new JbpmException("could not get available table names", e);
+ }
+ finally {
+ closeConnection();
+ }
+ }
+
+ public Map<String, Long> getRowsPerTable() {
+ Map<String, Long> rowsPerTable = new HashMap<String, Long>();
+ try {
+ createConnection();
Statement statement = connection.createStatement();
for (String tableName : getTableNames()) {
String sql = "SELECT COUNT(*) FROM " + tableName;
ResultSet resultSet = statement.executeQuery(sql);
- resultSet.next();
- recordCounts.put(tableName, resultSet.getInt(1));
+ if (!resultSet.next()) throw new JbpmException("empty result set: " + sql);
+
+ long count = resultSet.getLong(1);
+ if (resultSet.wasNull()) throw new JbpmException("count was null: " + sql);
+
+ rowsPerTable.put(tableName, count);
resultSet.close();
}
statement.close();
@@ -163,7 +142,7 @@
finally {
closeConnection();
}
- return recordCounts;
+ return rowsPerTable;
}
public void dropSchema() {
@@ -264,6 +243,10 @@
}
}
+ public List<SQLException> getExceptions() {
+ return exceptions;
+ }
+
private Table findTableMapping(String tableName) {
for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
Table table = (Table) i.next();
@@ -350,12 +333,21 @@
void execute(String... sqls) throws SQLException {
boolean showSql = settings.isShowSqlEnabled();
+ exceptions.clear();
try {
createConnection();
Statement statement = connection.createStatement();
for (String sql : sqls) {
if (showSql) System.out.println(sql);
- statement.executeUpdate(sql);
+ log.debug(sql);
+ try {
+ statement.executeUpdate(sql);
+ }
+ catch (SQLException e) {
+ exceptions.add(e);
+ log.debug("unsuccessful: " + sql);
+ log.debug(e.getMessage());
+ }
}
statement.close();
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -4,6 +4,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
@@ -15,8 +16,8 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.JbpmConfiguration;
-public class JobExecutor implements Serializable
-{
+public class JobExecutor implements Serializable {
+
private static final long serialVersionUID = 1L;
protected JbpmConfiguration jbpmConfiguration;
@@ -24,6 +25,8 @@
protected int nbrOfThreads;
protected int idleInterval;
protected int maxIdleInterval;
+ /** @deprecated this field was never used */
+ @Deprecated
protected int historyMaxSize;
protected int maxLockTime;
@@ -38,129 +41,115 @@
protected static String hostName;
- public synchronized void start()
- {
- if (!isStarted)
- {
+ public synchronized void start() {
+ if (!isStarted) {
log.debug("starting thread group '" + name + "'...");
- for (int i = 0; i < nbrOfThreads; i++)
- {
+ for (int i = 0; i < nbrOfThreads; i++) {
startThread();
}
- lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval, maxLockTime, lockBufferTime);
+ lockMonitorThread = new LockMonitorThread(jbpmConfiguration, lockMonitorInterval,
+ maxLockTime, lockBufferTime);
isStarted = true;
}
- else
- {
+ else {
log.debug("ignoring start: thread group '" + name + "' is already started'");
}
}
/**
- * signals to all threads in this job executor to stop. It may be that threads are in the middle of something and they will finish that first. Use {@link
- * #stopAndJoin()} in case you want a method that blocks until all the threads are actually finished.
- * @return a list of all the stopped threads. In case no threads were stopped an empty list will be returned.
+ * signals to all threads in this job executor to stop. Threads may be in the middle of processing
+ * a job and they will finish that first. Use {@link #stopAndJoin()} in case you want a method
+ * that blocks until all the threads are actually finished.
+ *
+ * @return a list of the stopped threads. In case no threads were stopped an empty list will be
+ * returned.
*/
- public synchronized List<Thread> stop()
- {
- List<Thread> stoppedThreads = new ArrayList<Thread>(threads.size());
- if (isStarted)
- {
+ public synchronized List<Thread> stop() {
+ List<Thread> stoppedThreads;
+ if (isStarted) {
log.debug("stopping thread group '" + name + "'...");
- for (int i = 0; i < nbrOfThreads; i++)
- {
+ isStarted = false;
+
+ stoppedThreads = new ArrayList<Thread>(threads.size());
+ for (int i = 0; i < nbrOfThreads; i++) {
stoppedThreads.add(stopThread());
}
-
- if (lockMonitorThread != null)
- lockMonitorThread.deactivate();
-
- isStarted = false;
+
+ if (lockMonitorThread != null) lockMonitorThread.deactivate();
}
- else
- {
+ else {
log.debug("ignoring stop: thread group '" + name + "' not started");
+ stoppedThreads = Collections.emptyList();
}
return stoppedThreads;
}
- public void stopAndJoin() throws InterruptedException
- {
- for (Thread thread : stop())
- {
+ public void stopAndJoin() throws InterruptedException {
+ for (Thread thread : stop()) {
thread.join();
}
-
- if (lockMonitorThread != null)
- lockMonitorThread.join();
+
+ if (lockMonitorThread != null) lockMonitorThread.join();
}
- protected synchronized void startThread()
- {
+ protected synchronized void startThread() {
String threadName = getNextThreadName();
Thread thread = createThread(threadName);
threads.put(threadName, thread);
+
log.debug("starting new job executor thread '" + threadName + "'");
thread.start();
}
- protected Thread createThread(String threadName)
- {
+ protected Thread createThread(String threadName) {
return new JobExecutorThread(threadName, this);
}
- protected String getNextThreadName()
- {
+ protected String getNextThreadName() {
return getThreadName(threads.size() + 1);
}
- protected String getLastThreadName()
- {
+ protected String getLastThreadName() {
return getThreadName(threads.size());
}
- private String getThreadName(int index)
- {
+ private String getThreadName(int index) {
return name + ":" + getHostAddress() + ":" + index;
}
- private static String getHostAddress()
- {
- if (hostName == null)
- {
- try
- {
+ private static String getHostAddress() {
+ if (hostName == null) {
+ try {
hostName = InetAddress.getLocalHost().getHostAddress();
}
- catch (UnknownHostException e)
- {
+ catch (UnknownHostException e) {
hostName = "127.0.0.1";
}
}
return hostName;
}
- protected synchronized Thread stopThread()
- {
+ protected synchronized Thread stopThread() {
String threadName = getLastThreadName();
- JobExecutorThread thread = (JobExecutorThread)threads.remove(threadName);
log.debug("removing job executor thread '" + threadName + "'");
- thread.deactivate();
+
+ Thread thread = threads.remove(threadName);
+ if (thread instanceof JobExecutorThread) {
+ JobExecutorThread jobThread = (JobExecutorThread) thread;
+ jobThread.deactivate();
+ }
return thread;
}
- public Set<Long> getMonitoredJobIds()
- {
+ public Set<Long> getMonitoredJobIds() {
return new HashSet<Long>(monitoredJobIds.values());
}
- public void addMonitoredJobId(String threadName, long jobId)
- {
+ public void addMonitoredJobId(String threadName, long jobId) {
monitoredJobIds.put(threadName, new Long(jobId));
}
- public void removeMonitoredJobId(String threadName)
- {
+ public void removeMonitoredJobId(String threadName) {
monitoredJobIds.remove(threadName);
}
@@ -169,36 +158,34 @@
* @deprecated <code>monitoredJobIds</code> is an internal control field
*/
@Deprecated
- public void setMonitoredJobIds(Map<String, Long> monitoredJobIds)
- {
+ public void setMonitoredJobIds(Map<String, Long> monitoredJobIds) {
throw new UnsupportedOperationException();
}
- public int getHistoryMaxSize()
- {
+ /** @deprecated this property was never used */
+ @Deprecated
+ public int getHistoryMaxSize() {
return historyMaxSize;
}
- public void setHistoryMaxSize(int historyMaxSize)
- {
+ /** @deprecated this property was never used */
+ @Deprecated
+ public void setHistoryMaxSize(int historyMaxSize) {
this.historyMaxSize = historyMaxSize;
}
- public int getIdleInterval()
- {
+ public int getIdleInterval() {
return idleInterval;
}
- public void setIdleInterval(int idleInterval)
- {
+ public void setIdleInterval(int idleInterval) {
this.idleInterval = idleInterval;
}
/**
* Tells whether this job executor has been {@linkplain #start() started}.
*/
- public boolean isStarted()
- {
+ public boolean isStarted() {
return isStarted;
}
@@ -207,38 +194,31 @@
* @deprecated <code>isStarted</code> is an internal control field
*/
@Deprecated
- public void setStarted(boolean isStarted)
- {
+ public void setStarted(boolean isStarted) {
throw new UnsupportedOperationException();
}
- public JbpmConfiguration getJbpmConfiguration()
- {
+ public JbpmConfiguration getJbpmConfiguration() {
return jbpmConfiguration;
}
- public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration)
- {
+ public void setJbpmConfiguration(JbpmConfiguration jbpmConfiguration) {
this.jbpmConfiguration = jbpmConfiguration;
}
- public int getMaxIdleInterval()
- {
+ public int getMaxIdleInterval() {
return maxIdleInterval;
}
- public void setMaxIdleInterval(int maxIdleInterval)
- {
+ public void setMaxIdleInterval(int maxIdleInterval) {
this.maxIdleInterval = maxIdleInterval;
}
- public String getName()
- {
+ public String getName() {
return name;
}
- public void setName(String name)
- {
+ public void setName(String name) {
this.name = name;
}
@@ -246,8 +226,7 @@
* @deprecated Replaced by {{@link #getNbrOfThreads()}
*/
@Deprecated
- public int getSize()
- {
+ public int getSize() {
return nbrOfThreads;
}
@@ -255,13 +234,11 @@
* @deprecated Replaced by {@link #setNbrOfThreads(int)}
*/
@Deprecated
- public void setSize(int nbrOfThreads)
- {
+ public void setSize(int nbrOfThreads) {
this.nbrOfThreads = nbrOfThreads;
}
- public Map<String, Thread> getThreads()
- {
+ public Map<String, Thread> getThreads() {
return threads;
}
@@ -270,48 +247,39 @@
* @deprecated <code>threads</code> is an internal control field
*/
@Deprecated
- public void setThreads(Map<String, Thread> threads)
- {
+ public void setThreads(Map<String, Thread> threads) {
throw new UnsupportedOperationException();
}
- public int getMaxLockTime()
- {
+ public int getMaxLockTime() {
return maxLockTime;
}
- public void setMaxLockTime(int maxLockTime)
- {
+ public void setMaxLockTime(int maxLockTime) {
this.maxLockTime = maxLockTime;
}
- public int getLockBufferTime()
- {
+ public int getLockBufferTime() {
return lockBufferTime;
}
- public void setLockBufferTime(int lockBufferTime)
- {
+ public void setLockBufferTime(int lockBufferTime) {
this.lockBufferTime = lockBufferTime;
}
- public int getLockMonitorInterval()
- {
+ public int getLockMonitorInterval() {
return lockMonitorInterval;
}
- public void setLockMonitorInterval(int lockMonitorInterval)
- {
+ public void setLockMonitorInterval(int lockMonitorInterval) {
this.lockMonitorInterval = lockMonitorInterval;
}
- public int getNbrOfThreads()
- {
+ public int getNbrOfThreads() {
return nbrOfThreads;
}
- public void setNbrOfThreads(int nbrOfThreads)
- {
+ public void setNbrOfThreads(int nbrOfThreads) {
this.nbrOfThreads = nbrOfThreads;
}
Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableDeleteLog.hbm.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableDeleteLog.hbm.xml 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableDeleteLog.hbm.xml 2009-02-18 03:40:51 UTC (rev 3909)
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -9,6 +8,13 @@
<subclass name="org.jbpm.context.log.VariableDeleteLog"
extends="org.jbpm.context.log.VariableLog"
discriminator-value="D">
+
+ <many-to-one name="variableInstance"
+ column="VARIABLEINSTANCE_"
+ cascade="all"
+ insert="false"
+ update="false" />
+
</subclass>
</hibernate-mapping>
Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableLog.hbm.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableLog.hbm.xml 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/context/log/VariableLog.hbm.xml 2009-02-18 03:40:51 UTC (rev 3909)
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
@@ -12,8 +11,6 @@
<many-to-one name="variableInstance"
column="VARIABLEINSTANCE_"
- class="org.jbpm.context.exe.VariableInstance"
- cascade="save-update"
foreign-key="FK_LOG_VARINST" />
</subclass>
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/bytes/ByteArrayDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -31,54 +31,78 @@
byte[] bytes = getMultipleBlockBytes();
ByteArray byteArray = new ByteArray(bytes);
session.save(byteArray);
+
newTransaction();
- ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(byteArray.getId()));
+ ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(
+ byteArray.getId()));
assertEquals(byteArray.byteBlocks.size(), retrievedByteArray.getByteBlocks().size());
assertTrue(Arrays.equals(byteArray.getBytes(), retrievedByteArray.getBytes()));
+
+ session.delete(retrievedByteArray);
}
public void testEmptyByteArray() {
byte[] bytes = new byte[0];
ByteArray byteArray = new ByteArray(bytes);
session.save(byteArray);
+
newTransaction();
- ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(byteArray.getId()));
+ ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(
+ byteArray.getId()));
assertNull(retrievedByteArray.getBytes());
+
+ session.delete(retrievedByteArray);
}
public void testByteArrayCopy() {
byte[] bytes = getMultipleBlockBytes();
ByteArray byteArray = new ByteArray(bytes);
session.save(byteArray);
+
newTransaction();
- ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(byteArray.getId()));
+ ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(
+ byteArray.getId()));
ByteArray copiedByteArray = new ByteArray(retrievedByteArray);
session.save(copiedByteArray);
+
newTransaction();
- retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(retrievedByteArray.getId()));
+ retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(
+ retrievedByteArray.getId()));
copiedByteArray = (ByteArray) session.load(ByteArray.class, new Long(copiedByteArray.getId()));
assertNotSame(retrievedByteArray.getByteBlocks(), copiedByteArray.getByteBlocks());
- for (int i=0; i<retrievedByteArray.getByteBlocks().size(); i++) {
+
+ for (int i = 0; i < retrievedByteArray.getByteBlocks().size(); i++) {
byte[] retrievedBytes = (byte[]) retrievedByteArray.getByteBlocks().get(i);
byte[] copiedBytes = (byte[]) copiedByteArray.getByteBlocks().get(i);
+
assertNotSame(retrievedBytes, copiedBytes);
assertTrue(Arrays.equals(retrievedBytes, copiedBytes));
}
+
+ session.delete(copiedByteArray);
+ session.delete(retrievedByteArray);
}
public void testNullByteArray() {
byte[] bytes = null;
ByteArray byteArray = new ByteArray(bytes);
session.save(byteArray);
+
newTransaction();
- ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(byteArray.getId()));
+ ByteArray retrievedByteArray = (ByteArray) session.load(ByteArray.class, new Long(
+ byteArray.getId()));
assertNull(retrievedByteArray.getBytes());
+
+ session.delete(retrievedByteArray);
}
private static byte[] getMultipleBlockBytes() {
- String text = "muchos bytes"; // (10 bytes)
- for (int i=0; i<8; i++) text+=text;
- // now text should be 2560 bytes
- return text.getBytes();
+ byte[] bytes = new byte[2560];
+ Arrays.fill(bytes, 0, 512, (byte) 67);
+ Arrays.fill(bytes, 512, 1024, (byte) 65);
+ Arrays.fill(bytes, 1024, 1536, (byte) 71);
+ Arrays.fill(bytes, 1536, 2048, (byte) 70);
+ Arrays.fill(bytes, 2048, 2560, (byte) 66);
+ return bytes;
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -21,6 +21,8 @@
*/
package org.jbpm.db;
+import java.util.Map;
+
import org.hibernate.cfg.Configuration;
import org.jbpm.AbstractJbpmTestCase;
@@ -30,26 +32,32 @@
* @author thomas.diesler(a)jboss.com
* @since 06-Nov-2008
*/
-public class JbpmSchemaDbTest extends AbstractJbpmTestCase
-{
- public void testCleanSchema()
- {
- Configuration config = new Configuration().configure();
- JbpmSchema jbpmSchema = new JbpmSchema(config);
- jbpmSchema.cleanSchema();
+public class JbpmSchemaDbTest extends AbstractJbpmTestCase {
+
+ JbpmSchema jbpmSchema;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ jbpmSchema = new JbpmSchema(new Configuration().configure());
}
-
- public void testDropSchema()
- {
- Configuration config = new Configuration().configure();
- JbpmSchema jbpmSchema = new JbpmSchema(config);
+
+ public void testCreateSchema() {
+ jbpmSchema.createSchema();
+ assertEquals(28, jbpmSchema.getAvailableTableNames().size());
+ }
+
+ public void testDropSchema() {
jbpmSchema.dropSchema();
+ assertEquals(0, jbpmSchema.getAvailableTableNames().size());
}
- public void testCreateSchema()
- {
- Configuration config = new Configuration().configure();
- JbpmSchema jbpmSchema = new JbpmSchema(config);
- jbpmSchema.createSchema();
+ public void testCleanSchema() {
+ jbpmSchema.cleanSchema();
+ Map<String, Long> rowsPerTable = jbpmSchema.getRowsPerTable();
+ assertEquals(28, rowsPerTable.size());
+ for (long rowCount : rowsPerTable.values()) {
+ assertEquals(0, rowCount);
+ }
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -13,8 +14,7 @@
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-public class JobExecutorDbTest extends AbstractDbTestCase
-{
+public class JobExecutorDbTest extends AbstractDbTestCase {
static final int nbrOfConcurrentProcessExecutions = 20;
static final int timeout = 60000;
@@ -23,29 +23,30 @@
static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
@Override
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
- deployProcess();
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(5);
}
@Override
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
getJbpmConfiguration().getJobExecutor().setNbrOfThreads(1);
- deleteProcess();
super.tearDown();
}
- public void testJobExecutor()
- {
- launchProcesses();
- processJobs(timeout);
- assertEquals(createExpectedResults(), collectedResults);
+ public void testJobExecutor() {
+ deployProcessDefinition();
+ try {
+ startProcessInstances();
+ processJobs(timeout);
+ assertEquals(getExpectedResults(), collectedResults);
+ }
+ finally {
+ deleteProcessDefinition();
+ }
}
- void deployProcess() {
+ void deployProcessDefinition() {
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='bulk messages'>"
+ " <start-state>"
+ " <transition to='a' />"
@@ -98,23 +99,20 @@
+ "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
+ newTransaction();
}
- void launchProcesses()
- {
- for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++)
- {
- newTransaction();
+ void startProcessInstances() {
+ for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++) {
ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("bulk messages");
processInstance.signal();
+ newTransaction();
}
}
- Set<String> createExpectedResults()
- {
- Set<String> expectedResults = new TreeSet<String>();
- for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++)
- {
+ Set<String> getExpectedResults() {
+ Set<String> expectedResults = new HashSet<String>();
+ for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++) {
String prefix = (i < 10 ? "0" : "");
expectedResults.add(prefix + i + "a");
expectedResults.add(prefix + i + "b");
@@ -128,19 +126,16 @@
return expectedResults;
}
- void deleteProcess()
- {
+ void deleteProcessDefinition() {
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("bulk messages");
graphSession.deleteProcessDefinition(processDefinition);
}
- public static class AutomaticActivity implements ActionHandler
- {
+ public static class AutomaticActivity implements ActionHandler {
private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception
- {
+ public void execute(ExecutionContext executionContext) throws Exception {
Long id = executionContext.getProcessInstance().getId();
String procIndex = getProcessIndex(id);
@@ -150,13 +145,11 @@
}
}
- public static class AsyncAction implements ActionHandler
- {
+ public static class AsyncAction implements ActionHandler {
private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception
- {
+ public void execute(ExecutionContext executionContext) throws Exception {
Long id = executionContext.getProcessInstance().getId();
String procIndex = getProcessIndex(id);
@@ -166,10 +159,8 @@
}
}
- static synchronized String getProcessIndex(Long id)
- {
- if (allocatedProcessIds.contains(id) == false)
- allocatedProcessIds.add(id);
+ static synchronized String getProcessIndex(Long id) {
+ if (allocatedProcessIds.contains(id) == false) allocatedProcessIds.add(id);
int procIndex = allocatedProcessIds.indexOf(id);
String prefix = (procIndex < 10 ? "0" : "");
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/logging/exe/LoggingConfigDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -1,10 +1,12 @@
package org.jbpm.logging.exe;
-import org.hibernate.Query;
+import java.util.List;
+
import org.jbpm.JbpmConfiguration;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.logging.log.ProcessLog;
public class LoggingConfigDbTest extends AbstractDbTestCase {
@@ -23,12 +25,15 @@
}
public void testLoggingconfiguration() {
- jbpmContext.deployProcessDefinition(new ProcessDefinition("logging"));
+ ProcessDefinition processDefinition = new ProcessDefinition("logging");
+ jbpmContext.deployProcessDefinition(processDefinition);
ProcessInstance processInstance = jbpmContext.newProcessInstance("logging");
processInstance.getContextInstance().setVariable("a", "1");
+
newTransaction();
+ List<?> logs = session.createCriteria(ProcessLog.class).list();
+ assertEquals(0, logs.size());
- Query query = session.createQuery("from org.jbpm.logging.log.ProcessLog");
- assertEquals(0, query.list().size());
+ graphSession.deleteProcessDefinition(processDefinition.getId());
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/seam/JobExecutorCustomizationTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -37,17 +37,15 @@
+ " <state name='end' />"
+ "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
+
newTransaction();
- try {
- jbpmContext.newProcessInstanceForUpdate("customjobexecution");
- processJobs(20 * 1000);
+ jbpmContext.newProcessInstanceForUpdate("customjobexecution");
- List<String> expectedJobEvents = Arrays.asList("before", "execute action", "after");
- assertEquals(expectedJobEvents, jobEvents);
- }
- finally {
- graphSession.deleteProcessDefinition(processDefinition.getId());
- }
+ processJobs(20 * 1000);
+ List<String> expectedJobEvents = Arrays.asList("before", "execute action", "after");
+ assertEquals(expectedJobEvents, jobEvents);
+
+ graphSession.deleteProcessDefinition(processDefinition.getId());
}
public static void addJobEvent(String event) {
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskInstanceDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskInstanceDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskInstanceDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -36,286 +35,251 @@
public class TaskInstanceDbTest extends AbstractDbTestCase {
- public void testTaskInstanceUnrelatedToAProcess()
- {
+ public void testTaskInstanceUnrelatedToAProcess() {
TaskInstance taskInstance = new TaskInstance("do laundry", "someoneelse");
session.save(taskInstance);
- long id = taskInstance.getId();
-
newTransaction();
- taskInstance = (TaskInstance)session.load(TaskInstance.class, new Long(id));
+ taskInstance = (TaskInstance) session.load(TaskInstance.class, taskInstance.getId());
assertNotNull(taskInstance);
assertEquals("do laundry", taskInstance.getName());
assertEquals("someoneelse", taskInstance.getActorId());
+
+ session.delete(taskInstance);
}
public void testTaskInstanceBasicLifeCycle() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling' />" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling' />"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
+
processInstance = saveAndReload(processInstance);
long tokenId = processInstance.getRootToken().getId();
- List taskInstances = taskMgmtSession.findTaskInstancesByToken(tokenId);
+ List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(tokenId);
assertEquals(1, taskInstances.size());
- TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
+
+ TaskInstance taskInstance = taskInstances.get(0);
assertFalse(taskInstance.hasEnded());
assertEquals(tokenId, taskInstance.getToken().getId());
// do some updates
taskInstance.end();
-
+
processInstance = saveAndReload(processInstance);
-
taskInstance = taskMgmtSession.loadTaskInstance(taskInstance.getId());
assertTrue(taskInstance.hasEnded());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
+
}
public void testTaskName() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling' />" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling' />"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
- processInstance = saveAndReload(processInstance);
- long tokenId = processInstance.getRootToken().getId();
- List taskInstances = taskMgmtSession.findTaskInstancesByToken(tokenId);
+ processInstance = saveAndReload(processInstance);
+ List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
+ .getId());
assertEquals(1, taskInstances.size());
- TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
+
+ TaskInstance taskInstance = taskInstances.get(0);
assertFalse(taskInstance.hasEnded());
assertEquals("clean ceiling", taskInstance.getName());
assertEquals("clean ceiling", taskInstance.getTask().getName());
// do some updates
taskInstance.setName("clean ceiling thoroughly");
-
+
processInstance = saveAndReload(processInstance);
taskInstance = taskMgmtSession.loadTaskInstance(taskInstance.getId());
-
assertEquals("clean ceiling thoroughly", taskInstance.getName());
assertEquals("clean ceiling", taskInstance.getTask().getName());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
-
+
public void testTaskComments() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='clean ceiling' />" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='clean ceiling' />"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
- processInstance = saveAndReload(processInstance);
- long tokenId = processInstance.getRootToken().getId();
- List taskInstances = taskMgmtSession.findTaskInstancesByToken(tokenId);
+ processInstance = saveAndReload(processInstance);
+ List<TaskInstance> taskInstances = taskMgmtSession.findTaskInstancesByToken(processInstance.getRootToken()
+ .getId());
assertEquals(1, taskInstances.size());
- TaskInstance taskInstance = (TaskInstance) taskInstances.get(0);
+ TaskInstance taskInstance = taskInstances.get(0);
taskInstance.addComment("please hurry!");
-
+
processInstance = saveAndReload(processInstance);
taskInstance = taskMgmtSession.loadTaskInstance(taskInstance.getId());
-
- List comments = taskInstance.getComments();
+
+ List<Comment> comments = taskInstance.getComments();
assertEquals(1, comments.size());
-
- Comment comment = (Comment) comments.get(0);
+
+ Comment comment = comments.get(0);
assertEquals("please hurry!", comment.getMessage());
assertSame(taskInstance, comment.getTaskInstance());
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
-
+
public void testBlockingTask() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <task-node name='a'>" +
- " <task name='laundry' blocking='true' />" +
- " <transition to='b' />" +
- " </task-node>" +
- " <state name='b' />" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <task-node name='a'>"
+ + " <task name='laundry' blocking='true' />"
+ + " <transition to='b' />"
+ + " </task-node>"
+ + " <state name='b' />"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
Token token = processInstance.getRootToken();
- processInstance.signal();
+ token.signal();
assertEquals("a", token.getNode().getName());
+
processInstance = saveAndReload(processInstance);
try {
processInstance.signal();
fail("expected exception");
- } catch (IllegalStateException e) {
+ }
+ catch (IllegalStateException e) {
// OK
}
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
public void testConditionalTasksOne() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='release' />" +
- " </start-state>" +
- " <task-node name='release'>" +
- " <task name='updateWebsite' condition='#{user.admin}' />" +
- " <task name='addNewsItem' />" +
- " <task name='publishRelease' condition='#{user.releaseManager}' />" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='release' />"
+ + " </start-state>"
+ + " <task-node name='release'>"
+ + " <task name='updateWebsite' condition='#{user.admin}' />"
+ + " <task name='addNewsItem' />"
+ + " <task name='publishRelease' condition='#{user.releaseManager}' />"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.getContextInstance().setVariable("user", new User(true, false));
processInstance.signal();
processInstance = saveAndReload(processInstance);
- Collection taskInstances = processInstance.getTaskMgmtInstance().getTaskInstances();
- Set createdTasks = new HashSet();
- Iterator iter = taskInstances.iterator();
- while (iter.hasNext()) {
- TaskInstance taskInstance = (TaskInstance) iter.next();
- createdTasks.add(taskInstance.getName());
- }
+ Collection<TaskInstance> taskInstances = processInstance.getTaskMgmtInstance()
+ .getTaskInstances();
- Set expectedTasks = new HashSet();
- expectedTasks.add("updateWebsite");
- expectedTasks.add("addNewsItem");
-
- assertEquals(expectedTasks, createdTasks);
+ Set<String> taskNames = new HashSet<String>();
+ for (TaskInstance taskInstance : taskInstances) {
+ taskNames.add(taskInstance.getName());
+ }
+ assertEquals(2, taskNames.size());
+ assert taskNames.contains("updateWebsite") : taskNames;
+ assert taskNames.contains("addNewsItem") : taskNames;
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
public void testConditionalTasksTwo() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='release' />" +
- " </start-state>" +
- " <task-node name='release'>" +
- " <task name='updateWebsite' condition='#{user.admin}' />" +
- " <task name='addNewsItem' />" +
- " <task name='publishRelease' condition='#{user.releaseManager}' />" +
- " </task-node>" +
- "</process-definition>"
- );
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition>"
+ + " <start-state>"
+ + " <transition to='release' />"
+ + " </start-state>"
+ + " <task-node name='release'>"
+ + " <task name='updateWebsite' condition='#{user.admin}' />"
+ + " <task name='addNewsItem' />"
+ + " <task name='publishRelease' condition='#{user.releaseManager}' />"
+ + " </task-node>"
+ + "</process-definition>");
processDefinition = saveAndReload(processDefinition);
- try
- {
+ try {
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.getContextInstance().setVariable("user", new User(false, true));
processInstance.signal();
processInstance = saveAndReload(processInstance);
- Collection taskInstances = processInstance.getTaskMgmtInstance().getTaskInstances();
- Set createdTasks = new HashSet();
- Iterator iter = taskInstances.iterator();
- while (iter.hasNext()) {
- TaskInstance taskInstance = (TaskInstance) iter.next();
- createdTasks.add(taskInstance.getName());
+ Collection<TaskInstance> taskInstances = processInstance.getTaskMgmtInstance()
+ .getTaskInstances();
+ Set<String> taskNames = new HashSet<String>();
+ for (TaskInstance taskInstance : taskInstances) {
+ taskNames.add(taskInstance.getName());
}
- Set expectedTasks = new HashSet();
- expectedTasks.add("addNewsItem");
- expectedTasks.add("publishRelease");
-
- assertEquals(expectedTasks, createdTasks);
+ assertEquals(2, taskNames.size());
+ assert taskNames.contains("addNewsItem") : taskNames;
+ assert taskNames.contains("publishRelease") : taskNames;
}
- finally
- {
+ finally {
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
- public static class User implements Serializable
- {
+ public static class User implements Serializable {
private static final long serialVersionUID = 1L;
boolean isAdmin;
boolean isReleaseManager;
- public User(boolean isAdmin, boolean isReleaseManager)
- {
+ public User(boolean isAdmin, boolean isReleaseManager) {
this.isAdmin = isAdmin;
this.isReleaseManager = isReleaseManager;
}
- public boolean isAdmin()
- {
+ public boolean isAdmin() {
return isAdmin;
}
- public boolean isReleaseManager()
- {
+ public boolean isReleaseManager() {
return isReleaseManager;
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/log/TaskLogDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/log/TaskLogDbTest.java 2009-02-17 20:07:30 UTC (rev 3908)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/log/TaskLogDbTest.java 2009-02-18 03:40:51 UTC (rev 3909)
@@ -24,66 +24,54 @@
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class TaskLogDbTest extends AbstractDbTestCase
-{
+public class TaskLogDbTest extends AbstractDbTestCase {
- TaskInstance taskInstance = null;
+ TaskInstance taskInstance;
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
taskInstance = new TaskInstance();
session.save(taskInstance);
}
- protected void tearDown() throws Exception
- {
- taskInstance = null;
+ protected void tearDown() throws Exception {
+ session.delete(taskInstance);
super.tearDown();
}
- public void testTaskCreateLog()
- {
+ public void testTaskCreateLog() {
TaskCreateLog taskLog = new TaskCreateLog(taskInstance, "someone else");
session.save(taskLog);
newTransaction();
+ taskLog = (TaskCreateLog) session.load(TaskCreateLog.class, new Long(taskLog.getId()));
+ assertEquals(taskInstance.getId(), (taskInstance = taskLog.getTaskInstance()).getId());
+ assertEquals("someone else", taskLog.getTaskActorId());
- taskLog = (TaskCreateLog)session.load(TaskCreateLog.class, new Long(taskLog.getId()));
- assertNotNull(taskLog);
- assertNotNull(taskLog.getTaskInstance());
- assertEquals("someone else", (taskLog.getTaskActorId()));
-
session.delete(taskLog);
}
- public void testTaskAssignLog()
- {
+ public void testTaskAssignLog() {
TaskAssignLog taskLog = new TaskAssignLog(taskInstance, "me", "toyou");
session.save(taskLog);
newTransaction();
+ taskLog = (TaskAssignLog) session.load(TaskAssignLog.class, new Long(taskLog.getId()));
+ assertEquals(taskInstance.getId(), (taskInstance = taskLog.getTaskInstance()).getId());
+ assertEquals("me", taskLog.getTaskOldActorId());
+ assertEquals("toyou", taskLog.getTaskNewActorId());
- taskLog = (TaskAssignLog)session.load(TaskAssignLog.class, new Long(taskLog.getId()));
- assertNotNull(taskLog);
- assertNotNull(taskLog.getTaskInstance());
- assertEquals("me", (taskLog.getTaskOldActorId()));
- assertEquals("toyou", (taskLog.getTaskNewActorId()));
-
session.delete(taskLog);
-}
+ }
- public void testTaskEndLog()
- {
+ public void testTaskEndLog() {
TaskEndLog taskLog = new TaskEndLog(taskInstance);
session.save(taskLog);
newTransaction();
+ taskLog = (TaskEndLog) session.load(TaskEndLog.class, new Long(taskLog.getId()));
+ assertEquals(taskInstance.getId(), (taskInstance = taskLog.getTaskInstance()).getId());
- taskLog = (TaskEndLog)session.load(TaskEndLog.class, new Long(taskLog.getId()));
- assertNotNull(taskLog);
- assertNotNull(taskLog.getTaskInstance());
-
session.delete(taskLog);
}
}
17 years, 2 months
JBoss JBPM SVN: r3908 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/cmd and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-02-17 15:07:30 -0500 (Tue, 17 Feb 2009)
New Revision: 3908
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
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/TaskServiceImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
Log:
adding task participant removal and adding swimlane participants
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -23,9 +23,11 @@
import java.util.List;
+import org.jbpm.task.GroupRef;
import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participant;
import org.jbpm.task.Task;
+import org.jbpm.task.UserRef;
/**
* Human task management facility.
@@ -56,7 +58,7 @@
/** add a role to a given task.
- * @param identityRef wither a new User(String) or a new Group(String)
+ * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
* @param participation specifies the kind of involvement of the participant
* in this task. see {@link Participant} for default constants. */
void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
@@ -67,18 +69,27 @@
/** removes a role to a given task. Nothing happens (no exception) if
* the role does not exist.
- * @param identityRef wither a new User(String) or a new Group(String)
+ * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
* @param participation specifies the kind of involvement of the participant
* in this task. see {@link Participant} for default constants. */
void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
- /*
- void addSwimlaneRole(long taskDbid, String refId, RoleType roleType, String role);
- List<UserRole> getSwimlaneRoles(long taskDbid, RoleType roleType, String role);
- void removeSwimlaneRole(long taskDbid, String refId, RoleType roleType, String userRoleType);
- */
+ /** add a role from a given swimlane.
+ * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
+ * @param participation specifies the kind of involvement of the participant
+ * in this swimlane. see {@link Participant} for default constants. */
+ void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation);
+ /** get roles related to a given swimlane. */
+ List<Participant> getSwimlaneParticipants(long szimlaneDbid);
+ /** remove a role from a given swimlane.
+ * @param identityRef wither a new {@link UserRef} or a new {@link GroupRef}
+ * @param participation specifies the kind of involvement of the participant
+ * in this swimlane. see {@link Participant} for default constants. */
+ void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation);
+
+
TaskQuery createTaskQuery();
/** retrieves the personal task of the given user, which might be different
@@ -90,5 +101,4 @@
* The user id will be resolved to a set of candidate identities
* by the identity spi. */
List<Task> getGroupTaskList(String userId, int firstResult, int maxResults);
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -56,7 +56,7 @@
throw new JbpmException("task "+taskDbid+" was not found");
}
- task.addRole(identityRef, participation);
+ task.addParticipant(identityRef, participation);
}
/*
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -21,8 +21,15 @@
*/
package org.jbpm.pvm.internal.cmd;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
import org.jbpm.cmd.Command;
import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.task.IdentityRef;
@@ -46,6 +53,25 @@
}
public Object execute(Environment environment) throws Exception {
+ Session session = Environment.getFromCurrent(Session.class);
+
+
+ if (taskDbid!=null) {
+ TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+ if (task==null) {
+ throw new JbpmException("task "+taskDbid+" was not found");
+ }
+
+ Set<ParticipantImpl> participants = new HashSet<ParticipantImpl>(task.getParticipants());
+ for (ParticipantImpl participant : participants) {
+ if ( participant.getIdentityRef().equals(identityRef)
+ && participant.getParticipation().equals(participation)
+ ) {
+ task.removeParticipant(participant);
+ }
+ }
+ }
+
return null;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -22,11 +22,13 @@
package org.jbpm.pvm.internal.task;
import java.io.Serializable;
-import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
+import org.jbpm.JbpmException;
import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.task.IdentityRef;
import org.jbpm.task.Participant;
import org.jbpm.task.Swimlane;
@@ -54,14 +56,43 @@
this.assignee = assignee;
}
- // candidates ///////////////////////////////////////////////////////////////
+ // participants /////////////////////////////////////////////////////////////
- public Collection<Participant> getParticipants() {
+ // participants /////////////////////////////////////////////////////////////
+
+ public Set<ParticipantImpl> getParticipants() {
if (participants==null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptySet();
}
- return (Collection)participants;
+ return participants;
}
+
+ public Participant addParticipant(IdentityRef identityRef, String participation) {
+ if (identityRef==null) {
+ throw new JbpmException("identityRef is null");
+ }
+ if (participation==null) {
+ throw new JbpmException("participation is null");
+ }
+ ParticipantImpl participant = new ParticipantImpl(identityRef, participation);
+ participant.setSwimlane(this);
+ if (participants==null) {
+ participants = new HashSet<ParticipantImpl>();
+ }
+ participants.add(participant);
+ return participant;
+ }
+
+ public void removeParticipant(ParticipantImpl participant) {
+ if (participant==null) {
+ throw new JbpmException("participant is null");
+ }
+ if ( (participants!=null)
+ && (participants.remove(participant))
+ ) {
+ ((ParticipantImpl)participant).setSwimlane(null);
+ }
+ }
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
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-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -138,7 +138,7 @@
return null;
}
- // roles ////////////////////////////////////////////////////////////////////
+ // participants /////////////////////////////////////////////////////////////
public Set<ParticipantImpl> getParticipants() {
if (participants==null) {
@@ -147,7 +147,7 @@
return participants;
}
- public Set<ParticipantImpl> getAllRoles() {
+ public Set<ParticipantImpl> getAllParticipants() {
Set<ParticipantImpl> allRoles = null;
if (participants!=null) {
allRoles = new HashSet<ParticipantImpl>(participants);
@@ -160,27 +160,30 @@
return allRoles;
}
- public Participant addRole(IdentityRef identityRef, String participation) {
+ public Participant addParticipant(IdentityRef identityRef, String participation) {
if (identityRef==null) {
- throw new JbpmException("identity is null");
+ throw new JbpmException("identityRef is null");
}
- ParticipantImpl role = new ParticipantImpl(identityRef, participation);
- role.setTask(this);
+ if (participation==null) {
+ throw new JbpmException("participation is null");
+ }
+ ParticipantImpl participant = new ParticipantImpl(identityRef, participation);
+ participant.setTask(this);
if (participants==null) {
participants = new HashSet<ParticipantImpl>();
}
- participants.add(role);
- return role;
+ participants.add(participant);
+ return participant;
}
- public void removeRole(ParticipantImpl role) {
- if (role==null) {
- throw new JbpmException("role is null");
+ public void removeParticipant(ParticipantImpl participant) {
+ if (participant==null) {
+ throw new JbpmException("participant is null");
}
if ( (participants!=null)
- && (participants.remove(role))
+ && (participants.remove(participant))
) {
- ((ParticipantImpl)role).setTask(null);
+ ((ParticipantImpl)participant).setTask(null);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -31,6 +31,7 @@
import org.jbpm.pvm.internal.cmd.GetParticipants;
import org.jbpm.pvm.internal.cmd.GetTaskCmd;
import org.jbpm.pvm.internal.cmd.NewTaskCmd;
+import org.jbpm.pvm.internal.cmd.RemoveParticipant;
import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
import org.jbpm.task.IdentityRef;
@@ -92,10 +93,21 @@
}
public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
- throw new UnsupportedOperationException();
- // commandService.execute(new RemoveRole(taskDbid, identityType, identityId, roleName));
+ commandService.execute(new RemoveParticipant(taskDbid, null, identityRef, participation));
}
+ public void addSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+ commandService.execute(new AddParticipant(null, szimlaneDbid, identityRef, participation));
+ }
+
+ public List<Participant> getSwimlaneParticipants(long szimlaneDbid) {
+ return commandService.execute(new GetParticipants(null, szimlaneDbid));
+ }
+
+ public void removeSwimlaneParticipant(long szimlaneDbid, IdentityRef identityRef, String participation) {
+ commandService.execute(new RemoveParticipant(null, szimlaneDbid, identityRef, participation));
+ }
+
public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
return createTaskQuery()
.assignee(assignee)
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-02-17 17:21:02 UTC (rev 3907)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-02-17 20:07:30 UTC (rev 3908)
@@ -69,8 +69,34 @@
expectedIdentityRefs.add(new UserRef("joesmoe"));
assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+
+ taskService.removeTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.OWNER);
+ taskService.removeTaskParticipant(taskDbid, new GroupRef("losers"), Participant.CANDIDATE);
+
+
+ taskParticipants = taskService.getTaskParticipants(taskDbid);
+
+ candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.CANDIDATE);
+
+ expectedIdentityRefs = new HashSet<IdentityRef>();
+ expectedIdentityRefs.add(new UserRef("johndoe"));
+ expectedIdentityRefs.add(new UserRef("joesmoe"));
+ expectedIdentityRefs.add(new GroupRef("dummies"));
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+
+ candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.OWNER);
+
+ expectedIdentityRefs = new HashSet<IdentityRef>();
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
}
+ public void testSwimlaneParticipants() {
+
+ }
+
+
public Set<IdentityRef> getIdentityRefs(List<Participant> taskParticipants, String participation) {
Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
for (Participant participant: taskParticipants) {
17 years, 2 months
JBoss JBPM SVN: r3907 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/session and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-02-17 12:21:02 -0500 (Tue, 17 Feb 2009)
New Revision: 3907
Added:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
Removed:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/processlog/
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.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/task/SwimlaneImpl.java
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/TaskServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
Log:
JBPM-1861 and JBPM-1998 adding task participants
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -23,7 +23,8 @@
import java.util.List;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Task;
/**
@@ -43,18 +44,41 @@
/** Retrieves the task with the given identifier from persistent storage.
* If no task with the given identifier exists,
* the call returns <code>null</code>. */
- Task getTask(String taskId);
+ Task getTask(long taskDbid);
/** Marks the task with the given identifier as completed.
* This operation may result in a process instance being resumed. */
- void submitTask(String taskId);
+ void submitTask(long taskDbid);
/** Removes the task with the given identifier from persistent storage. */
- void deleteTask(String taskId);
+ void deleteTask(long taskDbid);
+
+
- List<String> getCandidates(String taskId);
- List<Role> getRoles(String taskId);
+ /** add a role to a given task.
+ * @param identityRef wither a new User(String) or a new Group(String)
+ * @param participation specifies the kind of involvement of the participant
+ * in this task. see {@link Participant} for default constants. */
+ void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+
+
+ /** get roles related to a given task. */
+ List<Participant> getTaskParticipants(long taskDbid);
+ /** removes a role to a given task. Nothing happens (no exception) if
+ * the role does not exist.
+ * @param identityRef wither a new User(String) or a new Group(String)
+ * @param participation specifies the kind of involvement of the participant
+ * in this task. see {@link Participant} for default constants. */
+ void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation);
+
+ /*
+ void addSwimlaneRole(long taskDbid, String refId, RoleType roleType, String role);
+ List<UserRole> getSwimlaneRoles(long taskDbid, RoleType roleType, String role);
+ void removeSwimlaneRole(long taskDbid, String refId, RoleType roleType, String userRoleType);
+ */
+
+
TaskQuery createTaskQuery();
/** retrieves the personal task of the given user, which might be different
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/TaskDbSession.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -29,7 +29,7 @@
*/
public interface TaskDbSession extends DbSession {
- Task findTaskById(String taskId);
+ Task findTaskByDbid(long taskDbid);
void saveTask(Task task);
}
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,40 @@
+/*
+ * 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.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GroupRef extends IdentityRef {
+
+ private static final long serialVersionUID = 1L;
+
+ public GroupRef(String groupId) {
+ super(groupId);
+ }
+
+ public String toString() {
+ return "GroupRef("+id+")";
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/GroupRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,68 @@
+/*
+ * 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.task;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class IdentityRef implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String id;
+
+ public IdentityRef(String id) {
+ if (id==null) {
+ throw new JbpmException("id is null");
+ }
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IdentityRef other = (IdentityRef) obj;
+ if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/IdentityRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java (from rev 3880, jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java)
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Participant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,58 @@
+/*
+ * 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.task;
+
+
+/** a link to a participant (user or group) and the type of
+ * involvement of that participant.
+ *
+ * @author Tom Baeyens
+ */
+public interface Participant {
+
+ /** alternative owner, but as long as this person is not the owner.
+ * This person is allowed to make comments, but nothing else. */
+ String CANDIDATE = "candidate";
+
+ /** the person with ultimate responsibility over a task. */
+ String OWNER = "owner";
+
+ /** person that will be using the result of this task. This person is
+ * allowed to make comments, but nothing else. */
+ String CLIENT = "client";
+
+ /** person that is allowed to watch-but-not-touch this task */
+ String VIEWER = "viewer";
+
+ /** a person that was assigned to a task, but got replaced because of
+ * absence or another reason. This way, a trace can be left in case
+ * this person returns and wants to take back his tasks that got
+ * reassigned. */
+ String REPLACED_ASSIGNEE = "replaced-assignee";
+
+ long getDbid();
+
+ IdentityRef getIdentityRef();
+
+ /** see contants for default particpations */
+ String getParticipation();
+}
Deleted: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Role.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -1,48 +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.task;
-
-
-/** a role that a person fullfills for a task.
- *
- * @author Tom Baeyens
- */
-public interface Role {
-
- long getDbid();
-
- String getIdentityId();
- void setIdentityId(String identityId);
-
- /*
- User getUser();
- Group getGroup();
- */
-
- String getRoleType();
- void setRoleType(String roleType);
-
- String getDescription();
- void setDescription(String description);
-
- Task getTask();
-}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Swimlane.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -22,7 +22,6 @@
package org.jbpm.task;
import java.io.Serializable;
-import java.util.Collection;
/** a runtime process role that can store an assignment so that
* multiple related tasks are assigned to the same actor.
@@ -37,8 +36,4 @@
String getAssignee();
void setAssignee(String assignee);
-
- Collection<Role> getCandidates();
- Role createCandidate(String identityId);
- void removeCandidate(Role candidate);
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/Task.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -30,28 +30,8 @@
*/
public interface Task extends Serializable {
- /** can do anything with the task */
- String ROLETYPE_OWNER = "owner";
-
- /** alternative owner, but as long as this person is not the owner.
- * This person is allowed to make comments, but nothing else. */
- String ROLETYPE_CANDIDATE = "candidate";
-
- /** person that will be using the result of this task. This person is
- * allowed to make comments, but nothing else. */
- String ROLETYPE_CLIENT = "client";
-
- /** person that is allowed to watch-but-not-touch this task */
- String ROLETYPE_VIEWER = "viewer";
-
- /** a person that was assigned to a task, but got replaced because of
- * absence or another reason. This way, a trace can be left in case
- * This person returns and wants to take back his tasks that got
- * reassigned. */
- String ROLETYPE_REPLACED_ASSIGNEE = "replaced-assignee";
+ long getDbid();
- String getId();
-
String getName();
void setName(String name);
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,40 @@
+/*
+ * 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.task;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserRef extends IdentityRef {
+
+ private static final long serialVersionUID = 1L;
+
+ public UserRef(String userId) {
+ super(userId);
+ }
+
+ public String toString() {
+ return "UserRef("+id+")";
+ }
+}
Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/UserRef.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/TaskTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -46,7 +46,7 @@
assertEquals("johndoe", task.getAssignee());
// submit the task
- taskService.submitTask(task.getId());
+ taskService.submitTask(task.getDbid());
// verify that the task list is now empty
taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,75 @@
+/*
+ * 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.pvm.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.task.IdentityRef;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AddParticipant implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Long taskDbid;
+ protected Long swimlaneDbid;
+ protected IdentityRef identityRef;
+ protected String participation;
+
+ public AddParticipant(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+ this.taskDbid = taskDbid;
+ this.swimlaneDbid = swimlaneDbid;
+ this.identityRef = identityRef;
+ this.participation = participation;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = Environment.getFromCurrent(Session.class);
+
+ if (taskDbid!=null) {
+ TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
+ if (task==null) {
+ throw new JbpmException("task "+taskDbid+" was not found");
+ }
+
+ task.addRole(identityRef, participation);
+ }
+
+ /*
+ if (swimlaneDbid!=null) {
+ SwimlaneImpl swimlane = (TaskImpl) session.get(SwimlaneImpl.class, swimlaneDbid);
+ if (swimlane==null) {
+ throw new JbpmException("swimlane "+swimlaneDbid+" was not found");
+ }
+
+ swimlane.addRole(identityType, identityId, roleName);
+ }
+ */
+
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipant.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -33,15 +33,15 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
- public DeleteTaskCmd(String taskId) {
- this.taskId = taskId;
+ public DeleteTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Void execute(Environment environment) throws Exception {
TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
- Task task = taskDbSession.findTaskById(taskId);
+ Task task = taskDbSession.findTaskByDbid(taskDbid);
taskDbSession.delete(task);
return null;
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,79 @@
+/*
+ * 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.pvm.internal.cmd;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.JbpmException;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
+import org.jbpm.task.Participant;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetParticipants implements Command<List<Participant>> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Long taskDbid;
+ protected Long swimlaneDbid;
+
+ public GetParticipants(Long taskDbid, Long swimlaneDbid) {
+ this.taskDbid = taskDbid;
+ this.swimlaneDbid = swimlaneDbid;
+ }
+
+ public List<Participant> execute(Environment environment) throws Exception {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select role from ");
+ hql.append(ParticipantImpl.class.getName());
+ hql.append(" as role where ");
+
+ if (taskDbid!=null) {
+ hql.append(" role.task.dbid = :taskDbid ");
+
+ } else if (swimlaneDbid!=null) {
+ hql.append(" role.swimlane.dbid = :swimlaneDbid ");
+
+ } else {
+ throw new JbpmException("no task nor swimlane specified");
+ }
+
+ Session session = Environment.getFromCurrent(Session.class);
+ Query query = session.createQuery(hql.toString());
+
+ if (taskDbid!=null) {
+ query.setLong("taskDbid", taskDbid);
+
+ } else if (swimlaneDbid!=null) {
+ query.setLong("swimlaneDbid", swimlaneDbid);
+ }
+
+ List<Participant> participants = query.list();
+ return participants;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetParticipants.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/GetTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -33,14 +33,14 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
- public GetTaskCmd(String taskId) {
- this.taskId = taskId;
+ public GetTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Task execute(Environment environment) throws Exception {
TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
- return taskDbSession.findTaskById(taskId);
+ return taskDbSession.findTaskByDbid(taskDbid);
}
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,51 @@
+/*
+ * 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.pvm.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.IdentityRef;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RemoveParticipant implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Long taskDbid;
+ protected Long swimlaneDbid;
+ protected IdentityRef identityRef;
+ protected String participation;
+
+ public RemoveParticipant(Long taskDbid, Long swimlaneDbid, IdentityRef identityRef, String participation) {
+ this.swimlaneDbid = swimlaneDbid;
+ this.taskDbid = taskDbid;
+ this.identityRef = identityRef;
+ this.participation = participation;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipant.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SubmitTaskCmd.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -34,15 +34,15 @@
private static final long serialVersionUID = 1L;
- protected String taskId;
+ protected long taskDbid;
protected TaskImpl task;
public SubmitTaskCmd(TaskImpl task) {
this.task = task;
}
- public SubmitTaskCmd(String taskId) {
- this.taskId = taskId;
+ public SubmitTaskCmd(long taskDbid) {
+ this.taskDbid = taskDbid;
}
public Void execute(Environment environment) throws Exception {
@@ -50,7 +50,7 @@
if (task!=null) {
taskDbession.merge(task);
} else {
- task = (TaskImpl) taskDbession.findTaskById(taskId);
+ task = (TaskImpl) taskDbession.findTaskByDbid(taskDbid);
}
task.submit();
taskDbession.delete(task);
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-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateTaskDbSession.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -23,7 +23,6 @@
import java.io.Serializable;
-import org.hibernate.criterion.Restrictions;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.session.TaskDbSession;
import org.jbpm.task.Task;
@@ -33,12 +32,10 @@
*/
public class HibernateTaskDbSession extends HibernateDbSession implements TaskDbSession {
- public TaskImpl findTaskById(String taskId) {
+ public TaskImpl findTaskByDbid(long taskDbid) {
// TODO maybe we should move these criteria queries to hql queries in the
// hbm file so that users can easily customize.
- return (TaskImpl) session.createCriteria(TaskImpl.class)
- .add(Restrictions.eq("id", taskId))
- .uniqueResult();
+ return (TaskImpl) session.get(TaskImpl.class, taskDbid);
}
public void saveTask(Task task) {
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java (from rev 3881, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipantImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,107 @@
+/*
+ * 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.pvm.internal.task;
+
+import java.io.Serializable;
+
+import org.jbpm.JbpmException;
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.UserRef;
+
+
+/** the relation between a task and a person.
+ * @author Tom Baeyens
+ */
+public class ParticipantImpl implements Serializable, Participant {
+
+ private static final long serialVersionUID = 1L;
+
+ protected long dbid;
+ protected int dbversion;
+
+ protected String identityType;
+ protected String identityId;
+ protected String participation;
+ protected TaskImpl task;
+ protected SwimlaneImpl swimlane;
+
+ public ParticipantImpl() {
+ }
+
+ public ParticipantImpl(IdentityRef identityRef, String participation) {
+ setIdentityRef(identityRef);
+ this.participation = participation;
+ }
+
+ public IdentityRef getIdentityRef() {
+ if ("U".equals(identityType)) {
+ return new UserRef(identityId);
+ }
+ return new GroupRef(identityId);
+ }
+
+ public void setIdentityRef(IdentityRef identityRef) {
+ if (identityRef==null) {
+ throw new JbpmException("identityRef is null");
+ }
+
+ if (identityRef instanceof UserRef) {
+ identityType = "U";
+ } else if (identityRef instanceof GroupRef) {
+ identityType = "G";
+ } else {
+ throw new JbpmException("invalid identity type: "+identityRef.getClass().getName());
+ }
+
+ identityId = identityRef.getId();
+ }
+
+ public TaskImpl getTask() {
+ return task;
+ }
+ public void setTask(TaskImpl task) {
+ this.task = task;
+ }
+ public long getDbid() {
+ return dbid;
+ }
+ public SwimlaneImpl getSwimlane() {
+ return swimlane;
+ }
+ public void setSwimlane(SwimlaneImpl swimlane) {
+ this.swimlane = swimlane;
+ }
+ public String getParticipation() {
+ return participation;
+ }
+ public void setParticipation(String participation) {
+ this.participation = participation;
+ }
+ public String getIdentityId() {
+ return identityId;
+ }
+ public void setIdentityId(String identityId) {
+ this.identityId = identityId;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/RoleImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -1,81 +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.pvm.internal.task;
-
-import java.io.Serializable;
-
-import org.jbpm.task.Role;
-
-
-/** the relation between a task and a person.
- * @author Tom Baeyens
- */
-public class RoleImpl implements Serializable, Role {
-
- private static final long serialVersionUID = 1L;
-
- protected long dbid;
- protected int dbversion;
- protected String identityId;
- protected String roleType;
- protected String description;
- protected TaskImpl task;
- protected SwimlaneImpl swimlane;
-
- public String toString() {
- return roleType.toString()+"("+identityId+")";
- }
-
- public TaskImpl getTask() {
- return task;
- }
- public void setTask(TaskImpl task) {
- this.task = task;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public long getDbid() {
- return dbid;
- }
- public SwimlaneImpl getSwimlane() {
- return swimlane;
- }
- public void setSwimlane(SwimlaneImpl swimlane) {
- this.swimlane = swimlane;
- }
- public String getIdentityId() {
- return identityId;
- }
- public void setIdentityId(String identityId) {
- this.identityId = identityId;
- }
- public String getRoleType() {
- return roleType;
- }
- public void setRoleType(String roleType) {
- this.roleType = roleType;
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -24,14 +24,11 @@
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
-import org.jbpm.JbpmException;
import org.jbpm.pvm.internal.util.EqualsUtil;
-import org.jbpm.task.Role;
+import org.jbpm.task.Participant;
import org.jbpm.task.Swimlane;
-import org.jbpm.task.Task;
/**
* runtime process role for a specific process instance.
@@ -44,7 +41,7 @@
protected int dbversion;
protected String name = null;
protected String assignee = null;
- protected Set<RoleImpl> candidates = null;
+ protected Set<ParticipantImpl> participants = null;
protected SwimlaneDefinitionImpl swimlaneDefinition = null;
// assignment methods ///////////////////////////////////////////////////////
@@ -59,39 +56,13 @@
// candidates ///////////////////////////////////////////////////////////////
- public Collection<Role> getCandidates() {
- if (candidates==null) {
+ public Collection<Participant> getParticipants() {
+ if (participants==null) {
return Collections.EMPTY_LIST;
}
- return (Collection)candidates;
+ return (Collection)participants;
}
- public Role createCandidate(String identityId) {
- if (identityId==null) {
- throw new JbpmException("identityId is null");
- }
- RoleImpl role = new RoleImpl();
- role.setIdentityId(identityId);
- role.setRoleType(Task.ROLETYPE_CANDIDATE);
- role.setSwimlane(this);
- if (candidates==null) {
- candidates = new HashSet<RoleImpl>();
- }
- candidates.add(role);
- return role;
- }
-
- public void removeCandidate(Role candidate) {
- if (candidate==null) {
- throw new JbpmException("candidate is null");
- }
- if ( (candidates!=null)
- && (candidates.remove(candidate))
- ) {
- ((RoleImpl)candidate).setTask(null);
- }
- }
-
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
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-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -39,7 +39,8 @@
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Swimlane;
import org.jbpm.task.Task;
@@ -58,7 +59,7 @@
protected String description;
protected String assignee;
- protected Set<RoleImpl> roles;
+ protected Set<ParticipantImpl> participants;
protected Date create;
protected Date dueDate;
@@ -139,52 +140,47 @@
// roles ////////////////////////////////////////////////////////////////////
- public Set<RoleImpl> getRoles() {
- if (roles==null) {
+ public Set<ParticipantImpl> getParticipants() {
+ if (participants==null) {
return Collections.emptySet();
}
- return roles;
+ return participants;
}
-
- public Set<RoleImpl> getAllRoles() {
- Set<RoleImpl> allRoles = null;
- if (roles!=null) {
- allRoles = new HashSet<RoleImpl>(roles);
+
+ public Set<ParticipantImpl> getAllRoles() {
+ Set<ParticipantImpl> allRoles = null;
+ if (participants!=null) {
+ allRoles = new HashSet<ParticipantImpl>(participants);
} else {
- allRoles = new HashSet<RoleImpl>();
+ allRoles = new HashSet<ParticipantImpl>();
}
if (swimlane!=null) {
- allRoles.addAll((Set)swimlane.getCandidates());
+ allRoles.addAll((Set)swimlane.getParticipants());
}
return allRoles;
}
-
- public Role addRole(String identityId, String roleType) {
- if (identityId==null) {
- throw new JbpmException("userId is null");
+
+ public Participant addRole(IdentityRef identityRef, String participation) {
+ if (identityRef==null) {
+ throw new JbpmException("identity is null");
}
- if (roleType==null) {
- throw new JbpmException("roleType is null");
- }
- RoleImpl role = new RoleImpl();
- role.setIdentityId(identityId);
+ ParticipantImpl role = new ParticipantImpl(identityRef, participation);
role.setTask(this);
- role.setRoleType(roleType);
- if (roles==null) {
- roles = new HashSet<RoleImpl>();
+ if (participants==null) {
+ participants = new HashSet<ParticipantImpl>();
}
- roles.add(role);
+ participants.add(role);
return role;
}
-
- public void removeRole(Role role) {
+
+ public void removeRole(ParticipantImpl role) {
if (role==null) {
throw new JbpmException("role is null");
}
- if ( (roles!=null)
- && (roles.remove(role))
+ if ( (participants!=null)
+ && (participants.remove(role))
) {
- ((RoleImpl)role).setTask(null);
+ ((ParticipantImpl)role).setTask(null);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskServiceImpl.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -26,12 +26,15 @@
import org.jbpm.TaskQuery;
import org.jbpm.TaskService;
import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.cmd.AddParticipant;
import org.jbpm.pvm.internal.cmd.DeleteTaskCmd;
+import org.jbpm.pvm.internal.cmd.GetParticipants;
import org.jbpm.pvm.internal.cmd.GetTaskCmd;
import org.jbpm.pvm.internal.cmd.NewTaskCmd;
import org.jbpm.pvm.internal.cmd.SaveTaskCmd;
import org.jbpm.pvm.internal.cmd.SubmitTaskCmd;
-import org.jbpm.task.Role;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
import org.jbpm.task.Task;
/**
@@ -60,34 +63,39 @@
return commandService.execute(new NewTaskCmd());
}
- public Task getTask(String taskId) {
- return commandService.execute(new GetTaskCmd(taskId));
+ public Task getTask(long taskDbid) {
+ return commandService.execute(new GetTaskCmd(taskDbid));
}
public void saveTask(Task task) {
commandService.execute(new SaveTaskCmd((TaskImpl) task));
}
- public void deleteTask(String taskId) {
- commandService.execute(new DeleteTaskCmd(taskId));
+ public void deleteTask(long taskDbid) {
+ commandService.execute(new DeleteTaskCmd(taskDbid));
}
- public void submitTask(String taskId) {
- commandService.execute(new SubmitTaskCmd(taskId));
+ public void submitTask(long taskDbid) {
+ commandService.execute(new SubmitTaskCmd(taskDbid));
}
public void submitTask(Task task) {
commandService.execute(new SubmitTaskCmd((TaskImpl)task));
}
- public List<String> getCandidates(String taskId) {
- return null;
+ public void addTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ commandService.execute(new AddParticipant(taskDbid, null, identityRef, participation));
}
- public List<Role> getRoles(String taskId) {
- return null;
+ public List<Participant> getTaskParticipants(long taskDbid) {
+ return commandService.execute(new GetParticipants(taskDbid, null));
}
+ public void removeTaskParticipant(long taskDbid, IdentityRef identityRef, String participation) {
+ throw new UnsupportedOperationException();
+ // commandService.execute(new RemoveRole(taskDbid, identityType, identityId, roleName));
+ }
+
public List<Task> getPersonalTaskList(String assignee, int firstResult, int maxResults) {
return createTaskQuery()
.assignee(assignee)
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml 2009-02-17 17:21:02 UTC (rev 3907)
@@ -57,9 +57,9 @@
<property name="description" column="DESCR_"/>
<property name="assignee" column="ASSIGNEE_"/>
- <set name="roles" cascade="all-delete-orphan">
- <key column="TASK_" foreign-key="FK_ROLE_TASK" />
- <one-to-many class="RoleImpl" />
+ <set name="participants" cascade="all-delete-orphan">
+ <key column="TASK_" />
+ <one-to-many class="ParticipantImpl" />
</set>
<property name="priority" column="PRIORITY_"/>
@@ -98,24 +98,28 @@
</class>
- <!-- ### ROLE ########################################################### -->
- <class name="RoleImpl"
- discriminator-value="R">
+ <!-- ### PARTICIPANT #################################################### -->
+ <class name="ParticipantImpl">
<id name="dbid" column="DBID_">
<generator class="native" />
</id>
- <discriminator type="char" column="CLASS_"/>
<version name="dbversion" column="DBVERSION_" />
+ <property name="identityType" column="IDENTITYTYPE_"/>
<property name="identityId" column="IDENTITYID_"/>
- <property name="roleType" column="ROLETYPE_" />
- <property name="description" column="DESCR_"/>
+ <property name="participation" column="PARTICIPATION_" />
<many-to-one name="task"
class="TaskImpl"
column="TASK_"
- foreign-key="FK_ROLE_TASK" />
+ index="IDX_PART_TASK"
+ foreign-key="FK_PART_TASK" />
+ <many-to-one name="swimlane"
+ class="SwimlaneImpl"
+ column="SWIMLANE_"
+ foreign-key="FK_PART_SWIMLANE" />
+
</class>
<!-- ### SWIMLANE DEFINITION ############################################ -->
@@ -144,11 +148,11 @@
column="SWIMLANEDEF_"
foreign-key="FK_SWIMLANE_DEF" />
- <set name="candidates" cascade="all-delete-orphan">
- <key column="SWIMLANE_" foreign-key="FK_ROLE_SWIMLANE" />
- <one-to-many class="RoleImpl" />
+ <set name="participants" cascade="all-delete-orphan">
+ <key column="SWIMLANE_" />
+ <one-to-many class="ParticipantImpl" />
</set>
-
+
</class>
Modified: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -26,12 +26,12 @@
import java.util.Map;
import java.util.Set;
-import org.jbpm.pvm.internal.task.RoleImpl;
+import org.jbpm.pvm.internal.task.ParticipantImpl;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.task.Task;
+import org.jbpm.task.Participant;
import org.jbpm.test.BaseJbpmTestCase;
/**
@@ -76,37 +76,38 @@
assertEquals("joesmoe", task.getAssignee());
}
+ /*
public void testTaskRoles() {
TaskImpl task = TaskImpl.create();
assertNotNull(task.getRoles());
assertEquals(0, task.getRoles().size());
- task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
- task.addRole("joe smoe", Task.ROLETYPE_OWNER).setDescription("does what he wants");
- task.addRole("jack black", Task.ROLETYPE_CANDIDATE).setDescription("can take this task");
- task.addRole("jim slim", Task.ROLETYPE_VIEWER).setDescription("is allowed to see");
- task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+ task.addRole("john doe", Role.ROLETYPE_CLIENT).setDescription("uses the result");
+ task.addRole("joe smoe", Role.ROLETYPE_OWNER).setDescription("does what he wants");
+ task.addRole("jack black", Role.ROLETYPE_CANDIDATE).setDescription("can take this task");
+ task.addRole("jim slim", Role.ROLETYPE_VIEWER).setDescription("is allowed to see");
+ task.addRole("jeff nef", Role.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
Set<RoleImpl> roles = task.getRoles();
Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
for (RoleImpl role: roles) {
- roleMap.put(role.getIdentityId(), role);
+ roleMap.put(role.getUserId(), role);
}
- assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+ assertEquals(Role.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
assertEquals("uses the result", roleMap.get("john doe").getDescription());
- assertEquals(Task.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
+ assertEquals(Role.ROLETYPE_OWNER, roleMap.get("joe smoe").getRoleType());
assertEquals("does what he wants", roleMap.get("joe smoe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
assertEquals("can take this task", roleMap.get("jack black").getDescription());
- assertEquals(Task.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
+ assertEquals(Role.ROLETYPE_VIEWER, roleMap.get("jim slim").getRoleType());
assertEquals("is allowed to see", roleMap.get("jim slim").getDescription());
- assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+ assertEquals(Role.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
assertEquals("is sick", roleMap.get("jeff nef").getDescription());
assertEquals(5, roles.size());
@@ -129,53 +130,52 @@
assertNotNull(task.getAllRoles());
assertEquals(0, task.getAllRoles().size());
- task.addRole("john doe", Task.ROLETYPE_CLIENT).setDescription("uses the result");
+ task.addRole("john doe", Role.ROLETYPE_CLIENT).setDescription("uses the result");
SwimlaneImpl manager = new SwimlaneImpl();
task.setSwimlane(manager);
- manager.createCandidate("joe smoe").setDescription("tostesteron ambition");
- manager.createCandidate("jack black").setDescription("the pigeon");
- manager.createCandidate("jim slim").setDescription("lame duck");
+ manager.addCandidateUser("joe smoe").setDescription("tostesteron ambition");
+ manager.addCandidateUser("jack black").setDescription("the pigeon");
+ manager.addCandidateUser("jim slim").setDescription("lame duck");
- task.addRole("jeff nef", Task.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
+ task.addRole("jeff nef", Role.ROLETYPE_REPLACED_ASSIGNEE).setDescription("is sick");
Set<RoleImpl> roles = task.getAllRoles();
Map<String, RoleImpl> roleMap = new HashMap<String, RoleImpl>();
for (RoleImpl role: roles) {
- roleMap.put(role.getIdentityId(), role);
+ roleMap.put(role.getUserId(), role);
}
- assertEquals(Task.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
+ assertEquals(Role.ROLETYPE_CLIENT, roleMap.get("john doe").getRoleType());
assertEquals("uses the result", roleMap.get("john doe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("joe smoe").getRoleType());
assertEquals("tostesteron ambition", roleMap.get("joe smoe").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jack black").getRoleType());
assertEquals("the pigeon", roleMap.get("jack black").getDescription());
- assertEquals(Task.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
+ assertEquals(Role.ROLETYPE_CANDIDATE, roleMap.get("jim slim").getRoleType());
assertEquals("lame duck", roleMap.get("jim slim").getDescription());
- assertEquals(Task.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
+ assertEquals(Role.ROLETYPE_REPLACED_ASSIGNEE, roleMap.get("jeff nef").getRoleType());
assertEquals("is sick", roleMap.get("jeff nef").getDescription());
assertEquals(5, roles.size());
task.removeRole(roleMap.get("john doe"));
assertEquals(4, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("joe smoe"));
+ manager.removeCandidateUser(roleMap.get("joe smoe"));
assertEquals(3, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("jack black"));
+ manager.removeCandidateUser(roleMap.get("jack black"));
assertEquals(2, task.getAllRoles().size());
- manager.removeCandidate(roleMap.get("jim slim"));
+ manager.removeCandidateUser(roleMap.get("jim slim"));
assertEquals(1, task.getAllRoles().size());
task.removeRole(roleMap.get("jeff nef"));
assertEquals(0, task.getAllRoles().size());
}
- /*
public void testTaskComment() {
EnvironmentFactory environmentFactory = EnvironmentFactory.parseXmlString("<environment/>");
TaskImpl task = TaskImpl.create();
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -80,7 +80,7 @@
protected List<ProcessDefinition> registeredProcessDefinitions;
/** registered tasks will be deleted automatically in the tearDown.
* This is a convenience function as each test is expected to clean up the DB. */
- protected List<String> registeredTaskIds;
+ protected List<Long> registeredTaskIds;
protected void setUp() throws Exception {
super.setUp();
@@ -117,8 +117,8 @@
}
if (registeredTaskIds != null) {
- for (String taskId : registeredTaskIds) {
- taskService.deleteTask(taskId);
+ for (Long taskDbid : registeredTaskIds) {
+ taskService.deleteTask(taskDbid);
}
}
@@ -175,9 +175,9 @@
taskService.saveTask(task);
if (registeredTaskIds == null) {
- registeredTaskIds = new ArrayList<String>();
+ registeredTaskIds = new ArrayList<Long>();
}
- registeredTaskIds.add(task.getId());
+ registeredTaskIds.add(task.getDbid());
}
public HashSet<String> getActivityNames(String processInstanceId) {
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-02-17 15:20:07 UTC (rev 3906)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskCreateUpdateDeleteTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -34,45 +34,36 @@
public void testNewTask() {
// creation of a new non-persisted task
Task task = taskService.newTask();
- task = taskService.getTask(task.getId());
+ task = taskService.getTask(task.getDbid());
assertNull(task);
}
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveAndRegisterTask(task);
- assertNotNull(task.getId());
- }
-
public void testSaveTask() {
Task task = taskService.newTask();
saveAndRegisterTask(task);
- String taskId = task.getId();
+ long taskDbid = task.getDbid();
// task was made persistent
- task = taskService.getTask(taskId);
+ task = taskService.getTask(taskDbid);
assertNotNull("expected non-null task", task);
// make some change
Date dueDate = new Date();
task.setDueDate(dueDate);
taskService.saveTask(task);
// verify change is applied
- task = taskService.getTask(taskId);
+ task = taskService.getTask(taskDbid);
assertEquals(dueDate, task.getDueDate());
}
public void testDeleteTask() {
Task task = taskService.newTask();
taskService.saveTask(task);
- String taskId = task.getId();
+ long taskDbid = task.getDbid();
// task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
+ assertNotNull("expected non-null task", taskService.getTask(taskDbid));
// delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
+ taskService.deleteTask(taskDbid);
+ task = taskService.getTask(taskDbid);
assertNull("expected null, but was " + task, task);
}
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java 2009-02-17 17:21:02 UTC (rev 3907)
@@ -0,0 +1,83 @@
+/*
+ * 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.test.task;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.task.GroupRef;
+import org.jbpm.task.IdentityRef;
+import org.jbpm.task.Participant;
+import org.jbpm.task.Task;
+import org.jbpm.task.UserRef;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskParticipationsTest extends JbpmTestCase {
+
+ public void testTaskParticipants() {
+ Task task = taskService.newTask();
+ task.setName("do laundry");
+ saveAndRegisterTask(task);
+
+ long taskDbid = task.getDbid();
+
+ taskService.addTaskParticipant(taskDbid, new UserRef("johndoe"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new UserRef("joesmoe"), Participant.OWNER);
+ taskService.addTaskParticipant(taskDbid, new GroupRef("losers"), Participant.CANDIDATE);
+ taskService.addTaskParticipant(taskDbid, new GroupRef("dummies"), Participant.CANDIDATE);
+
+ List<Participant> taskParticipants = taskService.getTaskParticipants(taskDbid);
+
+ Set<IdentityRef> candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.CANDIDATE);
+
+ Set<IdentityRef> expectedIdentityRefs = new HashSet<IdentityRef>();
+ expectedIdentityRefs.add(new UserRef("johndoe"));
+ expectedIdentityRefs.add(new UserRef("joesmoe"));
+ expectedIdentityRefs.add(new GroupRef("losers"));
+ expectedIdentityRefs.add(new GroupRef("dummies"));
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+
+ candidateIdentityRefs = getIdentityRefs(taskParticipants, Participant.OWNER);
+
+ expectedIdentityRefs = new HashSet<IdentityRef>();
+ expectedIdentityRefs.add(new UserRef("joesmoe"));
+
+ assertEquals(expectedIdentityRefs, candidateIdentityRefs);
+ }
+
+ public Set<IdentityRef> getIdentityRefs(List<Participant> taskParticipants, String participation) {
+ Set<IdentityRef> identityRefs = new HashSet<IdentityRef>();
+ for (Participant participant: taskParticipants) {
+ if (participation.equals(participant.getParticipation())) {
+ identityRefs.add(participant.getIdentityRef());
+ }
+ }
+ return identityRefs;
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskParticipationsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 2 months
JBoss JBPM SVN: r3906 - jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf.
by do-not-reply@jboss.org
Author: mvecera(a)redhat.com
Date: 2009-02-17 10:20:07 -0500 (Tue, 17 Feb 2009)
New Revision: 3906
Modified:
jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
Log:
core, AsyncCallTest, report fix
Modified: jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
===================================================================
--- jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 15:12:40 UTC (rev 3905)
+++ jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 15:20:07 UTC (rev 3906)
@@ -88,6 +88,6 @@
}
public void execute(ExecutionContext executionContext) throws Exception {
- log.info("Action called, current ExecutionContext: " + executionContext);
+ // 023e:45AC NOP
}
}
17 years, 2 months
JBoss JBPM SVN: r3905 - jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf.
by do-not-reply@jboss.org
Author: mvecera(a)redhat.com
Date: 2009-02-17 10:12:40 -0500 (Tue, 17 Feb 2009)
New Revision: 3905
Modified:
jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
Log:
core, AsyncCallTest, report fix
Modified: jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
===================================================================
--- jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 15:08:48 UTC (rev 3904)
+++ jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 15:12:40 UTC (rev 3905)
@@ -82,10 +82,8 @@
long stop = System.currentTimeMillis();
log.info("=== TEST FINISHED PROCESSING " + INSTANCES + " INSTANCES IN " + (stop - start) + " MILLIS ===");
- log.info("=== THIS IS " + INSTANCES + " INSTANCES IN " + ((double) (stop - start) / INSTANCES) / 1000 + " PROCESSES PER SECOND ===");
+ log.info("=== THIS IS " + INSTANCES / ((double) (stop - start) / 1000) + " PROCESSES PER SECOND ===");
-
-
stopJobExecutor();
}
17 years, 2 months
JBoss JBPM SVN: r3904 - jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf.
by do-not-reply@jboss.org
Author: mvecera(a)redhat.com
Date: 2009-02-17 10:08:48 -0500 (Tue, 17 Feb 2009)
New Revision: 3904
Modified:
jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
Log:
core, AsyncCallTest
Modified: jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
===================================================================
--- jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 14:38:46 UTC (rev 3903)
+++ jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 15:08:48 UTC (rev 3904)
@@ -21,8 +21,10 @@
*/
package org.jbpm.perf;
+import junit.textui.TestRunner;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.criterion.Junction;
import org.jbpm.command.CommandService;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.command.impl.CommandServiceImpl;
@@ -36,7 +38,7 @@
private static final Log log = LogFactory.getLog(AsyncCallTest.class);
private static final long serialVersionUID = -2962894670623757448L;
private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
- private static final int INSTANCES = 1;
+ private static final int INSTANCES = 10000;
ProcessDefinition processDefinition;
@Override
@@ -79,9 +81,11 @@
}
long stop = System.currentTimeMillis();
- log.info("TEST FINISHED PROCESSING " + INSTANCES + " INSTANCES IN " + (stop - start) + " MILLIS");
- log.info("THIS IS " + INSTANCES + " INSTANCES IN " + ((double) (stop - start) / INSTANCES) / 1000 + " PROCESSES PER SECOND");
+ log.info("=== TEST FINISHED PROCESSING " + INSTANCES + " INSTANCES IN " + (stop - start) + " MILLIS ===");
+ log.info("=== THIS IS " + INSTANCES + " INSTANCES IN " + ((double) (stop - start) / INSTANCES) / 1000 + " PROCESSES PER SECOND ===");
+
+
stopJobExecutor();
}
17 years, 2 months
JBoss JBPM SVN: r3903 - in jbpm4/trunk/modules/enterprise/src: main/resources/META-INF and 1 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-17 09:38:46 -0500 (Tue, 17 Feb 2009)
New Revision: 3903
Removed:
jbpm4/trunk/modules/enterprise/src/test/resources/environment.cfg.xml
Modified:
jbpm4/trunk/modules/enterprise/src/main/resources/META-INF/jboss.xml
jbpm4/trunk/modules/enterprise/src/main/resources/jbpm.cfg.xml
Log:
Reference java:/JbpmDS instead of java:/DefaultDS
Modified: jbpm4/trunk/modules/enterprise/src/main/resources/META-INF/jboss.xml
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/resources/META-INF/jboss.xml 2009-02-17 14:34:54 UTC (rev 3902)
+++ jbpm4/trunk/modules/enterprise/src/main/resources/META-INF/jboss.xml 2009-02-17 14:38:46 UTC (rev 3903)
@@ -12,7 +12,7 @@
<local-jndi-name>java:jbpm/CommandExecutor</local-jndi-name>
<resource-ref>
<res-ref-name>jdbc/JbpmDataSource</res-ref-name>
- <jndi-name>java:DefaultDS</jndi-name>
+ <jndi-name>java:JbpmDS</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jms/JbpmConnectionFactory</res-ref-name>
Modified: jbpm4/trunk/modules/enterprise/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/resources/jbpm.cfg.xml 2009-02-17 14:34:54 UTC (rev 3902)
+++ jbpm4/trunk/modules/enterprise/src/main/resources/jbpm.cfg.xml 2009-02-17 14:38:46 UTC (rev 3903)
@@ -3,13 +3,12 @@
<!--
jBPM4 enterprise configuration.
Uses different command service and environment config.
- (i.e. skips the TX interceptor)
-
+ (i.e. skips the TX interceptor)
-->
<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
- <process-engine-context>
+ <process-engine>
<deployer-manager>
<check-process />
@@ -41,13 +40,13 @@
<holiday period="01/07/2008 - 31/08/2008"/>
</business-calendar>
- </process-engine-context>
+ </process-engine>
- <transaction-context>
+ <environment>
<hibernate-session current="true" />
<pvm-db-session />
<job-db-session />
<ejb-timer-session />
- </transaction-context>
+ </environment>
</jbpm-configuration>
Deleted: jbpm4/trunk/modules/enterprise/src/test/resources/environment.cfg.xml
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/resources/environment.cfg.xml 2009-02-17 14:34:54 UTC (rev 3902)
+++ jbpm4/trunk/modules/enterprise/src/test/resources/environment.cfg.xml 2009-02-17 14:38:46 UTC (rev 3903)
@@ -1,41 +0,0 @@
-<jbpm-configuration>
-
- <process-engine-context>
-
- <deployer-manager>
- <check-process />
- <check-problems />
- <save />
- </deployer-manager>
-
- <process-service />
- <execution-service />
- <management-service />
- <ejb-local-command-service />
-
- <hibernate-configuration resource="hibernate.cfg.xml"/>
-
- <hibernate-session-factory />
-
- <id-generator />
- <types resource="jbpm.pvm.types.xml" />
-
- <business-calendar>
- <monday hours="9:00-12:00 and 12:30-17:00"/>
- <tuesday hours="9:00-12:00 and 12:30-17:00"/>
- <wednesday hours="9:00-12:00 and 12:30-17:00"/>
- <thursday hours="9:00-12:00 and 12:30-17:00"/>
- <friday hours="9:00-12:00 and 12:30-17:00"/>
- <holiday period="01/07/2008 - 31/08/2008"/>
- </business-calendar>
-
- </process-engine-context>
-
- <transaction-context>
- <hibernate-session current="true" />
- <pvm-db-session />
- <job-db-session />
- <ejb-timer-session />
- </transaction-context>
-
-</jbpm-configuration>
17 years, 2 months
JBoss JBPM SVN: r3902 - jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf.
by do-not-reply@jboss.org
Author: mvecera(a)redhat.com
Date: 2009-02-17 09:34:54 -0500 (Tue, 17 Feb 2009)
New Revision: 3902
Added:
jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
Log:
core, AsyncCallTest
Added: jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java
===================================================================
--- jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java (rev 0)
+++ jbpm3/tags/jbpm-3.2.5.SP1/modules/core/src/test/java/org/jbpm/perf/AsyncCallTest.java 2009-02-17 14:34:54 UTC (rev 3902)
@@ -0,0 +1,91 @@
+/*
+ * 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.perf;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.StartProcessInstanceCommand;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ActionHandler;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.jbpm.graph.exe.ProcessInstance;
+
+public class AsyncCallTest extends AbstractDbTestCase implements ActionHandler {
+ private static final Log log = LogFactory.getLog(AsyncCallTest.class);
+ private static final long serialVersionUID = -2962894670623757448L;
+ private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
+ private static final int INSTANCES = 1;
+ ProcessDefinition processDefinition;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ createSchema();
+ processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition xmlns=\"urn:jbpm.org:jpdl-3.1\" name=\"processDefinition1\">" +
+ "<start-state name=\"start\">" +
+ "<transition name=\"to_state\" to=\"end\">" +
+ "<action class=\"org.jbpm.perf.AsyncCallTest\" />" +
+ "</transition>" +
+ "</start-state>" +
+ "<end-state name=\"end\">" +
+ "</end-state>" +
+ "</process-definition>");
+ saveAndReload(processDefinition);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
+ super.tearDown();
+ }
+
+ public void testAsyncCall() {
+ log.info("");
+ log.info("=== EXECUTING PERFORMANCE TEST ================================================");
+ log.info("");
+
+ startJobExecutor();
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < INSTANCES; i++) {
+ StartProcessInstanceCommand startCommand = new StartProcessInstanceCommand();
+ startCommand.setProcessDefinitionId(processDefinition.getId());
+ startCommand.setProcessDefinitionName("processDefinition1");
+ ProcessInstance pi = (ProcessInstance) commandService.execute(startCommand);
+ }
+
+ long stop = System.currentTimeMillis();
+ log.info("TEST FINISHED PROCESSING " + INSTANCES + " INSTANCES IN " + (stop - start) + " MILLIS");
+ log.info("THIS IS " + INSTANCES + " INSTANCES IN " + ((double) (stop - start) / INSTANCES) / 1000 + " PROCESSES PER SECOND");
+
+ stopJobExecutor();
+ }
+
+ public void execute(ExecutionContext executionContext) throws Exception {
+ log.info("Action called, current ExecutionContext: " + executionContext);
+ }
+}
17 years, 2 months
JBoss JBPM SVN: r3900 - in jbpm4/trunk: hudson and 1 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-17 06:14:42 -0500 (Tue, 17 Feb 2009)
New Revision: 3900
Modified:
jbpm4/trunk/hudson/profiles.xml.local.qa
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml
jbpm4/trunk/profiles.xml.example
Log:
Revert hsqldb settings
Modified: jbpm4/trunk/hudson/profiles.xml.local.qa
===================================================================
--- jbpm4/trunk/hudson/profiles.xml.local.qa 2009-02-17 10:12:50 UTC (rev 3899)
+++ jbpm4/trunk/hudson/profiles.xml.local.qa 2009-02-17 11:14:42 UTC (rev 3900)
@@ -30,7 +30,7 @@
<jdbc.hsql.server>localhost</jdbc.hsql.server>
<jdbc.hsql.port>3306</jdbc.hsql.port>
<jdbc.hsql.database>jbpm4</jdbc.hsql.database>
- <jdbc.hsql.url>jdbc:hsqldb:file:${user.home}/jbpm4_database</jdbc.hsql.url>
+ <jdbc.hsql.url>jdbc:hsqldb:mem:.</jdbc.hsql.url>
<jdbc.hsql.username>sa</jdbc.hsql.username>
<jdbc.hsql.password></jdbc.hsql.password>
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml 2009-02-17 10:12:50 UTC (rev 3899)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm-hsqldb-ds.xml 2009-02-17 11:14:42 UTC (rev 3900)
@@ -4,15 +4,10 @@
<local-tx-datasource>
<jndi-name>JbpmDS</jndi-name>
- <!--
- Default AS location
- <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}jbpm4DB</connection-url>
- -->
-
+ <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}jbpm4DB</connection-url>
<driver-class>org.hsqldb.jdbcDriver</driver-class>
- <connection-url>${jdbc.hsql.url}</connection-url>
- <user-name>${jdbc.hsql.username}</user-name>
- <password>${jdbc.hsql.password}</password>
+ <user-name>sa</user-name>
+ <password></password>
<!-- connection pool parameters -->
<min-pool-size>1</min-pool-size>
Modified: jbpm4/trunk/profiles.xml.example
===================================================================
--- jbpm4/trunk/profiles.xml.example 2009-02-17 10:12:50 UTC (rev 3899)
+++ jbpm4/trunk/profiles.xml.example 2009-02-17 11:14:42 UTC (rev 3900)
@@ -62,7 +62,7 @@
<jdbc.oracle.database>jbpm4</jdbc.oracle.database>
<jdbc.oracle.username>jbpmtest</jdbc.oracle.username>
<jdbc.oracle.password></jdbc.oracle.password>
- <jdbc.oracle.url>jdbc:oracle:thin:${jdbc.oracle.username}/${jdbc.oracle.password}@${jdbc.oracle.server}:${jdbc.oracle.port}:${jdbc.oracle.database}</jdbc.oracle.url>
+ <jdbc.oracle.url>jdbc:oracle:thin:${jdbc.oracle.username}/${jdbc.oracle.password}@${jdbc.oracle.server}:${jdbc.oracle.port}:${jdbc.oracle.database}</jdbc.oracle.url>
</properties>
</profile>
17 years, 2 months