use of com.centurylink.mdw.designer.runtime.ProcessInstancePage in project mdw-designer by CenturyLinkCloud.
the class LogWatcher method handleLogMessage.
private synchronized void handleLogMessage(String message) {
Matcher matcher = pattern.matcher(message);
if (matcher.matches()) {
String time = matcher.group(1);
final Long procId = new Long(matcher.group(2));
final Long procInstId = new Long(matcher.group(3));
String subtype = matcher.group(4);
String id = matcher.group(5);
String msg = matcher.group(6);
try {
ProcessInstanceVO processInstanceInfo = processInstances.get(procInstId);
if (processInstanceInfo == null) {
processInstanceInfo = new DesignerDataAccess(dataAccess).getProcessInstanceBase(procInstId, null);
// only interested in one masterRequestId
if (processInstanceInfo.getMasterRequestId().equals(masterRequestId))
processInstances.put(procInstId, processInstanceInfo);
}
if (!processInstanceInfo.getMasterRequestId().equals(masterRequestId))
return;
// log the message
outputStream.println(message);
if (watchProcess) {
openInstance(processInstanceInfo);
synchronized (this) {
ProcessInstancePage processInstancePage = processInstancePages.get(processInstanceInfo.getId());
accumulated.offer(new ProcessInstanceUpdater(procId, procInstId, processInstancePage, subtype, time, id, msg));
}
}
if (msg.startsWith(WorkStatus.LOGMSG_PROC_COMPLETE) && procId.equals(process.getId()))
scheduleShutdown = true;
} catch (Exception ex) {
PluginMessages.log(ex);
shutdown();
}
}
}
use of com.centurylink.mdw.designer.runtime.ProcessInstancePage in project mdw-designer by CenturyLinkCloud.
the class LogWatcher method startup.
public void startup(boolean watchProcess) {
this.watchProcess = watchProcess;
if (logListener != null)
// already started
return;
pattern = Pattern.compile(MESSAGE_REG_EX, Pattern.DOTALL);
processInstancePages = new HashMap<Long, ProcessInstancePage>();
processInstances = new HashMap<Long, ProcessInstanceVO>();
accumulated = new LinkedList<ProcessInstanceUpdater>();
scheduleShutdown = false;
MessageConsole console = MessageConsole.findConsole("Live View Log", icon, display);
console.setRunnableEntity(this);
console.setDefaultShowPref(true);
console.setStatus(MessageConsole.STATUS_RUNNING);
console.clearConsole();
outputStream = console.newMessageStream();
try {
dataAccess = new DesignerDataAccess(process.getProject().getDesignerProxy().getDesignerDataAccess());
logListener = new LogSubscriberSocket(dataAccess, serverSettings.getLogWatcherPort(), process.getProject().isOldNamespaces()) {
protected void handleMessage(String message) {
handleLogMessage(message);
}
};
logListener.start(true);
new Thread(new Runnable() {
public void run() {
processQueue();
}
}).start();
} catch (Exception ex) {
if (outputStream != null)
ex.printStackTrace(new PrintStream(outputStream));
if (logListener != null && !logListener.isClosed()) {
logListener.shutdown();
logListener = null;
}
PluginMessages.uiError(ex, "Monitor Logs", process.getProject());
}
}
use of com.centurylink.mdw.designer.runtime.ProcessInstancePage in project mdw-designer by CenturyLinkCloud.
the class LogWatcher method processQueue.
private void processQueue() {
while (isRunning()) {
ProcessInstanceUpdater pid = null;
final ProcessInstancePage pip;
// boolean isEmbedded = false;
synchronized (this) {
pid = accumulated.peek();
// isEmbedded = pid == null ? false :
// isEmbeddedProcess(processInstanceInfos.get(pid.getProcessInstanceId()));
pip = pid == null ? null : processInstancePages.get(pid.getProcessInstanceId());
if (pid != null) {
if (pip != null)
accumulated.remove();
}
}
if (pid != null && pip != null) {
pid.setProcessInstancePage(pip);
pid.handleMessage();
if (scheduleShutdown && accumulated.isEmpty())
shutdown();
EventQueue.invokeLater(new Runnable() {
public void run() {
pip.canvas.repaint();
}
});
}
try {
Thread.sleep(250);
} catch (InterruptedException ex) {
}
}
refresh();
}
use of com.centurylink.mdw.designer.runtime.ProcessInstancePage in project mdw-designer by CenturyLinkCloud.
the class LogWatcher method openInstance.
private synchronized void openInstance(final ProcessInstanceVO processInstanceInfo) {
final WorkflowProcess newProcess = new WorkflowProcess(process);
if (!processInstanceInfo.getProcessId().equals(process.getId())) {
// must be a subprocess
ProcessVO subprocVO = new ProcessVO();
subprocVO.setProcessId(processInstanceInfo.getProcessId());
subprocVO.setProcessName(processInstanceInfo.getProcessName());
newProcess.setProcessVO(subprocVO);
}
final boolean isEmbedded = isEmbeddedProcess(processInstanceInfo);
final ProcessInstanceVO pageInfo = isEmbedded ? processInstances.get(processInstanceInfo.getOwnerId()) : processInstanceInfo;
newProcess.setProcessInstance(pageInfo);
display.syncExec(new Runnable() {
public void run() {
ProcessInstancePage procInstPage = null;
try {
IWorkbenchPage page = MdwPlugin.getActivePage();
ProcessEditor editor = null;
if (processInstancePages.get(pageInfo.getId()) == null) {
newProcess.setDesignerDataAccess(dataAccess);
editor = (ProcessEditor) page.openEditor(newProcess, "mdw.editors.process");
procInstPage = editor.getProcessCanvasWrapper().getProcessInstancePage();
if (procInstPage != null) {
processInstancePages.put(pageInfo.getId(), procInstPage);
}
} else if (isEmbedded && processInstancePages.get(processInstanceInfo.getId()) == null) {
newProcess.getProject().getDesignerProxy().loadProcessInstance(newProcess, processInstancePages.get(pageInfo.getId()));
processInstancePages.put(processInstanceInfo.getId(), processInstancePages.get(pageInfo.getId()));
} else {
editor = (ProcessEditor) page.findEditor(newProcess);
if (editor != null)
page.activate(editor);
}
} catch (Exception ex) {
PluginMessages.log(ex);
processInstancePages.remove(processInstanceInfo.getId());
}
}
});
}
Aggregations