[jbpm-commits] JBoss JBPM SVN: r5005 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/cmd and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jun 8 07:49:49 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-06-08 07:49:49 -0400 (Mon, 08 Jun 2009)
New Revision: 5005
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryActivityInstanceQueryCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryProcessInstanceQueryCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateJobQueryCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessDefinitionQueryCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessInstanceQueryCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateTaskQueryCmd.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.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/HistoryProcessInstanceQueryImpl.java
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/ProcessDefinitionQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/RepositorySession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java
Log:
JBPM-2004 finished cleanup of test data
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ProcessInstanceQuery.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -36,6 +36,7 @@
ProcessInstanceQuery processInstanceId(String processInstanceId);
ProcessInstanceQuery suspended();
+ ProcessInstanceQuery notSuspended();
ProcessInstanceQuery orderAsc(String property);
ProcessInstanceQuery orderDesc(String property);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -35,7 +35,14 @@
void suspendDeployment(long deploymentDbid);
void resumeDeployment(long deploymentDbid);
+
+ /** deletes a deployment if the process definitions don't have
+ * running executions. history information (if any) remains
+ * in the database. */
void deleteDeployment(long deploymentDbid);
+
+ /** deletes deployment, contained process definitions, related process instances
+ * and their history information */
void deleteDeploymentCascade(long deploymentDbid);
InputStream getResourceAsStream(long deploymentDbid, String resourceName);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/TaskQuery.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -52,6 +52,9 @@
* associated as a candidate group to the task. */
TaskQuery candidate(String userId);
+ TaskQuery suspended();
+ TaskQuery notSuspended();
+
TaskQuery page(int firstResult, int maxResults);
TaskQuery orderAsc(String property);
TaskQuery orderDesc(String property);
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryActivityInstanceQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryActivityInstanceQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryActivityInstanceQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateHistoryActivityInstanceQueryCmd implements Command<HistoryActivityInstanceQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public HistoryActivityInstanceQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(DbSession.class).createHistoryActivityInstanceQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryActivityInstanceQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryProcessInstanceQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryProcessInstanceQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryProcessInstanceQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateHistoryProcessInstanceQueryCmd implements Command<HistoryProcessInstanceQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public HistoryProcessInstanceQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(DbSession.class).createHistoryProcessInstanceQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateHistoryProcessInstanceQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateJobQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateJobQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateJobQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateJobQueryCmd implements Command<JobQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public JobQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(DbSession.class).createJobQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateJobQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessDefinitionQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessDefinitionQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessDefinitionQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
+import org.jbpm.pvm.internal.session.RepositorySession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateProcessDefinitionQueryCmd implements Command<ProcessDefinitionQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ProcessDefinitionQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(RepositorySession.class).createProcessDefinitionQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessDefinitionQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessInstanceQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessInstanceQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessInstanceQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateProcessInstanceQueryCmd implements Command<ProcessInstanceQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ProcessInstanceQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(DbSession.class).createProcessInstanceQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateProcessInstanceQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateTaskQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateTaskQueryCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateTaskQueryCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.cmd;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.TaskQueryImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateTaskQueryCmd implements Command<TaskQueryImpl> {
+
+ private static final long serialVersionUID = 1L;
+
+ public TaskQueryImpl execute(Environment environment) throws Exception {
+ return environment.get(DbSession.class).createTaskQuery();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateTaskQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -26,8 +26,11 @@
import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessInstance;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
import org.jbpm.pvm.internal.repository.RepositoryCache;
import org.jbpm.pvm.internal.session.DbSession;
@@ -39,6 +42,8 @@
*/
public class DeleteDeploymentCmd implements Command<Object> {
+ private static final Log log = Log.getLog(DeleteDeploymentCmd.class.getName());
+
private static final long serialVersionUID = 1L;
long deploymentDbid;
@@ -63,20 +68,27 @@
for (ProcessDefinition processDefinition: processDefinitions) {
String processDefinitionId = processDefinition.getId();
- List<String> processInstanceIds = dbSession.findProcessInstanceIds(processDefinitionId);
+ List<ProcessInstance> processInstances = dbSession.createProcessInstanceQuery()
+ .processDefinitionId(processDefinitionId)
+ .list();
+
if (cascade) {
- for (String processInstanceId: processInstanceIds) {
- dbSession.deleteProcessInstance(processInstanceId, false);
+ for (ProcessInstance processInstance: processInstances) {
+ dbSession.deleteProcessInstance(processInstance.getId(), true);
}
+
+ dbSession.deleteProcessDefinitionHistory(processDefinitionId);
+
} else {
- if (!processInstanceIds.isEmpty()) {
- throw new JbpmException("cannot delete deployment "+deploymentDbid+": still executions for "+processDefinition+": "+processInstanceIds);
+ if (!processInstances.isEmpty()) {
+ throw new JbpmException("cannot delete deployment "+deploymentDbid+": still executions for "+processDefinition+": "+processInstances);
}
}
}
Session session = environment.get(Session.class);
DeploymentImpl deployment = (DeploymentImpl) session.load(DeploymentImpl.class, deploymentDbid);
+ log.debug("deleting deployment "+deploymentDbid);
session.delete(deployment);
RepositoryCache repositoryCache = environment.get(RepositoryCache.class);
@@ -84,5 +96,4 @@
return null;
}
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -36,14 +36,19 @@
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.task.Task;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
+import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.svc.DefaultCommandService;
-import org.jbpm.pvm.internal.task.SwimlaneImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.task.TaskQueryImpl;
import org.jbpm.pvm.internal.util.Clock;
/**
@@ -128,7 +133,7 @@
// and if hibernate knows about the history class
&& (isHistoryEnabled())
) {
- List<HistoryProcessInstance> historyProcessInstances = new HistoryProcessInstanceQueryImpl(new DefaultCommandService())
+ List<HistoryProcessInstance> historyProcessInstances = createHistoryProcessInstanceQuery()
.processDefinitionId(processDefinitionId)
.list();
@@ -150,6 +155,26 @@
ProcessDefinition processDefinition = findProcessDefinitionById(processDefinitionId);
session.delete(processDefinition);
}
+
+ public void deleteProcessDefinitionHistory(String processDefinitionId) {
+ List<HistoryProcessInstanceImpl> historyProcessInstances =
+ session.createQuery(
+ "select hpi " +
+ "from "+HistoryProcessInstanceImpl.class.getName()+" hpi "+
+ "where hpi.processDefinitionId = :processDefinitionId "
+ )
+ .setString("processDefinitionId", processDefinitionId)
+ .list();
+
+ for (HistoryProcessInstanceImpl hpi: historyProcessInstances) {
+ session.createQuery(
+ "delete "+HistoryActivityInstanceImpl.class.getName()+" hai " +
+ "where hai.historyProcessInstance = :historyProcessInstance ")
+ .setEntity("historyProcessInstance", hpi)
+ .executeUpdate();
+ session.delete(hpi);
+ }
+ }
public boolean isHistoryEnabled() {
ClassMetadata historyHibernateMetadata = session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class);
@@ -175,6 +200,14 @@
return (ClientExecution) query.uniqueResult();
}
+ public ClientExecution findProcessInstanceByIdIgnoreSuspended(String processInstanceId) {
+ // query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
+ Query query = session.getNamedQuery("findProcessInstanceByIdIgnoreSuspended");
+ query.setString("processInstanceId", processInstanceId);
+ query.setMaxResults(1);
+ return (ClientExecution) query.uniqueResult();
+ }
+
public ClientExecution findExecutionByKey(String processDefinitionName, String executionKey) {
// query definition can be found at the bottom of resource jbpm.pvm.execution.hbm.xml
Query query = session.getNamedQuery("findExecutionByKey");
@@ -184,7 +217,7 @@
return (ClientExecution) query.uniqueResult();
}
- public List<String> findProcessInstanceIds(String processDefinitionId) {
+ public List<String> findProcessInstanceIds(String processDefinitionId) {
// query definition can be found at the bottom of resource jbpm.pvm.job.hbm.xml
Query query = session.createQuery(
"select processInstance.id " +
@@ -222,7 +255,7 @@
}
}
- ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceById(processInstanceId);
+ ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
if (processInstance!=null) {
// delete remaining tasks for this process instance
List<TaskImpl> tasks = findTasks(processInstanceId);
@@ -379,4 +412,24 @@
query.setMaxResults(1);
return (JobImpl<?>) query.uniqueResult();
}
+
+ public ProcessInstanceQueryImpl createProcessInstanceQuery() {
+ return new ProcessInstanceQueryImpl();
+ }
+
+ public TaskQueryImpl createTaskQuery() {
+ return new TaskQueryImpl();
+ }
+
+ public HistoryProcessInstanceQueryImpl createHistoryProcessInstanceQuery() {
+ return new HistoryProcessInstanceQueryImpl();
+ }
+
+ public HistoryActivityInstanceQueryImpl createHistoryActivityInstanceQuery() {
+ return new HistoryActivityInstanceQueryImpl();
+ }
+
+ public JobQueryImpl createJobQuery() {
+ return new JobQueryImpl();
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/AbstractQuery.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -39,20 +39,11 @@
private static final long serialVersionUID = 1L;
- protected Session session;
protected CommandService commandService;
protected String orderByClause = null;
protected Page page = null;
protected boolean isWhereAdded = false;
- public AbstractQuery(CommandService commandService) {
- this.commandService = commandService;
- }
-
- public AbstractQuery(Session session) {
- this.session = session;
- }
-
protected abstract void applyParameters(Query query);
public abstract String hql();
@@ -68,7 +59,8 @@
public List untypedList() {
if (commandService!=null) {
return (List) commandService.execute(this);
- }
+ }
+ Session session = Environment.getFromCurrent(Session.class);
return (List) execute(session);
}
@@ -132,4 +124,8 @@
this.commandService = null;
return this;
}
+
+ public void setCommandService(CommandService commandService) {
+ this.commandService = commandService;
+ }
}
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-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryActivityInstanceQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -26,7 +26,6 @@
import org.hibernate.Query;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.history.HistoryActivityInstance;
import org.jbpm.api.history.HistoryActivityInstanceQuery;
import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
@@ -47,10 +46,6 @@
protected String executionId;
protected String activityName;
- public HistoryActivityInstanceQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
public String hql() {
StringBuilder hql = new StringBuilder();
hql.append("select hai ");
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-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -40,10 +40,6 @@
protected String state;
protected String processInstanceId;
- public HistoryProcessInstanceQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
public String hql() {
StringBuilder hql = new StringBuilder();
hql.append("select hpi ");
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-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -25,7 +25,6 @@
import org.hibernate.Query;
import org.jbpm.api.JobQuery;
-import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.job.Job;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.job.MessageImpl;
@@ -44,10 +43,6 @@
protected String processInstanceId = null;
protected Boolean exception;
- public JobQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
public String hql() {
StringBuilder hql = new StringBuilder();
hql.append("select j ");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -29,7 +29,6 @@
import org.hibernate.Session;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.env.Environment;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
@@ -61,14 +60,6 @@
protected boolean suspended;
protected Long deploymentDbid;
- public ProcessDefinitionQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
- public ProcessDefinitionQueryImpl(Session session) {
- super(session);
- }
-
public Object execute(Session session) {
List<Map<String, Object>> propertyMaps = (List<Map<String, Object>>) super.execute(session);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessInstanceQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -26,7 +26,6 @@
import org.hibernate.Query;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.ProcessInstanceQuery;
-import org.jbpm.api.cmd.CommandService;
import org.jbpm.pvm.internal.model.ExecutionImpl;
/**
@@ -38,12 +37,8 @@
protected String processDefinitionId;
protected String processInstanceId;
- protected boolean suspended;
+ protected Boolean suspended;
- public ProcessInstanceQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
public ProcessInstance uniqueResult() {
return (ProcessInstance)untypedUniqueResult();
}
@@ -61,10 +56,12 @@
appendWhereClause("processInstance.parent is null ", hql);
- if (suspended) {
- appendWhereClause("processInstance.state = '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
- } else {
- appendWhereClause("processInstance.state != '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
+ if (suspended!=null) {
+ if (suspended) {
+ appendWhereClause("processInstance.state = '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
+ } else {
+ appendWhereClause("processInstance.state != '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
+ }
}
if (processInstanceId!=null) {
@@ -112,4 +109,9 @@
this.suspended = true;
return this;
}
+
+ public ProcessInstanceQuery notSuspended() {
+ this.suspended = false;
+ return this;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -28,6 +28,7 @@
import org.jbpm.api.RepositoryService;
import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.model.ActivityCoordinates;
+import org.jbpm.pvm.internal.cmd.CreateProcessDefinitionQueryCmd;
import org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd;
import org.jbpm.pvm.internal.cmd.GetActivityCoordinates;
import org.jbpm.pvm.internal.cmd.GetResourceAsStreamCmd;
@@ -67,7 +68,9 @@
}
public ProcessDefinitionQuery createProcessDefinitionQuery() {
- return new ProcessDefinitionQueryImpl(commandService);
+ ProcessDefinitionQueryImpl query = commandService.execute(new CreateProcessDefinitionQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
public ActivityCoordinates getActivityCoordinates(String processDefinitionId, String activityName) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -149,10 +149,10 @@
// queries //////////////////////////////////////////////////////////////////
- public ProcessDefinitionQuery createProcessDefinitionQuery() {
- return new ProcessDefinitionQueryImpl(session);
+ public ProcessDefinitionQueryImpl createProcessDefinitionQuery() {
+ return new ProcessDefinitionQueryImpl();
}
-
+
public ProcessDefinitionImpl findProcessDefinitionByKey(String processDefinitionKey) {
ProcessDefinition processDefinition = createProcessDefinitionQuery()
.processDefinitionKey(processDefinitionKey)
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -29,6 +29,12 @@
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
+import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.task.TaskQueryImpl;
/**
@@ -59,7 +65,23 @@
// process execution queries ////////////////////////////////////////////////
- /** the execution uniquely identified by the given executionKey. */
+ /** create a process instance query */
+ ProcessInstanceQueryImpl createProcessInstanceQuery();
+
+ /** create a task query */
+ TaskQueryImpl createTaskQuery();
+
+ /** create a history process instance query */
+ HistoryProcessInstanceQueryImpl createHistoryProcessInstanceQuery();
+
+ /** create a history activity instance query */
+ HistoryActivityInstanceQueryImpl createHistoryActivityInstanceQuery();
+
+ /** create a process instance query */
+ JobQueryImpl createJobQuery();
+
+ /** the execution uniquely identified by the given executionKey.
+ * this method doesn't 'see' suspended executions. */
ClientExecution findExecutionById(String executionId);
/** the process instance uniquely identified by the given executionKey. */
@@ -75,6 +97,10 @@
/** delete the process instance including the history. */
void deleteProcessInstance(String processInstanceId);
+ /** deletes the history information for all process instances for
+ * the given process definition */
+ void deleteProcessDefinitionHistory(String processDefinitionId);
+
/** delete the process instance and optionally deletes the history. */
void deleteProcessInstance(String processInstanceId, boolean deleteHistory);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/RepositorySession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/RepositorySession.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/RepositorySession.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -24,8 +24,8 @@
import java.io.InputStream;
import org.jbpm.api.Deployment;
-import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.client.ClientProcessDefinition;
+import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
/**
@@ -39,7 +39,8 @@
InputStream getResourceAsStream(long deploymentDbid, String resourceName);
- ProcessDefinitionQuery createProcessDefinitionQuery();
+ /** create a process definition query */
+ ProcessDefinitionQueryImpl createProcessDefinitionQuery();
ClientProcessDefinition findProcessDefinitionById(String processDefinitionId);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -29,6 +29,7 @@
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.ProcessInstanceQuery;
+import org.jbpm.pvm.internal.cmd.CreateProcessInstanceQueryCmd;
import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
import org.jbpm.pvm.internal.cmd.EndProcessInstance;
import org.jbpm.pvm.internal.cmd.FindExecutionCmd;
@@ -106,7 +107,9 @@
public ProcessInstanceQuery createProcessInstanceQuery() {
- return new ProcessInstanceQueryImpl(commandService);
+ ProcessInstanceQueryImpl query = commandService.execute(new CreateProcessInstanceQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
public void endProcessInstance(String processInstanceId, String state) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/HistoryServiceImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -26,6 +26,8 @@
import org.jbpm.api.HistoryService;
import org.jbpm.api.history.HistoryActivityInstanceQuery;
import org.jbpm.api.history.HistoryProcessInstanceQuery;
+import org.jbpm.pvm.internal.cmd.CreateHistoryActivityInstanceQueryCmd;
+import org.jbpm.pvm.internal.cmd.CreateHistoryProcessInstanceQueryCmd;
import org.jbpm.pvm.internal.query.AvgDurationPerActivityQueryCmd;
import org.jbpm.pvm.internal.query.ChoiceDistributionQueryCmd;
import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
@@ -46,10 +48,14 @@
}
public HistoryProcessInstanceQuery createHistoryProcessInstanceQuery() {
- return new HistoryProcessInstanceQueryImpl(commandService);
+ HistoryProcessInstanceQueryImpl query = commandService.execute(new CreateHistoryProcessInstanceQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
public HistoryActivityInstanceQuery createHistoryActivityInstanceQuery() {
- return new HistoryActivityInstanceQueryImpl(commandService);
+ HistoryActivityInstanceQueryImpl query = commandService.execute(new CreateHistoryActivityInstanceQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ManagementServiceImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -23,6 +23,7 @@
import org.jbpm.api.JobQuery;
import org.jbpm.api.ManagementService;
+import org.jbpm.pvm.internal.cmd.CreateJobQueryCmd;
import org.jbpm.pvm.internal.cmd.ExecuteJobCmd;
import org.jbpm.pvm.internal.query.JobQueryImpl;
@@ -37,6 +38,8 @@
}
public JobQuery createJobQuery() {
- return new JobQueryImpl(commandService);
+ JobQueryImpl query = commandService.execute(new CreateJobQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/TaskServiceImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -104,7 +104,9 @@
}
public TaskQuery createTaskQuery() {
- return new TaskQueryImpl(commandService);
+ TaskQueryImpl query = commandService.execute(new CreateTaskQueryCmd());
+ query.setCommandService(commandService);
+ return query;
}
public List<Task> getSubTasks(long taskDbid) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskQueryImpl.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -27,12 +27,12 @@
import org.hibernate.Query;
import org.jbpm.api.JbpmException;
import org.jbpm.api.TaskQuery;
-import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.env.Environment;
import org.jbpm.api.identity.Group;
import org.jbpm.api.task.Task;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.query.AbstractQuery;
import org.jbpm.pvm.internal.query.Page;
@@ -49,14 +49,11 @@
protected boolean unassigned = false;
protected String assignee = null;
protected String candidate = null;
+ protected Boolean suspended = null;
/* groupIds transports the groupIds from the hql to the applyParameters */
protected List<String> groupIds;
- public TaskQueryImpl(CommandService commandService) {
- super(commandService);
- }
-
public TaskQuery assignee(String assignee) {
if (candidate!=null) {
throw new JbpmException("assignee(...) cannot be combined with candidate(...) in one query");
@@ -77,6 +74,16 @@
return this;
}
+ public TaskQuery suspended() {
+ this.suspended = true;
+ return this;
+ }
+
+ public TaskQuery notSuspended() {
+ this.suspended = false;
+ return this;
+ }
+
public TaskQuery orderAsc(String property) {
orderByClause = "task." + property + " asc ";
return this;
@@ -139,6 +146,14 @@
appendWhereClause("(participant.userId = :candidateUserId) or (participant.groupId in (:candidateGroupIds) ) ", hql);
}
}
+
+ if (suspended!=null) {
+ if (suspended) {
+ appendWhereClause("task.state = '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
+ } else {
+ appendWhereClause("task.state != '"+ExecutionImpl.STATE_SUSPENDED+"' ", hql);
+ }
+ }
appendWhereClause("task.state != '"+Task.STATE_SUSPENDED+"' ", hql);
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-06-08 11:49:49 UTC (rev 5005)
@@ -345,4 +345,13 @@
]]>
</query>
+ <query name="findProcessInstanceByIdIgnoreSuspended">
+ <![CDATA[
+ select processInstance
+ from org.jbpm.pvm.internal.model.ExecutionImpl as processInstance
+ where processInstance.id = :processInstanceId
+ and processInstance.parent is null
+ ]]>
+ </query>
+
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/tx/BasicTransactionTest.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -41,7 +41,6 @@
public void testCommit() {
commandService.execute(new Command<Object>() {
-
public Object execute(Environment environment) {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
@@ -50,11 +49,11 @@
});
commandService.execute(new Command<Object>() {
-
public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals("if i only had the time to write code", comments.get(0).getMessage());
+ session.delete(comments.get(0));
return null;
}
});
@@ -135,7 +134,6 @@
public void testSuccessfulSynchronization() {
commandService.execute(new Command<Object>() {
-
public Object execute(Environment environment) throws Exception {
Session session = environment.get(Session.class);
session.save(new CommentImpl("if i only had the time to write code"));
@@ -147,13 +145,14 @@
});
commandService.execute(new Command<Object>() {
-
public Object execute(Environment environment) {
Session session = environment.get(Session.class);
List<CommentImpl> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
assertEquals("if i only had the time to write code", comments.get(0).getMessage());
+ session.delete(comments.get(0));
List<StringVariable> stringVariables = session.createQuery("from " + StringVariable.class.getName()).list();
assertEquals("hello", stringVariables.get(0).getValue());
+ session.delete(stringVariables.get(0));
return null;
}
});
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-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -174,7 +174,7 @@
environmentFactory.set(TABLE_NAMES_KEY, tableNames);
}
- boolean recordsLeft = false;
+ String recordsLeft = "";
Session session = sessionFactory.openSession();
try {
for (String tableName : tableNames) {
@@ -183,7 +183,7 @@
sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
Long recordCount = (Long) sqlQuery.uniqueResult();
if (recordCount>0L) {
- recordsLeft = true;
+ recordsLeft += tableName+"["+recordCount+"] ";
log.error("FIXME: JBPM-2004 "+recordCount+" records left in table "+tableName);
}
}
@@ -191,8 +191,9 @@
session.close();
}
- if (recordsLeft) {
+ if (recordsLeft.length()>0) {
clean(environmentFactory);
+ throw new RuntimeException(recordsLeft);
}
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/SuspendDeploymentTest.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -107,6 +107,7 @@
processInstances = executionService
.createProcessInstanceQuery()
+ .notSuspended()
.list();
assertEquals(2, countProcessInstancesFor(processInstances, "claim"));
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java 2009-06-05 16:41:42 UTC (rev 5004)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskVariablesTest.java 2009-06-08 11:49:49 UTC (rev 5005)
@@ -40,5 +40,7 @@
assertEquals("hello", taskService.getVariable(taskDbid, "text"));
assertEquals(new Integer(5), taskService.getVariable(taskDbid, "number"));
+
+ taskService.deleteTask(taskDbid);
}
}
More information about the jbpm-commits
mailing list