use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.
the class FormPanel method setData.
/**
* this is invoked when coming from script list page or package tree
*/
public void setData(String formname, String data) throws Exception {
try {
formdoc = loadForm(formname);
datadoc = new FormDataDocument();
if (data != null && data.length() > 0)
datadoc.load(data);
canvas = new FormDesignCanvas(frame, this, dao);
canvas.setFormXml(formdoc, datadoc);
JScrollPane canvasScrollpane = new JScrollPane(canvas);
MbengNode rootnode = canvas.getFormXml().getRootNode();
String av = rootnode.getAttribute(FormConstants.FORMATTR_VW);
int w = (av == null) ? 800 : Integer.parseInt(av);
av = rootnode.getAttribute(FormConstants.FORMATTR_VH);
int h = (av == null) ? 600 : Integer.parseInt(av);
this.add(canvasScrollpane, BorderLayout.CENTER);
Container content_pane;
if (frame instanceof JDialog) {
content_pane = ((JDialog) frame).getContentPane();
} else {
content_pane = ((JFrame) frame).getContentPane();
}
content_pane.add(this);
frame.setSize(w + 10, h + 30);
} catch (Exception e) {
e.printStackTrace();
show_error("failed to set data for canvas: " + e.getMessage());
throw e;
}
}
use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method launchSwing.
public void launchSwing(final WorkflowProject project, final String title, final String formName, String dataInit) {
try {
if (title.equals("Java VisualVM")) {
String javaVersion = System.getProperty("java.version");
String badVersionMsg = "Cannot launch Java VisualVM.\nRequires Java version >= 1.6.0_07.\nRunning version: " + javaVersion + ".";
if (!javaVersion.startsWith("1.6") && !javaVersion.startsWith("1.7") && !javaVersion.startsWith("1.8")) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
} else if (javaVersion.startsWith("1.6")) {
// check minor version
String minorVer = javaVersion.substring(javaVersion.indexOf('_') + 1);
if (Integer.parseInt(minorVer) < 7) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
}
}
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jvisualvm.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote()) {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openjmx", project.getServerSettings().getHost() + ":" + project.getJmxPort() });
} else {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openid", String.valueOf(project.getVisualVmId()) });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else if (title.equals("JConsole")) {
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jconsole.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch JConsole", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote())
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { project.getServerSettings().getHost() + ":" + project.getJmxPort() });
else {
String serverProcId = project.getServerSettings().getServerProcessId();
if (serverProcId != null)
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { serverProcId });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else {
String request = null;
if (dataInit != null) {
FormDataDocument datadoc = new FormDataDocument();
datadoc.setAttribute(FormDataDocument.ATTR_ACTION, dataInit);
request = datadoc.format();
}
final String response = dataInit == null ? null : project.getDesignerProxy().getDesignerDataAccess().engineCall(request);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DesignerProxy designerProxy = project.getDesignerProxy();
JFrame propmgr_frame = new JFrame(title);
FormPanel mainform = new FormPanel(propmgr_frame, designerProxy.getDesignerDataAccess(), designerProxy.getPluginDataAccess().getPrivileges());
mainform.setData(formName, response);
propmgr_frame.setVisible(true);
} catch (final Exception ex) {
if (getShell() == null) {
PluginMessages.log(ex);
} else {
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
});
}
}
}
});
}
} catch (Exception ex) {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
}
use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method getTaskInstances.
private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
List<TaskInstanceVO> taskInstances = new ArrayList<>();
for (TaskInstanceVO taskInstance : allTaskInstances) {
String secondaryOwner = taskInstance.getSecondaryOwnerType();
if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
String formDataString = null;
if (OwnerType.DOCUMENT.equals(secondaryOwner))
formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
FormDataDocument formDataDoc = new FormDataDocument();
try {
formDataDoc.load(formDataString);
for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
taskInstances.add(taskInstance);
}
} catch (MbengException ex) {
throw new DataAccessException(-1, ex.getMessage(), ex);
}
} else {
// task instance secondary owner is work transition instance
Long workTransInstId = taskInstance.getSecondaryOwnerId();
for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
Long transitionId = transitionInstance.getTransitionID();
WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
if (workTrans == null && process.getSubProcesses() != null) {
for (ProcessVO subproc : process.getSubProcesses()) {
workTrans = subproc.getWorkTransition(transitionId);
if (workTrans != null)
break;
}
}
if (workTrans != null && workTrans.getToWorkId().equals(activityId))
taskInstances.add(taskInstance);
}
}
}
}
return taskInstances;
}
Aggregations