JBoss JBPM SVN: r5633 - in jbpm4/trunk/modules: distro/src/main/files and 2 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-14 09:04:36 -0400 (Mon, 14 Sep 2009)
New Revision: 5633
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java
jbpm4/trunk/modules/distro/src/main/files/readme.html
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
Log:
Fix for JBPM-2494: renamed isProcessInstance() -> getIsProcessInstance()
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java 2009-09-11 15:42:08 UTC (rev 5632)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Execution.java 2009-09-14 13:04:36 UTC (rev 5633)
@@ -156,8 +156,13 @@
/** the <a href="#state">state</a> of this execution. */
String getState();
- /** is this a process instance */
- boolean isProcessInstance();
+ /**
+ * Returns whether this execution is a process instance.
+ * Note that we cannot use 'isProcessInstance', since this
+ * would clash with 'getProcessInstance()' when using expressions.
+ * (see JBPM-2494)
+ * */
+ boolean getIsProcessInstance();
/** is this execution ended */
boolean isEnded();
Modified: jbpm4/trunk/modules/distro/src/main/files/readme.html
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-09-11 15:42:08 UTC (rev 5632)
+++ jbpm4/trunk/modules/distro/src/main/files/readme.html 2009-09-14 13:04:36 UTC (rev 5633)
@@ -35,10 +35,24 @@
</tr>
</table>
+
+<h1>Release Notes for jBPM 4.2</h1>
+
+<h2>API changes</h2>
+
+<ul>
+ <li>
+ <b>Execution.isProcessInstance()</b> is renamed to <b>Execution.getIsProcessInstance</b>
+ due to [ <a href="https://jira.jboss.org/jira/browse/JBPM-2494">JBPM-2494</a>].
+ </li>
+</ul>
+
+
<h1>Release Notes for jBPM 4.1</h1>
<h2>DB Migration</h2>
+
<p>Add column <code>CLASSNAME_</code> to the <code>JBPM4_VARIABLE</code> table.
The type of the column is dependent on the database and can be found in this table:
</p>
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java 2009-09-11 15:42:08 UTC (rev 5632)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ProcessManagementImpl.java 2009-09-14 13:04:36 UTC (rev 5633)
@@ -113,7 +113,7 @@
continue; // JBPM-2055: Execution is already ended. Should not show up in query
}
- if (processInstance.isProcessInstance()) { // parent execution
+ if (processInstance.getIsProcessInstance()) { // parent execution
results.add(ModelAdaptor.adoptExecution((ExecutionImpl) processInstance));
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-11 15:42:08 UTC (rev 5632)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-14 13:04:36 UTC (rev 5633)
@@ -1147,7 +1147,7 @@
return false;
}
- public boolean isProcessInstance() {
+ public boolean getIsProcessInstance() {
return parent==null;
}
14 years, 7 months
JBoss JBPM SVN: r5632 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/id and 6 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-09-11 11:42:08 -0400 (Fri, 11 Sep 2009)
New Revision: 5632
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
Log:
JBPM-2526 first cut at id generator
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,39 @@
+package org.jbpm.pvm.internal.id;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AcquireIdBlockCmd implements Command<Long> {
+
+ private static final long serialVersionUID = 1L;
+
+ long blocksize;
+
+ public AcquireIdBlockCmd(long blocksize) {
+ this.blocksize = blocksize;
+ }
+
+ public Long execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+
+ PropertyImpl property = (PropertyImpl) session.createQuery(
+ "select property " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
+ ).uniqueResult();
+
+ String nextIdText = property.getValue();
+ Long nextId = new Long(nextIdText);
+
+ property.setValue(Long.toString(nextId.longValue()+blocksize));
+
+ session.update(property);
+ session.flush();
+
+ return nextId;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,103 @@
+/*
+ * 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.id;
+
+import java.util.Random;
+
+import org.hibernate.StaleStateException;
+import org.jbpm.api.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.CommandService;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DatabaseIdGenerator extends IdGenerator {
+
+ private static Log log = Log.getLog(DatabaseIdGenerator.class.getName());
+
+ static Random random = new Random();
+
+ // configuration
+ CommandService commandService;
+ long blocksize = 10000;
+ int maxAttempts = 3;
+
+ // runtime state
+ long lastId = -2;
+ long nextId = -1;
+
+ public synchronized long getNextId() {
+ // if no more ids available
+ if (lastId<nextId) {
+ // acquire a next block of ids
+
+ // reset the id block
+ lastId = -2;
+ nextId = -1;
+
+ // try couple of times
+ try {
+ for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
+ try {
+ // acquire block
+ nextId = commandService.execute(new AcquireIdBlockCmd(blocksize));
+ lastId = nextId + blocksize - 1;
+
+ log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
+
+ } catch (StaleStateException e) {
+ // optimistic locking exception indicating another thread tried to
+ // acquire a block of ids concurrently
+ attempts--;
+
+ // if no attempts left
+ if (attempts==0) {
+ // fail the surrounding transaction
+ throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
+ }
+
+ // if there are still attempts left, first wait a bit
+ int millis = 20 + random.nextInt(200);
+ log.debug("optimistic locking failure while trying to acquire id block. retrying in "+millis+" millis");
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e1) {
+ log.debug("waiting after id block locking failure got interrupted");
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new JbpmException("couldn't acquire block of ids", e);
+ }
+ }
+
+ return nextId++;
+ }
+
+ public void initialize() {
+ nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
+ lastId = nextId + blocksize - 1;
+ log.debug("initial id block ["+nextId+"-"+lastId+"]");
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,47 @@
+/*
+ * 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.id;
+
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class IdGenerator {
+
+ static IdGenerator defaultIdGenerator = new MemoryIdGenerator();
+
+ public static IdGenerator getIdGenerator() {
+ IdGenerator idGenerator = EnvironmentImpl.getFromCurrent(IdGenerator.class, false);
+ if (idGenerator!=null) {
+ return idGenerator;
+ }
+ return getDefaultIdGenerator();
+ }
+
+ public static IdGenerator getDefaultIdGenerator() {
+ return defaultIdGenerator;
+ }
+
+ public abstract long getNextId();
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,103 @@
+/*
+ * 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.id;
+
+import org.hibernate.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class InitializePropertiesCmd implements Command<Long> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static Log log = Log.getLog(InitializePropertiesCmd.class.getName());
+
+ long blocksize;
+
+ public InitializePropertiesCmd(long blocksize) {
+ this.blocksize = blocksize;
+ }
+
+ public Long execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+
+ Long nextId = initializeNextId(session);
+ initializeSchemaVersion(session);
+
+ session.flush();
+
+ return nextId;
+ }
+
+ void initializeSchemaVersion(Session session) {
+ PropertyImpl property = (PropertyImpl) session.createQuery(
+ "select property " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+PropertyImpl.SCHEMA_VERSION_KEY+"'"
+ ).uniqueResult();
+
+ String jbpmVersion = "4.1-SNAPSHOT";
+
+ if (property==null) {
+ log.debug("initializing db schema version to "+jbpmVersion);
+ property = new PropertyImpl(PropertyImpl.SCHEMA_VERSION_KEY, jbpmVersion);
+ session.save(property);
+
+ } else {
+ String dbSchemaVersion = property.getValue();
+ if (!jbpmVersion.equals(dbSchemaVersion)) {
+ throw new JbpmException("jBPM runtime version "+jbpmVersion+" doesn't match with DB schema, which is version ");
+ } else {
+ log.debug("runtime and db schema version both "+jbpmVersion);
+ }
+ }
+ }
+
+ Long initializeNextId(Session session) {
+ PropertyImpl property = (PropertyImpl) session.createQuery(
+ "select property " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
+ ).uniqueResult();
+
+ Long nextId;
+ if (property==null) {
+ nextId = 1L;
+ property = new PropertyImpl(PropertyImpl.NEXT_ID_KEY, Long.toString(blocksize+1));
+ session.save(property);
+
+ } else {
+ String nextIdText = property.getValue();
+ nextId = new Long(nextIdText);
+ property.setValue(Long.toString(nextId.longValue()+blocksize));
+ session.update(property);
+ }
+
+ return nextId;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,36 @@
+/*
+ * 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.id;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MemoryIdGenerator extends IdGenerator {
+
+ static long nextId = 1;
+
+ public synchronized long getNextId() {
+ return nextId++;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,59 @@
+/*
+ * 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.id;
+
+
+/** jbpm installation properties.
+ *
+ * currently there are 2 use cases for these properties:
+ * 1) include the jbpm schema version into the DB
+ * 2) have a record to maintain the next dbid for the id generator
+ *
+ * @author Tom Baeyens
+ */
+public class PropertyImpl {
+
+ public static final String SCHEMA_VERSION_KEY = "schema.version";
+ public static final String NEXT_ID_KEY = "next.id";
+
+ protected int version;
+ protected String key;
+ protected String value;
+
+ protected PropertyImpl() {
+ }
+
+ public PropertyImpl(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+ public String getValue() {
+ return value;
+ }
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java 2009-09-11 15:11:04 UTC (rev 5631)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RefBinding.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -44,6 +44,9 @@
ReferenceDescriptor descriptor = new ReferenceDescriptor();
if (element.hasAttribute("object")) {
descriptor.setValue(element.getAttribute("object"));
+ } else if (element.hasAttribute("type")) {
+ descriptor.setType(element.getAttribute("type"));
+
} else {
parse.addProblem("ref must have object attribute: "+XmlUtil.toString(element), element);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java 2009-09-11 15:11:04 UTC (rev 5631)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ReferenceDescriptor.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -1,5 +1,6 @@
package org.jbpm.pvm.internal.wire.descriptor;
+import org.jbpm.api.JbpmException;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -19,6 +20,7 @@
private static final long serialVersionUID = 1L;
String text = null;
+ String type = null;
// TODO add a refExpression that is evaluated with el
// the base referenced descriptor always should have delayedInitialization = false;
@@ -31,14 +33,26 @@
}
public Object construct(WireContext wireContext) {
- return wireContext.get(text, isDelayedInitializationAllowed());
+ if (text!=null) {
+ return wireContext.get(text, isDelayedInitializationAllowed());
+ } else if (type!=null) {
+ try {
+ Class<?> clazz = wireContext.getClassLoader().loadClass(type);
+ return wireContext.get(clazz);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't load "+type, e);
+ }
+ }
+ return null;
}
public boolean isDelayedInitializationAllowed() {
return (init == INIT_EAGER || init == INIT_LAZY);
}
-
public void setValue(String objectName) {
this.text = objectName;
}
+ public void setType(String type) {
+ this.type = type;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-09-11 15:11:04 UTC (rev 5631)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-09-11 15:42:08 UTC (rev 5632)
@@ -17,6 +17,11 @@
</hibernate-configuration>
<hibernate-session-factory />
+
+ <object class="org.jbpm.pvm.internal.id.DatabaseIdGenerator" init="eager">
+ <field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
+ <invoke method="initialize" />
+ </object>
<script-manager default-expression-language="juel"
default-script-language="juel">
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-09-11 15:11:04 UTC (rev 5631)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-09-11 15:42:08 UTC (rev 5632)
@@ -48,4 +48,12 @@
<property name="longValue" column="LONGVAL_" />
</class>
+ <class name="org.jbpm.pvm.internal.id.PropertyImpl" table="JBPM4_PROPERTY">
+ <id name="key" column="KEY_">
+ <generator class="assigned" />
+ </id>
+ <version name="version" column="VERSION_" />
+ <property name="value" column="VALUE_" />
+ </class>
+
</hibernate-mapping>
Added: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -0,0 +1,61 @@
+/*
+ * 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.id;
+
+import junit.framework.TestCase;
+
+import org.hibernate.Session;
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.cmd.CommandService;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class IdGeneratorTest extends TestCase {
+
+ public void testIdGenerator() {
+ ProcessEngine processEngine = new Configuration().buildProcessEngine();
+
+ CommandService commandService = processEngine.get(CommandService.class);
+ commandService.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ assertEquals(2, session.createQuery("select property from "+PropertyImpl.class.getName()+" as property").list().size());
+ return null;
+ }
+ });
+
+ IdGenerator idGenerator = processEngine.get(IdGenerator.class);
+
+ for (int i=1; i<10020; i++) {
+ assertEquals(i, idGenerator.getNextId());
+ if ((i%100) == 0) {
+ System.err.println(i);
+ }
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java 2009-09-11 15:11:04 UTC (rev 5631)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java 2009-09-11 15:42:08 UTC (rev 5632)
@@ -171,12 +171,14 @@
Session session = sessionFactory.openSession();
try {
for (String tableName : tableNames) {
- String countSql = "select count(*) as RECORD_COUNT_ from "+tableName;
- SQLQuery sqlQuery = session.createSQLQuery(countSql);
- sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
- Long recordCount = (Long) sqlQuery.uniqueResult();
- if (recordCount>0L) {
- recordsLeftMsg += tableName+":"+recordCount+", ";
+ if (!"JBPM4_PROPERTY".equals(tableName)) {
+ String countSql = "select count(*) as RECORD_COUNT_ from "+tableName;
+ SQLQuery sqlQuery = session.createSQLQuery(countSql);
+ sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
+ Long recordCount = (Long) sqlQuery.uniqueResult();
+ if (recordCount>0L) {
+ recordsLeftMsg += tableName+":"+recordCount+", ";
+ }
}
}
} finally {
14 years, 7 months
JBoss JBPM SVN: r5631 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-11 11:11:04 -0400 (Fri, 11 Sep 2009)
New Revision: 5631
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
Log:
Fix for JBPM-2519: GPD zip has wrong location
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-09-11 15:07:44 UTC (rev 5630)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch02-Installation.xml 2009-09-11 15:11:04 UTC (rev 5631)
@@ -260,7 +260,7 @@
<para>The installation of the GPD uses the Eclipse Software Update
mechanism and is pretty straightforward. There is an archived update
site included in the runtime installation of jBPM when you unzip it
- at <literal>gpd/jbpm-gpd-site.zip</literal>
+ at <literal>install/src/gpd/jbpm-gpd-site.zip</literal>
</para>
<para>To add the update site to eclipse:
</para>
@@ -268,7 +268,7 @@
<listitem><literal>Help</literal> --> <literal>Install New Software...</literal></listitem>
<listitem>Click <literal>Add...</literal> </listitem>
<listitem>In dialog <literal>Add Site</literal> dialog, click <literal>Archive...</literal></listitem>
- <listitem>Navigate to <literal>gpd/jbpm-gpd-site.zip</literal> and click 'Open'</listitem>
+ <listitem>Navigate to <literal>install/src/gpd/jbpm-gpd-site.zip</literal> and click 'Open'</listitem>
<listitem>Clicking <literal>OK</literal> in the <literal>Add Site</literal> dialog will bring you back to the dialog 'Install'</listitem>
<listitem>Select the <literal>jPDL 4 GPD Update Site</literal> that has appeared</listitem>
<listitem>Click <literal>Next...</literal> and then <literal>Finish</literal></listitem>
14 years, 7 months
JBoss JBPM SVN: r5630 - jbpm4/trunk/modules/distro/src/main/files/install.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-11 11:07:44 -0400 (Fri, 11 Sep 2009)
New Revision: 5630
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
Log:
Fix for JBPM-2511: changed signavio war tmp folder to /install/generated/signavio-war
Fix for JBPM-2520: ant -p not showing Signavio install tasks
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-09-11 14:41:09 UTC (rev 5629)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-09-11 15:07:44 UTC (rev 5630)
@@ -55,6 +55,7 @@
<property name="signavio.war.file.name" value="jbpmeditor.war" />
<property name="signavio.src.dir" value="${jbpm.home}/install/src/signavio" />
+ <property name="signavio.tmp.dir" value="${jbpm.home}/install/generated/signavio-war" />
<property name="signavio.repo.dir.name" value="signavio-repository" />
<property name="signavio.repo.dir" value="${jbpm.home}/${signavio.repo.dir.name}"/>
@@ -718,12 +719,12 @@
</exec>
</target>
- <target name="install.signavio.into.jboss" depends="internal.set.signavio.repo.dir">
+ <target name="install.signavio.into.jboss" depends="internal.set.signavio.repo.dir" description="installs signavio into jboss">
<!-- Current version of Signavio needs to be unpacked in /deploy to work correctly -->
<unzip src="${signavio.src.dir}/${signavio.war.file.name}" dest="${jboss.server.deploy.dir}/${signavio.war.file.name}" />
</target>
- <target name="install.signavio.into.tomcat" depends="internal.set.signavio.repo.dir">
+ <target name="install.signavio.into.tomcat" depends="internal.set.signavio.repo.dir" description="installs signavio into tomcat">
<copy file="${signavio.src.dir}/${signavio.war.file.name}" todir="${tomcat.webapps.dir}"/>
</target>
@@ -791,20 +792,18 @@
<mkdir dir="${jbpm.home}/signavio-repository" />
<!-- unzip the signavio war -->
- <property name="temp.signavio.unzip" value="${jbpm.home}/temp-signavio-unzip" />
- <delete dir="${temp.signavio.unzip}" />
- <mkdir dir="${temp.signavio.unzip}" />
- <unzip src="${jbpm.home}/install/src/signavio/${signavio.war.file.name}" dest="${temp.signavio.unzip}" />
+ <delete dir="${signavio.tmp.dir}" />
+ <mkdir dir="${signavio.tmp.dir}" />
+ <unzip src="${jbpm.home}/install/src/signavio/${signavio.war.file.name}" dest="${signavio.tmp.dir}" />
<!-- replace the repo dir in he unzipped WEB-INF/web.xml -->
- <replaceregexp file="${temp.signavio.unzip}/WEB-INF/web.xml" flags="s"
+ <replaceregexp file="${signavio.tmp.dir}/WEB-INF/web.xml" flags="s"
match="<param-name>fileSystemRootDirectory</param-name>.*?<param-value>.*?</param-value>"
- replace="<param-name>fileSystemRootDirectory</param-name><param-value>${current.dir}/${signavio.repo.dir.name}</param-value>"/>
+ replace="<param-name>fileSystemRootDirectory</param-name><param-value>${current.dir}/${signavio.repo.dir.name}</param-value>"/>
<!-- zip it up again and copy it back to /lib-->
- <zip destfile="${temp.signavio.unzip}/${signavio.war.file.name}" basedir="${temp.signavio.unzip}" />
- <copy file="${temp.signavio.unzip}/${signavio.war.file.name}" todir="${signavio.src.dir}" overwrite="true"/>
- <delete dir="${temp.signavio.unzip}" />
+ <zip destfile="${signavio.tmp.dir}/${signavio.war.file.name}" basedir="${signavio.tmp.dir}" />
+ <copy file="${signavio.tmp.dir}/${signavio.war.file.name}" todir="${signavio.src.dir}" overwrite="true"/>
</target>
<target name="internal.install.eclipse.windows" if="isWindows">
14 years, 7 months
JBoss JBPM SVN: r5629 - jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-11 10:41:09 -0400 (Fri, 11 Sep 2009)
New Revision: 5629
Modified:
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
Log:
Fix for JBPM-2507
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-09-11 14:33:58 UTC (rev 5628)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-09-11 14:41:09 UTC (rev 5629)
@@ -136,6 +136,7 @@
task.setId(((TaskImpl) jbpmTask).getDbid());
task.setName(jbpmTask.getName());
+ task.setDescription(jbpmTask.getDescription());
task.setAssignee(jbpmTask.getAssignee());
task.setPriority(jbpmTask.getPriority());
@@ -149,7 +150,7 @@
// cast
//TaskImpl cast = ((TaskImpl) jbpmTask);
- //task.setSignalling(cast.isSignalling()); // TODO: wat met dit?
+ //task.setSignalling(cast.isSignalling()); // TODO: Still needed?
//ExecutionImpl execution = cast.getProcessInstance();
//task.setProcessInstanceId(cast.getProcessInstance().getId());
14 years, 7 months
JBoss JBPM SVN: r5628 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/history and 6 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-11 10:33:58 -0400 (Fri, 11 Sep 2009)
New Revision: 5628
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
Log:
Fix for JBPM-2502
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/JobQuery.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -37,7 +37,7 @@
public interface JobQuery {
/** duedate property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
- public static final String PROPERTY_DUEDATE = "dueDate";
+ public static final String PROPERTY_DUEDATE = "duedate";
/** state property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
public static final String PROPERTY_STATE = "state";
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryDetailQuery.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -55,7 +55,10 @@
* (this usually used in combination with {@link #processDefinitionId(String)}) */
HistoryDetailQuery comments();
- /** order selected process definitions descending for certain {@link #PROPERTY_USERID properties} */
+ /** order selected process definitions ascending */
+ HistoryDetailQuery orderAsc(String property);
+
+ /** order selected process definitions descending */
HistoryDetailQuery orderDesc(String property);
/** select a specific page in the result set */
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryTaskQuery.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -34,7 +34,7 @@
/** id property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
String PROPERTY_ID = "dbid";
/** starttime property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
- String PROPERTY_STARTTIME = "startTime";
+ String PROPERTY_CREATETIME = "createTime";
/** endtime property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
String PROPERTY_ENDTIME = "endTime";
/** executionId property to be used as property in {@link #orderAsc(String)} and {@link #orderDesc(String)} */
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -56,6 +56,8 @@
}
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -80,6 +80,8 @@
if (activityName!=null) {
appendWhereClause(" hai.activityName = '"+activityName+"'", hql);
}
+
+ appendOrderByClause(hql);
return hql.toString();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryDetailQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -72,6 +72,8 @@
appendWhereClause(" hd.time > :timeAfter ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -58,6 +58,8 @@
appendWhereClause(" hpi.state = '"+state+"' ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
@@ -83,7 +85,7 @@
}
public HistoryProcessInstanceQuery orderDesc(String property) {
- addOrderByClause("hpi."+property+" asc");
+ addOrderByClause("hpi."+property+" desc");
return this;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryTaskQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -88,6 +88,8 @@
appendWhereClause(" ht.startTime > :startedAfter ", hql);
}
+ appendOrderByClause(hql);
+
return hql.toString();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -67,6 +67,8 @@
appendWhereClause("j.exception is null ", hql);
}
}
+
+ appendOrderByClause(hql);
return hql.toString();
}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,132 +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.test.deploy;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.jbpm.api.Deployment;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DeploymentQueryTest extends JbpmTestCase {
-
- public void testSuspendDeployment() {
- String deploymentClaimId = repositoryService
- .createDeployment()
- .setName("Claim")
- .addResourceFromString("process.jpdl.xml",
- "<process name='claim'>" +
- " <start>" +
- " <transition to='c' />" +
- " </start>" +
- " <state name='c' />" +
- "</process>"
- )
- .deploy();
-
- String deploymentHireId = repositoryService
- .createDeployment()
- .setName("Hire")
- .addResourceFromString("process.jpdl.xml",
- "<process name='hire'>" +
- " <start>" +
- " <transition to='h' />" +
- " </start>" +
- " <state name='h' />" +
- "</process>"
- )
- .deploy();
-
- String deploymentFireId = repositoryService
- .createDeployment()
- .setName("Fire")
- .addResourceFromString("process.jpdl.xml",
- "<process name='fire'>" +
- " <start>" +
- " <transition to='f' />" +
- " </start>" +
- " <state name='f' />" +
- "</process>"
- )
- .deploy();
-
- repositoryService.suspendDeployment(deploymentHireId);
-
-
- // find all deployments
-
- List<Deployment> deployments = repositoryService
- .createDeploymentQuery()
- .list();
-
- Set<String> expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Claim");
- expectedDeploymentNames.add("Hire");
- expectedDeploymentNames.add("Fire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- // find suspended deployments
-
- deployments = repositoryService
- .createDeploymentQuery()
- .suspended()
- .list();
-
- expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Hire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- // find active deployments
-
- deployments = repositoryService
- .createDeploymentQuery()
- .notSuspended()
- .list();
-
- expectedDeploymentNames = new HashSet<String>();
- expectedDeploymentNames.add("Claim");
- expectedDeploymentNames.add("Fire");
-
- assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
-
- repositoryService.deleteDeploymentCascade(deploymentClaimId);
- repositoryService.deleteDeploymentCascade(deploymentHireId);
- repositoryService.deleteDeploymentCascade(deploymentFireId);
- }
-
- Set<String> getDeploymentNames(List<Deployment> deployments) {
- Set<String> deploymentNames = new HashSet<String>();
- for (Deployment deployment: deployments) {
- deploymentNames.add(deployment.getName());
- }
- return deploymentNames;
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,87 +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.test.history;
-
-import java.util.List;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.history.HistoryActivityInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryActivityInstanceQeuryTest extends JbpmTestCase {
-
- public void testSimpleQuery() {
- deployJpdlXmlString(
- "<process name='abc'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to ='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <transition to ='c' />" +
- " </state>" +
- " <state name='c'>" +
- " <transition to ='end' />" +
- " </state>" +
- " <end name='end' />" +
- "</process>"
- );
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
-
- processInstance = executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
- executionService.signalExecutionById(processInstance.getId());
-
- processInstance = executionService.startProcessInstanceByKey("abc");
- executionService.signalExecutionById(processInstance.getId());
-
- executionService.startProcessInstanceByKey("abc");
-
- List<HistoryActivityInstance> histActInsts = historyService.createHistoryActivityInstanceQuery()
- .activityName("a")
- .list();
-
- assertEquals(4, histActInsts.size());
-
- histActInsts = historyService.createHistoryActivityInstanceQuery()
- .activityName("b")
- .list();
-
- assertEquals(3, histActInsts.size());
-
- histActInsts = historyService.createHistoryActivityInstanceQuery()
- .activityName("c")
- .list();
-
- assertEquals(2, histActInsts.size());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,97 +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.test.history;
-
-import java.util.List;
-
-import org.jbpm.api.history.HistoryComment;
-import org.jbpm.api.history.HistoryDetail;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryDetailQueryTest extends JbpmTestCase {
-
- public void testTaskCommentDetail() {
- deployJpdlXmlString(
- "<process name='TaskCommentDetail'>" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <task name='t' assignee='johndoe'/>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TaskCommentDetail");
-
- String taskId = taskService.createTaskQuery().uniqueResult().getId();
-
- taskService.addTaskComment(taskId, "hello");
-
- List<HistoryDetail> historyDetails = historyService.createHistoryDetailQuery().list();
- assertEquals(historyDetails.toString(), 1, historyDetails.size());
-
- historyDetails = historyService
- .createHistoryDetailQuery()
- .comments()
- .list();
-
- assertEquals(historyDetails.toString(), 1, historyDetails.size());
-
- HistoryComment historyComment = (HistoryComment) historyDetails.get(0);
- assertEquals("hello", historyComment.getMessage());
- }
-
- public void testTaskCommentRepliesDetail() {
- deployJpdlXmlString(
- "<process name='TaskCommentRepliesDetail'>" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <task name='t' assignee='johndoe'/>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TaskCommentRepliesDetail");
-
- String taskId = taskService.createTaskQuery().uniqueResult().getId();
-
- processEngine.setAuthenticatedUserId("johndoe");
- String helloCommentId = taskService.addTaskComment(taskId, "hi, how are you guys?").getId();
-
- processEngine.setAuthenticatedUserId("joesmoe");
- taskService.addReplyComment(helloCommentId, "i'm doing fine, thanks");
-
- processEngine.setAuthenticatedUserId("jackblack");
- taskService.addReplyComment(helloCommentId, "i got a hangover");
-
- List<HistoryDetail> historyDetails = historyService.createHistoryDetailQuery().list();
- assertEquals(historyDetails.toString(), 3, historyDetails.size());
-
- historyDetails = historyService
- .createHistoryDetailQuery()
- .comments()
- .list();
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,111 +0,0 @@
-package org.jbpm.test.mgmt;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.jbpm.api.job.Job;
-import org.jbpm.test.JbpmTestCase;
-
-
-public class JobQueryTest extends JbpmTestCase {
-
- public void testQueryOutstandingTimers() {
- deployJpdlXmlString(
- "<process name='TimerQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <state name='t'>" +
- " <transition name='timeout' to='t'>" +
- " <timer duedate='20 seconds' />" +
- " </transition>" +
- " </state>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
- executionService.startProcessInstanceByKey("TimerQueryTest");
-
- List<Job> timers = managementService.createJobQuery()
- .timers()
- .list();
-
- assertEquals(4, timers.size());
- }
-
- public void testQueryBacklogMessages() {
- deployJpdlXmlString(
- "<process name='MessagesQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <state name='t' continue='async' />" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
- executionService.startProcessInstanceByKey("MessagesQueryTest");
-
- List<Job> timers = managementService.createJobQuery()
- .messages()
- .list();
-
- assertEquals(4, timers.size());
- }
-
-
- public static class Dog implements Serializable {
- private static final long serialVersionUID = 1L;
- public void bark() {
- throw new RuntimeException("wooof");
- }
- }
- public void testErrorMessages() {
- deployJpdlXmlString(
- "<process name='ErrorMsgQueryTest' >" +
- " <start>" +
- " <transition to='t' />" +
- " </start>" +
- " <java name='t' " +
- " continue='async' " +
- " class='"+Dog.class.getName()+"'" +
- " method='bark'>" +
- " </java>" +
- "</process>"
- );
-
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
- executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
-
-
- List<Job> messages = managementService.createJobQuery()
- .messages()
- .list();
-
- assertEquals(3, messages.size());
-
- managementService.executeJob(messages.get(0).getId());
- managementService.executeJob(messages.get(0).getId());
- managementService.executeJob(messages.get(0).getId());
-
- List<Job> errorJobs = managementService.createJobQuery()
- .exception(true)
- .list();
-
- assertEquals(1, errorJobs.size());
-
- assertTextPresent("wooof", errorJobs.get(0).getException());
-
- messages = managementService.createJobQuery()
- .messages()
- .exception(false)
- .list();
-
- assertEquals(2, messages.size());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,138 +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.test.process;
-
-import java.util.List;
-
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessDefinitionQueryTest extends JbpmTestCase {
-
- public void testQueryProcessDefinitionsEmpty() {
- List<ProcessDefinition> processDefinitions = repositoryService
- .createProcessDefinitionQuery()
- .list();
-
- assertEquals(0, processDefinitions.size());
- }
-
- public void testQueryProcessDefinitionsNameLike() {
- deployJpdlXmlString(
- "<process name='make print'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='use phone'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='clean whiteboard'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='fix coffeemaker'>" +
- " <start />" +
- "</process>"
- );
-
- List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
- .processDefinitionNameLike("%make%")
- .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
- .list();
-
- assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
- assertEquals("make friends", processDefinitions.get(1).getName());
- assertEquals("make print", processDefinitions.get(2).getName());
- }
-
- public void testQueryProcessDefinitionsKeyLike() {
- deployJpdlXmlString(
- "<process name='make print'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='use phone'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='make friends'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='clean whiteboard'>" +
- " <start />" +
- "</process>"
- );
-
- deployJpdlXmlString(
- "<process name='fix coffeemaker'>" +
- " <start />" +
- "</process>"
- );
-
- List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
- .processDefinitionNameLike("make%")
- .orderAsc(ProcessDefinitionQuery.PROPERTY_ID)
- .list();
-
- assertEquals("make_friends-1", processDefinitions.get(0).getId());
- assertEquals("make_friends-2", processDefinitions.get(1).getId());
- assertEquals("make_friends-3", processDefinitions.get(2).getId());
- assertEquals("make_print-1", processDefinitions.get(3).getId());
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-11 14:33:58 UTC (rev 5628)
@@ -1,260 +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.test.task;
-
-import java.lang.reflect.Method;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.api.TaskQuery;
-import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TaskQueryTest extends JbpmTestCase {
-
- public void testPropertyNames() {
- Task task = taskService.newTask();
- task.setName("write task query test");
- task.setAssignee("koen");
- task.setPriority(Integer.MAX_VALUE);
- task.setDescription("make sure the test fails if property names are incorrect");
- task.setDuedate(new Date());
- String taskId = taskService.saveTask(task);
-
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_ASSIGNEE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_CREATEDATE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_DUEDATE);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_NAME);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PRIORITY);
- checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PROGRESS);
-
- taskService.deleteTaskCascade(taskId);
- }
-
- private void checkProperty(TaskQuery taskQuery, Task task, String propertyName) {
- List<Task> taskList = taskQuery.orderAsc(propertyName).list();
- assertNotNull(taskList);
- assertContainsTask(taskList, task.getName());
- assertEquals(1, taskList.size());
- }
-
- public void testSimplestTaskQuery() {
- List<Task> tasks = createTestTasks();
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .list();
- assertNotNull(taskList);
-
- assertContainsTask(taskList, "do laundry");
- assertContainsTask(taskList, "change dyper");
- assertContainsTask(taskList, "start new business");
- assertContainsTask(taskList, "find venture capital");
-
- assertEquals(4, taskList.size());
-
- deleteTasks(tasks);
- }
-
- public void testOrderByName() {
- testOrderBy(TaskQuery.PROPERTY_NAME,
- new String[] {"change dyper", "do laundry", "find venture capital", "start new business"});
- }
-
- public void testOrderByAssignee() {
- testOrderBy(TaskQuery.PROPERTY_ASSIGNEE, new String[] {null, "Joram", "Koen", "Tom"});
- }
-
- public void testOrderByCreateTime() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_CREATEDATE, 4);
- }
-
- public void testOrderByDueDate() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_DUEDATE, 4);
- }
-
- public void testOrderByPriority() {
- testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_PRIORITY, 4);
- }
-
- public void testOrderByProgress() {
- testOrderBy(TaskQuery.PROPERTY_PROGRESS, new Integer[] {2, 15, 75, 99});
- }
-
-
- /* -------------------------------------------------------------------
- * HELPER METHODS
- * ------------------------------------------------------------------- */
-
- private List<Task> createTestTasks() {
- List<Task> result = new ArrayList<Task>();
-
- Task task1 = taskService.newTask();
- task1.setName("do laundry");
- task1.setAssignee("Tom");
- task1.setPriority(3);
- task1.setDuedate(stringToDate("10/10/1985"));
- task1.setProgress(15);
-
- Task task2 = taskService.newTask();
- task2.setName("change dyper");
- task2.setAssignee("Koen");
- task2.setPriority(1);
- task2.setDuedate(stringToDate("28/06/1989"));
- task2.setProgress(2);
-
- Task task3 = taskService.newTask();
- task3.setName("start new business");
- task3.setAssignee("Joram");
- task3.setPriority(4);
- task3.setProgress(75);
-
- Task task4 = taskService.newTask();
- task4.setName("find venture capital");
- task4.setPriority(7);
- task4.setDuedate(stringToDate("09/09/2009"));
- task4.setProgress(99);
-
- for (Task t : new Task[] {task1, task2, task3, task4}) {
- taskService.saveTask(t);
- result.add(t);
- }
-
- return result;
- }
-
- /**
- * Convience method:
- * - Creates a task query with order asc/desc on the given <i>property</i> param.
- * - Loops over both result lists and checks if the elements
- * are in the order as given by the <i>expectedValues</i> param.
- */
- private void testOrderBy(String property, Object[] expectedValues) {
- List<Task> tasks = createTestTasks();
-
- List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
- List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
-
- assertNotNull(taskListAsc);
- assertEquals(expectedValues.length, taskListAsc.size());
-
- assertNotNull(taskListDesc);
- assertEquals(expectedValues.length, taskListDesc.size());
-
- for (int i = 0; i < expectedValues.length; i++) {
-
- Object realValueAsc = null;
- Object realValueDesc = null;
-
- try {
-
- realValueAsc = invokeGetterOnTask(property, taskListAsc.get(i));
- realValueDesc = invokeGetterOnTask(property, taskListDesc.get((taskListDesc.size() -1) - i));
-
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- assertEquals("Incorrect order by ASC for property " + property, expectedValues[i], realValueAsc);
- assertEquals("Incorrect order by ASC for property " + property, expectedValues[i], realValueAsc);
-
- }
-
- deleteTasks(tasks);
- }
-
- /**
- * Creates a taskquery for tasks, orderd on the given property.
- * The resulting list is checked asc/desc for natural order.
- *
- * Note property must implement Comparable!
- */
- @SuppressWarnings("unchecked")
- private void testOrderByResultsInNaturalOrdening(String property, int expectedNrOfResults) {
- List<Task> tasks = createTestTasks();
- List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
- List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
-
- assertEquals(expectedNrOfResults, taskListAsc.size());
- assertEquals(expectedNrOfResults, taskListDesc.size());
-
- if (expectedNrOfResults > 1) {
-
- for (int i = 1; i < taskListAsc.size(); i++) {
-
- // ascending check
- Comparable c1 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i - 1));
- Comparable c2 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i));
- if (c1 != null && c2 != null) {
- assertTrue(c1.compareTo(c2) <= 0); // c1 <= c2 when ascending
- }
-
- // ascending check
- Comparable c3 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i - 1));
- Comparable c4 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i));
- if (c3 != null && c4 != null) {
- assertTrue(c3.compareTo(c4) >= 0); // c3 >= c4 when ascending
- }
-
- }
- }
-
- deleteTasks(tasks);
- }
-
- private Object invokeGetterOnTask(String property, Task task) {
- Method getter = ReflectUtil.getMethod(TaskImpl.class,
- "get" + property.substring(0, 1).toUpperCase() + property.substring(1), null);
- try {
- return getter.invoke(task);
- } catch (Exception e) {
- throw new RuntimeException("Couldn't invoke getter for property " + property);
- }
- }
-
- private void deleteTasks(List<Task> tasks) {
- for (Task t : tasks) {
- taskService.deleteTaskCascade(t.getId());
- }
- }
-
- private Date stringToDate(String dateString) {
- DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
- try {
- return dateFormat.parse(dateString);
- } catch (ParseException e) {
- throw new RuntimeException("Couldn't convert " + dateString);
- }
- }
-
-}
14 years, 7 months
JBoss JBPM SVN: r5627 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/task and 1 other directory.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-10 09:45:51 -0400 (Thu, 10 Sep 2009)
New Revision: 5627
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
Log:
Test case for JBPM-2535
Also added progress getter/setter to Task interface
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java 2009-09-10 10:21:20 UTC (rev 5626)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java 2009-09-10 13:45:51 UTC (rev 5627)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.util.Date;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.TaskService;
import org.jbpm.api.history.HistoryTask;
@@ -91,6 +92,21 @@
* Updates like this require you to invoke {@link TaskService#saveTask(Task)} afterwards. */
void setPriority(int priority);
+ /**
+ * The progress of this task. This is a data item for user purposes and
+ * doesn't influence the functionality of the engine.
+ */
+ Integer getProgress();
+
+ /**
+ * Change the progress of this task.
+ * Updates like this require you to invoke {@link TaskService#saveTask(Task)} afterwards.
+ *
+ * <b>IMPORTANT</b>: Only values between 0 and 100 are accepted.
+ * Using other values will cause a {@link JbpmException}.
+ */
+ void setProgress(Integer progress);
+
/** reference to the execution or null if this task is unrelated to an execution */
String getExecutionId();
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-10 10:21:20 UTC (rev 5626)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java 2009-09-10 13:45:51 UTC (rev 5627)
@@ -21,11 +21,19 @@
*/
package org.jbpm.test.task;
+import java.lang.reflect.Method;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.jbpm.api.TaskQuery;
import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.test.JbpmTestCase;
@@ -41,10 +49,8 @@
task.setPriority(Integer.MAX_VALUE);
task.setDescription("make sure the test fails if property names are incorrect");
task.setDuedate(new Date());
- String writeTestTaskId = taskService.saveTask(task);
+ String taskId = taskService.saveTask(task);
- //TaskQuery taskQuery = taskService.createTaskQuery();
-
checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_ASSIGNEE);
checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_CREATEDATE);
checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_DUEDATE);
@@ -52,7 +58,7 @@
checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PRIORITY);
checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PROGRESS);
- taskService.deleteTaskCascade(writeTestTaskId);
+ taskService.deleteTaskCascade(taskId);
}
private void checkProperty(TaskQuery taskQuery, Task task, String propertyName) {
@@ -63,29 +69,8 @@
}
public void testSimplestTaskQuery() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- String laudryTaskId = taskService.saveTask(task);
+ List<Task> tasks = createTestTasks();
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- String dyperTaskId = taskService.saveTask(task);
-
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- String startBusinessTaskId = taskService.saveTask(task);
-
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(4);
- String capitalTaskId = taskService.saveTask(task);
-
List<Task> taskList = taskService
.createTaskQuery()
.list();
@@ -98,52 +83,178 @@
assertEquals(4, taskList.size());
- taskService.deleteTaskCascade(capitalTaskId);
- taskService.deleteTaskCascade(startBusinessTaskId);
- taskService.deleteTaskCascade(dyperTaskId);
- taskService.deleteTaskCascade(laudryTaskId);
+ deleteTasks(tasks);
}
- public void testSimplestTaskQuerySortBy() {
- Task task = taskService.newTask();
- task.setName("do laundry");
- task.setAssignee("johndoe");
- task.setPriority(3);
- String laudryTaskId = taskService.saveTask(task);
+ public void testOrderByName() {
+ testOrderBy(TaskQuery.PROPERTY_NAME,
+ new String[] {"change dyper", "do laundry", "find venture capital", "start new business"});
+ }
+
+ public void testOrderByAssignee() {
+ testOrderBy(TaskQuery.PROPERTY_ASSIGNEE, new String[] {null, "Joram", "Koen", "Tom"});
+ }
+
+ public void testOrderByCreateTime() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_CREATEDATE, 4);
+ }
+
+ public void testOrderByDueDate() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_DUEDATE, 4);
+ }
+
+ public void testOrderByPriority() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_PRIORITY, 4);
+ }
+
+ public void testOrderByProgress() {
+ testOrderBy(TaskQuery.PROPERTY_PROGRESS, new Integer[] {2, 15, 75, 99});
+ }
+
+
+ /* -------------------------------------------------------------------
+ * HELPER METHODS
+ * ------------------------------------------------------------------- */
+
+ private List<Task> createTestTasks() {
+ List<Task> result = new ArrayList<Task>();
- task = taskService.newTask();
- task.setName("change dyper");
- task.setAssignee("johndoe");
- task.setPriority(1);
- String dyperTaskId = taskService.saveTask(task);
+ Task task1 = taskService.newTask();
+ task1.setName("do laundry");
+ task1.setAssignee("Tom");
+ task1.setPriority(3);
+ task1.setDuedate(stringToDate("10/10/1985"));
+ task1.setProgress(15);
- task = taskService.newTask();
- task.setName("start new business");
- task.setAssignee("joesmoe");
- task.setPriority(4);
- String startBusinessTaskId = taskService.saveTask(task);
+ Task task2 = taskService.newTask();
+ task2.setName("change dyper");
+ task2.setAssignee("Koen");
+ task2.setPriority(1);
+ task2.setDuedate(stringToDate("28/06/1989"));
+ task2.setProgress(2);
+
+ Task task3 = taskService.newTask();
+ task3.setName("start new business");
+ task3.setAssignee("Joram");
+ task3.setPriority(4);
+ task3.setProgress(75);
- task = taskService.newTask();
- task.setName("find venture capital");
- task.setPriority(7);
- String capitalTaskId = taskService.saveTask(task);
-
- List<Task> taskList = taskService
- .createTaskQuery()
- .orderAsc(TaskQuery.PROPERTY_NAME)
- .list();
- assertNotNull(taskList);
+ Task task4 = taskService.newTask();
+ task4.setName("find venture capital");
+ task4.setPriority(7);
+ task4.setDuedate(stringToDate("09/09/2009"));
+ task4.setProgress(99);
- assertEquals("change dyper", taskList.get(0).getName());
- assertEquals("do laundry", taskList.get(1).getName());
- assertEquals("find venture capital", taskList.get(2).getName());
- assertEquals("start new business", taskList.get(3).getName());
+ for (Task t : new Task[] {task1, task2, task3, task4}) {
+ taskService.saveTask(t);
+ result.add(t);
+ }
+
+ return result;
+ }
+
+ /**
+ * Convience method:
+ * - Creates a task query with order asc/desc on the given <i>property</i> param.
+ * - Loops over both result lists and checks if the elements
+ * are in the order as given by the <i>expectedValues</i> param.
+ */
+ private void testOrderBy(String property, Object[] expectedValues) {
+ List<Task> tasks = createTestTasks();
- assertEquals(4, taskList.size());
+ List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
+ List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
- taskService.deleteTaskCascade(capitalTaskId);
- taskService.deleteTaskCascade(startBusinessTaskId);
- taskService.deleteTaskCascade(dyperTaskId);
- taskService.deleteTaskCascade(laudryTaskId);
+ assertNotNull(taskListAsc);
+ assertEquals(expectedValues.length, taskListAsc.size());
+
+ assertNotNull(taskListDesc);
+ assertEquals(expectedValues.length, taskListDesc.size());
+
+ for (int i = 0; i < expectedValues.length; i++) {
+
+ Object realValueAsc = null;
+ Object realValueDesc = null;
+
+ try {
+
+ realValueAsc = invokeGetterOnTask(property, taskListAsc.get(i));
+ realValueDesc = invokeGetterOnTask(property, taskListDesc.get((taskListDesc.size() -1) - i));
+
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ assertEquals("Incorrect order by ASC for property " + property, expectedValues[i], realValueAsc);
+ assertEquals("Incorrect order by ASC for property " + property, expectedValues[i], realValueAsc);
+
+ }
+
+ deleteTasks(tasks);
}
+
+ /**
+ * Creates a taskquery for tasks, orderd on the given property.
+ * The resulting list is checked asc/desc for natural order.
+ *
+ * Note property must implement Comparable!
+ */
+ @SuppressWarnings("unchecked")
+ private void testOrderByResultsInNaturalOrdening(String property, int expectedNrOfResults) {
+ List<Task> tasks = createTestTasks();
+ List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
+ List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
+
+ assertEquals(expectedNrOfResults, taskListAsc.size());
+ assertEquals(expectedNrOfResults, taskListDesc.size());
+
+ if (expectedNrOfResults > 1) {
+
+ for (int i = 1; i < taskListAsc.size(); i++) {
+
+ // ascending check
+ Comparable c1 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i - 1));
+ Comparable c2 = (Comparable) invokeGetterOnTask(property, taskListAsc.get(i));
+ if (c1 != null && c2 != null) {
+ assertTrue(c1.compareTo(c2) <= 0); // c1 <= c2 when ascending
+ }
+
+ // ascending check
+ Comparable c3 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i - 1));
+ Comparable c4 = (Comparable) invokeGetterOnTask(property, taskListDesc.get(i));
+ if (c3 != null && c4 != null) {
+ assertTrue(c3.compareTo(c4) >= 0); // c3 >= c4 when ascending
+ }
+
+ }
+ }
+
+ deleteTasks(tasks);
+ }
+
+ private Object invokeGetterOnTask(String property, Task task) {
+ Method getter = ReflectUtil.getMethod(TaskImpl.class,
+ "get" + property.substring(0, 1).toUpperCase() + property.substring(1), null);
+ try {
+ return getter.invoke(task);
+ } catch (Exception e) {
+ throw new RuntimeException("Couldn't invoke getter for property " + property);
+ }
+ }
+
+ private void deleteTasks(List<Task> tasks) {
+ for (Task t : tasks) {
+ taskService.deleteTaskCascade(t.getId());
+ }
+ }
+
+ private Date stringToDate(String dateString) {
+ DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
+ try {
+ return dateFormat.parse(dateString);
+ } catch (ParseException e) {
+ throw new RuntimeException("Couldn't convert " + dateString);
+ }
+ }
+
}
14 years, 7 months
JBoss JBPM SVN: r5626 - in projects/jopr-integration/trunk: src/main/java/org/rhq/plugins/jbpm4 and 1 other directories.
by do-not-reply@jboss.org
Author: jim.ma
Date: 2009-09-10 06:21:20 -0400 (Thu, 10 Sep 2009)
New Revision: 5626
Modified:
projects/jopr-integration/trunk/pom.xml
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
Log:
Completed RemoteJBPMEngineConnector to test it in new released jopr2.3
Modified: projects/jopr-integration/trunk/pom.xml
===================================================================
--- projects/jopr-integration/trunk/pom.xml 2009-09-09 14:17:07 UTC (rev 5625)
+++ projects/jopr-integration/trunk/pom.xml 2009-09-10 10:21:20 UTC (rev 5626)
@@ -54,9 +54,17 @@
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-pvm</artifactId>
- <version>4.0-SNAPSHOT</version>
+ <version>4.0</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-enterprise</artifactId>
+ <version>4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java 2009-09-09 14:17:07 UTC (rev 5625)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/ProcessEngineDiscoveryComponent.java 2009-09-10 10:21:20 UTC (rev 5626)
@@ -67,7 +67,6 @@
//TODO:Review it and removed the jars not needed
String[] jarFileNames = { "lib/jbpm.jar",
"deploy/jbpm/jbpm-service.sar/freemarker.jar",
- "deploy/jbpm/jbpm-service.sar/jbpm-spi.jar",
"deploy/jbpm/jbpm-service.sar/juel.jar",
"deploy/jbpm/jbpm-service.sar/juel-engine.jar",
"deploy/jbpm/jbpm-service.sar/juel-impl.jar",
Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java 2009-09-09 14:17:07 UTC (rev 5625)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/LocalJBPMEngineConnector.java 2009-09-10 10:21:20 UTC (rev 5626)
@@ -213,8 +213,10 @@
}
public Job executeJob(String jobDbid) {
- CommandService commandService = processEngine.get(CommandService.class);
- return commandService.execute(new ExecuteJobCmd(jobDbid));
+ //These will cause jbpm4.1 class not fund org.jbpm.pvm.internal.cmd.Command execption
+ /*CommandService commandService = processEngine.get(CommandService.class);
+ return commandService.execute(new ExecuteJobCmd(jobDbid));*/
+ return null;
}
public List<HistoryProcessInstance> getHistoryProcessInstances(String definitionId, String processInstanceId, String state, Page page) {
Modified: projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java
===================================================================
--- projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java 2009-09-09 14:17:07 UTC (rev 5625)
+++ projects/jopr-integration/trunk/src/main/java/org/rhq/plugins/jbpm4/connector/RemoteJBPMEngineConnector.java 2009-09-10 10:21:20 UTC (rev 5626)
@@ -21,6 +21,11 @@
*/
package org.rhq.plugins.jbpm4.connector;
+import java.io.File;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
import javax.naming.Context;
@@ -28,11 +33,48 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jbpm.api.Deployment;
+import org.jbpm.api.DeploymentQuery;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.JobQuery;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.enterprise.internal.ejb.RemoteCommandExecutor;
+import org.jbpm.enterprise.internal.ejb.RemoteCommandExecutorHome;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.cmd.CreateDeploymentQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateHistoryProcessInstanceQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateHistoryTaskQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateJobQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateProcessDefinitionQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateProcessInstanceQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateTaskQueryCmd;
+import org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd;
+import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
+import org.jbpm.pvm.internal.cmd.DeployCmd;
+import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
+import org.jbpm.pvm.internal.cmd.ResumeDeploymentCmd;
+import org.jbpm.pvm.internal.cmd.StartProcessInstanceCmd;
+import org.jbpm.pvm.internal.cmd.SuspendDeploymentCmd;
+import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryTaskQueryImpl;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+import org.jbpm.pvm.internal.query.Page;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
+import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.TaskQueryImpl;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+
/**
* @author <a href mailto="ema(a)redhat.com">Jim Ma</a>
- *
+ *
*/
-public class RemoteJBPMEngineConnector implements JBPMEngineConnector {
+public class RemoteJBPMEngineConnector implements JBPMEngineConnector, JBPMEngineConnection {
private static final String NAMING_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
private static final String JNP_TIMEOUT_JNP_INIT_PROP = "jnp.timeout";
@@ -41,48 +83,362 @@
private static final int JNP_TIMEOUT = 60 * 1000; // 60 seconds
private static final int JNP_SO_TIMEOUT = 60 * 1000; // 60 seconds
private static final boolean JNP_DISABLE_DISCOVERY = true;
-
- //TODO: ProcessEngine can not be serialized. What is the instead ?
- private final String XXX__JNDI_NAME = "ProcessEngine";
+
+ // TODO: ProcessEngine can not be serialized. What is the instead ?
+ private final String CMD_EXECUTOR__JNDI_NAME = "jbpm/CommandExecutor";
private final Log log = LogFactory.getLog(this.getClass());
-
+
private String providerURL;
private String principal;
private String credentials;
- private InitialContext initialContext;
+ private RemoteCommandExecutor remoteCommandExecutor = null;
public RemoteJBPMEngineConnector(String providerURL, String principal, String credentials) {
- this.providerURL = providerURL;
- this.principal = principal;
- this.credentials = credentials;
+ this.providerURL = providerURL;
+ this.principal = principal;
+ this.credentials = credentials;
}
public JBPMEngineConnection connect() {
- Properties env = new Properties();
- env.setProperty(Context.PROVIDER_URL, providerURL);
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
- env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
- env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT));
- env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY));
- env.setProperty(Context.SECURITY_CREDENTIALS, this.credentials);
- env.setProperty(Context.SECURITY_PRINCIPAL, this.principal);
- /*ProcessEngine processEngine = null;
- log.debug("Connecting to ProcessEngine via remote JNDI using env [" + env + "]...");
- try {
- initialContext = new InitialContext(env);
- processEngine = (ProcessEngine)initialContext.lookup(this.PROCESSENGINE__JNDI_NAME);
- } catch (NamingException e) {
- throw new RuntimeException("Failed to create JNDI InitialContext.", e);
- }*/
- return null;
+ try {
+ remoteCommandExecutor = this.retrieveCommandExecutor();
+ return this;
+ } catch (Exception e) {
+ log.error("Failed to retrieve CommandExecutor");
+ }
+ return null;
}
-
+
public void disconnect() {
-
+
}
-
+
public boolean isConnected() {
return false;
}
-}
-
+
+ private RemoteCommandExecutor retrieveCommandExecutor() throws Exception {
+ Properties env = new Properties();
+ env.setProperty(Context.PROVIDER_URL, providerURL);
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
+ env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
+ env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT));
+ env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY));
+ env.setProperty(Context.SECURITY_CREDENTIALS, this.credentials);
+ env.setProperty(Context.SECURITY_PRINCIPAL, this.principal);
+
+ InitialContext initialContext = new InitialContext(env);
+ RemoteCommandExecutorHome remoteCommandExecutorHome = (RemoteCommandExecutorHome) initialContext
+ .lookup(CMD_EXECUTOR__JNDI_NAME);
+
+ return remoteCommandExecutorHome.create();
+ }
+
+ // implementation for JBPMEngineConnection
+ // the deployment api
+ // TODO: true or false
+ public void deleteDeployment(String deploymentId) {
+ DeleteDeploymentCmd delDeploymentCmd = new DeleteDeploymentCmd(deploymentId);
+ this.execute(delDeploymentCmd);
+ }
+
+ public List<Deployment> getDeployments() {
+ CreateDeploymentQueryCmd queryCmd = new CreateDeploymentQueryCmd();
+ DeploymentQuery deploymentQuery = execute(queryCmd);
+ return deploymentQuery.list();
+
+ }
+
+ public Deployment getDeployment(String deploymentId) {
+ CreateDeploymentQueryCmd queryCmd = new CreateDeploymentQueryCmd();
+ DeploymentQuery deploymentQuery = execute(queryCmd);
+ return (Deployment) deploymentQuery.deploymentDbid(Long.valueOf(deploymentId)).uniqueResult();
+
+ }
+
+ public void suspendDeployment(String deploymentId) {
+ SuspendDeploymentCmd suspendDeploymentCmd = new SuspendDeploymentCmd(deploymentId);
+
+ execute(suspendDeploymentCmd);
+
+ }
+
+ public void resumeDeployment(String deploymentId) {
+ ResumeDeploymentCmd resumeDeploymentCmd = new ResumeDeploymentCmd(deploymentId);
+ execute(resumeDeploymentCmd);
+
+ }
+
+ public String deployProcess(File processFile) throws Exception {
+ DeploymentImpl deploymentImpl = new DeploymentImpl();
+ deploymentImpl.addResourceFromFile(processFile);
+ DeployCmd deployCmd = new DeployCmd(deploymentImpl);
+ return (String) execute(deployCmd);
+
+ }
+
+ // definition api
+ public List<ProcessDefinition> getProcessDefs() {
+ CreateProcessDefinitionQueryCmd queryCmd = new CreateProcessDefinitionQueryCmd();
+
+ ProcessDefinitionQueryImpl queryIml = (ProcessDefinitionQueryImpl) execute(queryCmd);
+ return queryIml.list();
+
+ }
+
+ public ProcessDefinition getProcessDefById(String id) {
+ CreateProcessDefinitionQueryCmd queryCmd = new CreateProcessDefinitionQueryCmd();
+
+ ProcessDefinitionQueryImpl queryIpml = (ProcessDefinitionQueryImpl) execute(queryCmd);
+ queryIpml.processDefinitionId(id);
+ return queryIpml.uniqueResult();
+
+ }
+
+ // process instance api
+ public List<ProcessInstance> getProcessInstances(String defId, String processInstanceId, String state, Page page) {
+ CreateProcessInstanceQueryCmd queryCmd = new CreateProcessInstanceQueryCmd();
+
+ ProcessInstanceQueryImpl query = (ProcessInstanceQueryImpl) execute(queryCmd);
+ if (defId != null) {
+ query.processDefinitionId(defId);
+ }
+ if (processInstanceId != null) {
+ query.processInstanceId(processInstanceId);
+ }
+ if (state != null && state.equals(ProcessInstance.STATE_SUSPENDED)) {
+ query.suspended();
+ }
+
+ if (state != null && (!state.equals(ProcessInstance.STATE_SUSPENDED))) {
+ query.notSuspended();
+ }
+
+ if (page != null) {
+ query.page(page.firstResult, page.maxResults);
+ }
+
+ return query.list();
+
+ }
+
+ public void deleteProcessInstance(String instanceId) {
+ DeleteProcessInstance deleteInstance = new DeleteProcessInstance(instanceId);
+
+ execute(deleteInstance);
+
+ }
+
+ public ProcessInstance startProcessInstance(String defId) {
+ StartProcessInstanceCmd startCmd = new StartProcessInstanceCmd(defId, null, null);
+
+ return (ProcessInstance)execute(startCmd);
+
+ }
+
+ // Job api
+ public List<Job> queryJob(boolean timerOnly, boolean messageOnly, boolean exception, String processInstanceId) {
+ CreateJobQueryCmd queryCmd = new CreateJobQueryCmd();
+
+ JobQuery jobQuery = (JobQuery) execute(queryCmd);
+ if (processInstanceId != null) {
+ jobQuery.processInstanceId(processInstanceId);
+ }
+
+ if (exception) {
+ jobQuery.exception(true);
+ }
+
+ if (timerOnly) {
+ jobQuery = jobQuery.timers();
+ } else if (messageOnly) {
+ jobQuery = jobQuery.messages();
+ }
+ return jobQuery.list();
+
+ }
+
+ public Job getJob(String jobId) {
+ CreateJobQueryCmd queryCmd = new CreateJobQueryCmd();
+
+ JobQuery jobQuery = (JobQuery) execute(queryCmd);
+
+ List<Job> jobs = jobQuery.list();
+
+ for (Job job : jobs) {
+ if (job.getId().equals(jobId)) {
+ return job;
+ }
+ }
+ return null;
+
+ }
+
+ public Job executeJob(String jobDbid) {
+ ExecuteJobCmd executeJobCmd = new ExecuteJobCmd(jobDbid);
+
+ return (Job) execute(executeJobCmd);
+
+ }
+
+ // Activity api
+ public Map<String, Long> avgDurationPerActivity(String processDefinitionId) {
+ AvgDurationPerActivityQueryCmd command = new AvgDurationPerActivityQueryCmd(processDefinitionId);
+
+ return (Map<String, Long>) execute(command);
+
+ }
+
+ // History process instance api
+ public List<HistoryProcessInstance> getHistoryProcessInstances(String definitionId, String processInstanceId,
+ String state, Page page) {
+ CreateHistoryProcessInstanceQueryCmd command = new CreateHistoryProcessInstanceQueryCmd();
+
+ HistoryProcessInstanceQueryImpl historyQuery = (HistoryProcessInstanceQueryImpl) execute(command);
+ if (definitionId != null) {
+ historyQuery.processDefinitionId(definitionId);
+ }
+ if (processInstanceId != null) {
+ historyQuery.processInstanceId(processInstanceId);
+ }
+
+ if (state != null) {
+ historyQuery.state(state);
+ }
+
+ if (page != null) {
+ historyQuery.page(page.firstResult, page.maxResults);
+ }
+ return historyQuery.list();
+
+ }
+
+ // Task api
+ public List<Task> getTasks(String definitionId, String processInstanceId) {
+ CreateTaskQueryCmd command = new CreateTaskQueryCmd();
+
+ TaskQueryImpl taskQuery = (TaskQueryImpl) execute(command);
+ if (definitionId != null) {
+ taskQuery.processDefinitionId(definitionId);
+ }
+
+ if (processInstanceId != null) {
+ taskQuery.processInstanceId(processInstanceId);
+ }
+
+ return taskQuery.list();
+
+ }
+
+ public List<Task> getTasks(TaskQueryCondition condition) {
+ CreateTaskQueryCmd command = new CreateTaskQueryCmd();
+
+ TaskQueryImpl taskQuery = (TaskQueryImpl) execute(command);
+ if (condition.getActivityName() != null) {
+ taskQuery.activityName(condition.getActivityName());
+ }
+
+ if (condition.getAssignee() != null) {
+ taskQuery.assignee(condition.getAssignee());
+ }
+
+ if (condition.getCandidate() != null) {
+ taskQuery.assignee(condition.getAssignee());
+ }
+
+ if (condition.getDefinitionId() != null) {
+ taskQuery.processDefinitionId(condition.getDefinitionId());
+ }
+
+ if (condition.getUnAssigneed() != null) {
+ taskQuery.unassigned();
+ }
+ if (condition.getSuspended() != null && condition.getSuspended()) {
+ taskQuery.suspended();
+ }
+ if (condition.getSuspended() != null && (!condition.getSuspended())) {
+ taskQuery.notSuspended();
+ }
+
+ if (condition.getPage() != null) {
+ taskQuery.page(condition.getPage().firstResult, condition.getPage().maxResults);
+ }
+
+ return taskQuery.list();
+
+ }
+
+ // History task api
+ public List<HistoryTask> getHIstoryTasks(TaskHistoryQueryCondition condition) {
+ CreateHistoryTaskQueryCmd command = new CreateHistoryTaskQueryCmd();
+
+ HistoryTaskQueryImpl historyTaskQuery = (HistoryTaskQueryImpl) execute(command);
+ if (condition.getTaskId() != null) {
+ historyTaskQuery.taskId(condition.getTaskId());
+ }
+
+ if (condition.getProcessInstanceId() != null) {
+ historyTaskQuery.executionId(condition.getProcessInstanceId());
+ }
+
+ if (condition.getAssignee() != null) {
+ historyTaskQuery.assignee(condition.getAssignee());
+ }
+
+ if (condition.getOutcome() != null) {
+ historyTaskQuery.outcome(condition.getOutcome());
+ }
+
+ if (condition.getStartedAfter() != null) {
+ historyTaskQuery.startedAfter(condition.getStartedAfter());
+ }
+
+ if (condition.getStartedBefore() != null) {
+ historyTaskQuery.startedBefore(condition.getStartedBefore());
+ }
+
+ if (condition.getTookLessThen() != null) {
+ historyTaskQuery.tookLessThen(condition.getTookLessThen());
+ }
+
+ if (condition.getTookLongerThen() != null) {
+ historyTaskQuery.tookLongerThen(condition.getTookLongerThen());
+ }
+
+ List<HistoryTask> historyTasks = historyTaskQuery.list();
+ // TODO: ask jbpm team to add select historyTasks by process
+ // instance id
+ if (condition.getDefinitionId() != null) {
+ List<HistoryProcessInstance> historyInstances = getHistoryProcessInstances(condition.getDefinitionId(),
+ null, null, null);
+ List<String> hisInstances = new ArrayList<String>();
+ for (HistoryProcessInstance hisInstance : historyInstances) {
+ hisInstances.add(hisInstance.getProcessInstanceId());
+ }
+ List<HistoryTask> newHistoryTasks = new ArrayList<HistoryTask>();
+ for (HistoryTask task : historyTasks) {
+ if (hisInstances.contains(task.getExecutionId())) {
+ newHistoryTasks.add(task);
+ }
+ }
+ return newHistoryTasks;
+
+ }
+
+ return historyTasks;
+
+ }
+
+ public <T> T execute(Command<T> command) {
+ try {
+
+ Object result = remoteCommandExecutor.execute(command);
+ remoteCommandExecutor.remove();
+ return (T) result;
+
+ } catch (Exception e) {
+ throw new JbpmException("couldn't execute remote command: " + e.getMessage(), e);
+ }
+ }
+
+}
14 years, 7 months
JBoss JBPM SVN: r5625 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-09 10:17:07 -0400 (Wed, 09 Sep 2009)
New Revision: 5625
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
Log:
Test for JBPM-2517
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2009-09-09 13:05:35 UTC (rev 5624)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2009-09-09 14:17:07 UTC (rev 5625)
@@ -21,6 +21,8 @@
*/
package org.jbpm.test.timer;
+import java.util.Calendar;
+
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.job.Job;
import org.jbpm.test.JbpmTestCase;
@@ -57,5 +59,43 @@
managementService.executeJob(job.getId());
assertProcessInstanceEnded(processInstance);
}
+
+ /**
+ * Test case for https://jira.jboss.org/jira/browse/JBPM-2517
+ *
+ * In this issue, it is stated that the calculations for the timer
+ * will overflow if larger than 4 weeks due to integer limitations.
+ */
+ public void testTimerFarInFuture() {
+ deployJpdlXmlString(
+ "<process name='theProcess'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='750 years' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("theProcess");
+
+ Calendar now = Calendar.getInstance();
+ int currentYear = now.get(Calendar.YEAR);
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ Calendar jobDate = Calendar.getInstance();
+ jobDate.setTime(job.getDuedate());
+
+ assertEquals(currentYear + 750, jobDate.get(Calendar.YEAR));
+ }
+
}
\ No newline at end of file
14 years, 7 months
JBoss JBPM SVN: r5624 - jbpm4/trunk.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-09 09:05:35 -0400 (Wed, 09 Sep 2009)
New Revision: 5624
Modified:
jbpm4/trunk/pom.xml
Log:
Upgraded gtw-console to 1.1.2
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2009-09-09 05:24:28 UTC (rev 5623)
+++ jbpm4/trunk/pom.xml 2009-09-09 13:05:35 UTC (rev 5624)
@@ -49,7 +49,7 @@
<cactus.version>1.8.1</cactus.version>
<aspectjrt.version>1.5.3</aspectjrt.version>
<freemarker.version>2.3.15</freemarker.version>
- <gwt.console.version>1.1.2-SNAPSHOT</gwt.console.version>
+ <gwt.console.version>1.1.2</gwt.console.version>
<jbpm.gpd.version>4.1</jbpm.gpd.version>
<hibernate.version>3.3.1.GA</hibernate.version>
<slf4j.version>1.5.2</slf4j.version>
14 years, 7 months