riftsaw SVN: r1041 - in trunk: console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf and 2 other directories.
by riftsaw-commits@lists.jboss.org
Author: heiko.braun(a)jboss.com
Date: 2010-10-15 07:52:25 -0400 (Fri, 15 Oct 2010)
New Revision: 1041
Added:
trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/LineNumber.java
trunk/console/integration/src/main/resources/META-INF/services/org.jboss.bpm.console.server.plugin.ProcessActivityPlugin
Modified:
trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/EventAdapter.java
trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/JDBCPersistenceStrategy.java
trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/SVGPlugin.java
trunk/pom.xml
Log:
RIFTSAW-264, RIFTSAW-92
Modified: trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/EventAdapter.java
===================================================================
--- trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/EventAdapter.java 2010-10-14 15:08:18 UTC (rev 1040)
+++ trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/EventAdapter.java 2010-10-15 11:52:25 UTC (rev 1041)
@@ -19,6 +19,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.evt.*;
import org.jboss.bpm.monitor.model.bpaf.Event;
+import org.jboss.bpm.monitor.model.bpaf.Tuple;
import java.util.HashMap;
import java.util.Map;
@@ -54,6 +55,9 @@
target.setProcessDefinitionID(source.getProcessId().toString());
target.setProcessName(source.getProcessName().toString());
+ // required for bpel2svg. See https://jira.jboss.org/browse/RIFTSAW-264
+ target.addData(new LineNumber(bpelEvent.getLineNo()));
+
EventDetailMapping mapping = detailMapping.get(bpelEvent.getClass());
if(mapping!=null)
mapping.adoptDetails(target, source);
@@ -66,5 +70,5 @@
public interface EventDetailMapping<T extends ProcessEvent>
{
Event adoptDetails(Event target, T source);
- }
+ }
}
Modified: trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/JDBCPersistenceStrategy.java
===================================================================
--- trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/JDBCPersistenceStrategy.java 2010-10-14 15:08:18 UTC (rev 1040)
+++ trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/JDBCPersistenceStrategy.java 2010-10-15 11:52:25 UTC (rev 1041)
@@ -51,7 +51,7 @@
EntityManager entityManager = defaultLocator.locate();
// It's managed by JACORB
- // Hence we don't deal with the TX here
+ // Hence we don't deal with the TX here
entityManager.persist(event);
} catch (Exception e) {
Added: trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/LineNumber.java
===================================================================
--- trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/LineNumber.java (rev 0)
+++ trunk/console/bpaf/src/main/java/org/jboss/soa/bpel/console/bpaf/LineNumber.java 2010-10-15 11:52:25 UTC (rev 1041)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009 JBoss, a divison Red Hat, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.soa.bpel.console.bpaf;
+
+import org.jboss.bpm.monitor.model.bpaf.Tuple;
+
+/**
+ * @author: Heiko Braun <hbraun(a)redhat.com>
+ * @date: Oct 12, 2010
+ */
+public class LineNumber extends Tuple
+{
+ private final static String name = "line-number";
+
+ LineNumber(int value) {
+ setName(name);
+ setValue(String.valueOf(value));
+ }
+}
\ No newline at end of file
Modified: trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/SVGPlugin.java
===================================================================
--- trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/SVGPlugin.java 2010-10-14 15:08:18 UTC (rev 1040)
+++ trunk/console/integration/src/main/java/org/jboss/soa/bpel/console/SVGPlugin.java 2010-10-15 11:52:25 UTC (rev 1041)
@@ -21,12 +21,17 @@
import org.jboss.bpm.console.client.model.ActiveNodeInfo;
import org.jboss.bpm.console.client.model.DiagramInfo;
import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
+import org.jboss.bpm.console.server.plugin.ProcessActivityPlugin;
+import org.jboss.bpm.monitor.model.BPAFDataSource;
+import org.jboss.bpm.monitor.model.DataSourceFactory;
+import org.jboss.bpm.monitor.model.bpaf.Event;
+import org.jboss.bpm.monitor.model.bpaf.Tuple;
import org.jboss.soa.bpel.bpel2svg.BPEL2SVGUtil;
-import org.jboss.soa.bpel.console.util.LRUCache;
import org.jboss.soa.bpel.runtime.engine.BPELEngine;
import org.jboss.soa.bpel.runtime.engine.ode.BPELEngineImpl;
import org.jboss.soa.bpel.runtime.integration.ServerConfig;
import org.jboss.soa.bpel.runtime.integration.ServerConfigFactory;
+import org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface;
import org.wso2.carbon.bpel.ui.bpel2svg.SVGInterface;
import javax.naming.InitialContext;
@@ -38,7 +43,7 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -48,7 +53,7 @@
* @author: Heiko Braun <hbraun(a)redhat.com>
* @date: Oct 12, 2010
*/
-public class SVGPlugin implements GraphViewerPlugin {
+public class SVGPlugin implements GraphViewerPlugin, ProcessActivityPlugin {
protected final static Log log = LogFactory.getLog(SVGPlugin.class);
@@ -58,9 +63,9 @@
protected int webServicePort = 8080;
private BPELEngine engine;
+
+ private BPAFDataSource bpafDataSource;
- private LRUCache cache;
-
public SVGPlugin() {
// host & port resolution
@@ -78,7 +83,7 @@
throw new RuntimeException("Failed to initialize BPEL engine");
}
- cache = new LRUCache(20);
+ this.bpafDataSource = DataSourceFactory.createDataSource();
}
protected StringBuilder getBaseUrl() {
@@ -91,16 +96,52 @@
return spec;
}
+ public byte[] getProcessInstanceImage(String definitionId, String instanceId) {
+
+ QName qName = decode(definitionId);
+ SVGInterface svg = createSVG(qName);
+
+ List<Event> executionHistory =
+ bpafDataSource.getPastActivities(instanceId);// no need to decode?
+
+
+ for(Event event : executionHistory)
+ {
+ for(Tuple t : event.getDataElement())
+ {
+ if("line-number".equals(t.getName()))
+ {
+ Integer line = Integer.valueOf(t.getValue());
+ if(line>0) // TODO: still carries -1 for begin/end
+ {
+ ActivityInterface activity =
+ svg.getActivityAtLineNumber(line);
+ if(null==activity)
+ throw new RuntimeException("No activity matching line number "+
+ t.getValue() + " in process "
+ + qName);
+
+ activity.setState(ActivityInterface.ActivityState.Completed);
+ }
+ }
+ }
+ }
+
+ return svg.toPNGBytes();
+ }
+
public byte[] getProcessImage(String processId) {
- // any cache hits?
- byte[] cached = (byte[])cache.get(processId);
- if(cached !=null)
- return cached;
+ QName qName = decode(processId);
+ SVGInterface svg = createSVG(qName);
+ return svg.toPNGBytes();
+ }
- // generate new
- InputStream in = getBpelDescriptor(processId);
+ private SVGInterface createSVG(QName qName) {
+ // generate new
+ InputStream in = getBpelDescriptor(qName);
+
SVGInterface svg = null;
try {
@@ -112,18 +153,17 @@
} catch(Exception e) {
throw new RuntimeException("Failed to render process image", e);
}
+ return svg;
+ }
- byte[] bytes = svg.toPNGBytes();
-
- cache.put(processId, bytes);
-
- return bytes;
+ private static QName decode(String processId) {
+ String actualId = ModelAdaptor.decodeId(processId);
+ QName qName= QName.valueOf(actualId);
+ return qName;
}
- private InputStream getBpelDescriptor(String processId)
+ private InputStream getBpelDescriptor(QName qName)
{
- String actualId = ModelAdaptor.decodeId(processId);
- QName qName= QName.valueOf(actualId);
ProcessConf pconf = ((BPELEngineImpl)engine)._store.getProcessConfiguration(qName);
try {
@@ -140,7 +180,7 @@
}
public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId) {
- return new ArrayList<ActiveNodeInfo>(); // Not used
+ return Collections.EMPTY_LIST; // Not used
}
public URL getDiagramURL(String id) {
@@ -160,6 +200,6 @@
}
public List<ActiveNodeInfo> getNodeInfoForActivities(String processDefinitionId, List<String> activities) {
- return new ArrayList<ActiveNodeInfo>(); // Not used
+ return Collections.EMPTY_LIST; // Not used
}
}
Added: trunk/console/integration/src/main/resources/META-INF/services/org.jboss.bpm.console.server.plugin.ProcessActivityPlugin
===================================================================
--- trunk/console/integration/src/main/resources/META-INF/services/org.jboss.bpm.console.server.plugin.ProcessActivityPlugin (rev 0)
+++ trunk/console/integration/src/main/resources/META-INF/services/org.jboss.bpm.console.server.plugin.ProcessActivityPlugin 2010-10-15 11:52:25 UTC (rev 1041)
@@ -0,0 +1 @@
+org.jboss.soa.bpel.console.SVGPlugin
\ No newline at end of file
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-14 15:08:18 UTC (rev 1040)
+++ trunk/pom.xml 2010-10-15 11:52:25 UTC (rev 1041)
@@ -78,7 +78,7 @@
<riftsaw.ode.version>2.2.0-SNAPSHOT</riftsaw.ode.version>
<riftsaw.engine.version>2.2.0-SNAPSHOT</riftsaw.engine.version>
<bpel.console.version>2.2.2-SNAPSHOT</bpel.console.version>
- <activity.monitor.model.version>1.0.0-Beta1</activity.monitor.model.version>
+ <activity.monitor.model.version>1.0.0-SNAPSHOT</activity.monitor.model.version>
<commons.logging.version>1.1.1</commons.logging.version>
<junit.version>4.8.1</junit.version>
<jboss.version>5.1.0.GA</jboss.version>