* @author Kris Verlaenen
*/
public class GraphViewerPluginImpl implements GraphViewerPlugin {
public List<ActiveNodeInfo> getActiveNodeInfo(String instanceId) {
ProcessInstanceLog processInstance = ProcessInstanceDbLog.findProcessInstance(new Long(instanceId));
if (processInstance == null) {
throw new IllegalArgumentException("Could not find process instance " + instanceId);
}
Map<String, NodeInstanceLog> nodeInstances = new HashMap<String, NodeInstanceLog>();
for (NodeInstanceLog nodeInstance: ProcessInstanceDbLog.findNodeInstances(new Long(instanceId))) {
if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) {
nodeInstances.put(nodeInstance.getNodeInstanceId(), nodeInstance);
} else {
nodeInstances.remove(nodeInstance.getNodeInstanceId());
}
}
if (!nodeInstances.isEmpty()) {
List<ActiveNodeInfo> result = new ArrayList<ActiveNodeInfo>();
for (NodeInstanceLog nodeInstance: nodeInstances.values()) {
boolean found = false;
DiagramInfo diagramInfo = getDiagramInfo(processInstance.getProcessId());
for (DiagramNodeInfo nodeInfo: diagramInfo.getNodeList()) {
if (nodeInfo.getName().equals("id=" + nodeInstance.getNodeId())) {
result.add(new ActiveNodeInfo(diagramInfo.getWidth(), diagramInfo.getHeight(), nodeInfo));
found = true;
break;
}
}
if (!found) {
throw new IllegalArgumentException("Could not find info for node "
+ nodeInstance.getNodeId() + " of process " + processInstance.getProcessId());
}
}
return result;
}
return null;