[jbpm-commits] JBoss JBPM SVN: r5074 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/ant and 6 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jun 22 08:39:58 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-06-22 08:39:57 -0400 (Mon, 22 Jun 2009)
New Revision: 5074

Added:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
Removed:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.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/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/repository/DeploymentImpl.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
Log:
JBPM-2342 added deployment querying

Deleted: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java	2009-06-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -1,51 +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.api;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.zip.ZipInputStream;
-
-/** 
- * @author Tom Baeyens
- */
-public interface Deployment {
-  
-  long getDbid();
-  
-  String getName();
-  Deployment setName(String name);
-
-  long getTimestamp();
-  Deployment setTimestamp(long timestamp);
-  
-  Deployment addResourceFromString(String resourceName, String string);
-  Deployment addResourceFromInputStream(String resourceName, InputStream inputStream);
-  Deployment addResourceFromClasspath(String resourceName);
-  Deployment addResourceFromUrl(URL url);
-  Deployment addResourcesFromZipInputStream(ZipInputStream zipInputStream);
-  Deployment addResourceFromFile(File file);
-  
-  /** @return deploymentId */
-  long deploy();
-}

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,39 @@
+/*
+ * 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.api;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface Deployment {
+
+  String STATE_ACTIVE = "active";
+  String STATE_SUSPENDED = "suspended";
+
+  long getDbid();
+
+  String getName();
+  
+  long getTimestamp();
+  
+  String getState();
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,46 @@
+/*
+ * 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.api;
+
+import java.util.List;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface DeploymentQuery {
+  
+  String PROPERTY_NAME = "name";
+  String PROPERTY_TIMESTAMP = "timestamp";
+  String PROPERTY_STATE = "state";
+
+  DeploymentQuery deploymentDbid(long dbid);
+  DeploymentQuery suspended();
+  DeploymentQuery active();
+
+  DeploymentQuery orderAsc(String property);
+  DeploymentQuery orderDesc(String property);
+
+  DeploymentQuery page(int firstResult, int maxResults);
+  
+  List<Deployment> list();
+  Deployment uniqueResult();
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/DeploymentQuery.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java (from rev 5069, jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Deployment.java)
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.api;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.zip.ZipInputStream;
+
+/** 
+ * @author Tom Baeyens
+ */
+public interface NewDeployment extends Deployment {
+  
+  NewDeployment setName(String name);
+  NewDeployment setTimestamp(long timestamp);
+  NewDeployment addResourceFromString(String resourceName, String string);
+  NewDeployment addResourceFromInputStream(String resourceName, InputStream inputStream);
+  NewDeployment addResourceFromClasspath(String resourceName);
+  NewDeployment addResourceFromUrl(URL url);
+  NewDeployment addResourcesFromZipInputStream(ZipInputStream zipInputStream);
+  NewDeployment addResourceFromFile(File file);
+  
+  /** @return deploymentId */
+  long deploy();
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/RepositoryService.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -31,7 +31,7 @@
  */
 public interface RepositoryService {
 
-  Deployment createDeployment();
+  NewDeployment createDeployment();
 
   void suspendDeployment(long deploymentDbid);
   void resumeDeployment(long deploymentDbid);
@@ -48,6 +48,7 @@
   InputStream getResourceAsStream(long deploymentDbid, String resourceName);
 
   ProcessDefinitionQuery createProcessDefinitionQuery();
+  DeploymentQuery createDeploymentQuery();
   
   ActivityCoordinates getActivityCoordinates(String processDefinitionId, String activityName);
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java	2009-06-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -33,7 +33,7 @@
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.taskdefs.MatchingTask;
 import org.apache.tools.ant.types.FileSet;
-import org.jbpm.api.Deployment;
+import org.jbpm.api.NewDeployment;
 import org.jbpm.api.ProcessEngine;
 import org.jbpm.api.RepositoryService;
 
@@ -85,7 +85,7 @@
 
   protected void deployFile(ProcessEngine processEngine, File processFile) {
     RepositoryService repositoryService = processEngine.getRepositoryService();
-    Deployment deployment = repositoryService.createDeployment();
+    NewDeployment deployment = repositoryService.createDeployment();
     deployment.setName(processFile.getName());
     deployment.setTimestamp(System.currentTimeMillis());
     

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,42 @@
+/*
+ * 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.DeploymentQueryImpl;
+import org.jbpm.pvm.internal.query.JobQueryImpl;
+import org.jbpm.pvm.internal.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateDeploymentQueryCmd implements Command<DeploymentQueryImpl> {
+
+  private static final long serialVersionUID = 1L;
+
+  public DeploymentQueryImpl execute(Environment environment) throws Exception {
+    return environment.get(DbSession.class).createDeploymentQuery();
+  }
+
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/CreateDeploymentQueryCmd.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -41,13 +41,12 @@
 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.DeploymentQueryImpl;
 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.TaskImpl;
 import org.jbpm.pvm.internal.task.TaskQueryImpl;
 import org.jbpm.pvm.internal.util.Clock;
@@ -436,4 +435,8 @@
   public JobQueryImpl createJobQuery() {
     return new JobQueryImpl();
   }
+
+  public DeploymentQueryImpl createDeploymentQuery() {
+    return new DeploymentQueryImpl();
+  }
 }

Added: 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	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,98 @@
+/*
+ * 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.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.api.Deployment;
+import org.jbpm.api.DeploymentQuery;
+import org.jbpm.pvm.internal.repository.DeploymentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeploymentQueryImpl extends AbstractQuery implements DeploymentQuery {
+  
+  protected Long deploymentDbid = null;
+  protected String state = null;
+
+  public String hql() {
+    StringBuilder hql = new StringBuilder();
+    hql.append("select d ");
+    hql.append("from ");
+    hql.append(DeploymentImpl.class.getName());
+    hql.append(" as d ");
+    
+    if (deploymentDbid!=null) {
+      appendWhereClause("d.dbid = "+deploymentDbid+" ", hql);
+    }
+
+    if (state!=null) {
+      appendWhereClause(" d.state = '"+state+"' ", hql);
+    }
+    
+    return hql.toString();
+  }
+
+  protected void applyParameters(Query query) {
+  }
+
+  public DeploymentQuery deploymentDbid(long deploymentDbid) {
+    this.deploymentDbid = deploymentDbid;
+    return this;
+  }
+
+  public DeploymentQuery active() {
+    this.state = Deployment.STATE_ACTIVE;
+    return this;
+  }
+
+  public DeploymentQuery suspended() {
+    this.state = Deployment.STATE_SUSPENDED;
+    return this;
+  }
+
+  public DeploymentQuery orderAsc(String property) {
+    addOrderByClause("d."+property+" asc");
+    return this;
+  }
+
+  public DeploymentQuery orderDesc(String property) {
+    addOrderByClause("d."+property+" desc");
+    return this;
+  }
+
+  public DeploymentQuery page(int firstResult, int maxResults) {
+    this.page = new Page(firstResult, maxResults);
+    return this;
+  }
+
+  public List<Deployment> list() {
+    return untypedList();
+  }
+
+  public Deployment uniqueResult() {
+    return (Deployment) untypedUniqueResult();
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/DeploymentQueryImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/JobQueryImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -103,7 +103,7 @@
   }
 
   public JobQuery orderDesc(String property) {
-    addOrderByClause("j."+property+" asc");
+    addOrderByClause("j."+property+" desc");
     return this;
   }
 

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/ProcessDefinitionQueryImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -27,6 +27,7 @@
 
 import org.hibernate.Query;
 import org.hibernate.Session;
+import org.jbpm.api.Deployment;
 import org.jbpm.api.ProcessDefinition;
 import org.jbpm.api.ProcessDefinitionQuery;
 import org.jbpm.api.env.Environment;
@@ -90,9 +91,9 @@
     hql.append(" as versionProperty ");
 
     if (suspended) {
-      appendWhereClause("deployment.state = '"+DeploymentImpl.STATE_SUSPENDED+"'", hql);
+      appendWhereClause("deployment.state = '"+Deployment.STATE_SUSPENDED+"'", hql);
     } else {
-      appendWhereClause("deployment.state != '"+DeploymentImpl.STATE_SUSPENDED+"'", hql);
+      appendWhereClause("deployment.state != '"+Deployment.STATE_SUSPENDED+"'", hql);
     }
 
     appendWhereClause("idProperty.key = '"+DeploymentImpl.KEY_PROCESS_DEFINITION_ID+"'", hql);

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java	2009-06-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -36,6 +36,7 @@
 import java.util.zip.ZipInputStream;
 
 import org.jbpm.api.Deployment;
+import org.jbpm.api.NewDeployment;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.cmd.CommandService;
 import org.jbpm.api.env.Environment;
@@ -55,13 +56,10 @@
 /**
  * @author Tom Baeyens
  */
-public class DeploymentImpl extends ProblemList implements Deployment, Serializable {
+public class DeploymentImpl extends ProblemList implements NewDeployment, Serializable {
   
   private static final long serialVersionUID = 1L;
 
-  public static final String STATE_ACTIVE = "active";
-  public static final String STATE_SUSPENDED = "suspended";
-  
   public static final String KEY_PROCESS_DEFINITION_ID = "pdid";
   public static final String KEY_PROCESS_DEFINITION_KEY = "pdkey";
   public static final String KEY_PROCESS_DEFINITION_VERSION = "pdversion";
@@ -69,7 +67,7 @@
   protected long dbid;
   protected String name;
   protected long timestamp;
-  protected String state = STATE_ACTIVE;
+  protected String state = Deployment.STATE_ACTIVE;
   protected Map<String, Lob> resources;
 
   protected CommandService commandService;
@@ -91,17 +89,17 @@
     return commandService.execute(new DeployCmd(this));
   }
   
-  public Deployment addResourceFromClasspath(String resourceName) {
+  public NewDeployment addResourceFromClasspath(String resourceName) {
     addResourceFromStreamInput(resourceName, new ResourceStreamInput(resourceName));
     return this;
   }
 
-  public Deployment addResourceFromString(String resourceName, String text) {
+  public NewDeployment addResourceFromString(String resourceName, String text) {
     addResourceFromStreamInput(resourceName, new StringStreamInput(text));
     return this;
   }
   
-  public Deployment addResourcesFromZipInputStream(ZipInputStream zipInputStream) {
+  public NewDeployment addResourcesFromZipInputStream(ZipInputStream zipInputStream) {
     try {
       ZipEntry zipEntry = zipInputStream.getNextEntry();
       while(zipEntry!=null) {
@@ -118,22 +116,22 @@
     return this;
   }
 
-  public Deployment addResourceFromInputStream(String resourceName, InputStream inputStream) {
+  public NewDeployment addResourceFromInputStream(String resourceName, InputStream inputStream) {
     addResourceFromStreamInput(resourceName, new InputStreamInput(inputStream));
     return this;
   }
 
-  public Deployment addResourceFromUrl(URL url) {
+  public NewDeployment addResourceFromUrl(URL url) {
     addResourceFromStreamInput(url.toString(), new UrlStreamInput(url));
     return this;
   }
 
-  public Deployment addResourceFromFile(File file) {
+  public NewDeployment addResourceFromFile(File file) {
     addResourceFromStreamInput(file.getPath(), new FileStreamInput(file));
     return this;
   }
 
-  public Deployment addResourceFromStreamInput(String name, StreamInput streamInput) {
+  public NewDeployment addResourceFromStreamInput(String name, StreamInput streamInput) {
     if (resources==null) {
       resources = new HashMap<String, Lob>();
     }
@@ -254,7 +252,7 @@
     if (repositorySession!=null) {
       repositorySession.cascadeDeploymentSuspend(this);
     }
-    state = STATE_SUSPENDED;
+    state = Deployment.STATE_SUSPENDED;
   }
 
   public void resume() {
@@ -265,11 +263,11 @@
     if (repositorySession!=null) {
       repositorySession.cascadeDeploymentResume(this);
     }
-    state = STATE_ACTIVE; 
+    state = Deployment.STATE_ACTIVE; 
   }
   
   public boolean isSuspended() {
-    return STATE_SUSPENDED.equals(state); 
+    return Deployment.STATE_SUSPENDED.equals(state); 
   }
 
   protected Object writeReplace() throws ObjectStreamException {
@@ -300,4 +298,7 @@
     this.timestamp = timestamp;
     return this;
   }
+  public String getState() {
+    return state;
+  }
 }

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryServiceImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -24,17 +24,20 @@
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
-import org.jbpm.api.Deployment;
+import org.jbpm.api.DeploymentQuery;
+import org.jbpm.api.NewDeployment;
 import org.jbpm.api.ProcessDefinitionQuery;
 import org.jbpm.api.RepositoryService;
 import org.jbpm.api.cmd.CommandService;
 import org.jbpm.api.model.ActivityCoordinates;
+import org.jbpm.pvm.internal.cmd.CreateDeploymentQueryCmd;
 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;
 import org.jbpm.pvm.internal.cmd.ResumeDeploymentCmd;
 import org.jbpm.pvm.internal.cmd.SuspendDeploymentCmd;
+import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
 import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
 
 /**
@@ -44,7 +47,7 @@
   
   CommandService commandService;
   
-  public Deployment createDeployment() {
+  public NewDeployment createDeployment() {
     return new DeploymentImpl(commandService);
   }
   
@@ -78,6 +81,12 @@
     return query;
   }
 
+  public DeploymentQuery createDeploymentQuery() {
+    DeploymentQueryImpl query = commandService.execute(new CreateDeploymentQueryCmd());
+    query.setCommandService(commandService);
+    return query;
+  }
+
   public ActivityCoordinates getActivityCoordinates(String processDefinitionId, String activityName) {
     return commandService.execute(new GetActivityCoordinates(processDefinitionId, 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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -28,7 +28,7 @@
 
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.jbpm.api.Deployment;
+import org.jbpm.api.NewDeployment;
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.Problem;
 import org.jbpm.api.ProcessDefinition;
@@ -50,7 +50,7 @@
   protected RepositoryCache repositoryCache;
   protected DeployerManager deployerManager;
 
-  public long deploy(Deployment deployment) {
+  public long deploy(NewDeployment deployment) {
     DeploymentImpl deploymentImpl = (DeploymentImpl) deployment;
     session.save(deploymentImpl);
     

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -29,6 +29,7 @@
 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.DeploymentQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl;
 import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
 import org.jbpm.pvm.internal.query.JobQueryImpl;
@@ -79,6 +80,9 @@
   
   /** create a process instance query */
   JobQueryImpl createJobQuery();
+  
+  /** create a deployment query */
+  DeploymentQueryImpl createDeploymentQuery();
 
   /** the execution uniquely identified by the given executionKey. 
    * this method doesn't 'see' suspended executions. */ 

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-22 11:36:16 UTC (rev 5073)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/RepositorySession.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -21,7 +21,7 @@
  */
 package org.jbpm.pvm.internal.session;
 
-import org.jbpm.api.Deployment;
+import org.jbpm.api.NewDeployment;
 import org.jbpm.api.client.ClientProcessDefinition;
 import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
 
@@ -31,7 +31,7 @@
  */
 public interface RepositorySession {
 
-  long deploy(Deployment deployment);
+  long deploy(NewDeployment deployment);
 
   Object getObject(long deploymentDbid, String objectName);
 

Added: 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	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java	2009-06-22 12:39:57 UTC (rev 5074)
@@ -0,0 +1,132 @@
+/*
+ * 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() {
+    long deploymentClaimDbid = repositoryService
+        .createDeployment()
+        .setName("Claim")
+        .addResourceFromString("process.jpdl.xml", 
+          "<process name='claim'>" +
+          "  <start>" +
+          "    <transition to='c' />" +
+          "  </start>" +
+          "  <state name='c' />" +
+          "</process>"
+        )
+        .deploy();
+
+    long deploymentHireDbid = repositoryService
+      .createDeployment()
+      .setName("Hire")
+      .addResourceFromString("process.jpdl.xml", 
+        "<process name='hire'>" +
+        "  <start>" +
+        "    <transition to='h' />" +
+        "  </start>" +
+        "  <state name='h' />" +
+        "</process>"
+      )
+      .deploy();
+
+    long deploymentFireDbid = repositoryService
+      .createDeployment()
+      .setName("Fire")
+      .addResourceFromString("process.jpdl.xml", 
+        "<process name='fire'>" +
+        "  <start>" +
+        "    <transition to='f' />" +
+        "  </start>" +
+        "  <state name='f' />" +
+        "</process>"
+      )
+      .deploy();
+
+    repositoryService.suspendDeployment(deploymentHireDbid);
+
+    
+    // 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()
+      .active()
+      .list();
+  
+    expectedDeploymentNames = new HashSet<String>();
+    expectedDeploymentNames.add("Claim");
+    expectedDeploymentNames.add("Fire");
+  
+    assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
+    
+    repositoryService.deleteDeploymentCascade(deploymentClaimDbid);
+    repositoryService.deleteDeploymentCascade(deploymentHireDbid);
+    repositoryService.deleteDeploymentCascade(deploymentFireDbid);
+  }
+
+  Set<String> getDeploymentNames(List<Deployment> deployments) {
+    Set<String> deploymentNames = new HashSet<String>();
+    for (Deployment deployment: deployments) {
+      deploymentNames.add(deployment.getName());
+    }
+    return deploymentNames;
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the jbpm-commits mailing list