[jbpm-commits] JBoss JBPM SVN: r2570 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/command.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Oct 21 11:56:41 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-10-21 11:56:41 -0400 (Tue, 21 Oct 2008)
New Revision: 2570

Added:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessdefinitionCommand.java
Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
Log:
Retrieve instance by ID. Added DeleteProcessDefinition command

Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessdefinitionCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessdefinitionCommand.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessdefinitionCommand.java	2008-10-21 15:56:41 UTC (rev 2570)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.command;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * Delete a proces definition by ID 
+ * 
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class DeleteProcessdefinitionCommand extends AbstractGetObjectBaseCommand {
+
+   private static final long serialVersionUID = -1908847549444051495L;
+
+   private long id;
+   
+   public DeleteProcessdefinitionCommand(long id) {
+      super();
+      this.id = id;
+   }
+
+   public Object execute(JbpmContext jbpmContext) throws Exception
+   {
+      jbpmContext.getGraphSession().deleteProcessDefinition(id);      
+      return Boolean.TRUE;
+   }
+
+}


Property changes on: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessdefinitionCommand.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java	2008-10-21 15:16:57 UTC (rev 2569)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java	2008-10-21 15:56:41 UTC (rev 2570)
@@ -10,154 +10,194 @@
 
 /**
  * This command can retrieve all process instances (e.g. for admin client).
- * 
+ *
  * You have the possibility to filter the command, therefor use the available
  * attributes
- * 
+ *
  * @author Bernd Ruecker (bernd.ruecker at camunda.com)
  */
 public class GetProcessInstancesCommand extends AbstractGetObjectBaseCommand {
 
-    private static final long serialVersionUID = -5601050489405283851L;
+   private static final long serialVersionUID = -5601050489405283851L;
 
-    /*
-     * is true, only the running process instances are retrieved (ended and
-     * canceled ones are skipped)
-     */
-    private boolean onlyRunning = true;
+   /*
+   * is true, only the running process instances are retrieved (ended and
+   * canceled ones are skipped)
+   */
+   private boolean onlyRunning = true;
 
-    /*
-     * if given, only processes with start date >= given date are shown
-     */
-    private Date fromStartDate;
+   /*
+   * if given, only processes with start date >= given date are shown
+   */
+   private Date fromStartDate;
 
-    /*
-     * if given, only processes with start date <= given date are shown
-     */
-    private Date untilStartDate;
+   /*
+   * if given, only processes with start date <= given date are shown
+   */
+   private Date untilStartDate;
 
-    /*
-     * if given, only processes with this name are retrieved
-     */
-    private String processName;
+   /*
+   * if given, only processes with this name are retrieved
+   */
+   private String processName;
 
-    /*
-     * if given, only processes with this name are retrieved
-     */
-    private String stateName;
+   private long processId = -1;
+   /*
+   * if given, only processes with this name are retrieved
+   */
+   private String stateName;
 
-    private transient boolean firstExpression = true;
+   private String version = null;
 
-    private String getConcatExpression() {
-        if (firstExpression) {
-            firstExpression = false;
-            return " where ";
-        }
-        return " and ";
-    }
+   private transient boolean firstExpression = true;
 
-    public Object execute(JbpmContext jbpmContext) throws Exception {
-        setJbpmContext(jbpmContext);
-        firstExpression = true;
-        StringBuffer queryText = new StringBuffer("select pi" + " from org.jbpm.graph.exe.ProcessInstance as pi ");
+   private String getConcatExpression() {
+      if (firstExpression) {
+         firstExpression = false;
+         return " where ";
+      }
+      return " and ";
+   }
 
-        if (onlyRunning) {
-            queryText.append(getConcatExpression()).append(" pi.end = null");
-        }
+   public Object execute(JbpmContext jbpmContext) throws Exception {
+      setJbpmContext(jbpmContext);
+      firstExpression = true;
+      StringBuffer queryText = new StringBuffer("select pi" + " from org.jbpm.graph.exe.ProcessInstance as pi ");
 
-        if (fromStartDate != null) {
-            queryText.append(getConcatExpression()).append(" pi.start >= :from ");
-        }
-        if (untilStartDate != null) {
-            queryText.append(getConcatExpression()).append(" pi.start <= :until ");
-        }
+      if (onlyRunning) {
+         queryText.append(getConcatExpression()).append(" pi.end = null");
+      }
 
-        // name
-        if (processName != null && processName.length() > 0) {
-            queryText.append(getConcatExpression()).append(" pi.processDefinition.name = :processDefinitionName  ");
-        }
+      if (fromStartDate != null) {
+         queryText.append(getConcatExpression()).append(" pi.start >= :from ");
+      }
+      if (untilStartDate != null) {
+         queryText.append(getConcatExpression()).append(" pi.start <= :until ");
+      }
+      if (version != null) {
+         queryText.append(getConcatExpression()).append(" pi.version = :version ");
+      }
 
-        // TODO: this code only fecthes root tokens, child-tokens has to be
-        // considered too!
-        if (stateName != null && stateName.length() > 0) {
-            queryText.append(getConcatExpression()).append(" pi.rootToken.node.name = :nodeName ");
-        }
+      // name
+      if(processId!=-1)
+      {
+         queryText.append(getConcatExpression()).append(" pi.processDefinition.id = :processId  ");
+      }
+      else if (processName != null && processName.length() > 0) {
+         queryText.append(getConcatExpression()).append(" pi.processDefinition.name = :processDefinitionName  ");
+      }
 
-        queryText.append(" order by pi.start desc");
+      // TODO: this code only fecthes root tokens, child-tokens has to be
+      // considered too!
+      if (stateName != null && stateName.length() > 0) {
+         queryText.append(getConcatExpression()).append(" pi.rootToken.node.name = :nodeName ");
+      }
 
-        Query query = jbpmContext.getSession().createQuery(queryText.toString());
+      queryText.append(" order by pi.start desc");
 
-        if (fromStartDate != null) {
-            query.setTimestamp("from", fromStartDate);
-        }
-        if (untilStartDate != null) {
-            query.setTimestamp("until", untilStartDate);
-        }
+      Query query = jbpmContext.getSession().createQuery(queryText.toString());
 
-        if (processName != null && processName.length() > 0) {
-            query.setString("processDefinitionName", processName);
-        }
+      if (fromStartDate != null) {
+         query.setTimestamp("from", fromStartDate);
+      }
+      if (untilStartDate != null) {
+         query.setTimestamp("until", untilStartDate);
+      }
 
-        if (stateName != null && stateName.length() > 0) {
-            query.setString("nodeName", stateName);
-        }
+      if(processId!=-1)
+      {
+         query.setLong("processId", processId);  
+      }
+      if (processName != null && processName.length() > 0) {
+         query.setString("processDefinitionName", processName);
+      }
 
-        return retrieveProcessInstanceDetails(query.list());
-    }
+      if (stateName != null && stateName.length() > 0) {
+         query.setString("nodeName", stateName);
+      }
 
-    /**
-     * access everything on all processInstance objects, which is not in the
-     * default fetch group from hibernate, but needs to be accesible from the
-     * client
-     * 
-     * overwrite this, if you need more details in your client
-     */
-    public List retrieveProcessInstanceDetails(List processInstanceList) {
-        Iterator it = processInstanceList.iterator();
-        while (it.hasNext()) {
-            retrieveProcessInstance((ProcessInstance) it.next());
-        }
-        return processInstanceList;
-    }
+      if(version!=null)
+      {
+         query.setString("version", version);
+      }
 
-    public Date getFromStartDate() {
-        return fromStartDate;
-    }
+      return retrieveProcessInstanceDetails(query.list());
+   }
 
-    public void setFromStartDate(Date fromStartDate) {
-        this.fromStartDate = fromStartDate;
-    }
+   /**
+    * access everything on all processInstance objects, which is not in the
+    * default fetch group from hibernate, but needs to be accesible from the
+    * client
+    *
+    * overwrite this, if you need more details in your client
+    */
+   public List retrieveProcessInstanceDetails(List processInstanceList) {
+      Iterator it = processInstanceList.iterator();
+      while (it.hasNext()) {
+         retrieveProcessInstance((ProcessInstance) it.next());
+      }
+      return processInstanceList;
+   }
 
-    public boolean isOnlyRunning() {
-        return onlyRunning;
-    }
+   public Date getFromStartDate() {
+      return fromStartDate;
+   }
 
-    public void setOnlyRunning(boolean onlyRunning) {
-        this.onlyRunning = onlyRunning;
-    }
+   public void setFromStartDate(Date fromStartDate) {
+      this.fromStartDate = fromStartDate;
+   }
 
-    public String getProcessName() {
-        return processName;
-    }
+   public boolean isOnlyRunning() {
+      return onlyRunning;
+   }
 
-    public void setProcessName(String processName) {
-        this.processName = processName;
-    }
+   public void setOnlyRunning(boolean onlyRunning) {
+      this.onlyRunning = onlyRunning;
+   }
 
-    public String getStateName() {
-        return stateName;
-    }
+   public String getProcessName() {
+      return processName;
+   }
 
-    public void setStateName(String stateName) {
-        this.stateName = stateName;
-    }
+   public void setProcessName(String processName) {
+      this.processName = processName;
+   }
 
-    public Date getUntilStartDate() {
-        return untilStartDate;
-    }
+   public String getStateName() {
+      return stateName;
+   }
 
-    public void setUntilStartDate(Date untilStartDate) {
-        this.untilStartDate = untilStartDate;
-    }
+   public void setStateName(String stateName) {
+      this.stateName = stateName;
+   }
 
+   public Date getUntilStartDate() {
+      return untilStartDate;
+   }
+
+   public void setUntilStartDate(Date untilStartDate) {
+      this.untilStartDate = untilStartDate;
+   }
+
+
+   public String getVersion()
+   {
+      return version;
+   }
+
+   public void setVersion(String version)
+   {
+      this.version = version;
+   }
+
+
+   public long getProcessId()
+   {
+      return processId;
+   }
+
+   public void setProcessId(long processId)
+   {
+      this.processId = processId;
+   }
 }




More information about the jbpm-commits mailing list