Overlord SVN: r1000 - in activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model: metric and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-11 04:31:25 -0500 (Thu, 11 Mar 2010)
New Revision: 1000
Modified:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java
Log:
Fix activity average calculation
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -82,5 +82,5 @@
* @param processInstance the process instance ID
* @return a list of instance activity events.
*/
- List<Event> getInstanceEvents(String processInstance);
+ List<Event> getInstanceEvents(String... processInstance);
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -117,7 +117,7 @@
}
public List<Event> getDefinitionEvents(final String processDefinition, final Timespan timespan)
- {
+ {
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
public List<Event> execute(Session session)
@@ -144,26 +144,41 @@
return result;
}
- public List<Event> getInstanceEvents(final String processInstance)
+ public List<Event> getInstanceEvents(final String... processInstances)
{
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
public List<Event> execute(Session session)
{
- SQLQuery query = session.createSQLQuery("select e1.*\n" +
- "from BPAF_EVENT e1, BPAF_EVENT e2\n" +
- "where e1.processInstanceID=e2.processInstanceID\n" +
- "and ((e1.currentState=\"Open\" and e2.currentState=\"Closed\") OR (e2.currentState=\"Open\" and e1.currentState=\"Closed\"))\n" +
- "and e1.activityDefinitionID is not null\n" +
- "and e2.activityDefinitionID is not null\n" +
- "and e1.processInstanceID='"+processInstance+"' "+
- //"and e1.timeStamp>="+timespan.getStart()+" "+
- //"and e2.timeStamp<="+timespan.getEnd()+" "+
- "group by e1.activityInstanceID\n" +
- "order by e1.timeStamp, e1.processInstanceID");
+ StringBuffer sb = new StringBuffer("SELECT e1.* ");
+ sb.append("FROM BPAF_EVENT e1, BPAF_EVENT e2 ");
+ sb.append("WHERE e1.processInstanceID=e2.processInstanceID " );
+ sb.append("AND ((e1.currentState=\"Open\" and e2.currentState=\"Closed\") OR (e2.currentState=\"Open\" and e1.currentState=\"Closed\")) " );
+ sb.append("AND e1.activityDefinitionID is not null " );
+ sb.append("AND e2.activityDefinitionID is not null " );
+ sb.append("AND (");
+ for(int i=0; i<processInstances.length; i++)
+ {
+ if(i==0)
+ sb.append("e1.processInstanceID=\""+processInstances[i]+"\" ");
+ else
+ sb.append("OR e1.processInstanceID=\""+processInstances[i]+"\" ");
+ }
+
+ sb.append(") ");
+
+ //sb.append("and e1.timeStamp>="+timespan.getStart()+" ");
+ //sb.append("and e2.timeStamp<="+timespan.getEnd()+" ");
+
+ sb.append("GROUP BY e1.activityInstanceID " );
+ sb.append("ORDER BY e1.timeStamp, e1.processInstanceID");
+
+
+ SQLQuery query = session.createSQLQuery(sb.toString());
+
query.addEntity(Event.class);
-
+
return query.list();
}
});
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -60,8 +60,9 @@
System.out.println(Metrics.getInstanceAverage(instanceHistory));
// instance events
- String instance = instances.get(0);
- List<Event> activityHistory = ds.getInstanceEvents(instance);
+ String instance1 = instances.get(0);
+ String instance2 = instances.get(1);
+ List<Event> activityHistory = ds.getInstanceEvents(instance1, instance2);
System.out.println("Instance events: "+activityHistory.size());
for(String s : activities)
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -22,6 +22,8 @@
package org.jboss.bpm.monitor.model.metric;
/**
+ * Min, Max, Average for a particular key.
+ *
* @author: Heiko Braun <hbraun(a)redhat.com>
* @date: Mar 10, 2010
*/
@@ -37,6 +39,11 @@
this.key = key;
}
+ public String getKey()
+ {
+ return key;
+ }
+
public long getMin()
{
return min;
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -23,6 +23,7 @@
import org.jboss.bpm.monitor.model.bpaf.Event;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,6 +34,12 @@
*/
public class Metrics
{
+ /**
+ * Get the average instance execution time.
+ * @param events a list of events that belong to the same process definition
+ * (<tt>e0.processDefinitionID==e1.processDefinitionID, ..., eN</tt>)
+ * @return average instance execution time
+ */
public static Average getInstanceAverage(List<Event> events)
{
assert events.size()>0 : "Empty event list";
@@ -78,6 +85,13 @@
return stat;
}
+ /**
+ * Get the average execution time for an activity.
+ * @param events a list of event that belong to the same process definition
+ * (<tt>e0.processDefinitionID==e1.processDefinitionID, ..., eN</tt>)
+ * @param activityDefinition the activityDefinitionID
+ * @return an average
+ */
public static Average getActivityAverage(List<Event> events, String activityDefinition)
{
assert events.size()>0 : "Empty event list";
@@ -85,7 +99,8 @@
Average stat = new Average(activityDefinition);
- Map<String, Long> duration = new HashMap<String,Long>(events.size()/2);
+ Map<String, Long> in = new HashMap<String,Long>(events.size()/2);
+ List<Long> out = new ArrayList<Long>();
for(Event e : events)
{
String activity = e.getActivityDefinitionID();
@@ -93,25 +108,24 @@
if(!activity.equals(activityDefinition)) // skip non related events
continue;
- Long l0 = duration.get(activity);
+ Long l0 = in.get(activity);
if(l0!=null)
{
long l1 = e.getTimestamp();
if(l0<l1)
- duration.put(activity, (l1-l0)); // not necessarily in order
+ out.add(l1-l0); // not necessarily in order
else
- duration.put(activity, (l0-l1));
+ out.add(l0-l1);
}
else
{
- duration.put(activity, e.getTimestamp());
+ in.put(activity, e.getTimestamp());
}
}
long sum = 0;
- for(String activity : duration.keySet())
- {
- long l3 = duration.get(activity);
+ for(Long l3: out)
+ {
if(stat.getMin()==-1) // first iteration
{
stat.setMin(l3);
@@ -125,7 +139,7 @@
sum+=l3;
}
- stat.setAvg(sum/duration.entrySet().size());
+ stat.setAvg(sum/out.size());
return stat;
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java 2010-03-10 15:03:03 UTC (rev 999)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java 2010-03-11 09:31:25 UTC (rev 1000)
@@ -5,6 +5,9 @@
import java.util.Date;
/**
+ * Represents a certain time period.
+ * Includes factory methods to create common timespans.
+ *
* @author: Heiko Braun <hbraun(a)redhat.com>
* @date: Mar 10, 2010
*/
14 years, 2 months
Overlord SVN: r999 - activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-10 10:03:03 -0500 (Wed, 10 Mar 2010)
New Revision: 999
Modified:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
Log:
remove timespan from instance query. Doesn't make sense
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 15:00:07 UTC (rev 998)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 15:03:03 UTC (rev 999)
@@ -79,9 +79,8 @@
* Only return result sets that include matching State.Close events.
* Otherwise you include activities that are still running.
*
- * @param processInstance the process instance ID
- * @param timespan a timespan (inclusive)
+ * @param processInstance the process instance ID
* @return a list of instance activity events.
*/
- List<Event> getInstanceEvents(String processInstance, Timespan timespan);
+ List<Event> getInstanceEvents(String processInstance);
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 15:00:07 UTC (rev 998)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 15:03:03 UTC (rev 999)
@@ -144,7 +144,7 @@
return result;
}
- public List<Event> getInstanceEvents(final String processInstance, final Timespan timespan)
+ public List<Event> getInstanceEvents(final String processInstance)
{
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
@@ -157,8 +157,8 @@
"and e1.activityDefinitionID is not null\n" +
"and e2.activityDefinitionID is not null\n" +
"and e1.processInstanceID='"+processInstance+"' "+
- "and e1.timeStamp>="+timespan.getStart()+" "+
- "and e2.timeStamp<="+timespan.getEnd()+" "+
+ //"and e1.timeStamp>="+timespan.getStart()+" "+
+ //"and e2.timeStamp<="+timespan.getEnd()+" "+
"group by e1.activityInstanceID\n" +
"order by e1.timeStamp, e1.processInstanceID");
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 15:00:07 UTC (rev 998)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 15:03:03 UTC (rev 999)
@@ -61,7 +61,7 @@
// instance events
String instance = instances.get(0);
- List<Event> activityHistory = ds.getInstanceEvents(instance, timespan);
+ List<Event> activityHistory = ds.getInstanceEvents(instance);
System.out.println("Instance events: "+activityHistory.size());
for(String s : activities)
14 years, 2 months
Overlord SVN: r998 - in activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model: metric and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-10 10:00:07 -0500 (Wed, 10 Mar 2010)
New Revision: 998
Modified:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
Log:
implement activty selection
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 14:22:19 UTC (rev 997)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 15:00:07 UTC (rev 998)
@@ -144,16 +144,27 @@
return result;
}
- public List<Event> getInstanceEvents(final String processInstance, Timespan timespan)
+ public List<Event> getInstanceEvents(final String processInstance, final Timespan timespan)
{
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
public List<Event> execute(Session session)
{
- Criteria c = session.createCriteria(Event.class);
- c.add(Restrictions.isNotNull("activityDefinitionID"));
- c.add(Restrictions.eq("processInstanceID", processInstance));
- return c.list();
+ SQLQuery query = session.createSQLQuery("select e1.*\n" +
+ "from BPAF_EVENT e1, BPAF_EVENT e2\n" +
+ "where e1.processInstanceID=e2.processInstanceID\n" +
+ "and ((e1.currentState=\"Open\" and e2.currentState=\"Closed\") OR (e2.currentState=\"Open\" and e1.currentState=\"Closed\"))\n" +
+ "and e1.activityDefinitionID is not null\n" +
+ "and e2.activityDefinitionID is not null\n" +
+ "and e1.processInstanceID='"+processInstance+"' "+
+ "and e1.timeStamp>="+timespan.getStart()+" "+
+ "and e2.timeStamp<="+timespan.getEnd()+" "+
+ "group by e1.activityInstanceID\n" +
+ "order by e1.timeStamp, e1.processInstanceID");
+
+ query.addEntity(Event.class);
+
+ return query.list();
}
});
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 14:22:19 UTC (rev 997)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 15:00:07 UTC (rev 998)
@@ -56,12 +56,17 @@
// definition events
Timespan timespan = Timespan.lastQuarter();
System.out.println(timespan);
- List<Event> defLifecycle = ds.getDefinitionEvents(definitions.get(0), timespan);
- System.out.println("defLifecycle events: " +defLifecycle.size());
- System.out.println("Stat for definition: " + Metrics.getAverage(defLifecycle));
+ List<Event> instanceHistory = ds.getDefinitionEvents(definitions.get(0), timespan);
+ System.out.println(Metrics.getInstanceAverage(instanceHistory));
// instance events
- List<Event> instLifecycle = ds.getInstanceEvents(instances.get(0), timespan);
- System.out.println(instLifecycle);
+ String instance = instances.get(0);
+ List<Event> activityHistory = ds.getInstanceEvents(instance, timespan);
+ System.out.println("Instance events: "+activityHistory.size());
+
+ for(String s : activities)
+ {
+ System.out.println("- "+s+": " + Metrics.getActivityAverage(activityHistory, s));
+ }
}
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java 2010-03-10 14:22:19 UTC (rev 997)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java 2010-03-10 15:00:07 UTC (rev 998)
@@ -27,14 +27,14 @@
*/
public class Average
{
- String processDefinition;
+ String key;
long min = -1;
long max = -1;
long avg = -1;
- public Average(String processDefinition)
+ public Average(String key)
{
- this.processDefinition = processDefinition;
+ this.key = key;
}
public long getMin()
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 14:22:19 UTC (rev 997)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 15:00:07 UTC (rev 998)
@@ -33,7 +33,7 @@
*/
public class Metrics
{
- public static Average getAverage(List<Event> events)
+ public static Average getInstanceAverage(List<Event> events)
{
assert events.size()>0 : "Empty event list";
assert events.size()%2==0 : "Parity error: "+events.size() +" events. Every event should have closing counterpart!";
@@ -74,7 +74,59 @@
}
stat.setAvg(sum/duration.entrySet().size());
-
+
return stat;
}
+
+ public static Average getActivityAverage(List<Event> events, String activityDefinition)
+ {
+ assert events.size()>0 : "Empty event list";
+ assert events.size()%2==0 : "Parity error: "+events.size() +" events. Every event should have closing counterpart!";
+
+ Average stat = new Average(activityDefinition);
+
+ Map<String, Long> duration = new HashMap<String,Long>(events.size()/2);
+ for(Event e : events)
+ {
+ String activity = e.getActivityDefinitionID();
+
+ if(!activity.equals(activityDefinition)) // skip non related events
+ continue;
+
+ Long l0 = duration.get(activity);
+ if(l0!=null)
+ {
+ long l1 = e.getTimestamp();
+ if(l0<l1)
+ duration.put(activity, (l1-l0)); // not necessarily in order
+ else
+ duration.put(activity, (l0-l1));
+ }
+ else
+ {
+ duration.put(activity, e.getTimestamp());
+ }
+ }
+
+ long sum = 0;
+ for(String activity : duration.keySet())
+ {
+ long l3 = duration.get(activity);
+ if(stat.getMin()==-1) // first iteration
+ {
+ stat.setMin(l3);
+ stat.setMax(l3);
+ }
+ else if(l3<stat.getMin())
+ stat.setMin(l3);
+ else if(l3>stat.getMax())
+ stat.setMax(l3);
+
+ sum+=l3;
+ }
+
+ stat.setAvg(sum/duration.entrySet().size());
+
+ return stat;
+ }
}
14 years, 2 months
Overlord SVN: r997 - in activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model: metric and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-10 09:22:19 -0500 (Wed, 10 Mar 2010)
New Revision: 997
Added:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java
Modified:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
Log:
Added fixed timespan's
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 13:07:43 UTC (rev 996)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 14:22:19 UTC (rev 997)
@@ -22,6 +22,7 @@
package org.jboss.bpm.monitor.model;
import org.jboss.bpm.monitor.model.bpaf.Event;
+import org.jboss.bpm.monitor.model.metric.Timespan;
import java.util.List;
@@ -31,10 +32,56 @@
*/
public interface BPAFDataSource
{
+ /**
+ * Get a list of distinct process definition ID's that are known to the system.
+ * @return a collection of process definition ID's
+ */
List<String> getProcessDefinitions();
+
+ /**
+ * Get a list of distinct process instance ID's that are known to the system.
+ * @return a collection of process instance ID's
+ */
+
List<String> getProcessInstances(String processDefinition);
+
+ /**
+ * Get a list of distinct activity definition ID's that are known to the system.
+ * @return a collection of activity definition ID's
+ */
+
List<String> getActivityDefinitions(String processInstance);
- List<Event> getDefinitionEvents(String processDefinition, long start, long end);
- List<Event> getInstanceEvents(String processInstance, long start, long end);
+ /**
+ * Get a list of process definition events for a specific timespan.
+ * Process definition events are the ones that don't have and activityDefinition
+ * assigned to them. These events are typically used to indicated start and end of an
+ * process instance lifecycle.
+ * <p/>
+ * NOTE: Parity is important <code>(events.size()%2==0)</code>.
+ * Only return result sets that include matching State.Close events.
+ * Otherwise you include instances that are still running.
+ *
+ * @param processDefinition the process definition ID
+ * @param timespan a timespan (inclusive)
+ * @return List of <tt>State.Open</tt> and <tt>State.Closed</tt> events for a particluar process definition
+ * excluding the activity events (<tt>activityDefinitionID is null</tt>)
+ */
+ List<Event> getDefinitionEvents(String processDefinition, Timespan timespan);
+
+
+ /**
+ * Get a list of process instance events for specific timespan.
+ * Process instance event are the one that have an activity assigned to it.
+ *
+ * <p/>
+ * NOTE: Parity is important <code>(events.size()%2==0)</code>.
+ * Only return result sets that include matching State.Close events.
+ * Otherwise you include activities that are still running.
+ *
+ * @param processInstance the process instance ID
+ * @param timespan a timespan (inclusive)
+ * @return a list of instance activity events.
+ */
+ List<Event> getInstanceEvents(String processInstance, Timespan timespan);
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 13:07:43 UTC (rev 996)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 14:22:19 UTC (rev 997)
@@ -28,6 +28,7 @@
import org.hibernate.criterion.Restrictions;
import org.jboss.bpm.monitor.model.bpaf.Event;
import org.jboss.bpm.monitor.model.hibernate.HibernateUtil;
+import org.jboss.bpm.monitor.model.metric.Timespan;
import java.util.List;
@@ -115,8 +116,8 @@
return result;
}
- public List<Event> getDefinitionEvents(final String processDefinition, long start, long end)
- {
+ public List<Event> getDefinitionEvents(final String processDefinition, final Timespan timespan)
+ {
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
public List<Event> execute(Session session)
@@ -130,6 +131,8 @@
"and e1.activityDefinitionID is null " +
"and e2.activityDefinitionID is null " +
"and e1.processDefinitionID='"+processDefinition+"' "+
+ "and e1.timeStamp>="+timespan.getStart()+" "+
+ "and e2.timeStamp<="+timespan.getEnd()+" "+
"order by e1.timeStamp;");
query.addEntity(Event.class);
@@ -141,7 +144,7 @@
return result;
}
- public List<Event> getInstanceEvents(final String processInstance, long start, long end)
+ public List<Event> getInstanceEvents(final String processInstance, Timespan timespan)
{
List<Event> result = executeCommand(new SQLCommand<List<Event>>()
{
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 13:07:43 UTC (rev 996)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 14:22:19 UTC (rev 997)
@@ -23,6 +23,7 @@
import org.jboss.bpm.monitor.model.bpaf.Event;
import org.jboss.bpm.monitor.model.metric.Metrics;
+import org.jboss.bpm.monitor.model.metric.Timespan;
import java.util.List;
@@ -53,12 +54,14 @@
// definition events
- List<Event> defLifecycle = ds.getDefinitionEvents(definitions.get(0), 0, 0);
+ Timespan timespan = Timespan.lastQuarter();
+ System.out.println(timespan);
+ List<Event> defLifecycle = ds.getDefinitionEvents(definitions.get(0), timespan);
System.out.println("defLifecycle events: " +defLifecycle.size());
System.out.println("Stat for definition: " + Metrics.getAverage(defLifecycle));
// instance events
- List<Event> instLifecycle = ds.getInstanceEvents(instances.get(0), 0, 0);
- System.out.println(instLifecycle);
+ List<Event> instLifecycle = ds.getInstanceEvents(instances.get(0), timespan);
+ System.out.println(instLifecycle);
}
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 13:07:43 UTC (rev 996)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 14:22:19 UTC (rev 997)
@@ -35,7 +35,7 @@
{
public static Average getAverage(List<Event> events)
{
- assert events.size()>0;
+ assert events.size()>0 : "Empty event list";
assert events.size()%2==0 : "Parity error: "+events.size() +" events. Every event should have closing counterpart!";
Average stat = new Average(events.get(0).getProcessDefinitionID());
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Timespan.java 2010-03-10 14:22:19 UTC (rev 997)
@@ -0,0 +1,209 @@
+/* jboss.org */
+package org.jboss.bpm.monitor.model.metric;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public final class Timespan
+{
+ long start;
+ long end;
+
+ public Timespan(long start, long end)
+ {
+ this.start = start;
+ this.end = end;
+ }
+
+ public long getStart()
+ {
+ return start;
+ }
+
+ public long getEnd()
+ {
+ return end;
+ }
+
+ public String toString()
+ {
+ return "Timespan{ "+new Date(start)+" - "+new Date(end)+" }";
+ }
+
+ // ----------------------------------------
+
+ public static Timespan last24Hours()
+ {
+ Calendar cal = Calendar.getInstance();
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.DAY_OF_YEAR, -1);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan lastDay()
+ {
+ Calendar cal = Calendar.getInstance();
+
+ cal.roll(Calendar.DAY_OF_YEAR, -1);
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ long t1 = cal.getTimeInMillis();
+
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan last7Days()
+ {
+ Calendar cal = Calendar.getInstance();
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.DAY_OF_YEAR, -7);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan lastWeek()
+ {
+ Calendar cal = Calendar.getInstance();
+
+ cal.roll(Calendar.WEEK_OF_YEAR, -1);
+
+ cal.set(Calendar.DAY_OF_WEEK, 7);
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ long t1 = cal.getTimeInMillis();
+
+ cal.set(Calendar.DAY_OF_WEEK, 0);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan last4Weeks()
+ {
+ Calendar cal = Calendar.getInstance();
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.WEEK_OF_YEAR, -4);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan lastMonth()
+ {
+ Calendar cal = Calendar.getInstance();
+
+ cal.roll(Calendar.MONTH, -1);
+
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ long t1 = cal.getTimeInMillis();
+
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+
+ public static Timespan last3Month()
+ {
+ Calendar cal = Calendar.getInstance();
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.MONTH, -3);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan lastQuarter()
+ {
+ Calendar cal = Calendar.getInstance();
+
+ long currentMonth = cal.get(Calendar.MONTH);
+
+ if(currentMonth>=1 && currentMonth<=3)
+ cal.set(Calendar.MONTH, Calendar.MARCH);
+ else if(currentMonth>=4 && currentMonth<=6)
+ cal.set(Calendar.MONTH, Calendar.JUNE);
+ else if(currentMonth>=7 && currentMonth<=9)
+ cal.set(Calendar.MONTH, Calendar.SEPTEMBER);
+ else
+ cal.set(Calendar.MONTH, Calendar.DECEMBER);
+
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.MONTH, -2);
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+
+ public static Timespan last12Month()
+ {
+ Calendar cal = Calendar.getInstance();
+ long t1 = cal.getTimeInMillis();
+
+ cal.roll(Calendar.YEAR, -1);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+
+ public static Timespan lastYear()
+ {
+ Calendar cal = Calendar.getInstance();
+
+ cal.roll(Calendar.YEAR, -1);
+
+ cal.set(Calendar.MONTH, Calendar.DECEMBER);
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ long t1 = cal.getTimeInMillis();
+
+ cal.set(Calendar.MONTH, Calendar.JANUARY);
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ long t0 = cal.getTimeInMillis();
+
+ return new Timespan(t0, t1);
+ }
+}
14 years, 2 months
Overlord SVN: r996 - in activity-monitor/trunk: model and 6 other directories.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-10 08:07:43 -0500 (Wed, 10 Mar 2010)
New Revision: 996
Added:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/HibernateUtil.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/StateUserType.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
Removed:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/HibernateUtil.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/StateUserType.java
Modified:
activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/Emulation.java
activity-monitor/trunk/model/pom.xml
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/State.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/StateAdapter.java
activity-monitor/trunk/model/src/main/resources/hibernate.cfg.xml
activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml
Log:
Begin work on BPAFDataSource interface
Modified: activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/Emulation.java
===================================================================
--- activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/Emulation.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/Emulation.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -22,7 +22,7 @@
package org.jboss.bpm.monitor.emu;
import org.hibernate.Session;
-import org.jboss.bpm.monitor.model.HibernateUtil;
+import org.jboss.bpm.monitor.model.hibernate.HibernateUtil;
import org.jboss.bpm.monitor.model.bpaf.BPAFContext;
import org.jboss.bpm.monitor.model.bpaf.Event;
Modified: activity-monitor/trunk/model/pom.xml
===================================================================
--- activity-monitor/trunk/model/pom.xml 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/pom.xml 2010-03-10 13:07:43 UTC (rev 996)
@@ -39,6 +39,12 @@
<artifactId>javassist</artifactId>
</dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.12</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/BPAFDataSource.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,40 @@
+/*
+ * 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.monitor.model;
+
+import org.jboss.bpm.monitor.model.bpaf.Event;
+
+import java.util.List;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public interface BPAFDataSource
+{
+ List<String> getProcessDefinitions();
+ List<String> getProcessInstances(String processDefinition);
+ List<String> getActivityDefinitions(String processInstance);
+
+ List<Event> getDefinitionEvents(String processDefinition, long start, long end);
+ List<Event> getInstanceEvents(String processInstance, long start, long end);
+}
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/DefaultBPAFDataSource.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,159 @@
+/*
+ * 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.monitor.model;
+
+import org.hibernate.Criteria;
+import org.hibernate.Query;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.criterion.Restrictions;
+import org.jboss.bpm.monitor.model.bpaf.Event;
+import org.jboss.bpm.monitor.model.hibernate.HibernateUtil;
+
+import java.util.List;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public class DefaultBPAFDataSource implements BPAFDataSource
+{
+
+ private interface SQLCommand<T>
+ {
+ T execute(Session session);
+ }
+
+ private <T> T executeCommand(SQLCommand<T> cmd)
+ {
+ Session session = HibernateUtil.getSession();
+
+ try
+ {
+ return cmd.execute(session);
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException("Failed to execute query", e);
+ }
+ finally
+ {
+ session.close();
+ }
+
+ }
+
+ public List<String> getProcessDefinitions()
+ {
+ List<String> result = executeCommand(new SQLCommand<List<String>>()
+ {
+ public List<String> execute(Session session)
+ {
+ Query query = session.createQuery(
+ "select distinct e.processDefinitionID from org.jboss.bpm.monitor.model.bpaf.Event as e"
+ );
+ return query.list();
+ }
+ });
+
+ return result;
+ }
+
+ public List<String> getProcessInstances(final String processDefinition)
+ {
+ List<String> result = executeCommand(new SQLCommand<List<String>>()
+ {
+ public List<String> execute(Session session)
+ {
+ Query query = session.createQuery(
+ "select distinct e.processInstanceID from org.jboss.bpm.monitor.model.bpaf.Event as e" +
+ " where e.processDefinitionID=:id"
+ );
+ query.setString("id", processDefinition);
+ return query.list();
+ }
+ });
+
+ return result;
+ }
+
+ public List<String> getActivityDefinitions(final String processInstance)
+ {
+ List<String> result = executeCommand(new SQLCommand<List<String>>()
+ {
+ public List<String> execute(Session session)
+ {
+ Query query = session.createQuery(
+ "select distinct e.activityDefinitionID from org.jboss.bpm.monitor.model.bpaf.Event as e" +
+ " where e.processInstanceID=:id" +
+ " and e.activityDefinitionID!=null"
+ );
+ query.setString("id", processInstance);
+ return query.list();
+ }
+ });
+
+ return result;
+ }
+
+ public List<Event> getDefinitionEvents(final String processDefinition, long start, long end)
+ {
+ List<Event> result = executeCommand(new SQLCommand<List<Event>>()
+ {
+ public List<Event> execute(Session session)
+ {
+
+ SQLQuery query = session.createSQLQuery("select e1.* " +
+ "from BPAF_EVENT e1, BPAF_EVENT e2 " +
+ "where e1.processDefinitionID=e2.processDefinitionID " +
+ "and e1.processInstanceID=e2.processInstanceID " +
+ "and ((e1.currentState=\"Open\" and e2.currentState=\"Closed\") OR (e2.currentState=\"Open\" and e1.currentState=\"Closed\")) " +
+ "and e1.activityDefinitionID is null " +
+ "and e2.activityDefinitionID is null " +
+ "and e1.processDefinitionID='"+processDefinition+"' "+
+ "order by e1.timeStamp;");
+
+ query.addEntity(Event.class);
+
+ return query.list();
+ }
+ });
+
+ return result;
+ }
+
+ public List<Event> getInstanceEvents(final String processInstance, long start, long end)
+ {
+ List<Event> result = executeCommand(new SQLCommand<List<Event>>()
+ {
+ public List<Event> execute(Session session)
+ {
+ Criteria c = session.createCriteria(Event.class);
+ c.add(Restrictions.isNotNull("activityDefinitionID"));
+ c.add(Restrictions.eq("processInstanceID", processInstance));
+ return c.list();
+ }
+ });
+
+ return result;
+ }
+}
Deleted: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/HibernateUtil.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/HibernateUtil.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/HibernateUtil.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -1,57 +0,0 @@
-/*
- * 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.monitor.model;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-
-/**
- * @author: Heiko Braun <hbraun(a)redhat.com>
- * @date: Mar 6, 2010
- */
-public class HibernateUtil {
-
- private static final SessionFactory sessionFactory;
-
- static
- {
- try
- {
- sessionFactory =
- new Configuration()
- .configure()
- .buildSessionFactory();
- }
- catch (Throwable ex)
- {
- // Log exception!
- throw new ExceptionInInitializerError(ex);
- }
- }
-
- public static Session getSession() throws HibernateException
- {
- return sessionFactory.openSession();
- }
-}
\ No newline at end of file
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/Runner.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,64 @@
+/*
+ * 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.monitor.model;
+
+import org.jboss.bpm.monitor.model.bpaf.Event;
+import org.jboss.bpm.monitor.model.metric.Metrics;
+
+import java.util.List;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public class Runner
+{
+ public static void main(String[] args)
+ {
+ BPAFDataSource ds = new DefaultBPAFDataSource();
+
+ // definitions
+ List<String> definitions = ds.getProcessDefinitions();
+ System.out.println("Definitions: " +definitions);
+
+ // instances
+ String s0 = definitions.get(0);
+ List<String> instances = ds.getProcessInstances(s0);
+ System.out.println("Instances for "+s0 +": "+instances.size());
+
+ // activities
+ String s1 = instances.get(0);
+ List<String> activities = ds.getActivityDefinitions(s1);
+ System.out.println("Distinct activities: ");
+ for(String s : activities) System.out.println("- "+s);
+
+
+ // definition events
+ List<Event> defLifecycle = ds.getDefinitionEvents(definitions.get(0), 0, 0);
+ System.out.println("defLifecycle events: " +defLifecycle.size());
+ System.out.println("Stat for definition: " + Metrics.getAverage(defLifecycle));
+
+ // instance events
+ List<Event> instLifecycle = ds.getInstanceEvents(instances.get(0), 0, 0);
+ System.out.println(instLifecycle);
+ }
+}
Deleted: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/StateUserType.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/StateUserType.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/StateUserType.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -1,106 +0,0 @@
-/*
- * 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.monitor.model;
-
-/**
- * @author: Heiko Braun <hbraun(a)redhat.com>
- * @date: Mar 7, 2010
- */
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Properties;
-
-import org.hibernate.HibernateException;
-import org.hibernate.MappingException;
-import org.hibernate.usertype.ParameterizedType;
-import org.hibernate.usertype.UserType;
-import org.jboss.bpm.monitor.model.bpaf.State;
-
-public class StateUserType implements UserType, ParameterizedType {
-
- private Class clazz = State.class;
-
- public void setParameterValues(Properties params) {
-
- }
-
- private static final int[] SQL_TYPES = {Types.VARCHAR};
- public int[] sqlTypes() {
- return SQL_TYPES;
- }
-
- public Class returnedClass() {
- return clazz;
- }
-
- public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
- throws HibernateException, SQLException {
- String name = resultSet.getString(names[0]);
- Object result = null;
- if (!resultSet.wasNull()) {
- result = State.valueOf(name);
- }
- return result;
- }
-
- public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index)
- throws HibernateException, SQLException {
- if (null == value) {
- preparedStatement.setNull(index, Types.VARCHAR);
- } else {
- preparedStatement.setString(index, ((State)value).toString());
- }
- }
-
- public Object deepCopy(Object value) throws HibernateException{
- return value;
- }
-
- public boolean isMutable() {
- return false;
- }
-
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
- }
-
- public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable)value;
- }
-
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
- }
- public int hashCode(Object x) throws HibernateException {
- return x.hashCode();
- }
- public boolean equals(Object x, Object y) throws HibernateException {
- if (x == y)
- return true;
- if (null == x || null == y)
- return false;
- return x.equals(y);
- }
-}
\ No newline at end of file
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -478,6 +478,23 @@
this.previousState = previousState;
}
+ @Override
+ public String toString()
+ {
+ return "EventDetails{" +
+ "currentState=" + currentState +
+ '}';
+ }
}
+ @Override
+ public String toString()
+ {
+ return "Event{" +
+ "timestamp=" + timestamp +
+ ", processDefinitionID='" + processDefinitionID + '\'' +
+ ", processInstanceID='" + processInstanceID + '\'' +
+ ", eventDetails=" + eventDetails +
+ '}';
+ }
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/State.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/State.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/State.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -35,25 +35,116 @@
@XmlJavaTypeAdapter(StateAdapter.class)
public enum State
{
+ /**
+ * An activity or process instance in the state OPEN can change state.
+ */
Open,
+
+ /**
+ * No active work is being performed on the process in this state.
+ * Time spent in this state would be recorded as idle time or wait time.
+ */
Open_NotRunning,
+
+ /**
+ * The process/activity is ready to be processed
+ * but has not been assigned to a particular participant.
+ */
Open_NotRunning_Ready,
+
+ /**
+ * The process/activity has been assigned to a role (potentially a group of participants),
+ * but work has not started yet.
+ */
Open_NotRunning_Assigned,
+
+ /**
+ * The process/activity has been assigned to a named user (a single participant),
+ * but work has not started yet.
+ */
Open_NotRunning_Reserved,
+
+ /**
+ * The process/activity has been moved into a hibernation state.
+ * Execution has not yet begun at this point,
+ * i.e. the process/activity cannot be executed from this state
+ * but has to be reactivated before execution can begin.
+ */
Open_NotRunning_Suspended,
+
+ /**
+ * The process/activity has been moved
+ * into a hibernation state after its execution has begun.
+ */
Open_NotRunning_Suspended_Assigned,
Open_NotRunning_Suspended_Reserved,
+
+ /**
+ * The process is actively being worked on.
+ * Time spent in this state would be recorded as processing time or work time.
+ */
Open_Running,
Open_Running_InProgress,
+
+ /**
+ * The process/activity has been moved
+ * into a hibernation state after its execution has begun.
+ */
Open_Running_Suspended,
+
+ /**
+ * An activity or process instance in the state CLOSED can no longer change state.
+ */
Closed,
+
+ /**
+ * The process has been fully executed.
+ * Processes in this state may or may not have achieved their objective.
+ */
Closed_Completed,
+
+ /**
+ * The process/activity has completed as planned and has achieved its objectives.
+ */
Closed_Completed_Success,
+
+ /**
+ * The process/activity has completed as planned but has not achieved its objectives.
+ */
Closed_Completed_Failed,
+
+ /**
+ * The process has been forcefully terminated.
+ * Processes in this state have not achieved their objective.
+ */
Closed_Cancelled,
+
+ /**
+ * The process/activity has ended because it was manually exited prior to its completion
+ */
Closed_Cancelled_Exited,
+
+ /**
+ * The process/activity has ended due to an error in the execution.
+ */
Closed_Cancelled_Error,
+
+ /**
+ * The process/activity has ended because it has been superseded by a more recent version.
+ * This might occur if a process instance is migrated to a newer schema during the course of its execution and an activity that was part only
+ * of the old schema has become ready for execution but has not been executed yet.
+ */
Closed_Cancelled_Obsolete,
+
+ /**
+ * The process/activity has been forcibly but gracefully ended, i.e. running activities and subprocesses were allowed
+ * to complete as scheduled before the end of the process instance.
+ */
Closed_Cancelled_Aborted,
+
+ /**
+ * The process/activity has been forcibly ended, i.e. running activities
+ * and subprocesses were terminated before their scheduled completion.
+ */
Closed_Cancelled_Terminated
}
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/StateAdapter.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/StateAdapter.java 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/StateAdapter.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -32,13 +32,14 @@
@Override
public State unmarshal(String v) throws Exception
{
- return State.valueOf(v);
+ String interim = v.replace(".", "_");
+ return State.valueOf(interim);
}
@Override
public String marshal(State v) throws Exception
{
if(null==v) return null;
- else return v.toString();
+ else return v.toString().replace("_", ".");
}
}
Copied: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/HibernateUtil.java (from rev 989, activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/HibernateUtil.java)
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/HibernateUtil.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/HibernateUtil.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,57 @@
+/*
+ * 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.monitor.model.hibernate;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 6, 2010
+ */
+public class HibernateUtil {
+
+ private static final SessionFactory sessionFactory;
+
+ static
+ {
+ try
+ {
+ sessionFactory =
+ new Configuration()
+ .configure()
+ .buildSessionFactory();
+ }
+ catch (Throwable ex)
+ {
+ // Log exception!
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ public static Session getSession() throws HibernateException
+ {
+ return sessionFactory.openSession();
+ }
+}
\ No newline at end of file
Copied: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/StateUserType.java (from rev 989, activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/StateUserType.java)
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/StateUserType.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/hibernate/StateUserType.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,106 @@
+/*
+ * 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.monitor.model.hibernate;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 7, 2010
+ */
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.UserType;
+import org.jboss.bpm.monitor.model.bpaf.State;
+
+public class StateUserType implements UserType, ParameterizedType {
+
+ private Class clazz = State.class;
+
+ public void setParameterValues(Properties params) {
+
+ }
+
+ private static final int[] SQL_TYPES = {Types.VARCHAR};
+ public int[] sqlTypes() {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass() {
+ return clazz;
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner)
+ throws HibernateException, SQLException {
+ String name = resultSet.getString(names[0]);
+ Object result = null;
+ if (!resultSet.wasNull()) {
+ result = State.valueOf(name);
+ }
+ return result;
+ }
+
+ public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index)
+ throws HibernateException, SQLException {
+ if (null == value) {
+ preparedStatement.setNull(index, Types.VARCHAR);
+ } else {
+ preparedStatement.setString(index, ((State)value).toString());
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException{
+ return value;
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable)value;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+ public boolean equals(Object x, Object y) throws HibernateException {
+ if (x == y)
+ return true;
+ if (null == x || null == y)
+ return false;
+ return x.equals(y);
+ }
+}
\ No newline at end of file
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Average.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,79 @@
+/*
+ * 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.monitor.model.metric;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public class Average
+{
+ String processDefinition;
+ long min = -1;
+ long max = -1;
+ long avg = -1;
+
+ public Average(String processDefinition)
+ {
+ this.processDefinition = processDefinition;
+ }
+
+ public long getMin()
+ {
+ return min;
+ }
+
+ public void setMin(long min)
+ {
+ this.min = min;
+ }
+
+ public long getMax()
+ {
+ return max;
+ }
+
+ public void setMax(long max)
+ {
+ this.max = max;
+ }
+
+ public long getAvg()
+ {
+ return avg;
+ }
+
+ public void setAvg(long avg)
+ {
+ this.avg = avg;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Average{" +
+ "min=" + min +
+ ", max=" + max +
+ ", avg=" + avg +
+ '}';
+ }
+}
Added: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java (rev 0)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/metric/Metrics.java 2010-03-10 13:07:43 UTC (rev 996)
@@ -0,0 +1,80 @@
+/*
+ * 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.monitor.model.metric;
+
+import org.jboss.bpm.monitor.model.bpaf.Event;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Mar 10, 2010
+ */
+public class Metrics
+{
+ public static Average getAverage(List<Event> events)
+ {
+ assert events.size()>0;
+ assert events.size()%2==0 : "Parity error: "+events.size() +" events. Every event should have closing counterpart!";
+
+ Average stat = new Average(events.get(0).getProcessDefinitionID());
+
+ Map<String, Long> duration = new HashMap<String,Long>(events.size()/2);
+ for(Event e : events)
+ {
+ String processInstance = e.getProcessInstanceID();
+ Long l0 = duration.get(processInstance);
+ if(l0!=null)
+ {
+ long l1 = e.getTimestamp();
+ if(l0<l1)
+ duration.put(processInstance, (l1-l0)); // not necessarily in order
+ else
+ duration.put(processInstance, (l0-l1));
+ }
+ else
+ {
+ duration.put(processInstance, e.getTimestamp());
+ }
+ }
+
+ long sum = 0;
+ for(String processInstance : duration.keySet())
+ {
+ long l3 = duration.get(processInstance);
+ if(stat.getMin()==-1) // first iteration
+ stat.setMin(l3);
+ else if(l3<stat.getMin())
+ stat.setMin(l3);
+ else if(l3>stat.getMax())
+ stat.setMax(l3);
+
+ sum+=l3;
+ }
+
+ stat.setAvg(sum/duration.entrySet().size());
+
+ return stat;
+ }
+}
Modified: activity-monitor/trunk/model/src/main/resources/hibernate.cfg.xml
===================================================================
--- activity-monitor/trunk/model/src/main/resources/hibernate.cfg.xml 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/resources/hibernate.cfg.xml 2010-03-10 13:07:43 UTC (rev 996)
@@ -13,7 +13,7 @@
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">false</property>
- <property name="hibernate.hbm2ddl.auto">create</property>
+ <!--property name="hibernate.hbm2ddl.auto">create</property-->
<mapping resource="org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml"/>
Modified: activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml
===================================================================
--- activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml 2010-03-09 14:01:15 UTC (rev 995)
+++ activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml 2010-03-10 13:07:43 UTC (rev 996)
@@ -26,12 +26,12 @@
<component name="eventDetails">
<property name="currentState" column="currentState" not-null="true">
- <type name="org.jboss.bpm.monitor.model.StateUserType">
+ <type name="org.jboss.bpm.monitor.model.hibernate.StateUserType">
<param name="enumClass">org.jboss.bpm.monitor.model.bpaf.State</param>
</type>
</property>
<property name="previousState" column="previousState">
- <type name="org.jboss.bpm.monitor.model.StateUserType">
+ <type name="org.jboss.bpm.monitor.model.hibernate.StateUserType">
<param name="enumClass">org.jboss.bpm.monitor.model.bpaf.State</param>
</type>
</property>
14 years, 2 months
Overlord SVN: r995 - bpm-console/trunk/gui/war.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-09 09:01:15 -0500 (Tue, 09 Mar 2010)
New Revision: 995
Modified:
bpm-console/trunk/gui/war/pom.xml
Log:
Fix BPMC-55: remove slf4j from war files
Modified: bpm-console/trunk/gui/war/pom.xml
===================================================================
--- bpm-console/trunk/gui/war/pom.xml 2010-03-09 12:53:50 UTC (rev 994)
+++ bpm-console/trunk/gui/war/pom.xml 2010-03-09 14:01:15 UTC (rev 995)
@@ -15,9 +15,10 @@
</parent>
<properties>
- <gwt-maven.version>2.0-RC1</gwt-maven.version>
+ <gwt-maven.version>2.0-RC1</gwt-maven.version>
<mvel.version>2.0.16</mvel.version>
<guice.version>2.0</guice.version>
+ <slf4j.version>1.5.2</slf4j.version>
</properties>
<!-- Dependencies -->
@@ -27,6 +28,20 @@
<groupId>org.jboss.errai</groupId>
<artifactId>errai-bus</artifactId>
<version>${errai.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -92,7 +107,7 @@
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
- <version>${mvel.version}</version>
+ <version>${mvel.version}</version>
</dependency>
<dependency>
@@ -188,6 +203,31 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<!-- Plugins -->
@@ -348,22 +388,7 @@
<artifactId>gwt-console-profile-jbpm</artifactId>
<version>${version}</version>
<scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- <version>1.5.10</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>provided</scope>
- <version>1.5.10</version>
- </dependency>
-
+ </dependency>
</dependencies>
<properties>
<console.app.webcontext>jbpm-console</console.app.webcontext>
14 years, 2 months
Overlord SVN: r994 - in bpm-console/trunk/gui: war/src/main/java/org/jboss/bpm/console/client/process and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-09 07:53:50 -0500 (Tue, 09 Mar 2010)
New Revision: 994
Modified:
bpm-console/trunk/gui/profiles/riftsaw/src/main/resources/toolset-profile.properties
bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
Log:
Include terminate button in riftsaw build
Modified: bpm-console/trunk/gui/profiles/riftsaw/src/main/resources/toolset-profile.properties
===================================================================
--- bpm-console/trunk/gui/profiles/riftsaw/src/main/resources/toolset-profile.properties 2010-03-08 09:30:16 UTC (rev 993)
+++ bpm-console/trunk/gui/profiles/riftsaw/src/main/resources/toolset-profile.properties 2010-03-09 12:53:50 UTC (rev 994)
@@ -1,7 +1,7 @@
#org.jboss.bpm.console.client.task.AssignedTasksModule
#org.jboss.bpm.console.client.task.OpenTasksModule
org.jboss.bpm.console.client.process.ProcessModule
-org.jboss.bpm.console.client.engine.DeploymentModule
+#org.jboss.bpm.console.client.engine.DeploymentModule
#org.jboss.bpm.console.client.engine.JobListModule
org.jboss.bpm.console.client.PreferencesModule
org.jboss.bpm.console.client.ServerStatusModule
Modified: bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
===================================================================
--- bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2010-03-08 09:30:16 UTC (rev 993)
+++ bpm-console/trunk/gui/war/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java 2010-03-09 12:53:50 UTC (rev 994)
@@ -310,26 +310,16 @@
if(!isRiftsawInstance) // riftsaw doesn't support instance operations
{
- toolBar.add(
- startBtn
- );
+ toolBar.add(startBtn);
+ toolBar.add(deleteBtn);
- toolBar.add(
- terminateBtn
- );
-
- toolBar.add(
- deleteBtn
- );
-
startBtn.setEnabled(false);
- terminateBtn.setEnabled(false);
deleteBtn.setEnabled(false);
}
- else
- {
- toolBar.add(new HTML(" "));
- }
+
+ // terminate works on any BPM Engine
+ toolBar.add(terminateBtn);
+ terminateBtn.setEnabled(false);
toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
14 years, 2 months
Overlord SVN: r993 - in bpm-console/trunk: gui/war and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-08 04:30:16 -0500 (Mon, 08 Mar 2010)
New Revision: 993
Modified:
bpm-console/trunk/gui/war/pom.xml
bpm-console/trunk/pom.xml
Log:
Partially apply Maciej's changes
Modified: bpm-console/trunk/gui/war/pom.xml
===================================================================
--- bpm-console/trunk/gui/war/pom.xml 2010-03-07 19:48:11 UTC (rev 992)
+++ bpm-console/trunk/gui/war/pom.xml 2010-03-08 09:30:16 UTC (rev 993)
@@ -15,9 +15,8 @@
</parent>
<properties>
- <gwt-maven.version>2.0-RC1</gwt-maven.version>
- <errai.version>1.0-SNAPSHOT</errai.version>
- <mvel.version>2.0.16-SNAPSHOT</mvel.version>
+ <gwt-maven.version>2.0-RC1</gwt-maven.version>
+ <mvel.version>2.0.16</mvel.version>
<guice.version>2.0</guice.version>
</properties>
Modified: bpm-console/trunk/pom.xml
===================================================================
--- bpm-console/trunk/pom.xml 2010-03-07 19:48:11 UTC (rev 992)
+++ bpm-console/trunk/pom.xml 2010-03-08 09:30:16 UTC (rev 993)
@@ -54,7 +54,7 @@
<resteasy.version>1.0.2.GA</resteasy.version>
<stax-api.version>1.0-2</stax-api.version>
<report.server.version>1.2.0</report.server.version>
- <errai.version>1.1-SNAPSHOT</errai.version>
+ <errai.version>1.0.0</errai.version>
</properties>
<modules>
14 years, 2 months
Overlord SVN: r992 - in activity-monitor/trunk: model and 2 other directories.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-07 14:48:11 -0500 (Sun, 07 Mar 2010)
New Revision: 992
Added:
activity-monitor/trunk/model/scripts/
activity-monitor/trunk/model/scripts/antrun-schema.xml
Modified:
activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/ProcessRunnable.java
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
Log:
added bpaf costraints to hibernate model
Modified: activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/ProcessRunnable.java
===================================================================
--- activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/ProcessRunnable.java 2010-03-07 19:34:43 UTC (rev 991)
+++ activity-monitor/trunk/emu/src/main/java/org/jboss/bpm/monitor/emu/ProcessRunnable.java 2010-03-07 19:48:11 UTC (rev 992)
@@ -49,6 +49,7 @@
{
Event startEvent = new Event(true);
startEvent.setProcessName(process.getName());
+ startEvent.setProcessDefinitionID(process.getName());
startEvent.setProcessInstanceID(process.getInstanceId());
startEvent.getEventDetails().setCurrentState(State.Open);
@@ -78,8 +79,9 @@
// lifecycle end event
Event endEvent = new Event(true);
+ endEvent.setProcessDefinitionID(process.getName());
+ endEvent.setProcessInstanceID(process.getInstanceId());
endEvent.setProcessName(process.getName());
- endEvent.setProcessInstanceID(process.getInstanceId());
endEvent.getEventDetails().setCurrentState(State.Closed);
handler.processEvent(endEvent);
@@ -87,26 +89,26 @@
private Event createActivityEvent(String actitivity, State state)
{
- Event activityEvent = new Event(true);
- activityEvent.setProcessName(process.getName());
- activityEvent.setActivityDefinitionID(actitivity);
- activityEvent.setActivityInstanceID(actitivity+"_"+System.currentTimeMillis());
- activityEvent.getEventDetails().setCurrentState(state);
- return activityEvent;
- }
+ Event event = new Event(true);
- private Event createActivityEvent(String actitivity, State state, long timestamp)
- {
- Event event = new Event();
- event.setTimestamp(timestamp);
+ event.setProcessDefinitionID(process.getName());
+ event.setProcessInstanceID(process.getInstanceId());
event.setProcessName(process.getName());
- event.setProcessInstanceID(process.getInstanceId());
+
event.setActivityDefinitionID(actitivity);
event.setActivityInstanceID(actitivity+"_"+System.currentTimeMillis());
+
event.getEventDetails().setCurrentState(state);
return event;
}
+ private Event createActivityEvent(String actitivity, State state, long timestamp)
+ {
+ Event event = createActivityEvent(actitivity, state);
+ event.setTimestamp(timestamp);
+ return event;
+ }
+
private String invokeActivity()
throws InterruptedException
{
Added: activity-monitor/trunk/model/scripts/antrun-schema.xml
===================================================================
--- activity-monitor/trunk/model/scripts/antrun-schema.xml (rev 0)
+++ activity-monitor/trunk/model/scripts/antrun-schema.xml 2010-03-07 19:48:11 UTC (rev 992)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ============================================================ -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- ============================================================ -->
+
+<project>
+
+ <!-- ##################### -->
+ <!-- ### CREATE SCHEMA ### -->
+ <!-- ##################### -->
+
+ <target name="create-schema">
+ <taskdef name="schemaexport"
+ classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
+ classpathref="maven.compile.classpath" />
+
+ <mkdir dir="${project.output.dir}" />
+
+ <!--create-ddl db="hsqldb" />
+ <create-ddl db="oracle" />
+ <create-ddl db="postgresql" /-->
+ <create-ddl db="mysql" />
+ <!--replace file="${project.output.dir}/jbpm.mysql.create.sql"
+ token="BLOB_VALUE_ blob"
+ value="BLOB_VALUE_ longblob" /-->
+ </target>
+
+ <macrodef name="create-ddl">
+ <attribute name="db" />
+
+ <sequential>
+ <echo />
+ <echo>=====================</echo>
+ <echo>Schema Create @{db}</echo>
+ <echo>=====================</echo>
+
+ <schemaexport output="${project.output.dir}/bpaf.(a){db}.create.sql"
+ create="yes"
+ drop="no"
+ config="src/main/resources/hibernate.cfg.xml"
+ text="yes"
+ delimiter=";"
+ quiet="yes" />
+
+ <echo />
+ <echo>=====================</echo>
+ <echo>Schema Drop @{db}</echo>
+ <echo>=====================</echo>
+ <schemaexport output="${project.output.dir}/bpaf.(a){db}.drop.sql"
+ create="no"
+ drop="yes"
+ config="src/main/resources/hibernate.cfg.xml"
+ text="yes"
+ delimiter=";"
+ quiet="yes" />
+
+ </sequential>
+ </macrodef>
+
+</project>
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-07 19:34:43 UTC (rev 991)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-07 19:48:11 UTC (rev 992)
@@ -1,11 +1,3 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2010.03.05 at 08:26:33 PM CET
-//
-
-
package org.jboss.bpm.monitor.model.bpaf;
import java.util.ArrayList;
@@ -81,8 +73,7 @@
/**
* A globally unique identifier for the individual event
*/
- @XmlAttribute(name = "EventID", required = true)
- @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlAttribute(name = "EventID", required = true)
protected long eventID;
/**
14 years, 2 months
Overlord SVN: r991 - in activity-monitor/trunk/model/src/main: resources/org/jboss/bpm/monitor/model/bpaf and 1 other directory.
by overlord-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-03-07 14:34:43 -0500 (Sun, 07 Mar 2010)
New Revision: 991
Modified:
activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml
Log:
update javadocs
Modified: activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java
===================================================================
--- activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-07 19:26:24 UTC (rev 990)
+++ activity-monitor/trunk/model/src/main/java/org/jboss/bpm/monitor/model/bpaf/Event.java 2010-03-07 19:34:43 UTC (rev 991)
@@ -24,9 +24,10 @@
/**
- * <p>Java class for anonymous complex type.
+ * <p>Every state change in the BPAF state model can be represented as an XML message following the BPAF Event Format.
+ *
*
- * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>This format has the following basic components:
*
* <pre>
* <complexType>
@@ -77,41 +78,74 @@
@XmlElement(name = "DataElement")
protected List<Tuple> dataElement;
+ /**
+ * A globally unique identifier for the individual event
+ */
@XmlAttribute(name = "EventID", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected long eventID;
+ /**
+ * [optional]: A globally unique identifier for the originating server of the event
+ */
@XmlAttribute(name = "ServerID")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String serverID;
+ /**
+ * The identifier of the process definition
+ * from which the current process instance has been derived.
+ */
@XmlAttribute(name = "ProcessDefinitionID", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String processDefinitionID;
+ /**
+ * The identifier of the process instance
+ * that serves as the context of the event.
+ */
@XmlAttribute(name = "ProcessInstanceID", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String processInstanceID;
+ /**
+ * [optional]: The name of the process definition
+ * from which the current process instance has been derived.
+ */
@XmlAttribute(name = "ProcessName")
protected String processName;
+ /**
+ * [optional]: The identifier of the activity definition
+ * from which the current activity instance has been derived.
+ */
@XmlAttribute(name = "ActivityDefinitionID")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String activityDefinitionID;
+ /**
+ * [optional]: The identifier of the activity instance
+ * that serves as the context of the event.
+ */
@XmlAttribute(name = "ActivityInstanceID")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String activityInstanceID;
+ /**
+ * [optional]: The name of the activity definition
+ * from which the current activity instance has been derived.
+ */
@XmlAttribute(name = "ActivityName")
protected String activityName;
+ /**
+ * The time of the event occurrence
+ */
@XmlAttribute(name = "Timestamp", required = true)
@XmlSchemaType(name = "long")
protected long timestamp;
@@ -153,26 +187,10 @@
}
/**
- * Gets the value of the dataElement property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the dataElement property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getDataElement().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link Object }
- *
- *
+ * A name-value-pair that can be used to store additional process data
+ * that can later be used to correlate or aggregate events.
+ *
+ * @return
*/
@OneToMany(mappedBy="event")
public List<Tuple> getDataElement() {
@@ -434,8 +452,18 @@
@Embeddable
public static class EventDetails {
+ /**
+ * An identifier of the current state
+ * of the object that changed state, derived from the BPAF state model
+ */
@XmlAttribute(name = "CurrentState", required = true)
protected State currentState;
+
+ /**
+ * [optional]: An identifier of
+ * the previous state of the object that changed state,
+ * derived from the BPAF state model
+ */
@XmlAttribute(name = "PreviousState")
protected State previousState;
Modified: activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml
===================================================================
--- activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml 2010-03-07 19:26:24 UTC (rev 990)
+++ activity-monitor/trunk/model/src/main/resources/org/jboss/bpm/monitor/model/bpaf/BPAF.hbm.xml 2010-03-07 19:34:43 UTC (rev 991)
@@ -13,19 +13,19 @@
<property name="serverID" column="serverID"/>
- <property name="processDefinitionID" column="processDefinitionID"/>
- <property name="processInstanceID" column="processInstanceID"/>
+ <property name="processDefinitionID" column="processDefinitionID" not-null="true"/>
+ <property name="processInstanceID" column="processInstanceID" not-null="true"/>
<property name="processName" column="processName" />
<property name="activityDefinitionID" column="activityDefinitionID"/>
<property name="activityInstanceID" column="activityInstanceID"/>
<property name="activityName" column="activityName"/>
- <property name="timestamp" column="timestamp"/>
+ <property name="timestamp" column="timestamp" not-null="true"/>
<component name="eventDetails">
- <property name="currentState" column="currentState">
+ <property name="currentState" column="currentState" not-null="true">
<type name="org.jboss.bpm.monitor.model.StateUserType">
<param name="enumClass">org.jboss.bpm.monitor.model.bpaf.State</param>
</type>
14 years, 2 months