[jbpm-commits] JBoss JBPM SVN: r2544 - in jbpm3/trunk/modules/gwt-console: rpc/src/main/java/org/jboss/bpm/console/client/model/util and 5 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Oct 15 09:03:28 EDT 2008
Author: heiko.braun at jboss.com
Date: 2008-10-15 09:03:28 -0400 (Wed, 15 Oct 2008)
New Revision: 2544
Added:
jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
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/util/SimpleDateFormat.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/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.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:
Instance status and date formatting fixed
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstance.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -36,23 +36,46 @@
private long parentId;
private String key;
- private String status;
+ private enum STATE {CREATED, STARTED, SUSPENDED, ENDED};
+
private Date startDate;
private Date endDate;
+ private boolean suspended;
+
+ private STATE state; // gson is field based, hence why...
+
+ private transient Lifecycle lifecycle;
+
public ProcessInstance()
{
+ initLifecycle();
}
- public ProcessInstance(long id, long parentId, String status, Date startDate, Date endDate)
+ public ProcessInstance(long id, long parentId, Date startDate, Date endDate, boolean suspended)
{
this.instanceId = id;
this.parentId = parentId;
- this.status = status;
this.startDate = startDate;
this.endDate = endDate;
+ this.suspended = suspended;
+ initLifecycle();
}
+ private void initLifecycle()
+ {
+ if(hasEnded())
+ this.lifecycle = new Lifecycle(STATE.ENDED);
+ else if(isSuspended())
+ this.lifecycle = new Lifecycle(STATE.SUSPENDED);
+ else if (isStarted())
+ this.lifecycle = new Lifecycle(STATE.STARTED);
+ else
+ this.lifecycle = new Lifecycle(STATE.CREATED);
+
+ this.state = lifecycle.getState();
+ }
+
@XmlElement(name = "instanceId")
public long getInstanceId()
{
@@ -87,14 +110,15 @@
}
@XmlElement(name = "status")
- public String getStatus()
+ public STATE getState()
{
- return status;
+ return this.state;
}
- public void setStatus(String status)
+ public void setState(STATE nextState)
{
- this.status = status;
+ this.lifecycle = this.lifecycle.transitionTo(nextState);
+ this.state = this.lifecycle.getState();
}
@XmlElement(name = "start")
@@ -119,4 +143,86 @@
this.endDate = endDate;
}
+ public boolean isStarted()
+ {
+ return this.startDate!=null;
+ }
+
+ public boolean hasEnded()
+ {
+ return isStarted() && this.endDate!=null;
+ }
+
+ public boolean isSuspended()
+ {
+ return isStarted() && suspended;
+ }
+
+ public void setSuspended(boolean suspended)
+ {
+ this.suspended = suspended;
+ }
+
+ private class Lifecycle
+ {
+ private STATE current;
+
+ public Lifecycle(STATE current)
+ {
+ this.current = current;
+ }
+
+ public Lifecycle transitionTo(STATE next)
+ {
+ Lifecycle nextLifecycle = null;
+
+ switch(next)
+ {
+ case STARTED:
+ if(!STATE.ENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ }
+ break;
+ case SUSPENDED:
+ if(STATE.STARTED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ case ENDED:
+ if(STATE.STARTED.equals(current) || STATE.SUSPENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(next);
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ default:
+ throw new IllegalTransitionException(current, next);
+ }
+
+ return nextLifecycle;
+ }
+
+ public STATE getState()
+ {
+ return current;
+ }
+ }
+
+ private class IllegalTransitionException extends IllegalArgumentException
+ {
+
+ public IllegalTransitionException(STATE current, STATE next)
+ {
+ super("Illegal transition current " + current + " next " + next);
+ }
+ }
}
Modified: jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/rpc/src/main/java/org/jboss/bpm/console/client/model/util/SimpleDateFormat.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -21,6 +21,8 @@
public class SimpleDateFormat {
private String format;
private DateLocale locale = new DateLocale();
+ public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
/**
* Gets the support locale for formatting and parsing dates
@@ -34,6 +36,17 @@
this.locale = locale;
}
+ /**
+ * Use {@link #DEFAULT_FORMAT}
+ */
+ public SimpleDateFormat()
+ {
+ format = DEFAULT_FORMAT;
+ }
+
+ /**
+ * Use a custom format
+ */
public SimpleDateFormat(String pattern) {
format = pattern;
}
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/MockProcessDAO.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -51,12 +51,12 @@
final static List<ProcessInstance> instances = new ArrayList<ProcessInstance>();
static
{
- instances.add( new ProcessInstance(2, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(3, -1, "Stopped", new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12))));
- instances.add( new ProcessInstance(4, -1, "Ended", new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24))));
- instances.add( new ProcessInstance(5, -1, "Suspended", new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17))));
- instances.add( new ProcessInstance(6, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(7, -1, "Running", new Date(), null));
+ instances.add( new ProcessInstance(2, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(3, -1, new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12)), false));
+ instances.add( new ProcessInstance(4, -1, new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24)), false));
+ instances.add( new ProcessInstance(5, -1, new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17)), false));
+ instances.add( new ProcessInstance(6, -1, new Date(), null, true));
+ instances.add( new ProcessInstance(7, -1, new Date(), null, true));
}
public List<ProcessDefinition> getAllDefinitions()
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/dao/internal/Transform.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -37,10 +37,12 @@
}
public static ProcessInstance processInstance(org.jbpm.graph.exe.ProcessInstance i0)
- {
- // TODO: status?
+ {
Date start = i0.getStart();
Date end = i0.getEnd();
- return new ProcessInstance(i0.getId(), i0.getProcessDefinition().getId(), "Unknown", start, end);
+ boolean suspended = i0.isSuspended();
+ long processId = i0.getProcessDefinition().getId();
+ long instanceId = i0.getId();
+ return new ProcessInstance(instanceId, processId, start, end, suspended);
}
}
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java 2008-10-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/model/internal/MockProcessInstanceDAO.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -21,8 +21,8 @@
*/
package org.jboss.bpm.console.client.model.internal;
+import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.model.ProcessInstanceDAO;
-import org.jboss.bpm.console.client.model.ProcessInstance;
import java.util.ArrayList;
import java.util.Date;
@@ -37,12 +37,12 @@
final static List instances = new ArrayList();
static
{
- instances.add( new ProcessInstance(2, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(3, -1, "Stopped", new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12))));
- instances.add( new ProcessInstance(4, -1, "Ended", new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24))));
- instances.add( new ProcessInstance(5, -1, "Suspended", new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17))));
- instances.add( new ProcessInstance(6, -1, "Running", new Date(), null));
- instances.add( new ProcessInstance(7, -1, "Running", new Date(), null));
+ instances.add( new ProcessInstance(2, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(3, -1, new Date(System.currentTimeMillis()-(1000*60*120)), new Date(System.currentTimeMillis()-(1000*60*12)), false));
+ instances.add( new ProcessInstance(4, -1, new Date(System.currentTimeMillis()-(1000*60*60)), new Date(System.currentTimeMillis()-(1000*60*24)), false));
+ instances.add( new ProcessInstance(5, -1, new Date(System.currentTimeMillis()-(1000*60*90)), new Date(System.currentTimeMillis()-(1000*60*17)), false));
+ instances.add( new ProcessInstance(6, -1, new Date(), null, false));
+ instances.add( new ProcessInstance(7, -1, new Date(), null, false));
}
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -28,6 +28,7 @@
import com.gwtext.client.widgets.grid.ColumnConfig;
import com.gwtext.client.widgets.grid.ColumnModel;
import org.jboss.bpm.console.client.ConsoleView;
+import org.jboss.bpm.console.client.util.DateRenderer;
import org.jboss.bpm.console.client.model.ProcessDefinition;
import org.jboss.bpm.console.client.model.ProcessInstance;
import org.jboss.bpm.console.client.widgets.RemoteListView;
@@ -121,10 +122,9 @@
ProcessInstance pd = new ProcessInstance(
id,
Long.valueOf( r.getAsString("parentId")),
- r.getAsString("status"),
r.getAsDate("startDate"),
- r.getAsDate("endDate")
- );
+ r.getAsDate("endDate"),
+ r.getAsBoolean("suspended"));
row2InstanceMap.put(i, pd);
i++;
@@ -134,16 +134,16 @@
}
protected ColumnModel createColumnModel()
- {
+ {
final ColumnModel columnModel = new ColumnModel(
new ColumnConfig[]
{
new ColumnConfig("Instance ID", "instanceId", 75, true),
//new ColumnConfig("Process ID", "parentId", 25, true),
//new ColumnConfig("Key", "key", 50, true),
- new ColumnConfig("Status", "status", 100, true, null, "expand"),
- new ColumnConfig("Start Date", "startDate", 125, true),
- new ColumnConfig("End Date", "endDate", 125, true)
+ new ColumnConfig("State", "state", 100, true, null, "expand"),
+ new ColumnConfig("Start Date", "startDate", 125, true, new DateRenderer("startDate")),
+ new ColumnConfig("End Date", "endDate", 125, true, new DateRenderer("endDate"))
}
);
@@ -157,7 +157,7 @@
new IntegerFieldDef("instanceId"),
new IntegerFieldDef("parentId"),
new StringFieldDef("key"),
- new StringFieldDef("status"),
+ new StringFieldDef("state"),
new DateFieldDef("startDate", DATE_FORMAT),
new DateFieldDef("endDate", DATE_FORMAT)
}
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceListEditor.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -91,7 +91,7 @@
//the field names must match the data field values from the Store
fieldSet.add(new TextField("Id", "instanceId", 230));
fieldSet.add(new TextField("Key", "key", 230));
- fieldSet.add(new TextField("Status", "status", 230));
+ fieldSet.add(new TextField("State", "state", 230));
fieldSet.add(new DateField("Start Date", "startDate", 230));
fieldSet.add(new DateField("End Date", "endDate", 230));
Panel inner = new PaddedPanel(fieldSet, 0, 10, 0, 0);
Added: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java (rev 0)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.util;
+
+import com.gwtext.client.widgets.grid.Renderer;
+import com.gwtext.client.widgets.grid.CellMetadata;
+import com.gwtext.client.data.Store;
+import com.gwtext.client.data.Record;
+
+import java.util.Date;
+
+import org.jboss.bpm.console.client.model.util.SimpleDateFormat;
+
+/**
+ * Renders a Date according to {@link org.jboss.bpm.console.client.model.util.SimpleDateFormat#DEFAULT_FORMAT}
+ *
+ * @author Heiko.Braun <heiko.braun at jboss.com>
+ */
+public class DateRenderer implements Renderer
+{
+ private String fieldName;
+
+ public DateRenderer(String fieldName)
+ {
+ this.fieldName = fieldName;
+ }
+
+ /**
+ * Returns an empty string (field is null) or a formatted date (field is set).
+ */
+ public String render(Object value, CellMetadata cellMetadata, Record record,
+ int rowIndex, int colNum, Store store)
+ {
+ String s = "";
+ SimpleDateFormat df = new SimpleDateFormat();
+ Date d = record.getAsDate(fieldName);
+ if(d!=null)
+ s = df.format(d);
+
+ return s;
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/util/DateRenderer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-15 09:42:59 UTC (rev 2543)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/java/org/jboss/bpm/console/client/widgets/RemoteListView.java 2008-10-15 13:03:28 UTC (rev 2544)
@@ -132,7 +132,7 @@
pagingToolbar.setPageSize(PAGE_SIZE);
pagingToolbar.setDisplayInfo(true);
pagingToolbar.setDisplayMsg("{0} - {1} of {2}");
- pagingToolbar.setEmptyMsg("No topics to display");
+ pagingToolbar.setEmptyMsg("No entities to display");
pagingToolbar.addButton(
new ToolbarButton("Examine", new ButtonListenerAdapter() {
More information about the jbpm-commits
mailing list