Initial commit of the governance details view
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.classpath b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.classpath
new file mode 100644
index 0000000..8a8f166
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.project b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.project
new file mode 100644
index 0000000..474dc0c
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.soa.mangrove.governance.propView</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f287d53
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/META-INF/MANIFEST.MF b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6ccb0ce
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Properties View for Mangrove Governance Elements
+Bundle-SymbolicName: org.eclipse.soa.mangrove.governance.propView; singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.soa.mangrove.governance.propview.Activator
+Bundle-Vendor: Xerox Research
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.soa.mangrove,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor,
+ org.eclipse.soa.mangrove.edit;bundle-version="1.0.0",
+ org.eclipse.soa.mangrove.editor;bundle-version="1.0.0",
+ org.eclipse.soa.mangrove.diagram;bundle-version="1.0.0",
+ org.eclipse.soa.mangrove.governance.view;bundle-version="0.0.1",
+ org.eclipse.gmf.runtime.diagram.core;bundle-version="1.7.0",
+ org.swtchart;bundle-version="0.9.0",
+ org.swtchart.ext;bundle-version="0.9.0",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.7.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.ui.forms.widgets
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/bin/.gitignore b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/bin/.gitignore
new file mode 100644
index 0000000..571ee51
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/bin/.gitignore
@@ -0,0 +1 @@
+/org
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/build.properties b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/build.properties
new file mode 100644
index 0000000..255e23b
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ contexts.xml
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/contexts.xml b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/contexts.xml
new file mode 100644
index 0000000..b3b18ae
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/contexts.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<contexts>
+ <context id="viewer" title="Sample View">
+ <description>This is the context help for the sample view with a table viewer. It was generated by a PDE template.</description>
+ <topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
+ <enablement>
+ <with variable="platform">
+ <test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
+ </with>
+ </enablement>
+ </topic>
+ </context>
+</contexts>
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/icons/sample.gif b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/icons/sample.gif
Binary files differ
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/plugin.xml b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/plugin.xml
new file mode 100644
index 0000000..81b8129
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/plugin.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ name="Mangrove Governance Details View"
+ icon="icons/sample.gif"
+ category="org.eclipse.soa.mangrove.governance"
+ class="org.eclipse.soa.mangrove.governance.propview.views.MangroveDetailsView"
+ id="org.eclipse.soa.mangrove.governance.propview.views.MangroveDetailsView">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.eclipse.jdt.ui.JavaPerspective">
+ <view
+ ratio="0.5"
+ relative="org.eclipse.ui.views.ProblemView"
+ relationship="right"
+ id="org.eclipse.soa.mangrove.governance.propview.views.MangroveDetailsView">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.help.contexts">
+ <contexts
+ file="contexts.xml">
+ </contexts>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/Activator.java b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/Activator.java
new file mode 100644
index 0000000..d40b92f
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/Activator.java
@@ -0,0 +1,61 @@
+package org.eclipse.soa.mangrove.governance.propview;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.soa.mangrove.governance.propView"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ActivityMonitoringData.java b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ActivityMonitoringData.java
new file mode 100644
index 0000000..ef44a9b
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ActivityMonitoringData.java
@@ -0,0 +1,64 @@
+package org.eclipse.soa.mangrove.governance.propview.views;
+
+/**
+ * @author Adrian Mos
+ * Holder for monitoring data for BPMS activities
+ */
+public class ActivityMonitoringData {
+ public String getProcName() {
+ return procName;
+ }
+ public void setProcName(String procName) {
+ this.procName = procName;
+ }
+ public String getProcID() {
+ return procID;
+ }
+ public void setProcID(String procID) {
+ this.procID = procID;
+ }
+ public String getActivityName() {
+ return activityName;
+ }
+ public void setActivityName(String activityName) {
+ this.activityName = activityName;
+ }
+ public String getGrantedRole() {
+ return grantedRole;
+ }
+ public void setGrantedRole(String grantedRole) {
+ this.grantedRole = grantedRole;
+ }
+ public String getUser() {
+ return user;
+ }
+ public void setUser(String user) {
+ this.user = user;
+ }
+ public long getLastExecTime() {
+ return lastExecTime;
+ }
+ public void setLastExecTime(long l) {
+ this.lastExecTime = l;
+ }
+ public long getAvgExecTime() {
+ return avgExecTime;
+ }
+ public void setAvgExecTime(long l) {
+ this.avgExecTime = l;
+ }
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+ public void setTimeStamp(String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+ private String procName;
+ private String procID;
+ private String activityName;
+ private String grantedRole;
+ private String user;
+ private long lastExecTime;
+ private long avgExecTime;
+ private String timeStamp;
+}
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/BPMSMonitoringHandler.java b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/BPMSMonitoringHandler.java
new file mode 100644
index 0000000..ffe6d04
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/BPMSMonitoringHandler.java
@@ -0,0 +1,226 @@
+package org.eclipse.soa.mangrove.governance.propview.views;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Scanner;
+import java.util.Vector;
+
+/**
+ * @author Adrian Mos
+ * Helper class to deal with monitoring data from BPMS
+ */
+public class BPMSMonitoringHandler {
+
+ String activityFileName = "C:\\XRCE_PushMonitoring_FileStore\\monitoring_Activity.info";
+ String processFileName = "C:\\XRCE_PushMonitoring_FileStore\\monitoring_Process.info";
+ private Path activityFile;
+ private Path processFile;
+ private HashMap<String, ActivityMonitoringData> activityExecMap; //maps activity names composed of ProcessName+ActivityName to activity execution details
+ private HashMap<String, Vector<Long>> activityExecHistoryMap; //maps activity names composed of ProcessName+ActivityName to activity execution history
+ private HashMap<String, ProcessMonitoringData> processExecMap; //maps activity names composed of ProcessName+ActivityName to activity execution details
+ private HashMap<String, Vector<Long>> processExecHistoryMap; //maps activity names composed of ProcessName+ActivityName to activity execution history
+
+
+
+ public BPMSMonitoringHandler() {
+ activityFile = Paths.get(activityFileName);
+ processFile = Paths.get(processFileName);
+ initializeActivityDataStructures();
+ initializeProcessDataStructures();
+ try {
+ processActivityMonitoringFile();
+ processProcessMonitoringFile();
+ } catch (IOException e) {
+ System.err.println("Could not process the monitoring file at " + activityFileName);
+ }
+ try {
+ processProcessMonitoringFile();
+ } catch (IOException e) {
+ System.err.println("Could not process the monitoring file at " + processFileName);
+ }
+
+ }
+
+ private void processProcessMonitoringFile() throws IOException {
+ Scanner s = new Scanner(processFile);
+ initializeProcessDataStructures();
+ while (s.hasNextLine()){
+ ProcessMonitoringData data = processProcessLine (s.nextLine());
+ if (null!=data){
+ processExecMap.put(data.getProcessName(), data);
+ }
+ }
+ s.close();
+ //this.printDataStructures();
+
+ }
+
+ private ProcessMonitoringData processProcessLine(String nextLine) {
+ ProcessMonitoringData data = new ProcessMonitoringData();
+ Scanner ls = new Scanner(nextLine);
+ ls.useDelimiter("::");
+ try{
+ if (ls.hasNext()){
+ data.setProcessName(ls.next());
+ data.setProcID(ls.next());
+
+ // add the list of activities
+ Vector<String> activityNames = new Vector<String>();
+ Scanner aNames = new Scanner(ls.next());
+ aNames.useDelimiter(";");
+ while(aNames.hasNext()) activityNames.add(aNames.next());
+ data.setPerformedActivityNames(activityNames);
+ aNames.close();
+
+ data.setUser(ls.next());
+ data.setLastExecTime(ls.nextLong());
+ data.setAvgExecTime(ls.nextLong());
+ data.setTimeStamp(ls.next());
+
+ String key = data.getProcessName();
+ Vector<Long> v;
+ if (processExecHistoryMap.containsKey(key)) v = processExecHistoryMap.get(key);
+ else v = new Vector<Long>();
+ v.add(data.getLastExecTime());
+ processExecHistoryMap.put(key, v);
+ }
+ } catch (Exception e){
+ data = null;
+ }
+
+ ls.close();
+ return data;
+ }
+
+ private void initializeActivityDataStructures(){
+ activityExecMap = new HashMap<String, ActivityMonitoringData>();
+ activityExecHistoryMap = new HashMap<String, Vector<Long>>();
+ }
+
+ private void initializeProcessDataStructures(){
+ processExecMap = new HashMap<String, ProcessMonitoringData>();
+ processExecHistoryMap = new HashMap<String, Vector<Long>>();
+ }
+
+ public static void main(String[] args) {
+ BPMSMonitoringHandler h = new BPMSMonitoringHandler();
+ try {
+ ActivityMonitoringData d = h.findLatestActivityMonitoringData("TimeSheetBP_1", "ViewTimeSheets");
+ if (null!=d) System.out.println("FOUND Latest Activity Data: " + d.getAvgExecTime());
+ Vector v = h.getActivityExecutionTimes("TimeSheetBP_1", "ViewTimeSheets");
+ System.out.println(v);
+
+ ProcessMonitoringData p = h.findLatestProcessMonitoringData("TimeSheetBP_1");
+ if (null!=p) {
+ System.out.println("FOUND Latest Data: " + p.getAvgExecTime());
+ Vector act = p.getPerformedActivityNames();
+ System.out.println("Executed activities for last instance " + p.getProcID() + ": " + act);
+ }
+ Vector vp = h.getProcessExecutionTimes("TimeSheetBP_1");
+ System.out.println(vp);
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void processActivityMonitoringFile() throws IOException{
+ Scanner s = new Scanner(activityFile);
+ initializeActivityDataStructures();
+ while (s.hasNextLine()){
+ ActivityMonitoringData data = processActivityLine (s.nextLine());
+ if (null!=data){
+ //System.out.println(data.getActivityName() + " executed in " + data.getLastExecTime() + " at " + data.getTimeStamp());
+ activityExecMap.put(data.getProcName() + "::" + data.getActivityName(), data);
+ }
+ }
+ s.close();
+ //this.printDataStructures();
+ }
+
+ private void printDataStructures(){
+ System.out.println("Printing Activity TO Execution Data HashMap");
+ for (String key : activityExecMap.keySet()){
+ System.out.println("Activity: " + key + " :: "+ activityExecMap.get(key));
+ }
+
+ System.out.println("Printing Activity TO Execution History HashMap");
+ for (String key : activityExecHistoryMap.keySet()){
+ System.out.println("Activity: " + key + " :: "+ activityExecHistoryMap.get(key));
+ }
+
+
+ }
+
+ /**
+ * @param processName
+ * @param activityName
+ * @return the object containing execution details for the last execution of this activity regardless of process instance
+ * @throws IOException
+ */
+ public ActivityMonitoringData findLatestActivityMonitoringData(String processName, String activityName) throws IOException{
+ ActivityMonitoringData data = null;
+ String key = processName + "::" + activityName; //our convention, used also when storing values in the map
+ this.processActivityMonitoringFile(); //updates the contents of the map (only the last values will be stored) due to the nature of the map
+ if (activityExecMap.containsKey(key)) data = activityExecMap.get(key);
+ return data;
+ }
+
+ public Vector<Long> getActivityExecutionTimes(String processName, String activityName) {
+ //System.out.println("LOOKING FOR EXECUTION TIMES FOR ACTIVITY: " + activityName + " IN PROCESS: " + processName);
+ Vector<Long> v = null;
+ String key = processName + "::" + activityName; //our convention, used also when storing values in the map
+ if (activityExecHistoryMap.containsKey(key)) v = activityExecHistoryMap.get(key);
+ //System.out.println("FOUND these values: " + v);
+ return v;
+ }
+
+ public ProcessMonitoringData findLatestProcessMonitoringData(String processName) throws IOException{
+ ProcessMonitoringData data = null;
+ this.processProcessMonitoringFile(); //updates the contents of the map (only the last values will be stored) due to the nature of the map
+ if (processExecMap.containsKey(processName)) data = processExecMap.get(processName);
+ return data;
+ }
+
+ public Vector<Long> getProcessExecutionTimes(String processName) {
+ //System.out.println("LOOKING FOR EXECUTION TIMES FOR PROCESS: " + processName);
+ Vector<Long> v = null;
+ if (processExecHistoryMap.containsKey(processName)) v = processExecHistoryMap.get(processName);
+ //System.out.println("FOUND these values: " + v);
+ return v;
+ }
+
+ private ActivityMonitoringData processActivityLine(String nextLine) {
+ ActivityMonitoringData data = new ActivityMonitoringData();
+ Scanner ls = new Scanner(nextLine);
+ ls.useDelimiter("::");
+ try{
+ if (ls.hasNext()){
+ data.setProcName(ls.next());
+ data.setProcID(ls.next());
+ data.setActivityName(ls.next());
+ data.setGrantedRole(ls.next());
+ data.setUser(ls.next());
+ data.setLastExecTime(ls.nextLong());
+ data.setAvgExecTime(ls.nextLong());
+ data.setTimeStamp(ls.next());
+
+ String key = data.getProcName() + "::" + data.getActivityName(); //our convention, used also when storing values in the map
+ Vector<Long> v;
+ if (activityExecHistoryMap.containsKey(key)) v = activityExecHistoryMap.get(key);
+ else v = new Vector<Long>();
+ v.add(data.getLastExecTime());
+ activityExecHistoryMap.put(key, v);
+ }
+ } catch (Exception e){
+ data = null;
+ }
+
+ ls.close();
+ return data;
+ }
+
+}
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/MangroveDetailsView.java b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/MangroveDetailsView.java
new file mode 100644
index 0000000..8d40810
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/MangroveDetailsView.java
@@ -0,0 +1,357 @@
+package org.eclipse.soa.mangrove.governance.propview.views;
+
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.soa.mangrove.diagram.edit.parts.ProcessEditPart;
+import org.eclipse.soa.mangrove.diagram.edit.parts.StepEditPart;
+import org.eclipse.soa.mangrove.diagram.part.IntermediateModelDiagramEditor;
+import org.eclipse.soa.mangrove.governance.view.GovernanceView;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.internal.win32.FLICK_POINT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.ViewPart;
+import org.swtchart.Chart;
+import org.swtchart.IAxis;
+import org.swtchart.IAxisSet;
+import org.swtchart.IBarSeries;
+import org.swtchart.ISeries;
+import org.swtchart.ISeriesSet;
+import org.swtchart.ISeries.SeriesType;
+
+
+public class MangroveDetailsView extends ViewPart {
+
+ private BPMSMonitoringHandler monitoringHandler;
+
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "org.eclipse.soa.mangrove.governance.propview.views.MangroveDetailsView";
+
+ /**
+ * ensure that the Mangrove details view displays the information about the selected mangrove element
+ */
+ private ISelectionListener mangroveElementListener = new ISelectionListener() {
+ public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
+ //System.out.println(">>>> DETAILS VIEW >>>> sourcepart: " + sourcepart + " >>> selection: " + selection);
+ if ( (sourcepart instanceof GovernanceView) || (sourcepart instanceof IntermediateModelDiagramEditor) ){
+ //System.out.println(">>>> Mangrove element selected: " + sourcepart + " >>> selection: " + selection.getClass() + " >>> " + selection);
+ if (selection instanceof TreeSelection) { //this originates in a tree based view such as the Governance View or some Mangrove tree view
+ TreeSelection ts = (TreeSelection) selection;
+ String selectedItem = null;
+ String parentItem = null;
+ if (null!=ts && null!=ts.getFirstElement()){
+ selectedItem = ts.getFirstElement().toString();
+ if( (ts.getPaths() != null) && (ts.getPaths().length > 0) ){
+ TreePath p = ts.getPaths()[0];
+ if (null!=p && null!=p.getParentPath() && null!=p.getParentPath().getLastSegment()){
+ parentItem = p.getParentPath().getLastSegment().toString();
+ //must check to see the activity name actually points to an activity name (i.e. it's top-level parent is "Processes")
+ if (p.getParentPath().getFirstSegment().toString().equalsIgnoreCase("Processes")){
+ activityName = selectedItem;
+ processName = parentItem;
+ //if the activity name is in fact a process (i.e. its top-level parent is "Processes" but this is also its direct parent)
+ //this means the selection in fact pertains to a process (the user selected a process)
+ //so the activity is set to null
+ if (processName.equalsIgnoreCase("Processes")){
+ processName = activityName;
+ activityName = null;
+ handleProcessSelection(processName);
+ }
+ else {
+ handleActivitySelection(processName, activityName);
+ }
+ }
+ else {
+ activityName = null;
+ processName = null;
+
+ }
+
+ }
+
+ }
+ }
+ } else if (selection instanceof StructuredSelection){
+ StructuredSelection sel = (StructuredSelection)selection;
+ Object element = sel.getFirstElement();
+ if(element instanceof ProcessEditPart) { //the user clicked on a Mangrove Process
+ ProcessEditPart procPart = (ProcessEditPart)element;
+ processName = procPart.getContentPane().getChildren().get(0).toString();
+ //System.out.println("PROCESS NAME: " + processName);
+ handleProcessSelection(processName);
+ }
+ else if(element instanceof StepEditPart){ //the user clicked on a Mangrove Step
+ StepEditPart stepPart = (StepEditPart)element;
+ activityName = stepPart.getContentPane().getChildren().get(0).toString();
+ processName = ((ProcessEditPart)(stepPart.getParent())).getContentPane().getChildren().get(0).toString();
+ //System.out.println("PROCESS NAME: " + processName + ":: ACTIVITY NAME: " + activityName);
+ handleActivitySelection(processName, activityName);
+ }
+
+ }
+ }
+ }
+ };
+
+ private String activityName = null;
+ private String processName = null;
+ private Composite compositeParent;
+
+ private Chart chart;
+ private Table detailsTable;
+ private Table activitiesTable;
+
+ private ISeries chartSeries;
+
+ private Label activity;
+ private Label process;
+ private Label activityNames;
+
+ private Composite infoBox;
+
+ private ScrolledComposite sc;
+
+ private Composite chartHolder;
+
+
+ /**
+ * @param processName
+ * @param activityName
+ * Handles the selection somewhere in the workspace of an item that corresponds to a BPMS activity
+ * It will display all the monitoring elements required for it
+ */
+ private void handleActivitySelection(String processName, String activityName){
+ ActivityMonitoringData data = null;
+ try {
+ data = monitoringHandler.findLatestActivityMonitoringData(processName, activityName);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ setUpInfoBox();
+ RowLayout boxLayout = new RowLayout();
+ boxLayout.type = SWT.VERTICAL;
+ infoBox.setLayout(boxLayout);
+
+ if(null!=activity) activity.dispose();
+ if(null!=process) process.dispose();
+
+ activity = new Label(infoBox, PROP_TITLE);
+ activity.setText("Activity Name: " + activityName);
+ FontData[] fD = activity.getFont().getFontData();
+ fD[0].setHeight(16);
+ activity.setFont( new Font(Display.getCurrent(),fD[0]));
+
+ process = new Label(infoBox, PROP_TITLE);
+ process.setText("Process: " + processName);
+
+ Map<String, String> dataMap = null;
+
+ if (null!=data){
+ dataMap = new HashMap<String, String>();
+
+ process.setText("Process: " + processName + " | ID: " + data.getProcID());
+
+ dataMap.put("User executing the activity: ", data.getUser() );
+ dataMap.put("Role executing the activity: ", data.getGrantedRole());
+ dataMap.put("The duration of the last execution was: ", String.valueOf(data.getLastExecTime()) + "ms");
+ dataMap.put("The average execution time for the activity is: ", String.valueOf(data.getAvgExecTime()) + "ms");
+
+ }
+ this.updateTable(dataMap);
+ infoBox.layout();
+ updateChart(activityName, monitoringHandler.getActivityExecutionTimes(processName, activityName));
+ compositeParent.layout();
+ }
+
+
+ /**
+ * @param processName
+ * Handles the selection somewhere in the workspace of an item that corresponds to a BPMS process
+ * It will display all the monitoring elements required for it
+ */
+ protected void handleProcessSelection(String processName) {
+ ProcessMonitoringData data = null;
+ try {
+ data = monitoringHandler.findLatestProcessMonitoringData(processName);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ setUpInfoBox();
+ RowLayout boxLayout = new RowLayout();
+ boxLayout.type = SWT.VERTICAL;
+ infoBox.setLayout(boxLayout);
+
+ if(null!=process) process.dispose();
+ process = new Label(infoBox, PROP_TITLE);
+ process.setText("Process: " + processName);
+ FontData[] fD = process.getFont().getFontData();
+ fD[0].setHeight(16);
+ process.setFont( new Font(Display.getCurrent(),fD[0]));
+
+ Vector<String> actNames = null;
+ String procID = "";
+ Map<String, String> dataMap = null;
+ if (null!=data){
+ dataMap = new HashMap<String, String>();
+ dataMap.put("User executing the process: ", data.getUser() );
+ dataMap.put("The duration of the last execution was: ", String.valueOf(data.getLastExecTime()) + "ms");
+ dataMap.put("The average execution time for the activity is: ", String.valueOf(data.getAvgExecTime()) + "ms");
+ procID = data.getProcID();
+ actNames = data.getPerformedActivityNames();
+ }
+
+
+ this.updateTable(dataMap);
+
+ if(null!=activityNames) activityNames.dispose();
+ activityNames = new Label(infoBox, PROP_TITLE);
+ activityNames.setText("Activities executed by last instance " + procID);
+ FontData[] fD2 = activityNames.getFont().getFontData();
+ fD2[0].setHeight(12);
+ activityNames.setFont( new Font(Display.getCurrent(),fD2[0]));
+
+ this.updateActivitiesTable(actNames);
+ infoBox.layout();
+
+ updateChart(processName, monitoringHandler.getProcessExecutionTimes(processName));
+ compositeParent.layout();
+
+ }
+
+
+ private void setUpInfoBox() {
+ if(null!=infoBox) infoBox.dispose();
+ infoBox = new Composite(compositeParent, SWT.BORDER);
+ //sc.setContent(infoBox);
+ }
+
+ /**
+ * The constructor.
+ */
+ public MangroveDetailsView() {
+ monitoringHandler = new BPMSMonitoringHandler();
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+
+ FillLayout flayout = new FillLayout();
+ //flayout.type = SWT.VERTICAL;
+ parent.setLayout(flayout);
+ this.compositeParent = parent;
+
+ //add the listener for the any changes, the idea is that when the user selects a Mangrove element, the governance view gets updated
+ //System.out.println("ADDING Governance Details LISTENER");
+ getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this.mangroveElementListener);
+ }
+
+
+ /**
+ * updates the SWT Table component with the details about the activity or the process selected
+ */
+ private void updateTable(Map<String, String> tableContents){
+ if (null!=detailsTable) detailsTable.dispose();
+ detailsTable = new Table(infoBox, SWT.BORDER);
+ detailsTable.setSize(450, 200);
+ TableColumn titlesColumn = new TableColumn(detailsTable, SWT.LEFT);
+ titlesColumn.setWidth(300);
+ titlesColumn.setText("Parameter");
+ TableColumn valuesColumn = new TableColumn(detailsTable, SWT.RIGHT);
+ valuesColumn.setText("Value");
+ valuesColumn.setWidth(150);
+ detailsTable.setHeaderVisible(true);
+ detailsTable.setLinesVisible(true);
+ if(null!=tableContents){
+ for(String key : tableContents.keySet()){
+ //System.out.println("Adding line: " + key + " :: " + tableContents.get(key));
+ TableItem line = new TableItem(detailsTable, SWT.NONE);
+ line.setText(new String[] {key, tableContents.get(key)});
+ }
+ }
+ detailsTable.layout();
+ }
+
+ private void updateActivitiesTable(Vector<String> actNames){
+ if (null!=activitiesTable) activitiesTable.dispose();
+ activitiesTable = new Table(infoBox, SWT.BORDER);
+ activitiesTable.setSize(250, 100);
+ TableColumn titlesColumn = new TableColumn(activitiesTable, SWT.CENTER);
+ titlesColumn.setWidth(250);
+ titlesColumn.setText("Activity");
+ activitiesTable.setHeaderVisible(true);
+ activitiesTable.setLinesVisible(true);
+ if(null!=actNames){
+ for(String value : actNames){
+ //System.out.println("Adding line: " + key + " :: " + tableContents.get(key));
+ TableItem line = new TableItem(activitiesTable, SWT.NONE);
+ line.setText(new String[] {value});
+ }
+ }
+ activitiesTable.layout();
+ }
+
+ /**
+ * updates the SWT Chart component with the relevant execution history data for the process or activity selected
+ */
+ private void updateChart(String title, Vector<Long> values) {
+
+ if (null!=chart) chart.dispose();
+
+ chart = new Chart(compositeParent, SWT.BORDER);
+ chart.getAxisSet().getXAxis(0).getTitle().setText("Execution instance");
+ chart.getAxisSet().getYAxis(0).getTitle().setText("Execution Time (ms)");
+
+ ISeriesSet seriesSet = chart.getSeriesSet();
+ chartSeries = seriesSet.createSeries (SeriesType.LINE, "execution history");
+ chart.getTitle().setText("Execution History for " + title);
+ chartSeries.setDescription(title);
+ chart.getTitle().setText("Execution History for " + title);
+
+ //System.out.println("Looking for historical data for " + activityName + " in process " + processName);
+ if (null != values) {
+ double[] doubleValues = new double[values.size()];
+ for (int i = 0; i < values.size(); i++) doubleValues[i] = values.get(i).doubleValue();
+ chartSeries.setYSeries(doubleValues);
+ IAxisSet axisSet = chart.getAxisSet();
+ axisSet.adjustRange();
+ }
+
+ chart.layout();
+
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+
+ }
+}
\ No newline at end of file
diff --git a/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ProcessMonitoringData.java b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ProcessMonitoringData.java
new file mode 100644
index 0000000..ae933d1
--- /dev/null
+++ b/org.eclipse.soa.mangrove.leaves/trunk/org.eclipse.soa.mangrove.governance.propView/src/org/eclipse/soa/mangrove/governance/propview/views/ProcessMonitoringData.java
@@ -0,0 +1,59 @@
+package org.eclipse.soa.mangrove.governance.propview.views;
+
+import java.util.Vector;
+
+/**
+ * @author Adrian Mos
+ * Holder for monitoring data for BPMS processes
+ */
+public class ProcessMonitoringData {
+ public String getProcessName() {
+ return procName;
+ }
+ public void setProcessName(String procName) {
+ this.procName = procName;
+ }
+ public String getProcID() {
+ return procID;
+ }
+ public void setProcID(String procID) {
+ this.procID = procID;
+ }
+ public Vector<String> getPerformedActivityNames() {
+ return performedActivityNames;
+ }
+ public void setPerformedActivityNames(Vector<String> performedAactivityNames) {
+ this.performedActivityNames = performedAactivityNames;
+ }
+ public String getUser() {
+ return user;
+ }
+ public void setUser(String user) {
+ this.user = user;
+ }
+ public long getLastExecTime() {
+ return lastExecTime;
+ }
+ public void setLastExecTime(long lastExecTime) {
+ this.lastExecTime = lastExecTime;
+ }
+ public long getAvgExecTime() {
+ return avgExecTime;
+ }
+ public void setAvgExecTime(long avgExecTime) {
+ this.avgExecTime = avgExecTime;
+ }
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+ public void setTimeStamp(String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+ private String procName;
+ private String procID;
+ private Vector<String> performedActivityNames;
+ private String user;
+ private long lastExecTime;
+ private long avgExecTime;
+ private String timeStamp;
+}