JBoss JBPM SVN: r2560 - in jbpm3/trunk/modules/gwt-console: server and 6 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-20 10:35:06 -0400 (Mon, 20 Oct 2008)
New Revision: 2560
Modified:
jbpm3/trunk/modules/gwt-console/pom.xml
jbpm3/trunk/modules/gwt-console/server/pom.xml
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
Log:
Implement process upload
Modified: jbpm3/trunk/modules/gwt-console/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/pom.xml 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/pom.xml 2008-10-20 14:35:06 UTC (rev 2560)
@@ -21,6 +21,8 @@
<jaf.version>1.1</jaf.version>
<resteasy.version>1.0-beta-8</resteasy.version>
<gson.version>1.2.2</gson.version>
+ <commons.fileupload.version>1.2.1</commons.fileupload.version>
+ <commons.io.version>1.3.2</commons.io.version>
</properties>
<modules>
@@ -59,8 +61,18 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
- <version>${gson.version}</version>
+ <version>${gson.version}</version>
</dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>${commons.fileupload.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons.io.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
</project>
Modified: jbpm3/trunk/modules/gwt-console/server/pom.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/pom.xml 2008-10-20 14:35:06 UTC (rev 2560)
@@ -58,8 +58,17 @@
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
+ <artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>${commons.io.version}</version>
+ </dependency>
</dependencies>
<build>
@@ -84,5 +93,5 @@
</plugin>
</plugins>
<finalName>gwt-console-server</finalName>
- </build>
+ </build>
</project>
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/JBPM3Management.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -21,6 +21,10 @@
*/
package org.jboss.bpm.console.server;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.jboss.bpm.console.client.model.jbpm3.ActiveNodeInfo;
import org.jboss.bpm.console.client.model.jbpm3.DiagramInfo;
import org.jboss.bpm.console.server.dao.DAOFactory;
@@ -28,12 +32,11 @@
import org.jboss.bpm.console.server.dao.ProcessDAO;
import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
+import java.util.Iterator;
+import java.util.List;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -68,6 +71,58 @@
}
+ @POST
+ @Path("definitions/new")
+ @Produces("application/json")
+ public void postNewDefinition(
+ @Context
+ HttpServletRequest request
+ )
+ {
+ try
+ {
+ FileItemFactory factory = new DiskFileItemFactory();
+ ServletFileUpload upload = new ServletFileUpload(factory);
+ List items = upload.parseRequest(request);
+
+ Iterator iter = items.iterator();
+ while (iter.hasNext())
+ {
+ FileItem item = (FileItem) iter.next();
+
+ if (item.isFormField())
+ {
+ // ignore
+ System.out.println("Caught form field on file upload: " + item.getName());
+ }
+ else
+ {
+ String fieldName = item.getFieldName();
+ String fileName = item.getName();
+ String contentType = item.getContentType();
+ boolean isInMemory = item.isInMemory();
+ long sizeInBytes = item.getSize();
+
+ // Process a file upload in memory
+ byte[] data = item.get();
+
+ getProcessDAO(request).deployNewDefinition(data);
+
+ // Process stream
+ //InputStream uploadedStream = item.getInputStream();
+ //uploadedStream.close();
+
+ }
+
+
+ }
+ } catch (Exception e)
+ {
+ throw new WebApplicationException(e);
+ }
+
+ }
+
@GET
@Path("definitions/{id}/image")
@Produces("image/jpeg")
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -46,4 +46,6 @@
void changeState(long instanceId, String nextState);
ProcessInstance newInstance(long processId);
+
+ ProcessDefinition deployNewDefinition(byte[] data);
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -78,7 +78,7 @@
public List<ProcessDefinition> getActualDefinitions()
{
List<org.jbpm.graph.def.ProcessDefinition> defs = (List<org.jbpm.graph.def.ProcessDefinition>)
- facade.execute( new GetProcessDefinitionsCommand() );
+ facade.execute( new GetProcessDefinitionsCommand(false) );
return defs;
}
@@ -129,4 +129,13 @@
return instance;
}
+
+ public ProcessDefinition deploy(byte[] data)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = (org.jbpm.graph.def.ProcessDefinition)
+ facade.execute(
+ new DeployProcessCommand(data)
+ );
+ return p0;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -91,9 +91,16 @@
public void changeState(long instanceId, String nextState)
{
org.jbpm.graph.exe.ProcessInstance p0 = delegate.getActualInstance(instanceId);
- Transform.doTransition(p0, nextState);
+ Transform.doTransition(p0, nextState); // modifies the actual PI
- // persist
+ // TX commit will persist changes to the actual PI
+
}
+
+ public ProcessDefinition deployNewDefinition(byte[] data)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = delegate.deploy(data);
+ return Transform.processDefinition(p0);
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -142,4 +142,10 @@
{
throw new RuntimeException("Not implemented");
}
+
+
+ public ProcessDefinition deployNewDefinition(byte[] data)
+ {
+ throw new RuntimeException("Not implemented");
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -104,4 +104,9 @@
{
return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances/new";
}
+
+ public String getUploadDefinitionURL()
+ {
+ return getBaseUrl() + "/rs/jbpm3/definitions/new";
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -43,7 +43,7 @@
public ProcessDefinitionList(String titleName, final ConsoleView view)
{
- super(titleName, view, getResourceUrl(view));
+ super(titleName, view, getResourceUrl(view), false);
}
private static String getResourceUrl(ConsoleView view)
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionListEditor.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -21,21 +21,29 @@
*/
package org.jboss.bpm.console.client.process;
+import com.google.gwt.user.client.ui.HTML;
+import com.gwtext.client.core.Connection;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Toolbar;
+import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.Form;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.event.FormListenerAdapter;
import com.gwtext.client.widgets.layout.ColumnLayout;
import com.gwtext.client.widgets.layout.ColumnLayoutData;
import com.gwtext.client.widgets.layout.VerticalLayout;
-import com.gwtext.client.widgets.*;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.core.EventObject;
-import com.google.gwt.user.client.ui.HTML;
import org.jboss.bpm.console.client.ConsoleView;
import org.jboss.bpm.console.client.metric.MetricOverviewEditor;
import org.jboss.bpm.console.client.model.DAOFactory;
import org.jboss.bpm.console.client.model.HelpDAO;
import org.jboss.bpm.console.client.widgets.*;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -62,10 +70,71 @@
// ----------------------------------
+ final Panel leftHand = new Panel();
+ leftHand.setFrame(false);
+ leftHand.setHeader(false);
+ leftHand.setBorder(false);
+
processDefinitions = new ProcessDefinitionList("Process Definitions", view);
// ----------------------------------
+ Panel outerFormPanel = new Panel();
+ outerFormPanel.setBorder(false);
+ outerFormPanel.setPaddings(10);
+
+
+ final FormPanel formPanel = new FormPanel();
+ formPanel.setFrame(true);
+ formPanel.setTitle("Upload new process definition");
+ formPanel.setLabelWidth(75);
+ formPanel.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
+
+ formPanel.setFileUpload(true);
+ final TextField file = new TextField("File", "file");
+ file.setInputType("file");
+
+ formPanel.add(file);
+
+ Button uploadButton = new Button("Upload", new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject e)
+ {
+ formPanel.getForm().submit(
+ view.getRestURL().getUploadDefinitionURL(), null,
+ Connection.POST, "Uploading definition ...", false);
+ }
+ });
+ formPanel.addButton(uploadButton);
+ formPanel.getForm().addListener(
+ new FormListenerAdapter()
+ {
+
+ public boolean doBeforeAction(Form form)
+ {
+ // TODO: validation
+ return true;
+ }
+
+ public void onActionComplete(Form form, int i, String string)
+ {
+ processDefinitions.reloadStore();
+ leftHand.doLayout();
+ form.reset();
+ }
+
+ public void onActionFailed(Form form, int i, String string)
+ {
+ super.onActionFailed(form, i, string);
+ view.setError("Failed to upload process definition: " + string );
+ }
+ }
+ );
+
+ outerFormPanel.add(formPanel);
+
+ // ----------------------------------
+
// TODO: introduce abstractions and integrate with DAO
Map chartValues = new HashMap();
chartValues.put("1", new Double(0.65));
@@ -99,7 +168,7 @@
Toolbar bottomToolbar = new Toolbar();
bottomToolbar.addFill();
- bottomToolbar.addButton(
+ bottomToolbar.addButton(
new ToolbarButton("More metrics", new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e)
{
@@ -122,15 +191,18 @@
HelpPanel help = new HelpPanel(UIConstants.TEASER_PANEL_WIDTH, 180, "About process definitions");
help.setContent( DAOFactory.createHelpDAO().getHelpByReference(HelpDAO.REF_PROCESS_DEFINITIONS));
- // ----------------------------------
+ // ----------------------------------
teaserPanel = new TeaserPanel();
teaserPanel.add(help);
teaserPanel.add(metricPanel);
- // ----------------------------------
+ // ----------------------------------
+
+ leftHand.add(processDefinitions);
+ leftHand.add(outerFormPanel);
- this.add(processDefinitions, new ColumnLayoutData(0.7) );
+ this.add(leftHand, new ColumnLayoutData(0.7) );
this.add(teaserPanel , new ColumnLayoutData(0.3) );
// init gchart
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -48,7 +48,7 @@
public ProcessInstanceList(ProcessDefinition procDef, String titleName, ConsoleView view)
{
- super(titleName, view, getResourceUrl(view, procDef.getProcessId()));
+ super(titleName, view, getResourceUrl(view, procDef.getProcessId()), true);
this.parent = procDef;
}
@@ -138,6 +138,7 @@
public void onResponseReceived(Request request, Response response)
{
reloadStore();
+ doLayout();
}
public void onError(Request request, Throwable t)
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-20 14:30:32 UTC (rev 2559)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-20 14:35:06 UTC (rev 2560)
@@ -39,7 +39,7 @@
* The view will be lazily initialized by calling {@link com.gwtext.client.data.Store#load()}
* in {@link com.gwtext.client.widgets.event.PanelListenerAdapter#doBeforeRender(com.gwtext.client.widgets.Component)}
* and subsequently add the grid to the container panel upon {@link com.gwtext.client.data.event.StoreListenerAdapter#onLoad(com.gwtext.client.data.Store, com.gwtext.client.data.Record[])}
- *
+ *
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
public abstract class RemoteListView extends Panel
@@ -54,13 +54,15 @@
private PagingToolbar pagingToolbar;
private boolean storeInit = false;
-
- public RemoteListView(String titleName, ConsoleView view, String resourceUrl)
+ private boolean hasAddButton;
+
+ public RemoteListView(String titleName, ConsoleView view, String resourceUrl, boolean hasAddButton)
{
super();
this.title = titleName;
this.view = view;
+ this.hasAddButton = hasAddButton;
// ----------------------------------------
@@ -117,9 +119,9 @@
grid.setTitle(titleName);
grid.setFrame(true);
- grid.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
+ grid.setWidth(UIConstants.EDITOR_PANEL_WIDTH);
grid.stripeRows(true);
- grid.setLoadMask(true);
+ grid.setLoadMask(true);
grid.addGridCellListener( new ListViewCellListener() );
@@ -132,7 +134,7 @@
pagingToolbar.setPageSize(PAGE_SIZE);
pagingToolbar.setDisplayInfo(true);
pagingToolbar.setDisplayMsg("{0} - {1} of {2}");
- pagingToolbar.setEmptyMsg("No entities to display");
+ //pagingToolbar.setEmptyMsg("No entities to display");
pagingToolbar.addSeparator();
pagingToolbar.addSpacer();
@@ -152,17 +154,20 @@
pagingToolbar.addButton(examineButton);
- ToolbarButton addButton = new ToolbarButton("Add", new ButtonListenerAdapter()
+ if(hasAddButton)
{
- public void onClick(Button button, EventObject e)
+ ToolbarButton addButton = new ToolbarButton("Add", new ButtonListenerAdapter()
{
- onAdd();
- }
- });
- //addButton.setIcon("images/icons/add.png");
- addButton.setTooltip("Add");
- pagingToolbar.addButton( addButton );
-
+ public void onClick(Button button, EventObject e)
+ {
+ onAdd();
+ }
+ });
+ //addButton.setIcon("images/icons/add.png");
+ addButton.setTooltip("Add");
+ pagingToolbar.addButton( addButton );
+ }
+
ToolbarButton deleteButton = new ToolbarButton("Remove", new ButtonListenerAdapter()
{
public void onClick(Button button, EventObject e)
@@ -179,12 +184,12 @@
//deleteButton.setIcon("images/icons/remove.png");
deleteButton.setTooltip("Remove");
pagingToolbar.addButton(deleteButton);
-
+
return pagingToolbar;
}
protected abstract void onAdd();
-
+
protected abstract void onExamine(final int row);
protected abstract void onDelete(final int row);
@@ -206,7 +211,7 @@
this.containerPanel = containerPanel;
this.grid = grid;
}
-
+
/**
* load callback will push records to implementation
* and (!) add the grid to the container panel.
@@ -257,6 +262,6 @@
public void reloadStore()
{
- store.load(0,PAGE_SIZE);
+ store.load(0,PAGE_SIZE);
}
}
17 years, 6 months
JBoss JBPM SVN: r2559 - jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-20 10:30:32 -0400 (Mon, 20 Oct 2008)
New Revision: 2559
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java
Log:
Fix date parsing routine
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java 2008-10-20 12:21:59 UTC (rev 2558)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/GsonFactory.java 2008-10-20 14:30:32 UTC (rev 2559)
@@ -32,7 +32,7 @@
public static Gson createInstance()
{
Gson gson = new GsonBuilder()
- .setDateFormat("y-M-d H:m:s")
+ .setDateFormat("y-M-d HH:mm:ss")
.registerTypeAdapter(java.sql.Timestamp.class, new SQLDateTypeAdapter())
.create();
return gson;
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java 2008-10-20 12:21:59 UTC (rev 2558)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/gson/SQLDateTypeAdapter.java 2008-10-20 14:30:32 UTC (rev 2559)
@@ -41,7 +41,7 @@
*/
public class SQLDateTypeAdapter implements JsonSerializer<java.sql.Timestamp>, JsonDeserializer<Date>
{
- private final DateFormat format = new SimpleDateFormat("y-M-d H:m:s");
+ private final DateFormat format = new SimpleDateFormat("y-M-d HH:mm:ss");
public JsonElement serialize(java.sql.Timestamp src, Type typeOfSrc, JsonSerializationContext context)
{
17 years, 6 months
JBoss JBPM SVN: r2558 - in jbpm3/branches/tbaeyens/modules/core/src: test/java/org/jbpm/graph/node and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-10-20 08:21:59 -0400 (Mon, 20 Oct 2008)
New Revision: 2558
Modified:
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/graph/node/ProcessStateDbTest.java
jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
Log:
test fixes
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-10-20 10:09:11 UTC (rev 2557)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-10-20 12:21:59 UTC (rev 2558)
@@ -49,7 +49,7 @@
{
private static Log log = LogFactory.getLog(AbstractDbTestCase.class);
- private JbpmConfiguration jbpmConfiguration;
+ protected JbpmConfiguration jbpmConfiguration;
protected JbpmContext jbpmContext;
protected SchemaExport schemaExport;
@@ -98,7 +98,7 @@
|| (count != 0)
) {
hasLeftOvers = true;
- System.err.println("FIXME: "+count+" left over records in " + tableName);
+ System.err.println("FIXME: "+getClass().getName()+"."+getName()+" left "+count+" records in " + tableName);
}
}
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2008-10-20 10:09:11 UTC (rev 2557)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2008-10-20 12:21:59 UTC (rev 2558)
@@ -117,6 +117,8 @@
{
if (cleanSql == null)
{
+ new SchemaExport(configuration);
+
String catalog = properties.getProperty(Environment.DEFAULT_CATALOG);
String schema = properties.getProperty(Environment.DEFAULT_SCHEMA);
@@ -134,25 +136,16 @@
{
ForeignKey fk = (ForeignKey)subIter.next();
- // Prevent NPE in ForeignKey.isPhysicalConstraint
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-3479
- if (fk.getReferencedTable() != null)
+ if (fk.isPhysicalConstraint())
{
- if (fk.isPhysicalConstraint())
- {
- // collect the drop foreign key constraint sql
- String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
- dropForeignKeysSql.add(sqlDropString);
+ // collect the drop foreign key constraint sql
+ String sqlDropString = fk.sqlDropString(dialect, catalog, schema);
+ dropForeignKeysSql.add(sqlDropString);
- // and collect the create foreign key constraint sql
- String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
- createForeignKeysSql.add(sqlCreateString);
- }
+ // and collect the create foreign key constraint sql
+ String sqlCreateString = fk.sqlCreateString(dialect, mapping, catalog, schema);
+ createForeignKeysSql.add(sqlCreateString);
}
- else
- {
- System.out.println("NoReferencedTable: " + fk);
- }
}
}
}
Modified: jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/graph/node/ProcessStateDbTest.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/graph/node/ProcessStateDbTest.java 2008-10-20 10:09:11 UTC (rev 2557)
+++ jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/graph/node/ProcessStateDbTest.java 2008-10-20 12:21:59 UTC (rev 2558)
@@ -33,6 +33,10 @@
public class ProcessStateDbTest extends AbstractDbTestCase
{
+ static{
+ // making sure System.err and System.out are synchronized
+ System.setErr(System.out);
+ }
public void testProcessStateName()
{
@@ -54,6 +58,73 @@
}
}
+ public void testRecursiveProcessDefinition()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='recursive process'>" +
+ " <start-state>" +
+ " <transition to='first wait' />" +
+ " </start-state>" +
+ " <state name='first wait'>" +
+ " <transition to='subprocessnode' />" +
+ " <transition name='done' to='end' />" +
+ " </state>" +
+ " <process-state name='subprocessnode'>" +
+ " <sub-process name='recursive process' />" +
+ " <transition to='end' />" +
+ " </process-state>" +
+ " <end-state name='end' />" +
+ "</process-definition>"
+ );
+
+ processDefinition = saveAndReload(processDefinition);
+ try
+ {
+ ProcessInstance superProcessInstance = processDefinition.createProcessInstance();
+ superProcessInstance.signal();
+ superProcessInstance.signal();
+
+ superProcessInstance = saveAndReload(superProcessInstance);
+
+ Token superToken = superProcessInstance.getRootToken();
+ assertEquals("subprocessnode", superToken.getNode().getName());
+
+ ProcessInstance subProcessInstance = superToken.getSubProcessInstance();
+ assertNotNull(subProcessInstance);
+ assertEquals("recursive process", subProcessInstance.getProcessDefinition().getName());
+ Token subToken = subProcessInstance.getRootToken();
+
+ assertEquals("first wait", subToken.getNode().getName());
+
+ subProcessInstance.signal("done");
+
+ subProcessInstance = saveAndReload(subProcessInstance);
+ superProcessInstance = graphSession.loadProcessInstance(superProcessInstance.getId());
+
+ assertTrue(subProcessInstance.hasEnded());
+ assertTrue(superProcessInstance.hasEnded());
+
+ }
+ finally
+ {
+ newTransaction();
+ try {
+ jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ } finally {
+ newTransaction();
+ }
+ }
+ }
+
+ public void testMultipleRecursiveProcessDefinitions() {
+ for (int i=0; i<20; i++) {
+ testRecursiveProcessDefinition();
+ }
+ }
+
+
public void testProcessStateSubProcessDefinition()
{
// create the subprocess
@@ -108,6 +179,41 @@
}
}
+ public void testSubProcessBindingWithLatestVersion()
+ {
+ jbpmContext.deployProcessDefinition(new ProcessDefinition("the multiversion subprocess"));
+ jbpmContext.deployProcessDefinition(new ProcessDefinition("the multiversion subprocess"));
+ jbpmContext.deployProcessDefinition(new ProcessDefinition("the multiversion subprocess"));
+
+ newTransaction();
+
+ ProcessDefinition processDefinitionTwo = ProcessDefinition.parseXmlString(
+ "<process-definition>" +
+ " <process-state name='the sub process state'>" +
+ " <sub-process name='the multiversion subprocess'/>" +
+ " </process-state>" +
+ "</process-definition>"
+ );
+ processDefinitionTwo = saveAndReload(processDefinitionTwo);
+ try
+ {
+ ProcessState processState = (ProcessState) processDefinitionTwo.getNode("the sub process state");
+ assertEquals("the multiversion subprocess", processState.getSubProcessDefinition().getName() );
+ assertEquals(3, processState.getSubProcessDefinition().getVersion() );
+ }
+ finally
+ {
+ newTransaction();
+ ProcessDefinition processDefinition = graphSession.findProcessDefinition("the multiversion subprocess", 1);
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ processDefinition = graphSession.findProcessDefinition("the multiversion subprocess", 2);
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ processDefinition = graphSession.findProcessDefinition("the multiversion subprocess", 3);
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ graphSession.deleteProcessDefinition(processDefinitionTwo.getId());
+ }
+ }
+
public void testAverageSubProcess()
{
ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlString(
@@ -223,91 +329,6 @@
}
}
- public void testSubProcessBindingWithLatestVersion()
- {
- ProcessDefinition processDefinitionOne = new ProcessDefinition("the multiversion subprocess");
- jbpmContext.deployProcessDefinition(processDefinitionOne);
- jbpmContext.deployProcessDefinition(processDefinitionOne);
- jbpmContext.deployProcessDefinition(processDefinitionOne);
-
- newTransaction();
-
- ProcessDefinition processDefinitionTwo = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <process-state name='the sub process state'>" +
- " <sub-process name='the multiversion subprocess'/>" +
- " </process-state>" +
- "</process-definition>"
- );
- processDefinitionTwo = saveAndReload(processDefinitionTwo);
- try
- {
- ProcessState processState = (ProcessState) processDefinitionTwo.getNode("the sub process state");
- assertEquals("the multiversion subprocess", processState.getSubProcessDefinition().getName() );
- assertEquals(3, processState.getSubProcessDefinition().getVersion() );
- }
- finally
- {
- newTransaction();
- jbpmContext.getGraphSession().deleteProcessDefinition(processDefinitionOne.getId());
- jbpmContext.getGraphSession().deleteProcessDefinition(processDefinitionTwo.getId());
- }
- }
-
- public void testRecursiveProcessDefinition()
- {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='recursive process'>" +
- " <start-state>" +
- " <transition to='first wait' />" +
- " </start-state>" +
- " <state name='first wait'>" +
- " <transition to='subprocessnode' />" +
- " <transition name='done' to='end' />" +
- " </state>" +
- " <process-state name='subprocessnode'>" +
- " <sub-process name='recursive process' />" +
- " <transition to='end' />" +
- " </process-state>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
-
- processDefinition = saveAndReload(processDefinition);
- try
- {
- ProcessInstance superProcessInstance = new ProcessInstance(processDefinition);
- superProcessInstance.signal();
- superProcessInstance.signal();
-
- superProcessInstance = saveAndReload(superProcessInstance);
-
- Token superToken = superProcessInstance.getRootToken();
- assertEquals("subprocessnode", superToken.getNode().getName());
-
- ProcessInstance subProcessInstance = superToken.getSubProcessInstance();
- assertNotNull(subProcessInstance);
- assertEquals("recursive process", subProcessInstance.getProcessDefinition().getName());
- Token subToken = subProcessInstance.getRootToken();
-
- assertEquals("first wait", subToken.getNode().getName());
-
- subProcessInstance.signal("done");
-
- subProcessInstance = saveAndReload(subProcessInstance);
- superProcessInstance = graphSession.loadProcessInstance(superProcessInstance.getId());
-
- assertTrue(subProcessInstance.hasEnded());
- assertTrue(superProcessInstance.hasEnded());
-
- }
- finally
- {
- newTransaction();
- jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- }
- }
-
public void testSubProcessLogs() {
ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlString(
"<process-definition name='subprocess'>" +
Modified: jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-10-20 10:09:11 UTC (rev 2557)
+++ jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm1452/JBPM1452Test.java 2008-10-20 12:21:59 UTC (rev 2558)
@@ -36,13 +36,23 @@
*/
public class JBPM1452Test extends AbstractDbTestCase
{
- @Override
+
+ static{
+ // making sure System.err and System.out are synchronized
+ System.setErr(System.out);
+ }
+
+@Override
protected JbpmConfiguration getJbpmConfiguration()
{
- return JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <null name='jbpm.job.executor' />" +
- "</jbpm-configuration>");
+ if (jbpmConfiguration == null)
+ {
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <null name='jbpm.job.executor' />" +
+ "</jbpm-configuration>");
+ }
+ return jbpmConfiguration;
}
public void testNoJobExecutor()
@@ -52,8 +62,15 @@
assertTrue("expected object factory to have object jbpm.job.executor", objectFactory.hasObject("jbpm.job.executor"));
assertNull(objectFactory.createObject("jbpm.job.executor"));
// start and end a process instance, no exception should be thrown
- jbpmContext.deployProcessDefinition(new ProcessDefinition("Audit"));
- ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("Audit");
- processInstance.end();
+ ProcessDefinition processDefinition = new ProcessDefinition("Audit");
+ jbpmContext.deployProcessDefinition(processDefinition);
+ try {
+ jbpmContext.newProcessInstanceForUpdate("Audit");
+ } catch(Throwable t) {
+ t.printStackTrace();
+ } finally {
+ newTransaction();
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ }
}
}
17 years, 6 months
JBoss JBPM SVN: r2557 - in jbpm3/trunk/modules/gwt-console: server/src/main/java/org/jboss/bpm/console/server/dao and 7 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-20 06:09:11 -0400 (Mon, 20 Oct 2008)
New Revision: 2557
Added:
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/examine.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove_small.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop.png
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop_small.png
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css
Log:
Start new instance implemented
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -25,6 +25,7 @@
import com.google.gson.GsonBuilder;
import org.jboss.bpm.console.client.model.ProcessDefinitionWrapper;
import org.jboss.bpm.console.client.model.ProcessInstanceWrapper;
+import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.server.dao.DAOFactory;
import org.jboss.bpm.console.server.dao.ProcessDAO;
import org.jboss.bpm.console.server.gson.GsonFactory;
@@ -102,6 +103,20 @@
}
@POST
+ @Path("definitions/{id}/instances/new")
+ @Produces("application/json")
+ public Response newInstance(
+ @PathParam("id")
+ long processId,
+ @Context
+ HttpServletRequest request)
+ {
+
+ ProcessInstance instance = getProcessDAO(request).newInstance(processId);
+ return createJsonResponse(instance);
+ }
+
+ @POST
@Path("instances/{id}/state/{next}")
@Produces("application/json")
public Response changeState(
@@ -116,7 +131,6 @@
return Response.ok().build();
}
-
private Response createJsonResponse(Object wrapper)
{
Gson gson = GsonFactory.createInstance();
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -44,4 +44,6 @@
ProcessInstance getInstanceById(long instanceId);
void changeState(long instanceId, String nextState);
+
+ ProcessInstance newInstance(long processId);
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3CommandDelegate.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -21,9 +21,7 @@
*/
package org.jboss.bpm.console.server.dao.internal;
-import org.jbpm.command.GetProcessDefinitionsCommand;
-import org.jbpm.command.GetProcessInstanceCommand;
-import org.jbpm.command.GetProcessInstancesCommand;
+import org.jbpm.command.*;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
import org.jbpm.graph.def.ProcessDefinition;
@@ -122,4 +120,13 @@
return instances;
}
+
+ public org.jbpm.graph.exe.ProcessInstance startNewInstance(long processId)
+ {
+ org.jbpm.graph.def.ProcessDefinition p0 = getActualDefinition(processId);
+ org.jbpm.graph.exe.ProcessInstance instance = (org.jbpm.graph.exe.ProcessInstance)
+ facade.execute(new NewProcessInstanceCommand(p0.getName()));
+
+ return instance;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -63,6 +63,13 @@
throw new RuntimeException("Not implemented");
}
+
+ public ProcessInstance newInstance(long processId)
+ {
+ org.jbpm.graph.exe.ProcessInstance instance = delegate.startNewInstance(processId);
+ return Transform.processInstance(instance);
+ }
+
public List<ProcessInstance> getInstancesByProcessId(long processId)
{
List<org.jbpm.graph.exe.ProcessInstance> instances = delegate.getActualInstances(processId);
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -136,4 +136,10 @@
return match;
}
+
+
+ public ProcessInstance newInstance(long processId)
+ {
+ throw new RuntimeException("Not implemented");
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-20 10:09:11 UTC (rev 2557)
@@ -46,6 +46,13 @@
</tr>
<tr>
+ <td>POST</td>
+ <td>/rs/process/definitions/{processId}/instances/new</td>
+ <td>Create a new process instance</td>
+ <td>application/json</td>
+ </tr>
+
+ <tr>
<td colspan=4><h3>User Management</h3></td>
</tr>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -99,4 +99,9 @@
{
return getBaseUrl() + "/rs/process/instances/" + instanceId + "/state/"+state;
}
+
+ public String getStartNewInstanceURL(long processId)
+ {
+ return getBaseUrl() + "/rs/process/definitions/"+processId+"/instances/new";
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -139,6 +139,12 @@
});
}
+
+ protected void onAdd()
+ {
+
+ }
+
protected void onRecordsLoaded(Record[] records)
{
int i = 0;
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -114,6 +114,52 @@
});
}
+
+ protected void onAdd()
+ {
+ MessageBox.show(new MessageBoxConfig() {
+ {
+ setTitle("New instance");
+ setMsg("Would you like to start a new instance?");
+ setButtons(MessageBox.YESNOCANCEL);
+ setCallback(new MessageBox.PromptCallback() {
+ public void execute(String btnID, String text)
+ {
+ if("yes".equals( btnID) )
+ {
+ String url = view.getRestURL().getStartNewInstanceURL(parent.getProcessId());
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
+
+ try
+ {
+ rb.sendRequest("",
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ reloadStore();
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // auth failed
+ view.setError("Failed to start new instance: "+t.getMessage());
+ t.printStackTrace(System.out);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ view.setError(e1.getMessage());
+ e1.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+
protected void onRecordsLoaded(Record[] records)
{
int i = 0;
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -29,6 +29,8 @@
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.PaddedPanel;
import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.layout.ColumnLayout;
+import com.gwtext.client.widgets.layout.ColumnLayoutData;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.DateField;
import com.gwtext.client.widgets.form.FieldSet;
@@ -41,6 +43,8 @@
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.widgets.EditorView;
import org.jboss.bpm.console.client.widgets.UIConstants;
+import org.jboss.bpm.console.client.widgets.TeaserPanel;
+import org.jboss.bpm.console.client.widgets.HelpPanel;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -58,25 +62,33 @@
public ProcessInstanceListEditor(ProcessDefinition proc, ConsoleView view)
{
super();
+
+ this.parent = proc;
this.view = view;
this.setId(ProcessInstanceEditor.ID+"."+proc.getName());
- parent = proc;
+ // --------------------------------------------------
+ this.setLayout( new ColumnLayout() );
+ this.setWidth(UIConstants.EDITOR_WIDTH);
+
// ---------------
+ Panel leftHand = new Panel();
+ leftHand.setFrame(false);
+ leftHand.setHeader(false);
+ leftHand.setBorder(false);
+
instanceList = new ProcessInstanceList(
proc, "Process Instances", view
);
- this.add(instanceList);
-
// ---------------
- Panel panel = new Panel();
- panel.setBorder(false);
- panel.setFrame(false);
- panel.setPaddings(10);
+ Panel outerFormPanel = new Panel();
+ outerFormPanel.setBorder(false);
+ outerFormPanel.setFrame(false);
+ outerFormPanel.setPaddings(10);
// ---------------
@@ -116,8 +128,10 @@
selectedInstance.setState(ProcessInstance.STATE.SUSPENDED);
persistStateChange();
}
- }
- );
+ }
+ );
+ //suspendButton.setIcon("images/icons/pause.png");
+
final Button resumeButton = new Button("Resume",
new ButtonListenerAdapter()
{
@@ -129,7 +143,8 @@
}
}
);
-
+ //resumeButton.setIcon("images/icons/play.png");
+
formPanel.addButton(suspendButton);
formPanel.addButton(resumeButton);
@@ -170,9 +185,23 @@
}, 10);
- panel.add(formPanel);
- this.add(panel);
+ outerFormPanel.add(formPanel);
+ // ----------------------------------
+
+ HelpPanel help = new HelpPanel(UIConstants.TEASER_PANEL_WIDTH, 200, "Managing process instances");
+
+ TeaserPanel teaserPanel = new TeaserPanel();
+ teaserPanel.add(help);
+
+ // ----------------------------------
+
+ leftHand.add(instanceList);
+ leftHand.add(outerFormPanel);
+
+ this.add(leftHand, new ColumnLayoutData(0.7) );
+ this.add(teaserPanel , new ColumnLayoutData(0.3) );
+
}
private void persistStateChange()
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-20 10:09:11 UTC (rev 2557)
@@ -134,38 +134,57 @@
pagingToolbar.setDisplayMsg("{0} - {1} of {2}");
pagingToolbar.setEmptyMsg("No entities to display");
- pagingToolbar.addButton(
- new ToolbarButton("Examine", new ButtonListenerAdapter() {
- public void onClick(Button button, EventObject e)
- {
- if(-1== selectedRowIndex)
- MessageBox.alert("Please select a process.");
- else
- onExamine(selectedRowIndex);
- }
- })
- );
+ pagingToolbar.addSeparator();
+ pagingToolbar.addSpacer();
- pagingToolbar.addButton(
- new ToolbarButton("Delete", new ButtonListenerAdapter()
- {
- public void onClick(Button button, EventObject e)
- {
- if(-1== selectedRowIndex)
- {
- MessageBox.alert("Please select a process.");
- }
- else
- {
- onDelete(selectedRowIndex);
- }
- }
- })
- );
+ ToolbarButton examineButton = new ToolbarButton("Examine", new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject e)
+ {
+ if (-1 == selectedRowIndex)
+ MessageBox.alert("Please select a process.");
+ else
+ onExamine(selectedRowIndex);
+ }
+ });
+ //examineButton.setIcon("images/icons/examine.png");
+ examineButton.setTooltip("Examine");
+ pagingToolbar.addButton(examineButton);
+
+
+ ToolbarButton addButton = new ToolbarButton("Add", new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject e)
+ {
+ onAdd();
+ }
+ });
+ //addButton.setIcon("images/icons/add.png");
+ addButton.setTooltip("Add");
+ pagingToolbar.addButton( addButton );
+
+ ToolbarButton deleteButton = new ToolbarButton("Remove", new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject e)
+ {
+ if (-1 == selectedRowIndex)
+ {
+ MessageBox.alert("Please select a process.");
+ } else
+ {
+ onDelete(selectedRowIndex);
+ }
+ }
+ });
+ //deleteButton.setIcon("images/icons/remove.png");
+ deleteButton.setTooltip("Remove");
+ pagingToolbar.addButton(deleteButton);
return pagingToolbar;
}
+ protected abstract void onAdd();
+
protected abstract void onExamine(final int row);
protected abstract void onDelete(final int row);
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css 2008-10-17 02:39:19 UTC (rev 2556)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/console.css 2008-10-20 10:09:11 UTC (rev 2557)
@@ -100,7 +100,30 @@
text-align: center;
}
+.bpm-examine-icon {
+ background-image: url( images/icons/examine.png)
+}
+.bpm-add-icon {
+ background-image: url( images/icons/add.png)
+}
+
+.bpm-remove-icon {
+ background-image: url( images/icons/remove.png)
+}
+
+.bpm-play-icon {
+ background-image: url( images/icons/play.png)
+}
+
+.bpm-stop-icon {
+ background-image: url( images/icons/stop.png)
+}
+
+.bpm-pause-icon {
+ background-image: url( images/icons/pause.png)
+}
+
div.activeNode {
position:absolute;
border-width:1px;
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/add_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/confirm_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/deny_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/examine.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/examine.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/large_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/pause_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/play_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/remove_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop_small.png
===================================================================
(Binary files differ)
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/resources/org/jboss/bpm/console/public/images/icons/stop_small.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 6 months
JBoss JBPM SVN: r2556 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/jpdl/xml and 4 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 22:39:19 -0400 (Thu, 16 Oct 2008)
New Revision: 2556
Added:
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.3.xsd
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Join.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/graph/node/Join.hbm.xml
jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jpdl/xml/files/testProcessDefinitionWithSchemaLocation.xml
Log:
[JBPM-1755] made field Join.parentLockMode persistent
allow any lock mode, not just UPGRADE
added lock attribute to join element in xml schema
registered jpdl 3.3 schema in parser
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Join.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Join.java 2008-10-16 22:56:53 UTC (rev 2555)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Join.java 2008-10-17 02:39:19 UTC (rev 2556)
@@ -76,10 +76,14 @@
public void read(Element element, JpdlXmlReader jpdlReader) {
String lock = element.attributeValue("lock");
- if ( (lock!=null)
- && (lock.equalsIgnoreCase("pessimistic"))
- ) {
- parentLockMode = LockMode.UPGRADE.toString();
+ if (lock != null) {
+ LockMode lockMode = LockMode.parse(lock);
+ if (lockMode != null)
+ parentLockMode = lockMode.toString();
+ else if ("pessimistic".equals(lock))
+ parentLockMode = LockMode.UPGRADE.toString();
+ else
+ jpdlReader.addError("invalid parent lock mode '" + lock + "'");
}
}
@@ -211,6 +215,12 @@
return reactivateParent;
}
+ public String getParentLockMode() {
+ return parentLockMode;
+ }
+ public void setParentLockMode(String parentLockMode) {
+ this.parentLockMode = parentLockMode;
+ }
public Script getScript() {
return script;
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-10-16 22:56:53 UTC (rev 2555)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-10-17 02:39:19 UTC (rev 2556)
@@ -157,6 +157,7 @@
schemaResources.add("org/jbpm/jpdl/xml/jpdl-3.0.xsd");
schemaResources.add("org/jbpm/jpdl/xml/jpdl-3.1.xsd");
schemaResources.add("org/jbpm/jpdl/xml/jpdl-3.2.xsd");
+ schemaResources.add("org/jbpm/jpdl/xml/jpdl-3.3.xsd");
schemaResources.add("org/jboss/seam/pageflow-2.0.xsd");
return schemaResources;
}
Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/graph/node/Join.hbm.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/graph/node/Join.hbm.xml 2008-10-16 22:56:53 UTC (rev 2555)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/graph/node/Join.hbm.xml 2008-10-17 02:39:19 UTC (rev 2556)
@@ -5,8 +5,9 @@
<hibernate-mapping auto-import="false" default-access="field" >
- <subclass name="org.jbpm.graph.node.Join"
- discriminator-value="J"
- extends="org.jbpm.graph.def.Node" />
+ <subclass name="org.jbpm.graph.node.Join" discriminator-value="J"
+ extends="org.jbpm.graph.def.Node">
+ <property name="parentLockMode" column="PARENTLOCKMODE_"/>
+ </subclass>
</hibernate-mapping>
Added: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.3.xsd
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.3.xsd (rev 0)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/jpdl/xml/jpdl-3.3.xsd 2008-10-17 02:39:19 UTC (rev 2556)
@@ -0,0 +1,511 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xs:schema targetNamespace="urn:jbpm.org:jpdl-3.3"
+ elementFormDefault="qualified"
+ xmlns="urn:jbpm.org:jpdl-3.3"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <!-- PROCESS-DEFINITION -->
+ <!-- ################## -->
+ <xs:element name="process-definition">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element ref="swimlane" />
+ <xs:element ref="start-state" />
+ <xs:group ref="node-elements"/>
+ <xs:group ref="action-elements" />
+ <xs:element ref="event" />
+ <xs:element ref="exception-handler" />
+ <xs:element ref="task" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- SWIMLANE -->
+ <!-- ######## -->
+ <xs:element name="swimlane">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="1">
+ <xs:element ref="assignment"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- NODES -->
+ <!-- ##### -->
+ <xs:element name="start-state">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element ref="task"/>
+ <xs:element ref="transition"/>
+ <xs:element ref="event"/>
+ <xs:element ref="exception-handler"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="end-state">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element ref="event"/>
+ <xs:element ref="exception-handler"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="end-complete-process" type="booleanType" use="optional" default="false"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="decision">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element name="handler" type="delegation" />
+ <xs:element ref="event"/>
+ <xs:element ref="exception-handler"/>
+ <xs:element ref="transition"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="expression" type="xs:string" />
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="fork">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="script" />
+ <xs:group ref="node-content-elements" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="join">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="node-content-elements" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ <xs:attribute name="lock" type="lockMode"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="node">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:group ref="action-elements" />
+ </xs:choice>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="node-content-elements" />
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="process-state">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="sub-process">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string"
+ use="required" />
+ <xs:attribute name="version" type="xs:integer" />
+ <xs:attribute name="binding" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element ref="variable" />
+ <xs:group ref="node-content-elements" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="async" type="xs:string" default="false" />
+ <xs:attribute name="binding" type="bindingType"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="state">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="node-content-elements"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="super-state">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="node-elements"/>
+ <xs:group ref="node-content-elements"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="task-node">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="task" />
+ <xs:group ref="node-content-elements" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="create-tasks" type="booleanType" default="true" />
+ <xs:attribute name="end-tasks" type="booleanType" default="false" />
+ <xs:attribute name="signal" default="last">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="unsynchronized"/>
+ <xs:enumeration value="never"/>
+ <xs:enumeration value="first"/>
+ <xs:enumeration value="first-wait"/>
+ <xs:enumeration value="last"/>
+ <xs:enumeration value="last-wait"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="mail-node">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="subject" />
+ <xs:element ref="text" />
+ <xs:group ref="node-content-elements"/>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ <xs:attribute name="template" type="xs:string"/>
+ <xs:attribute name="actors" type="xs:string"/>
+ <xs:attribute name="to" type="xs:string"/>
+ <xs:attribute name="subject" type="xs:string"/>
+ <xs:attribute name="text" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+
+ <!-- TRANSITION -->
+ <!-- ########## -->
+ <xs:element name="transition">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element name="condition">
+ <xs:complexType mixed="true">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="expression" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ <xs:group ref="action-elements"/>
+ <xs:element ref="exception-handler" />
+ </xs:choice>
+ <xs:attribute name="to" type="xs:string" use="required" />
+ <xs:attribute name="name" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- ACTIONS -->
+ <!-- ####### -->
+ <xs:element name="action">
+ <xs:complexType mixed="true">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="class" type="xs:string" />
+ <xs:attribute name="config-type" default="field" type="xs:string" />
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="ref-name" type="xs:string" />
+ <xs:attribute name="accept-propagated-events" type="booleanType" default="true" />
+ <xs:attribute name="expression" type="xs:string" />
+ <xs:attribute name="async" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="cancel-timer">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="create-timer">
+ <xs:complexType>
+ <xs:choice minOccurs="0">
+ <xs:element ref="action"/>
+ <xs:element ref="script"/>
+ </xs:choice>
+ <xs:attribute name="duedate" type="xs:string" use="required" />
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="repeat" type="xs:string" />
+ <xs:attribute name="transition" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="script">
+ <xs:complexType mixed="true">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="accept-propagated-events" type="booleanType" default="true" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="mail">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="subject" />
+ <xs:element ref="text" />
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="async" type="xs:string" default="false" />
+ <xs:attribute name="template" type="xs:string"/>
+ <xs:attribute name="actors" type="xs:string"/>
+ <xs:attribute name="to" type="xs:string"/>
+ <xs:attribute name="subject" type="xs:string"/>
+ <xs:attribute name="text" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- EVENT -->
+ <!-- ##### -->
+ <xs:element name="event">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="action-elements"/>
+ </xs:choice>
+ <xs:attribute name="type" use="required">
+ <xs:simpleType>
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:string"/>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="node-enter"/>
+ <xs:enumeration value="node-leave"/>
+ <xs:enumeration value="process-start"/>
+ <xs:enumeration value="process-end"/>
+ <xs:enumeration value="task-create"/>
+ <xs:enumeration value="task-assign"/>
+ <xs:enumeration value="task-start"/>
+ <xs:enumeration value="task-end"/>
+ <xs:enumeration value="before-signal"/>
+ <xs:enumeration value="after-signal"/>
+ <xs:enumeration value="superstate-enter"/>
+ <xs:enumeration value="superstate-leave"/>
+ <xs:enumeration value="timer-create"/>
+ <xs:enumeration value="subprocess-created"/>
+ <xs:enumeration value="subprocess-end"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- EXCEPTION-HANDLER -->
+ <!-- ################# -->
+ <xs:element name="exception-handler">
+ <xs:complexType>
+ <xs:choice minOccurs="1" maxOccurs="unbounded">
+ <xs:element ref="action"/>
+ <xs:element ref="script"/>
+ </xs:choice>
+ <xs:attribute name="exception-class" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- TASK -->
+ <!-- #### -->
+ <xs:element name="task">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="description" />
+ <xs:element ref="assignment"/>
+ <xs:element ref="controller"/>
+ <xs:element ref="event"/>
+ <xs:element ref="timer"/>
+ <xs:element name="reminder">
+ <xs:complexType>
+ <xs:attribute name="duedate" type="xs:string" use="required" />
+ <xs:attribute name="repeat" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="blocking" type="booleanType" default="false"/>
+ <xs:attribute name="signalling" type="booleanType" default="true"/>
+ <xs:attribute name="description" type="xs:string" />
+ <xs:attribute name="duedate" type="xs:string" />
+ <xs:attribute name="swimlane" type="xs:string" />
+ <xs:attribute name="priority" type="priorityType" default="normal" />
+ <xs:attribute name="notify" type="booleanType" default="false"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="controller" type="delegation" />
+
+ <xs:element name="assignment">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="delegation">
+ <xs:attribute name="expression" type="xs:string" />
+ <xs:attribute name="actor-id" type="xs:string" />
+ <xs:attribute name="pooled-actors" type="xs:string" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- TIMER -->
+ <!-- ##### -->
+ <xs:element name="timer">
+ <xs:complexType>
+ <xs:choice minOccurs="0" maxOccurs="1">
+ <xs:group ref="action-elements" />
+ </xs:choice>
+ <xs:attribute name="duedate" type="xs:string" use="required" />
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="repeat" type="xs:string" />
+ <xs:attribute name="transition" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="variable">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="access" type="xs:string" default="read,write"/>
+ <xs:attribute name="mapped-name" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+
+ <!-- MAIL -->
+ <!-- #### -->
+ <xs:element name="to" type="xs:string"/>
+ <xs:element name="recipients" type="xs:string"/>
+ <xs:element name="subject" type="xs:string"/>
+ <xs:element name="text" type="xs:string"/>
+ <xs:element name="template" type="xs:string"/>
+
+ <!-- TYPES AND GROUPS -->
+ <!-- ################ -->
+
+ <xs:element name="description" type="xs:string" />
+
+ <xs:complexType name="delegation" mixed="true">
+ <xs:sequence>
+ <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ <xs:attribute name="class" type="xs:string" />
+ <xs:attribute name="config-type" default="field" type="xs:string" />
+ </xs:complexType>
+
+ <xs:simpleType name="configType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="field"/>
+ <xs:enumeration value="bean"/>
+ <xs:enumeration value="constructor"/>
+ <xs:enumeration value="configuration-property"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="booleanType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="yes"/>
+ <xs:enumeration value="no"/>
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ <xs:enumeration value="on"/>
+ <xs:enumeration value="off"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="priorityType">
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="highest"/>
+ <xs:enumeration value="high"/>
+ <xs:enumeration value="normal"/>
+ <xs:enumeration value="low"/>
+ <xs:enumeration value="lowest"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="xs:int"/>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+
+ <xs:group name="node-elements">
+ <xs:choice>
+ <xs:element ref="node"/>
+ <xs:element ref="state"/>
+ <xs:element ref="task-node"/>
+ <xs:element ref="super-state"/>
+ <xs:element ref="process-state"/>
+ <xs:element ref="fork"/>
+ <xs:element ref="join"/>
+ <xs:element ref="decision"/>
+ <xs:element ref="end-state"/>
+ <xs:element ref="mail-node"/>
+ </xs:choice>
+ </xs:group>
+
+ <xs:group name="action-elements">
+ <xs:choice>
+ <xs:element ref="action"/>
+ <xs:element ref="script"/>
+ <xs:element ref="create-timer"/>
+ <xs:element ref="cancel-timer"/>
+ <xs:element ref="mail"/>
+ </xs:choice>
+ </xs:group>
+
+ <xs:group name="node-content-elements">
+ <xs:choice>
+ <xs:element ref="description" />
+ <xs:element ref="event"/>
+ <xs:element ref="exception-handler"/>
+ <xs:element ref="timer"/>
+ <xs:element ref="transition"/>
+ </xs:choice>
+ </xs:group>
+
+ <xs:simpleType name="bindingType">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="late"/>
+ <xs:enumeration value="early"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="lockMode">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="NONE"/>
+ <xs:enumeration value="READ"/>
+ <xs:enumeration value="UPGRADE"/>
+ <xs:enumeration value="UPGRADE_NOWAIT"/>
+ <xs:enumeration value="FORCE"/>
+ <xs:enumeration value="pessimistic"/>
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/node/JoinDbTest.java 2008-10-17 02:39:19 UTC (rev 2556)
@@ -0,0 +1,63 @@
+/*
+ * 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.graph.node;
+
+import org.hibernate.LockMode;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * Verifies the join node can be persisted correctly.
+ * @author Alejandro Guizar
+ */
+public class JoinDbTest extends AbstractDbTestCase {
+
+ private long processDefinitionId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='" + getName() + "'>" +
+ " <join name='read' lock='READ' />" +
+ " <join name='nowait' lock='UPGRADE_NOWAIT' />" +
+ " <join name='upgrade' lock='pessimistic' />" +
+ "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+ processDefinitionId = processDefinition.getId();
+ newTransaction();
+ }
+
+ protected void tearDown() throws Exception {
+ graphSession.deleteProcessDefinition(processDefinitionId);
+ super.tearDown();
+ }
+
+ public void testParentLockMode() {
+ ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition(getName());
+ Join join = (Join) processDefinition.getNode("read");
+ assertEquals(LockMode.READ.toString(), join.getParentLockMode());
+ join = (Join) processDefinition.getNode("nowait");
+ assertEquals(LockMode.UPGRADE_NOWAIT.toString(), join.getParentLockMode());
+ join = (Join) processDefinition.getNode("upgrade");
+ assertEquals(LockMode.UPGRADE.toString(), join.getParentLockMode());
+ }
+}
Modified: jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jpdl/xml/files/testProcessDefinitionWithSchemaLocation.xml
===================================================================
--- jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jpdl/xml/files/testProcessDefinitionWithSchemaLocation.xml 2008-10-16 22:56:53 UTC (rev 2555)
+++ jbpm3/trunk/modules/core/src/test/resources/org/jbpm/jpdl/xml/files/testProcessDefinitionWithSchemaLocation.xml 2008-10-17 02:39:19 UTC (rev 2556)
@@ -1,7 +1,7 @@
<process-definition
xmlns="urn:jbpm.org:jpdl-3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:jbpm.org:jpdl-3.1 http://jbpm.org/jpdl-3.2.xsd"
+ xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/jpdl-3.2.xsd"
name="process definition with schema location">
<blablablab />
17 years, 6 months
JBoss JBPM SVN: r2555 - in jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm: enterprise/test and 3 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-16 18:56:53 -0400 (Thu, 16 Oct 2008)
New Revision: 2555
Added:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/JmsMessageTest.java
Removed:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/ActionRecorder.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/GetCurrentTime.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Recorder.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/AsyncProcessingTest.java
Modified:
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/AppServerConfigurationsTest.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/persistence/jta/JtaDbPersistenceTest.java
jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerTest.java
Log:
merged revisions 2058, 2062, 2072, 2080, 2114, 2134, 2155, 2185, 2218 and 2257 from https://svn.jboss.org/repos/jbpm/jbpm3/trunk/modules/enterprise/jar/src/t...
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/AppServerConfigurationsTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/AppServerConfigurationsTest.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/AppServerConfigurationsTest.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -37,17 +37,20 @@
}
public void testJtaDbPersistenceFactoryConfiguration() {
- assertSame(JtaDbPersistenceServiceFactory.class, jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE).getClass());
+ assertSame(JtaDbPersistenceServiceFactory.class, jbpmConfiguration.getServiceFactory(
+ Services.SERVICENAME_PERSISTENCE).getClass());
JtaDbPersistenceServiceFactory persistenceServiceFactory = (JtaDbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
assertFalse(persistenceServiceFactory.isTransactionEnabled());
assertTrue(persistenceServiceFactory.isCurrentSessionEnabled());
}
public void testJmsMessageServiceFactoryConfiguration() {
- assertSame(JmsMessageServiceFactoryImpl.class, jbpmConfiguration.getServiceFactory(Services.SERVICENAME_MESSAGE).getClass());
+ assertSame(JmsMessageServiceFactoryImpl.class, jbpmConfiguration.getServiceFactory(
+ Services.SERVICENAME_MESSAGE).getClass());
}
public void testEjbSchedulerServiceFactoryConfiguration() {
- assertSame(EntitySchedulerServiceFactory.class, jbpmConfiguration.getServiceFactory(Services.SERVICENAME_SCHEDULER).getClass());
+ assertSame(EntitySchedulerServiceFactory.class, jbpmConfiguration.getServiceFactory(
+ Services.SERVICENAME_SCHEDULER).getClass());
}
}
Deleted: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/ActionRecorder.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/ActionRecorder.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/ActionRecorder.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -1,37 +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.enterprise.test;
-
-import org.jbpm.graph.def.Action;
-import org.jbpm.graph.exe.ExecutionContext;
-
-public class ActionRecorder extends Recorder {
-
- private static final long serialVersionUID = 1L;
-
- public void record(String processInstanceId, ExecutionContext executionContext) {
- Action action = executionContext.getAction();
- String actionName = action.getName();
- collectedResults.add(processInstanceId+actionName);
- }
-
-}
Added: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java (rev 0)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/EventCallback.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -0,0 +1,146 @@
+/*
+ * 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.enterprise.test;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.Event;
+
+public class EventCallback implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = LogFactory.getLog(EventCallback.class);
+
+ private static Map eventSemaphores = new HashMap();
+
+ public void processStart() {
+ registerNotification(Event.EVENTTYPE_PROCESS_START);
+ }
+
+ public void processEnd() {
+ registerNotification(Event.EVENTTYPE_PROCESS_END);
+ }
+
+ public void nodeEnter() {
+ registerNotification(Event.EVENTTYPE_NODE_ENTER);
+ }
+
+ public void nodeLeave() {
+ registerNotification(Event.EVENTTYPE_NODE_LEAVE);
+ }
+
+ public void taskCreate() {
+ registerNotification(Event.EVENTTYPE_TASK_CREATE);
+ }
+
+ public void taskEnd() {
+ registerNotification(Event.EVENTTYPE_TASK_END);
+ }
+
+ public void timerCreate() {
+ registerNotification(Event.EVENTTYPE_TIMER_CREATE);
+ }
+
+ public void timer() {
+ registerNotification(Event.EVENTTYPE_TIMER);
+ }
+
+ public void transition() {
+ registerNotification(Event.EVENTTYPE_TRANSITION);
+ }
+
+ private static void registerNotification(final String event) {
+ Synchronization notification = new Synchronization() {
+
+ public void beforeCompletion() {
+ }
+
+ public void afterCompletion(int status) {
+ if (status == Status.STATUS_COMMITTED) {
+ log.debug("sending '" + event + "' notification");
+ Semaphore eventSemaphore = getEventSemaphore(event);
+ eventSemaphore.release();
+ }
+ }
+
+ };
+ JbpmContext.getCurrentJbpmContext()
+ .getSession()
+ .getTransaction()
+ .registerSynchronization(notification);
+ }
+
+ public static void waitForEvent(String event) {
+ waitForEvent(event, 10000);
+ }
+
+ public static void waitForEvent(String event, long timeout) {
+ log.debug("waiting for " + event);
+ Semaphore eventSemaphore = getEventSemaphore(event);
+ try {
+ if (eventSemaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+ log.debug("received '" + event + "' notification");
+ }
+ else {
+ log.warn("event '" + event + "' did not occur within " + timeout + " ms");
+ }
+ }
+ catch (InterruptedException e) {
+ // reassert interruption
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private static Semaphore getEventSemaphore(String event) {
+ synchronized (eventSemaphores) {
+ Semaphore semaphore = (Semaphore) eventSemaphores.get(event);
+ if (semaphore == null) {
+ semaphore = new Semaphore(0);
+ eventSemaphores.put(event, semaphore);
+ }
+ return semaphore;
+ }
+ }
+
+ public static void clear() {
+ for (Iterator i = eventSemaphores.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ Semaphore semaphore = (Semaphore) entry.getValue();
+ int permits = semaphore.drainPermits();
+ if (permits != 0) {
+ log.warn("event '" + entry.getKey() + "' has " + permits + " outstanding notifications");
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/GetCurrentTime.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/GetCurrentTime.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/GetCurrentTime.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -1,34 +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.enterprise.test;
-
-import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.exe.ExecutionContext;
-import org.jbpm.util.Clock;
-
-public class GetCurrentTime implements ActionHandler {
- String variable;
- private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception {
- executionContext.setVariable(variable, Clock.getCurrentTime());
- }
-}
\ No newline at end of file
Deleted: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Recorder.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Recorder.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/enterprise/test/Recorder.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -1,60 +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.enterprise.test;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.jbpm.graph.def.ActionHandler;
-import org.jbpm.graph.exe.ExecutionContext;
-
-public class Recorder implements ActionHandler {
-
- private static final long serialVersionUID = 1L;
-
- public static Set collectedProcessInstanceIds = null;
- public static Set collectedResults = null;
- public volatile static int executions = 0;
-
- public static void resetCollections() {
- collectedProcessInstanceIds = Collections.synchronizedSet(new HashSet());
- collectedResults = Collections.synchronizedSet(new TreeSet());
- executions = 0;
- }
-
- public void execute(ExecutionContext executionContext) throws Exception {
- synchronized (Recorder.class) {
- executions++;
- }
- String id = (String) Long.toString(executionContext.getProcessInstance().getId());
- collectedProcessInstanceIds.add(id);
- record(id, executionContext);
- }
-
- public void record(String processInstanceId, ExecutionContext executionContext) {
- String nodeName = executionContext.getNode().getName();
- collectedResults.add(processInstanceId+nodeName);
- executionContext.leaveNode();
- }
-}
Deleted: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/AsyncProcessingTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/AsyncProcessingTest.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/AsyncProcessingTest.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -1,200 +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.msg.jms;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.TreeSet;
-
-import javax.naming.InitialContext;
-
-import org.apache.cactus.ServletTestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Session;
-import org.jbpm.JbpmContext;
-import org.jbpm.command.Command;
-import org.jbpm.command.DeployProcessCommand;
-import org.jbpm.command.StartProcessInstanceCommand;
-import org.jbpm.ejb.LocalCommandService;
-import org.jbpm.ejb.LocalCommandServiceHome;
-import org.jbpm.enterprise.test.ActionRecorder;
-import org.jbpm.enterprise.test.Recorder;
-
-public class AsyncProcessingTest extends ServletTestCase {
-
- private LocalCommandService commandService;
-
- static int nbrOfConcurrentProcessExecutions = 20;
- static int maxWaitTime = 30000;
-
- protected void setUp() throws Exception {
- InitialContext initialContext = new InitialContext();
- LocalCommandServiceHome localCommandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/LocalCommandServiceBean");
- commandService = localCommandServiceHome.create();
- }
-
- public void testBulkJobs() {
- Recorder.resetCollections();
- deleteAllJobs();
- deployProcess();
- launchProcesses();
- processAllJobs(maxWaitTime);
- Set expectedResults = createExpectedResults();
- assertEquals(Recorder.collectedProcessInstanceIds.toString()+" wasn't the expected size: "+nbrOfConcurrentProcessExecutions, nbrOfConcurrentProcessExecutions, Recorder.collectedProcessInstanceIds.size());
- assertEquals(expectedResults, Recorder.collectedResults);
- }
-
- protected void deleteAllJobs() {
- execute( new Command() {
- private static final long serialVersionUID = 1L;
- public Object execute(JbpmContext jbpmContext) throws Exception {
- Session session = jbpmContext.getSession();
- session.createQuery("delete from org.jbpm.job.Job").executeUpdate();
- return null;
- }
- });
- }
-
- protected Object execute(Command command) {
- return commandService.execute(command);
- }
-
-
- protected void deployProcess() {
- log.debug("start deploy process");
- execute(new DeployProcessCommand(
- "<process-definition name='bulk messages'>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <node name='a' async='true'>" +
- " <action class='"+Recorder.class.getName()+"' />" +
- " <transition to='b' />" +
- " </node>" +
- " <node name='b' async='true'>" +
- " <event type='node-enter'>" +
- " <action name='X' async='true' class='"+ActionRecorder.class.getName()+"' />" +
- " </event>" +
- " <action class='"+Recorder.class.getName()+"' />" +
- " <transition to='c' />" +
- " </node>" +
- " <node name='c' async='true'>" +
- " <action class='"+Recorder.class.getName()+"' />" +
- " <transition to='d'>" +
- " <action name='Y' async='true' class='"+ActionRecorder.class.getName()+"' />" +
- " </transition>" +
- " </node>" +
- " <node name='d' async='true'>" +
- " <action class='"+Recorder.class.getName()+"' />" +
- " <transition to='e' />" +
- " <event type='node-leave'>" +
- " <action name='Z' async='true' class='"+ActionRecorder.class.getName()+"' />" +
- " </event>" +
- " </node>" +
- " <node name='e' async='true'>" +
- " <action class='"+Recorder.class.getName()+"' />" +
- " <transition to='end' />" +
- " </node>" +
- " <end-state name='end'/>" +
- "</process-definition>"));
- }
-
- protected void launchProcesses() {
- for (int i=0; i<nbrOfConcurrentProcessExecutions; i++) {
- StartProcessInstanceCommand command = new StartProcessInstanceCommand();
- command.setProcessName("bulk messages");
- execute(command);
- }
- }
-
- protected Set createExpectedResults() {
- Set expectedResults = new TreeSet();
- Iterator iter = Recorder.collectedProcessInstanceIds.iterator();
- while (iter.hasNext()) {
- String id = (String) iter.next();
- expectedResults.add(id+"a");
- expectedResults.add(id+"b");
- expectedResults.add(id+"c");
- expectedResults.add(id+"d");
- expectedResults.add(id+"e");
- expectedResults.add(id+"X");
- expectedResults.add(id+"Y");
- expectedResults.add(id+"Z");
- }
- return expectedResults;
- }
-
- private void processAllJobs(final long maxWait) {
- boolean jobsAvailable = true;
-
- // install a timer that will interrupt if it takes too long
- // if that happens, it will lead to an interrupted exception and the test will fail
- TimerTask interruptTask = new TimerTask() {
- Thread testThread = Thread.currentThread();
- public void run() {
- log.debug("test "+getName()+" took too long. going to interrupt...");
- testThread.interrupt();
- }
- };
- Timer timer = new Timer();
- timer.schedule(interruptTask, maxWait);
-
- try {
- while (jobsAvailable) {
- log.debug("going to sleep for 200 millis, waiting for the job executor to process more jobs");
- Thread.sleep(200);
- jobsAvailable = areJobsAvailable();
- }
-
- } catch (InterruptedException e) {
- fail("test execution exceeded treshold of "+maxWait+" milliseconds");
- } finally {
- timer.cancel();
- }
- }
-
- protected int getNbrOfJobsAvailable() {
- Integer nbrOfJobsAvailable = (Integer) execute( new Command() {
- private static final long serialVersionUID = 1L;
- public Object execute(JbpmContext jbpmContext) throws Exception {
- Integer nbrOfJobsAvailable = null;
- Session session = jbpmContext.getSession();
- Number jobs = (Number) session.createQuery("select count(*) from org.jbpm.job.Job").uniqueResult();
- log.debug("there are '"+jobs+"' jobs currently in the job table");
- if (jobs!=null) {
- nbrOfJobsAvailable = new Integer(jobs.intValue());
- }
- return nbrOfJobsAvailable;
- }
- });
- return nbrOfJobsAvailable.intValue();
- }
-
- protected boolean areJobsAvailable() {
- return (getNbrOfJobsAvailable()>0);
- }
-
- private static Log log = LogFactory.getLog(AsyncProcessingTest.class);
-}
Added: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/JmsMessageTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/JmsMessageTest.java (rev 0)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/msg/jms/JmsMessageTest.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -0,0 +1,268 @@
+/*
+ * 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.msg.jms;
+
+import java.util.Collections;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jbpm.enterprise.test.EventCallback;
+import org.jbpm.JbpmContext;
+import org.jbpm.command.Command;
+import org.jbpm.command.DeployProcessCommand;
+import org.jbpm.command.StartProcessInstanceCommand;
+import org.jbpm.ejb.LocalCommandService;
+import org.jbpm.ejb.LocalCommandServiceHome;
+import org.jbpm.graph.def.Event;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * Exercises for the {@linkplain JmsMessageServiceImpl JMS message service}.
+ * @author Alejandro Guizar
+ */
+public class JmsMessageTest extends ServletTestCase {
+
+ private LocalCommandService commandService;
+
+ private static LocalCommandServiceHome commandServiceHome;
+
+ static final int processExecutionCount = 20;
+ static final int maxWaitTime = 10000;
+
+ protected void setUp() throws Exception {
+ if (commandServiceHome == null) {
+ Context initialContext = new InitialContext();
+ try {
+ commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/LocalCommandServiceBean");
+ }
+ finally {
+ initialContext.close();
+ }
+ }
+ commandService = commandServiceHome.create();
+ log.info("### " + getName() + " started ###");
+ }
+
+ protected void tearDown() throws Exception {
+ log.info("### " + getName() + " done ###");
+ EventCallback.clear();
+ commandService = null;
+ }
+
+ public void testAsyncNode() {
+ deployProcess("<process-definition name='node'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a' async='true'>"
+ + " <transition to='end' />"
+ + " </node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("node").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(hasProcessEnded(processId));
+ }
+
+ public void testAsyncAction() {
+ deployProcess("<process-definition name='action'>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a'>"
+ + " <event type='node-enter'>"
+ + " <action async='true' expression='#{eventCallback.nodeEnter}' />"
+ + " </event>"
+ + " <event type='node-leave'>"
+ + " <action async='true' expression='#{eventCallback.nodeLeave}' />"
+ + " </event>"
+ + " <transition to='end'>"
+ + " <action async='true' expression='#{eventCallback.transition}' />"
+ + " </transition>"
+ + " </node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("action").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
+ EventCallback.waitForEvent(Event.EVENTTYPE_NODE_LEAVE);
+ EventCallback.waitForEvent(Event.EVENTTYPE_TRANSITION);
+ assertTrue(hasProcessEnded(processId));
+ }
+
+ public void testAsyncSequence() {
+ deployProcess("<process-definition name='sequence'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a' async='true'>"
+ + " <transition to='b' />"
+ + " </node>"
+ + " <node name='b' async='true'>"
+ + " <transition to='c' />"
+ + " </node>"
+ + " <node name='c' async='true'>"
+ + " <transition to='d' />"
+ + " </node>"
+ + " <node name='d' async='true'>"
+ + " <transition to='e' />"
+ + " </node>"
+ + " <node name='e' async='true'>"
+ + " <transition to='end' />"
+ + " </node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("sequence").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(hasProcessEnded(processId));
+ }
+
+ public void testAsyncFork() {
+ deployProcess("<process-definition name='fork'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='f' />"
+ + " </start-state>"
+ + " <fork name='f'>"
+ + " <transition name='a' to='a' />"
+ + " <transition name='b' to='b' />"
+ + " <transition name='c' to='c' />"
+ + " <transition name='d' to='d' />"
+ + " <transition name='e' to='e' />"
+ + " </fork>"
+ + " <node name='a'>"
+ + " <transition to='j' />"
+ + " </node>"
+ + " <node name='b' async='true'>"
+ + " <transition to='j' />"
+ + " </node>"
+ + " <node name='c' async='true'>"
+ + " <transition to='j' />"
+ + " </node>"
+ + " <node name='d' async='true'>"
+ + " <transition to='j' />"
+ + " </node>"
+ + " <node name='e' async='true'>"
+ + " <transition to='j' />"
+ + " </node>"
+ + " <join name='j'>"
+ + " <transition to='end' />"
+ + " </join>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("fork").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(hasProcessEnded(processId));
+ }
+
+ public void testAsyncExecutions() {
+ deployProcess("<process-definition name='execution'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}' />"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <node name='a' async='true'>"
+ + " <transition to='b' />"
+ + " </node>"
+ + " <node name='b'>"
+ + " <event type='node-enter'>"
+ + " <action async='true' expression='#{eventCallback.nodeEnter}' />"
+ + " </event>"
+ + " <transition to='c' />"
+ + " </node>"
+ + " <node name='c' async='true'>"
+ + " <transition to='d' />"
+ + " </node>"
+ + " <node name='d'>"
+ + " <event type='node-leave'>"
+ + " <action async='true' expression='#{eventCallback.nodeLeave}' />"
+ + " </event>"
+ + " <transition to='e' />"
+ + " </node>"
+ + " <node name='e' async='true'>"
+ + " <transition to='end' />"
+ + " </node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long[] processIds = new long[processExecutionCount];
+ for (int i = 0; i < processExecutionCount; i++) {
+ processIds[i] = launchProcess("execution").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_NODE_ENTER);
+ EventCallback.waitForEvent(Event.EVENTTYPE_NODE_LEAVE);
+ }
+ for (int i = 0; i < processExecutionCount; i++) {
+ waitForProcessEnd(processIds[i]);
+ assertTrue(hasProcessEnded(processIds[i]));
+ }
+ }
+
+ private ProcessDefinition deployProcess(String xml) {
+ return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
+ }
+
+ private ProcessInstance launchProcess(String processName) {
+ StartProcessInstanceCommand command = new StartProcessInstanceCommand();
+ command.setProcessName(processName);
+ command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
+ return (ProcessInstance) commandService.execute(command);
+ }
+
+ private boolean hasProcessEnded(final long processId) {
+ Boolean isFinished = (Boolean) commandService.execute(new Command() {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ return jbpmContext.loadProcessInstance(processId).hasEnded();
+ }
+ });
+ return isFinished.booleanValue();
+ }
+
+ private void waitForProcessEnd(long processId) {
+ long startTime = System.currentTimeMillis();
+ do {
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END, 1000);
+ if (System.currentTimeMillis() - startTime > maxWaitTime) {
+ log.warn("process " + processId + " took too long");
+ break;
+ }
+ } while (!hasProcessEnded(processId));
+ }
+
+ private static Log log = LogFactory.getLog(JmsMessageTest.class);
+}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/persistence/jta/JtaDbPersistenceTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/persistence/jta/JtaDbPersistenceTest.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/persistence/jta/JtaDbPersistenceTest.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -42,7 +42,6 @@
protected void setUp() throws Exception {
jbpmConfiguration = JbpmConfiguration.getInstance();
- getUserTransaction();
}
public void testUserTx() throws Exception {
@@ -73,7 +72,8 @@
private long deployProcess() throws Exception {
if (definitionId == 0) {
try {
- if (tx != null) tx.begin();
+ if (tx != null)
+ tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
@@ -90,16 +90,19 @@
definitionId = definition.getId();
}
catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
+ if (tx == null)
+ jbpmContext.setRollbackOnly();
throw e;
}
finally {
jbpmContext.close();
}
- if (tx != null) tx.commit();
+ if (tx != null)
+ tx.commit();
}
catch (Exception e) {
- if (tx != null) tx.rollback();
+ if (tx != null)
+ tx.rollback();
throw e;
}
}
@@ -108,7 +111,8 @@
private long launchProcess(long definitionId) throws Exception {
try {
- if (tx != null) tx.begin();
+ if (tx != null)
+ tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
ProcessInstance instance;
try {
@@ -120,54 +124,62 @@
jbpmContext.save(instance);
}
catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
+ if (tx == null)
+ jbpmContext.setRollbackOnly();
throw e;
}
finally {
jbpmContext.close();
}
- if (tx != null) tx.commit();
+ if (tx != null)
+ tx.commit();
return instance.getId();
}
catch (Exception e) {
- if (tx != null) tx.rollback();
+ if (tx != null)
+ tx.rollback();
throw e;
}
}
private void signal(long instanceId) throws Exception {
try {
- if (tx != null) tx.begin();
+ if (tx != null)
+ tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
assertEquals(tx == null, isTxCreatedByService(jbpmContext));
ProcessInstance instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
instance.signal();
- if (rollback && tx == null) jbpmContext.setRollbackOnly();
+ if (rollback && tx == null)
+ jbpmContext.setRollbackOnly();
}
catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
+ if (tx == null)
+ jbpmContext.setRollbackOnly();
throw e;
}
finally {
jbpmContext.close();
}
if (tx != null) {
- if (rollback)
+ if (rollback)
tx.rollback();
else
tx.commit();
}
}
catch (Exception e) {
- if (tx != null) tx.rollback();
+ if (tx != null)
+ tx.rollback();
throw e;
}
}
private boolean hasEnded(long instanceId) throws Exception {
try {
- if (tx != null) tx.begin();
+ if (tx != null)
+ tx.begin();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
ProcessInstance instance;
try {
@@ -175,17 +187,20 @@
instance = jbpmContext.loadProcessInstanceForUpdate(instanceId);
}
catch (RuntimeException e) {
- if (tx == null) jbpmContext.setRollbackOnly();
+ if (tx == null)
+ jbpmContext.setRollbackOnly();
throw e;
}
finally {
jbpmContext.close();
}
- if (tx != null) tx.commit();
+ if (tx != null)
+ tx.commit();
return instance.hasEnded();
}
catch (Exception e) {
- if (tx != null) tx.rollback();
+ if (tx != null)
+ tx.rollback();
throw e;
}
}
Modified: jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerTest.java 2008-10-16 13:32:12 UTC (rev 2554)
+++ jbpm3/branches/jpdl-3.2.3.GA_JBPM-1704/enterprise/src/test/java/org/jbpm/scheduler/ejbtimer/EjbSchedulerTest.java 2008-10-16 22:56:53 UTC (rev 2555)
@@ -21,257 +21,292 @@
*/
package org.jbpm.scheduler.ejbtimer;
+import java.util.Collections;
+
+import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.cactus.ServletTestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jbpm.enterprise.test.EventCallback;
import org.jbpm.JbpmContext;
import org.jbpm.command.Command;
import org.jbpm.command.DeployProcessCommand;
import org.jbpm.command.StartProcessInstanceCommand;
import org.jbpm.ejb.LocalCommandService;
import org.jbpm.ejb.LocalCommandServiceHome;
-import org.jbpm.enterprise.test.ActionRecorder;
-import org.jbpm.enterprise.test.GetCurrentTime;
-import org.jbpm.enterprise.test.Recorder;
+import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
+/**
+ * Exercises for the {@linkplain EntitySchedulerService EJB scheduler service}.
+ * @author Alejandro Guizar
+ */
public class EjbSchedulerTest extends ServletTestCase {
-
+
private LocalCommandService commandService;
private static LocalCommandServiceHome commandServiceHome;
+ private static final Log log = LogFactory.getLog(EjbSchedulerTest.class);
+
protected void setUp() throws Exception {
if (commandServiceHome == null) {
- InitialContext initialContext = new InitialContext();
- commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/LocalCommandServiceBean");
+ Context initialContext = new InitialContext();
+ try {
+ commandServiceHome = (LocalCommandServiceHome) initialContext.lookup("java:comp/env/ejb/LocalCommandServiceBean");
+ }
+ finally {
+ initialContext.close();
+ }
}
commandService = commandServiceHome.create();
+ log.info("### " + getName() + " started ###");
}
protected void tearDown() throws Exception {
+ log.info("### " + getName() + " done ###");
commandService = null;
}
public void testScheduleFuture() throws Exception {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='timer included'>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <state name='a'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- launchProcess("timer included");
- assertEquals(0, Recorder.executions);
- Thread.sleep(500);
- assertEquals(0, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
+ deployProcess("<process-definition name='future'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <state name='a'>"
+ + " <timer duedate='1 second' transition='timeout' />"
+ + " <transition name='timeout' to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("future").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(isProcessFinished(processId));
}
public void testSchedulePast() throws Exception {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='timer included'>" +
- " <start-state>" +
- " <transition to='a'>" +
- " <action class='" + GetCurrentTime.class.getName() + "'>" +
- " <variable>now</variable>" +
- " </action>" +
- " </transition>" +
- " </start-state>" +
- " <state name='a'>" +
- " <timer duedate='#{now} - 1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- launchProcess("timer included");
- assertEquals(0, Recorder.executions);
- Thread.sleep(500);
- assertEquals(1, Recorder.executions);
+ deployProcess("<process-definition name='past'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <state name='a'>"
+ + " <timer duedate='-1 second' transition='timeout' />"
+ + " <transition name='timeout' to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("past").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(isProcessFinished(processId));
}
public void testScheduleRepeat() throws Exception {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='repeat included'>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <state name='a'>" +
- " <timer duedate='1 second' repeat='2 seconds'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- long tokenId = launchProcess("repeat included").getRootToken().getId();
- assertEquals(0, Recorder.executions);
- Thread.sleep(500);
- assertEquals(0, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(2, Recorder.executions);
- cancelTimer("a", tokenId);
+ deployProcess("<process-definition name='repeat'>"
+ + " <event type='timer'>"
+ + " <action expression='#{eventCallback.timer}'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <state name='a'>"
+ + " <timer duedate='1 second' repeat='1 second' />"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("repeat").getId();
+ for (int i = 0; i < 3; i++) {
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
+ assertEquals("a", getProcessState(processId));
+ }
+ signalProcess(processId);
+ assertTrue(isProcessFinished(processId));
}
public void testCancel() throws Exception {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='repeat included'>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <state name='a'>" +
- " <timer duedate='1 second' repeat='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- long tokenId = launchProcess("repeat included").getRootToken().getId();
- assertEquals(0, Recorder.executions);
- Thread.sleep(500);
- assertEquals(0, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
- cancelTimer("a", tokenId);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(1, Recorder.executions);
+ deployProcess("<process-definition name='cancel'>"
+ + " <event type='timer'>"
+ + " <action expression='#{eventCallback.timer}'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <state name='a'>"
+ + " <timer duedate='1 second' repeat='1 second' />"
+ + " <transition to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ ProcessInstance process = launchProcess("cancel");
+ long processId = process.getId();
+ // first expiration
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
+ assertEquals("a", getProcessState(processId));
+ // repeated expiration
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
+ assertEquals("a", getProcessState(processId));
+ // no more expirations
+ cancelTimer("a", process.getRootToken().getId());
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER, 2000);
+ signalProcess(processId);
+ assertTrue(isProcessFinished(processId));
}
- public void testScheduleMultiple() throws Exception {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='timers included'>" +
- " <start-state>" +
- " <transition to='a' />" +
- " </start-state>" +
- " <state name='a'>" +
- " <timer duedate='500 milliseconds' transition='next'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " <transition name='next' to='b' />" +
- " </state>" +
- " <state name='b'>" +
- " <timer duedate='500 milliseconds' transition='next'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " <transition name='next' to='c' />" +
- " </state>" +
- " <state name='c'>" +
- " <timer duedate='500 milliseconds' transition='next'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " <transition name='next' to='d' />" +
- " </state>" +
- " <state name='d'>" +
- " <timer duedate='500 milliseconds' transition='next'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " <transition name='next' to='e' />" +
- " </state>" +
- " <state name='e'>" +
- " <timer duedate='500 milliseconds'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- launchProcess("timers included");
- assertEquals(0, Recorder.executions);
- Thread.sleep(250);
- assertEquals(0, Recorder.executions);
- for (int i = 1; i <= 5; i++) {
- Thread.sleep(500);
- assertEquals(i, Recorder.executions);
+ public void testScheduleSequence() throws Exception {
+ deployProcess("<process-definition name='sequence'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <event type='timer'>"
+ + " <action expression='#{eventCallback.timer}'/>"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='a' />"
+ + " </start-state>"
+ + " <state name='a'>"
+ + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <transition name='timeout' to='b' />"
+ + " </state>"
+ + " <state name='b'>"
+ + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <transition name='timeout' to='c' />"
+ + " </state>"
+ + " <state name='c'>"
+ + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <transition name='timeout' to='d' />"
+ + " </state>"
+ + " <state name='d'>"
+ + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <transition name='timeout' to='e' />"
+ + " </state>"
+ + " <state name='e'>"
+ + " <timer duedate='500 milliseconds' transition='timeout' />"
+ + " <transition name='timeout' to='end' />"
+ + " </state>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("sequence").getId();
+ char state = 'b';
+ for (int i = 0; i < 4; i++) {
+ EventCallback.waitForEvent(Event.EVENTTYPE_TIMER);
+ assertEquals(Character.toString(state++), getProcessState(processId));
}
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(isProcessFinished(processId));
}
- public void testScheduleConcurrent() throws InterruptedException {
- Recorder.resetCollections();
- deployProcess(
- "<process-definition name='timers included'>" +
- " <start-state>" +
- " <transition to='f' />" +
- " </start-state>" +
- " <fork name='f'>" +
- " <transition name='a' to='a' />" +
- " <transition name='b' to='b' />" +
- " <transition name='c' to='c' />" +
- " <transition name='d' to='d' />" +
- " <transition name='e' to='e' />" +
- " </fork>" +
- " <state name='a'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- " <state name='b'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- " <state name='c'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- " <state name='d'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- " <state name='e'>" +
- " <timer duedate='1 second'>" +
- " <action class='" + ActionRecorder.class.getName() + "' />" +
- " </timer>" +
- " </state>" +
- "</process-definition>");
- launchProcess("timers included");
- assertEquals(0, Recorder.executions);
- Thread.sleep(500);
- assertEquals(0, Recorder.executions);
- Thread.sleep(1000);
- assertEquals(5, Recorder.executions);
+ public void testScheduleFork() throws InterruptedException {
+ deployProcess("<process-definition name='fork'>"
+ + " <event type='process-end'>"
+ + " <action expression='#{eventCallback.processEnd}'/>"
+ + " </event>"
+ + " <start-state>"
+ + " <transition to='f' />"
+ + " </start-state>"
+ + " <fork name='f'>"
+ + " <transition name='a' to='a' />"
+ + " <transition name='b' to='b' />"
+ + " <transition name='c' to='c' />"
+ + " <transition name='d' to='d' />"
+ + " <transition name='e' to='e' />"
+ + " </fork>"
+ + " <state name='a'>"
+ + " <timer duedate='0.25 seconds' transition='timeout' />"
+ + " <transition name='timeout' to='j' />"
+ + " </state>"
+ + " <state name='b'>"
+ + " <timer duedate='0.5 seconds' transition='timeout' />"
+ + " <transition name='timeout' to='j' />"
+ + " </state>"
+ + " <state name='c'>"
+ + " <timer duedate='0.75 seconds' transition='timeout' />"
+ + " <transition name='timeout' to='j' />"
+ + " </state>"
+ + " <state name='d'>"
+ + " <timer duedate='1 second' transition='timeout' />"
+ + " <transition name='timeout' to='j' />"
+ + " </state>"
+ + " <state name='e'>"
+ + " <timer duedate='1.25 second' transition='timeout' />"
+ + " <transition name='timeout' to='j' />"
+ + " </state>"
+ + " <join name='j'>"
+ + " <transition to='end' />"
+ + " </join>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
+ long processId = launchProcess("fork").getId();
+ EventCallback.waitForEvent(Event.EVENTTYPE_PROCESS_END);
+ assertTrue(isProcessFinished(processId));
}
- protected ProcessDefinition deployProcess(String xml) {
+ private ProcessDefinition deployProcess(String xml) {
return (ProcessDefinition) commandService.execute(new DeployProcessCommand(xml));
}
-
- protected ProcessInstance launchProcess(final String processName) {
+
+ private ProcessInstance launchProcess(String processName) {
StartProcessInstanceCommand command = new StartProcessInstanceCommand();
command.setProcessName(processName);
+ command.setVariables(Collections.singletonMap("eventCallback", new EventCallback()));
return (ProcessInstance) commandService.execute(command);
}
- protected void cancelTimer(String timerName, long tokenId) {
- commandService.execute(new CancelTimerCommand(timerName, tokenId));
+ private void signalProcess(final long processId) {
+ commandService.execute(new Command() {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ jbpmContext.loadProcessInstanceForUpdate(processId).signal();
+ return null;
+ }
+ });
}
- protected static class CancelTimerCommand implements Command {
- final String timerName;
- final long tokenId;
- private static final long serialVersionUID = 1L;
- public CancelTimerCommand(String timerName, long tokenId) {
- this.timerName = timerName;
- this.tokenId = tokenId;
- }
- public Object execute(JbpmContext jbpmContext) throws Exception {
- Token token = jbpmContext.loadToken(tokenId);
- jbpmContext.getJobSession().cancelTimersByName(timerName, token);
- return null;
- }
+ private String getProcessState(final long processId) {
+ return (String) commandService.execute(new Command() {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ return jbpmContext.loadProcessInstance(processId).getRootToken().getNode().getName();
+ }
+ });
}
+
+ private boolean isProcessFinished(final long processId) {
+ Boolean isFinished = (Boolean) commandService.execute(new Command() {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ return jbpmContext.loadProcessInstance(processId).hasEnded();
+ }
+ });
+ return isFinished.booleanValue();
+ }
+
+ private void cancelTimer(final String timerName, final long tokenId) {
+ commandService.execute(new Command() {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(JbpmContext jbpmContext) throws Exception {
+ Token token = jbpmContext.loadToken(tokenId);
+ jbpmContext.getServices().getSchedulerService().deleteTimersByName(timerName, token);
+ return null;
+ }
+ });
+ }
}
17 years, 6 months
JBoss JBPM SVN: r2554 - in jbpm3/branches/tbaeyens/modules/core/src: main/java/org/jbpm/graph/exe and 5 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-10-16 09:32:12 -0400 (Thu, 16 Oct 2008)
New Revision: 2554
Modified:
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java
jbpm3/branches/tbaeyens/modules/core/src/main/resources/hibernate.common.xml
jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/SignalLog.hbm.xml
jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/TransitionLog.hbm.xml
jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
Log:
process instance deletion fixes
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -21,12 +21,16 @@
*/
package org.jbpm.db;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
+import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
@@ -37,6 +41,8 @@
import org.jbpm.job.Job;
import org.jbpm.job.executor.JobExecutor;
import org.jbpm.logging.log.ProcessLog;
+import org.jbpm.persistence.db.DbPersistenceService;
+import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.taskmgmt.exe.TaskInstance;
public abstract class AbstractDbTestCase extends AbstractJbpmTestCase
@@ -68,55 +74,37 @@
{
resetMembers();
closeJbpmContext();
+ ensureCleanDatabase();
- if (hasLeftOverRecords())
- {
- dropSchema();
- // Failing here, will probably hide a potential previous failure.
- // Is there a better way to fail without hiding a potential cause?
- fail("Test failed to cleanup database records");
- }
-
super.tearDown();
}
- private boolean hasLeftOverRecords()
+ private void ensureCleanDatabase()
{
- boolean foundLeftOvers = false;
- JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
- Session session = jbpmContext.getSession();
- try
- {
- if (session.createQuery("from " + ProcessDefinition.class.getName()).list().size() > 0)
- {
- System.err.println("FIXME: left over ProcessDefinition after: " + getShortName());
- foundLeftOvers = true;
+ boolean hasLeftOvers = false;
+
+ DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) getJbpmConfiguration().getServiceFactory("persistence");
+ Configuration configuration = dbPersistenceServiceFactory.getConfiguration();
+ JbpmSchema jbpmSchema = new JbpmSchema(configuration);
+
+ Map jbpmTablesRecordCount = jbpmSchema.getJbpmTablesRecordCount();
+ Iterator iter = jbpmTablesRecordCount.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ String tableName = (String) entry.getKey();
+ Integer count = (Integer) entry.getValue();
+
+ if ( (count==null)
+ || (count != 0)
+ ) {
+ hasLeftOvers = true;
+ System.err.println("FIXME: "+count+" left over records in " + tableName);
}
- if (session.createQuery("from " + ProcessInstance.class.getName()).list().size() > 0)
- {
- System.err.println("FIXME: left over ProcessInstance after: " + getShortName());
- foundLeftOvers = true;
- }
- if (session.createQuery("from " + ProcessLog.class.getName()).list().size() > 0)
- {
- System.err.println("FIXME: left over ProcessLog after: " + getShortName());
- foundLeftOvers = true;
- }
- if (session.createQuery("from " + Token.class.getName()).list().size() > 0)
- {
- System.err.println("FIXME: left over Token after: " + getShortName());
- foundLeftOvers = true;
- }
}
- catch (Exception ex)
- {
- System.err.println("FIXME: cannot query left overs: " + ex);
+
+ if (hasLeftOvers) {
+ jbpmSchema.cleanSchema();
}
- finally
- {
- jbpmContext.close();
- }
- return foundLeftOvers;
}
public void beginSessionTransaction()
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -29,6 +29,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Query;
@@ -38,6 +39,7 @@
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.graph.node.ProcessState;
+import org.jbpm.logging.log.ProcessLog;
/**
* are the graph related database operations.
@@ -379,52 +381,45 @@
public void deleteProcessInstance(ProcessInstance processInstance, boolean includeTasks, boolean includeJobs) {
if (processInstance==null) throw new JbpmException("processInstance is null in JbpmSession.deleteProcessInstance()");
+ log.debug("deleting process instance "+processInstance.getId());
+ session.flush();
try {
- // find the tokens
- Query query = session.getNamedQuery("GraphSession.findTokensForProcessInstance");
- query.setEntity("processInstance", processInstance);
- List tokens = query.list();
-
- if (!tokens.isEmpty()) {
- // deleteSubProcesses
- Iterator iter = tokens.iterator();
- while (iter.hasNext()) {
- Token token = (Token) iter.next();
- deleteSubProcesses(token);
- }
- }
-
// jobs
if (includeJobs) {
- query = session.getNamedQuery("GraphSession.deleteJobsForProcessInstance");
+ log.debug("deleting jobs for process instance "+processInstance.getId());
+ Query query = session.getNamedQuery("GraphSession.deleteJobsForProcessInstance");
query.setEntity("processInstance", processInstance);
query.executeUpdate();
+ session.flush();
}
// tasks
if (includeTasks) {
- query = session.getNamedQuery("GraphSession.findTaskInstanceIdsForProcessInstance");
+ Query query = session.getNamedQuery("GraphSession.findTaskInstanceIdsForProcessInstance");
query.setEntity("processInstance", processInstance);
List taskInstanceIds = query.list();
- query = session.getNamedQuery("GraphSession.deleteTaskInstancesById");
- query.setParameterList("taskInstanceIds", taskInstanceIds);
- }
-
- if (!tokens.isEmpty()) {
- // delete the logs for all the process instance's tokens
- query = session.getNamedQuery("GraphSession.selectLogsForTokens");
- query.setParameterList("tokens", tokens);
- List logs = query.list();
- Iterator iter = logs.iterator();
- while (iter.hasNext()) {
- session.delete(iter.next());
+ if ( (taskInstanceIds!=null)
+ && (!taskInstanceIds.isEmpty())
+ ) {
+ log.debug("deleting tasks "+taskInstanceIds+" for process instance "+processInstance.getId());
+ query = session.getNamedQuery("GraphSession.deleteTaskInstancesById");
+ query.setParameterList("taskInstanceIds", taskInstanceIds);
}
+ session.flush();
}
- // then delete the process instance
+ // delete the logs
+ deleteLogs(processInstance);
+
+ // delete the tokens and subprocess instances
+ deleteSubProcesses(processInstance.getRootToken());
+
+ // add the process instance
+ log.debug("deleting process instance "+processInstance.getId());
session.delete(processInstance);
-
+ session.flush();
+
} catch (Exception e) {
log.error(e);
jbpmSession.handleException();
@@ -432,33 +427,40 @@
}
}
- void deleteSubProcesses(Token token) {
- Query query = session.getNamedQuery("GraphSession.findSubProcessInstances");
- query.setEntity("processInstance", token.getProcessInstance());
- List processInstances = query.list();
-
- if (processInstances == null || processInstances.isEmpty()) {
- return;
- }
-
- Iterator iter = processInstances.iterator();
+ void deleteLogs(ProcessInstance processInstance) {
+ Query query = session.getNamedQuery("GraphSession.findLogsForProcessInstance");
+ query.setEntity("processInstance", processInstance);
+ List logs = query.list();
+ Iterator iter = logs.iterator();
while (iter.hasNext()) {
- ProcessInstance subProcessInstance = (ProcessInstance) iter.next();
- subProcessInstance.setSuperProcessToken(null);
- token.setSubProcessInstance(null);
- deleteProcessInstance(subProcessInstance);
- session.flush();
+ ProcessLog processLog = (ProcessLog) iter.next();
+ session.delete(processLog);
}
-
- if (token.getChildren()!=null) {
- iter = token.getChildren().values().iterator();
+ }
+
+ void deleteSubProcesses(Token token) {
+ if (token!=null) {
+ Query query = session.getNamedQuery("GraphSession.findSubProcessInstances");
+ query.setEntity("processInstance", token.getProcessInstance());
+ List processInstances = query.list();
+
+ if (processInstances == null || processInstances.isEmpty()) {
+ log.debug("no subprocesses to delete for token "+token.getId());
+ return;
+ }
+
+ Iterator iter = processInstances.iterator();
while (iter.hasNext()) {
- Token child = (Token) iter.next();
- deleteSubProcesses(child);
+ ProcessInstance subProcessInstance = (ProcessInstance) iter.next();
+ subProcessInstance.setSuperProcessToken(null);
+ token.setSubProcessInstance(null);
+ log.debug("deleting sub process "+subProcessInstance.getId());
+ deleteProcessInstance(subProcessInstance);
}
}
}
+
public static class AverageNodeTimeEntry {
private long nodeId;
private String nodeName;
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -35,8 +35,10 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -210,7 +212,41 @@
}
return jbpmTableNames;
}
+
+ public Map getJbpmTablesRecordCount() {
+ Map recordCounts = new HashMap();
+
+ String sql = null;
+
+ try
+ {
+ Iterator iter = getJbpmTables().iterator();
+ createConnection();
+ while (iter.hasNext()) {
+ statement = connection.createStatement();
+ String tableName = (String) iter.next();
+ sql = "SELECT COUNT(*) FROM "+tableName;
+ ResultSet resultSet = statement.executeQuery(sql);
+ resultSet.next();
+ int count = resultSet.getInt(1);
+ resultSet.close();
+ statement.close();
+ recordCounts.put(tableName, count);
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new JbpmException("couldn't execute sql '" + sql + "'", e);
+ }
+ finally
+ {
+ closeConnection();
+ }
+
+ return recordCounts;
+ }
+
public void dropSchema()
{
execute(getDropSql());
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -663,7 +663,7 @@
public boolean isLocked() {
return lock!=null;
}
-
+
// getters and setters //////////////////////////////////////////////////////
public long getId() {
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/java/org/jbpm/logging/log/ProcessLog.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -82,4 +82,7 @@
public int getIndex() {
return index;
}
+ public List getChildren() {
+ return null;
+ }
}
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/resources/hibernate.common.xml 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/resources/hibernate.common.xml 2008-10-16 13:32:12 UTC (rev 2554)
@@ -25,7 +25,7 @@
<property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<!-- logging properties -->
- <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.format_sql">false</property>
<property name="hibernate.use_sql_comments">true</property>
<!-- ############################################ -->
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2008-10-16 13:32:12 UTC (rev 2554)
@@ -133,14 +133,6 @@
]]>
</query>
- <query name="GraphSession.findTokensForProcessInstance">
- <![CDATA[
- select token
- from org.jbpm.graph.exe.Token token
- where token.processInstance = :processInstance
- ]]>
- </query>
-
<query name="GraphSession.findTokensForProcessInNode">
<![CDATA[
select token
@@ -158,15 +150,16 @@
and processInstance.key = :key
]]>
</query>
-
- <query name="GraphSession.selectLogsForTokens">
+
+ <query name="GraphSession.findLogsForProcessInstance">
<![CDATA[
select pl
from org.jbpm.logging.log.ProcessLog as pl
- where pl.token in (:tokens)
+ where pl.token.processInstance = :processInstance
]]>
</query>
+
<query name="GraphSession.findTaskInstanceIdsForProcessInstance">
<![CDATA[
select t
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2008-10-16 13:32:12 UTC (rev 2554)
@@ -7,7 +7,7 @@
<hibernate-mapping auto-import="false" default-access="field">
<subclass name="org.jbpm.graph.log.ActionLog"
- extends="org.jbpm.logging.log.ProcessLog"
+ extends="org.jbpm.logging.log.CompositeLog"
discriminator-value="A">
<property name="exception" column="EXCEPTION_" type="text"/>
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/SignalLog.hbm.xml
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/SignalLog.hbm.xml 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/SignalLog.hbm.xml 2008-10-16 13:32:12 UTC (rev 2554)
@@ -7,7 +7,7 @@
<hibernate-mapping auto-import="false" default-access="field">
<subclass name="org.jbpm.graph.log.SignalLog"
- extends="org.jbpm.logging.log.ProcessLog"
+ extends="org.jbpm.logging.log.CompositeLog"
discriminator-value="S">
<many-to-one name="transition" column="TRANSITION_" class="org.jbpm.graph.def.Transition" foreign-key="FK_LOG_TRANSITION" />
</subclass>
Modified: jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/TransitionLog.hbm.xml
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/TransitionLog.hbm.xml 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/main/resources/org/jbpm/graph/log/TransitionLog.hbm.xml 2008-10-16 13:32:12 UTC (rev 2554)
@@ -7,7 +7,7 @@
<hibernate-mapping auto-import="false" default-access="field">
<subclass name="org.jbpm.graph.log.TransitionLog"
- extends="org.jbpm.logging.log.ProcessLog"
+ extends="org.jbpm.logging.log.CompositeLog"
discriminator-value="T">
<many-to-one name="transition"
Modified: jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java
===================================================================
--- jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-10-16 10:53:31 UTC (rev 2553)
+++ jbpm3/branches/tbaeyens/modules/core/src/test/java/org/jbpm/jbpm983/JBPM983Test.java 2008-10-16 13:32:12 UTC (rev 2554)
@@ -113,30 +113,20 @@
public void testConcurrentJobs() throws Exception
{
- if (true)
- {
- System.out.println("FIXME [JBPM-1736]: Cleanup JBPM983Test");
- return;
- }
-
assertTrue(getJbpmConfiguration().getJobExecutor().getNbrOfThreads() > 1);
log.info("### TEST: deploy + start processes ###");
ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlString(SUBPROCESS_XML);
+ jbpmContext.deployProcessDefinition(subProcessDefinition);
+
+ newTransaction();
+
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(PROCESS_XML);
+ jbpmContext.deployProcessDefinition(processDefinition);
- JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
- try
- {
- jbpmContext.deployProcessDefinition(subProcessDefinition);
- jbpmContext.deployProcessDefinition(processDefinition);
- }
- finally
- {
- jbpmContext.close();
- }
-
+ newTransaction();
+
// create test properties
Map testVariables = new HashMap();
testVariables.put("test", "true");
@@ -147,18 +137,11 @@
{
log.info("#################### TEST: starting process " + i + " ####################");
- jbpmContext = getJbpmConfiguration().createJbpmContext();
- try
- {
- ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("superprocess");
- pi.getContextInstance().addVariables(testVariables);
- pi.signal();
- piIds[i] = pi.getId();
- }
- finally
- {
- jbpmContext.close();
- }
+ ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("superprocess");
+ pi.getContextInstance().addVariables(testVariables);
+ pi.signal();
+ piIds[i] = pi.getId();
+ newTransaction();
}
for (int i = 0; i < processCount; i++)
@@ -168,19 +151,18 @@
long piId = piIds[i];
waitFor(piId);
- jbpmContext = getJbpmConfiguration().createJbpmContext();
- try
- {
- ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
- assertEquals("end-state-success", pi.getRootToken().getNode().getName());
- }
- finally
- {
- jbpmContext.close();
- }
-
- log.info("#################### TEST: finished ####################");
+ ProcessInstance pi = jbpmContext.loadProcessInstance(piId);
+ assertEquals("end-state-success", pi.getRootToken().getNode().getName());
}
+
+ log.info("#################### TEST: cleanup ####################");
+
+ newTransaction();
+ graphSession.deleteProcessDefinition(processDefinition.getId());
+ newTransaction();
+ graphSession.deleteProcessDefinition(subProcessDefinition.getId());
+
+ session.flush();
}
protected void waitFor(long piId) throws Exception
@@ -199,7 +181,7 @@
log.info("waiting for workflow completion....");
try
{
- Thread.sleep(1000);
+ Thread.sleep(500);
}
catch (InterruptedException e)
{
@@ -232,13 +214,7 @@
String tokenName = executionContext.getToken().toString();
log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): begin");
-
- for (int i = 0; i < 5; i++)
- {
- log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): working...");
- Thread.sleep(100);
- }
-
+ Thread.sleep(50);
log.info("ACTION (process=" + processName + ",node=" + nodeName + ",token=" + tokenName + "): end");
executionContext.leaveNode();
17 years, 6 months
JBoss JBPM SVN: r2553 - in jbpm3/trunk/modules/gwt-console: server/src/main/java/org/jboss/bpm/console/server and 6 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-16 06:53:31 -0400 (Thu, 16 Oct 2008)
New Revision: 2553
Modified:
jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
Log:
Added suspend/resume capabilties to both the UI and the console server
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -36,7 +36,7 @@
private long parentId;
private String key;
- private enum STATE {CREATED, STARTED, SUSPENDED, ENDED};
+ public enum STATE {RUNNING, SUSPENDED, ENDED};
private Date startDate;
private Date endDate;
@@ -54,6 +54,13 @@
public ProcessInstance(long id, long parentId, Date startDate, Date endDate, boolean suspended)
{
+
+ if(null==startDate)
+ throw new IllegalArgumentException("An instance requires a start date");
+
+ if(endDate!=null && suspended)
+ throw new IllegalArgumentException("An instance cannot be ended and suspended at the same time");
+
this.instanceId = id;
this.parentId = parentId;
this.startDate = startDate;
@@ -62,16 +69,17 @@
initLifecycle();
}
+ /**
+ * If not ENDED or SUSPENDED the instance is RUNNING
+ */
private void initLifecycle()
{
if(hasEnded())
- this.lifecycle = new Lifecycle(STATE.ENDED);
+ this.lifecycle = new Lifecycle(this, STATE.ENDED);
else if(isSuspended())
- this.lifecycle = new Lifecycle(STATE.SUSPENDED);
- else if (isStarted())
- this.lifecycle = new Lifecycle(STATE.STARTED);
+ this.lifecycle = new Lifecycle(this, STATE.SUSPENDED);
else
- this.lifecycle = new Lifecycle(STATE.CREATED);
+ this.lifecycle = new Lifecycle(this, STATE.RUNNING);
this.state = lifecycle.getState();
}
@@ -115,6 +123,11 @@
return this.state;
}
+ public void setState(String nextState)
+ {
+ setState(STATE.valueOf(nextState));
+ }
+
public void setState(STATE nextState)
{
this.lifecycle = this.lifecycle.transitionTo(nextState);
@@ -143,32 +156,30 @@
this.endDate = endDate;
}
- public boolean isStarted()
+ public boolean isRunning()
{
- return this.startDate!=null;
+ return this.startDate!=null && !isSuspended();
}
public boolean hasEnded()
{
- return isStarted() && this.endDate!=null;
+ return this.startDate!=null
+ && this.endDate!=null;
}
public boolean isSuspended()
{
- return isStarted() && suspended;
+ return null==this.endDate && suspended;
}
-
- public void setSuspended(boolean suspended)
- {
- this.suspended = suspended;
- }
-
+
private class Lifecycle
{
private STATE current;
+ private ProcessInstance instance;
- public Lifecycle(STATE current)
+ public Lifecycle(ProcessInstance instance, STATE current)
{
+ this.instance = instance;
this.current = current;
}
@@ -177,27 +188,35 @@
Lifecycle nextLifecycle = null;
switch(next)
- {
- case STARTED:
- if(!STATE.ENDED.equals(current))
+ {
+ case SUSPENDED: // only RUNNING instances can be SUSPENDED
+ if(STATE.RUNNING.equals(current))
{
- nextLifecycle = new Lifecycle(next);
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = true;
+ break;
}
- break;
- case SUSPENDED:
- if(STATE.STARTED.equals(current))
+ else
{
- nextLifecycle = new Lifecycle(next);
+ throw new IllegalTransitionException(current, next);
+ }
+ case ENDED: // both RUNNING and SUSPENDED instances can be ENDED
+ if(STATE.RUNNING.equals(current) || STATE.SUSPENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = false;
+ instance.endDate = new Date();
break;
}
else
{
throw new IllegalTransitionException(current, next);
}
- case ENDED:
- if(STATE.STARTED.equals(current) || STATE.SUSPENDED.equals(current))
+ case RUNNING: // only SUSPENDED instances can become RUNNING
+ if(STATE.SUSPENDED.equals(current))
{
- nextLifecycle = new Lifecycle(next);
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = false;
break;
}
else
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -102,19 +102,21 @@
}
@POST
- @Path("instances/{id}/remove")
+ @Path("instances/{id}/state/{next}")
@Produces("application/json")
- public Response removeInstancesJSON(
+ public Response changeState(
@PathParam("id")
long instanceId,
+ @PathParam("next")
+ String next,
@Context
HttpServletRequest request)
{
- ProcessInstanceWrapper wrapper =
- new ProcessInstanceWrapper(getProcessDAO(request).removeInstance(instanceId));
- return createJsonResponse(wrapper);
+ getProcessDAO(request).changeState(instanceId, next);
+ return Response.ok().build();
}
+
private Response createJsonResponse(Object wrapper)
{
Gson gson = GsonFactory.createInstance();
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/ProcessDAO.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -43,5 +43,5 @@
ProcessInstance getInstanceById(long instanceId);
- List<ProcessInstance> removeInstance(long instanceId);
+ void changeState(long instanceId, String nextState);
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/JBPM3ProcessDAO.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -80,8 +80,13 @@
return Transform.processInstance(instance);
}
- public List<ProcessInstance> removeInstance(long instanceId)
+
+ public void changeState(long instanceId, String nextState)
{
- throw new RuntimeException("Not implemented");
+ org.jbpm.graph.exe.ProcessInstance p0 = delegate.getActualInstance(instanceId);
+ Transform.doTransition(p0, nextState);
+
+ // persist
+
}
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -103,27 +103,25 @@
return instances;
}
- public List<ProcessInstance> removeInstance(long instanceId)
+
+ public void changeState(long instanceId, String nextState)
{
- System.out.println("Remove instance " + instanceId);
+ System.out.println("Change instance state" + instanceId + " to " + nextState);
- ProcessInstance toBeRemoved = null;
+ ProcessInstance toBeChanged = null;
for(ProcessInstance instance : instances)
{
if(instanceId == instance.getInstanceId())
- toBeRemoved = instance;
+ toBeChanged = instance;
}
- if(null==toBeRemoved)
+ if(null==toBeChanged)
throw new IllegalArgumentException("No process with id " + instanceId);
- else
- instances.remove(toBeRemoved);
-
- return instances;
+
+ toBeChanged.setState(nextState);
}
-
public ProcessInstance getInstanceById(long instanceId)
{
ProcessInstance match = null;
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -45,4 +45,26 @@
long instanceId = i0.getId();
return new ProcessInstance(instanceId, processId, start, end, suspended);
}
+
+ public static void doTransition(org.jbpm.graph.exe.ProcessInstance p0, String nextState)
+ {
+ ProcessInstance instance = Transform.processInstance(p0);
+ instance.setState(nextState); // has lifecycle build in, hence the extra round
+
+ switch(instance.getState())
+ {
+ case ENDED:
+ p0.setEnd(instance.getEndDate());
+ p0.end();
+ break;
+ case SUSPENDED:
+ p0.suspend();
+ break;
+ case RUNNING:
+ if(p0.isSuspended())
+ p0.resume();
+ }
+
+ }
+
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-16 10:53:31 UTC (rev 2553)
@@ -40,9 +40,9 @@
<tr>
<td>POST</td>
- <td>/rs/process/instances/{instanceId}/remove</td>
- <td>Removes a particular process instance</td>
- <td>application/json</td>
+ <td>/rs/process/instances/{id}/state/{next}</td>
+ <td>Change instance state (RUNNING, SUSPENDED, ENDED)</td>
+ <td>*/*</td>
</tr>
<tr>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/RestURL.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -21,6 +21,8 @@
*/
package org.jboss.bpm.console.client;
+import org.jboss.bpm.console.client.model.ProcessInstance;
+
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@@ -72,16 +74,12 @@
return getBaseUrl() + "/rs/user/roles?roleCheck="+sb.toString();
}
+ @Deprecated
public String getRemoveDefinitionURL(long processId)
{
return getBaseUrl() + "/rs/process/definitions/" + processId + "/remove";
}
- public String getRemoveInstanceURL(long instanceId)
- {
- return getBaseUrl() + "/rs/process/instances/" + instanceId + "/remove";
- }
-
public String getProcessImageURL(long processId)
{
return getBaseUrl() + "/rs/jbpm3/definitions/" + processId + "/image";
@@ -96,4 +94,9 @@
{
return getBaseUrl() + "/rs/jbpm3/instances/" + instanceId + "/activeNodeInfo";
}
+
+ public String getStateChangeURL(long instanceId, ProcessInstance.STATE state)
+ {
+ return getBaseUrl() + "/rs/process/instances/" + instanceId + "/state/"+state;
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -80,7 +80,8 @@
if("yes".equals( btnID) )
{
ProcessInstance instance = row2InstanceMap.get(row);
- String url = view.getRestURL().getRemoveInstanceURL(instance.getInstanceId());
+ instance.setState(ProcessInstance.STATE.ENDED);
+ String url = view.getRestURL().getStateChangeURL(instance.getInstanceId(), instance.getState());
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
try
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -21,23 +21,26 @@
*/
package org.jboss.bpm.console.client.process;
+import com.google.gwt.http.client.*;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.core.Function;
+import com.gwtext.client.core.Position;
+import com.gwtext.client.data.Record;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.PaddedPanel;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.DateField;
+import com.gwtext.client.widgets.form.FieldSet;
+import com.gwtext.client.widgets.form.FormPanel;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.grid.RowSelectionModel;
+import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
import org.jboss.bpm.console.client.ConsoleView;
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.widgets.EditorView;
import org.jboss.bpm.console.client.widgets.UIConstants;
-import com.gwtext.client.widgets.form.FieldSet;
-import com.gwtext.client.widgets.form.TextField;
-import com.gwtext.client.widgets.form.DateField;
-import com.gwtext.client.widgets.form.FormPanel;
-import com.gwtext.client.widgets.PaddedPanel;
-import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.grid.RowSelectionModel;
-import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
-import com.gwtext.client.core.Position;
-import com.gwtext.client.core.Function;
-import com.gwtext.client.data.Record;
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
@@ -48,21 +51,25 @@
{
private ProcessDefinition parent;
+ private ProcessInstance selectedInstance;
+ private ConsoleView view;
+ private ProcessInstanceList instanceList;
public ProcessInstanceListEditor(ProcessDefinition proc, ConsoleView view)
{
super();
+ this.view = view;
this.setId(ProcessInstanceEditor.ID+"."+proc.getName());
parent = proc;
// ---------------
- ProcessInstanceList list = new ProcessInstanceList(
+ instanceList = new ProcessInstanceList(
proc, "Process Instances", view
);
- this.add(list);
+ this.add(instanceList);
// ---------------
@@ -100,9 +107,29 @@
formPanel.add(inner);
- final Button suspendButton = new Button("Suspend");
- final Button resumeButton = new Button("Resume");
+ final Button suspendButton = new Button("Suspend",
+ new ButtonListenerAdapter()
+ {
+ public void onClick(Button button, EventObject eventObject)
+ {
+ selectedInstance.setState(ProcessInstance.STATE.SUSPENDED);
+ persistStateChange();
+ }
+ }
+ );
+ final Button resumeButton = new Button("Resume",
+ new ButtonListenerAdapter()
+ {
+
+ public void onClick(Button button, EventObject eventObject)
+ {
+ selectedInstance.setState(ProcessInstance.STATE.RUNNING);
+ persistStateChange();
+ }
+ }
+ );
+
formPanel.addButton(suspendButton);
formPanel.addButton(resumeButton);
@@ -114,8 +141,8 @@
{
public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record)
{
- ProcessInstance pi = ProcessInstanceList.transform(record);
- if(pi.isSuspended())
+ selectedInstance = ProcessInstanceList.transform(record);
+ if(selectedInstance.isSuspended())
{
suspendButton.disable();
resumeButton.enable();
@@ -131,10 +158,10 @@
}
}
);
- list.getGrid().setSelectionModel(sm);
+ instanceList.getGrid().setSelectionModel(sm);
//select the first row after a little delay so that the rows are rendered
- list.getGrid().doOnRender(
+ instanceList.getGrid().doOnRender(
new Function()
{
public void execute() {
@@ -148,7 +175,40 @@
}
+ private void persistStateChange()
+ {
+ RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, view.getRestURL().getStateChangeURL(
+ selectedInstance.getInstanceId(), selectedInstance.getState())
+ );
+ try
+ {
+ rb.sendRequest(null,
+ new RequestCallback() {
+
+ public void onResponseReceived(Request request, Response response)
+ {
+ // success
+ instanceList.reloadStore();
+ selectedInstance = null;
+ }
+
+ public void onError(Request request, Throwable t)
+ {
+ // Unknown error
+ view.setError(t.getMessage());
+ t.printStackTrace(System.out);
+ }
+ });
+ }
+ catch (RequestException e1)
+ {
+ view.setError(e1.getMessage());
+ e1.printStackTrace();
+ }
+ }
+
+
public String getEditorId()
{
return getId();
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-16 09:53:22 UTC (rev 2552)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-16 10:53:31 UTC (rev 2553)
@@ -236,7 +236,7 @@
return grid;
}
- protected void reloadStore()
+ public void reloadStore()
{
store.load(0,PAGE_SIZE);
}
17 years, 6 months
JBoss JBPM SVN: r2552 - jbpm3/branches.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-10-16 05:53:22 -0400 (Thu, 16 Oct 2008)
New Revision: 2552
Added:
jbpm3/branches/tbaeyens/
Log:
creating personal tbaeyens branch for jbpm3
Copied: jbpm3/branches/tbaeyens (from rev 2551, jbpm3/trunk)
17 years, 6 months
JBoss JBPM SVN: r2551 - jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-16 05:06:48 -0400 (Thu, 16 Oct 2008)
New Revision: 2551
Modified:
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
Log:
Parse suspend attributes on ProcessInstance. Add suspend/resume buttons
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-16 07:37:50 UTC (rev 2550)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-16 09:06:48 UTC (rev 2551)
@@ -118,14 +118,7 @@
int i = 0;
for(Record r : records)
{
- Long id = Long.valueOf(r.getAsString("instanceId"));
- ProcessInstance pd = new ProcessInstance(
- id,
- Long.valueOf( r.getAsString("parentId")),
- r.getAsDate("startDate"),
- r.getAsDate("endDate"),
- r.getAsBoolean("suspended"));
-
+ ProcessInstance pd = transform(r);
row2InstanceMap.put(i, pd);
i++;
}
@@ -133,6 +126,17 @@
System.out.println("Loaded " + row2InstanceMap.size() + " records");
}
+ public static ProcessInstance transform(Record r)
+ {
+ ProcessInstance pd = new ProcessInstance(
+ Long.valueOf(r.getAsString("instanceId")),
+ Long.valueOf( r.getAsString("parentId")),
+ r.getAsDate("startDate"),
+ r.getAsDate("endDate"),
+ r.getAsBoolean("suspended"));
+ return pd;
+ }
+
protected ColumnModel createColumnModel()
{
final ColumnModel columnModel = new ColumnModel(
@@ -159,7 +163,8 @@
new StringFieldDef("key"),
new StringFieldDef("state"),
new DateFieldDef("startDate", DATE_FORMAT),
- new DateFieldDef("endDate", DATE_FORMAT)
+ new DateFieldDef("endDate", DATE_FORMAT),
+ new BooleanFieldDef("suspended")
}
);
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-16 07:37:50 UTC (rev 2550)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-16 09:06:48 UTC (rev 2551)
@@ -23,6 +23,7 @@
import org.jboss.bpm.console.client.ConsoleView;
import org.jboss.bpm.console.client.model.ProcessDefinition;
+import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.widgets.EditorView;
import org.jboss.bpm.console.client.widgets.UIConstants;
import com.gwtext.client.widgets.form.FieldSet;
@@ -31,6 +32,7 @@
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.PaddedPanel;
import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.grid.RowSelectionModel;
import com.gwtext.client.widgets.grid.event.RowSelectionListenerAdapter;
import com.gwtext.client.core.Position;
@@ -40,7 +42,7 @@
/**
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*
- * @see org.jboss.bpm.console.client.process.ProcessDefinitionList#onExamine(int)
+ * @see org.jboss.bpm.console.client.process.ProcessDefinitionList#onExamine(int)
*/
public class ProcessInstanceListEditor extends EditorView
{
@@ -49,9 +51,9 @@
public ProcessInstanceListEditor(ProcessDefinition proc, ConsoleView view)
{
- super();
+ super();
this.setId(ProcessInstanceEditor.ID+"."+proc.getName());
-
+
parent = proc;
// ---------------
@@ -86,7 +88,7 @@
fieldSet.setTitle("Process Instance Details");
fieldSet.setAutoHeight(true);
fieldSet.setBorder(false);
-
+
// ---------------
//the field names must match the data field values from the Store
fieldSet.add(new TextField("Id", "instanceId", 230));
@@ -98,6 +100,12 @@
formPanel.add(inner);
+ final Button suspendButton = new Button("Suspend");
+ final Button resumeButton = new Button("Resume");
+
+ formPanel.addButton(suspendButton);
+ formPanel.addButton(resumeButton);
+
// ----------------
final RowSelectionModel sm = new RowSelectionModel(true);
@@ -106,7 +114,20 @@
{
public void onRowSelect(RowSelectionModel sm, int rowIndex, Record record)
{
+ ProcessInstance pi = ProcessInstanceList.transform(record);
+ if(pi.isSuspended())
+ {
+ suspendButton.disable();
+ resumeButton.enable();
+ }
+ else
+ {
+ resumeButton.disable();
+ suspendButton.enable();
+ }
+
formPanel.getForm().loadRecord(record);
+ formPanel.doLayout();
}
}
);
@@ -124,7 +145,7 @@
panel.add(formPanel);
this.add(panel);
-
+
}
@@ -135,7 +156,7 @@
public String getTitle()
{
- return parent.getName();
+ return parent.getName();
}
17 years, 6 months