use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestActionGroup method createOpenProcessInstanceAction.
private IAction createOpenProcessInstanceAction() {
IAction action = new Action() {
public void run() {
if (openProcessInstanceApplies(view.getSelectedItem())) {
WorkflowProject project = ((WorkflowElement) view.getSelectedItem()).getProject();
try {
Long procInstId = null;
if (view.getSelectedItem() instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) view.getSelectedItem();
procInstId = expectedResults.getActualProcessInstanceId();
} else if (view.getSelectedItem() instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) view.getSelectedItem();
File resultsFile = expectedResult.getActualResultFile();
TestFile testFile = new TestFile(null, resultsFile.getPath());
testFile.load();
TestFileLine line1 = testFile.getLines().get(0);
procInstId = new Long(line1.getWord(3));
}
if (procInstId == null) {
MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file.");
return;
}
ProcessInstanceVO procInst = project.getDataAccess().getProcessInstance(procInstId);
Long processId = procInst.getProcessId();
ProcessVO procVO = project.getProcess(processId).getProcessVO();
if (procVO == null)
PluginMessages.uiError("Unable to locate process: " + processId, "Open Process Instance", project);
WorkflowProcess instance = new WorkflowProcess(project, procVO);
instance.setProcessInstance(procInst);
actionHandler.open(instance);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Open Process Instance", project);
}
}
}
};
action.setId(MdwMenuManager.MDW_MENU_PREFIX + "open.process.instance");
action.setText("Open Process Instance");
ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
action.setImageDescriptor(imageDesc);
return action;
}
use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceListView method createTable.
private void createTable(Composite parent) {
int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
processInstanceTable = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 10;
processInstanceTable.setLayoutData(gridData);
processInstanceTable.setLinesVisible(true);
processInstanceTable.setHeaderVisible(true);
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
int styles = SWT.LEFT;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
TableColumn column = new TableColumn(processInstanceTable, styles, i);
column.setText(colSpec.label);
column.setWidth(colSpec.width);
column.setResizable(colSpec.resizable);
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableColumn sortColumn = tableViewer.getTable().getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int direction = tableViewer.getTable().getSortDirection();
if (sortColumn == currentColumn) {
direction = direction == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
tableViewer.getTable().setSortColumn(currentColumn);
direction = SWT.DOWN;
}
tableViewer.getTable().setSortDirection(direction);
ProcessInstanceSort sort = contentProvider.getSort();
sort.setSort(currentColumn.getText());
sort.setAscending(direction == SWT.UP);
refreshTable();
}
});
}
// double-click
processInstanceTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) e.item.getData();
handleOpen(processInstanceInfo);
}
});
// right-click menu
processInstanceTable.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
processInstanceTable.setMenu(createContextMenu(processInstanceTable.getShell()));
}
});
// auto-adjust column width
processInstanceTable.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int tableWidth = processInstanceTable.getBounds().width;
int cumulative = 0;
TableColumn[] tableColumns = processInstanceTable.getColumns();
for (int i = 0; i < tableColumns.length; i++) {
if (i == tableColumns.length - 1)
tableColumns[i].setWidth(tableWidth - cumulative - 25);
cumulative += tableColumns[i].getWidth();
}
}
});
}
use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceListView method createContextMenu.
private Menu createContextMenu(Shell shell) {
Menu menu = new Menu(shell, SWT.POP_UP);
final StructuredSelection selection = (StructuredSelection) getTableViewer().getSelection();
if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement();
// open instance
MenuItem openItem = new MenuItem(menu, SWT.PUSH);
openItem.setText("Open");
ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
openItem.setImage(openImageDesc.createImage());
openItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleOpen(processInstanceInfo);
}
});
// owning document
if (OwnerType.DOCUMENT.equals(processInstanceInfo.getOwner()) || OwnerType.TESTER.equals(processInstanceInfo.getOwner())) {
MenuItem docItem = new MenuItem(menu, SWT.PUSH);
docItem.setText("View Owning Document");
ImageDescriptor docImageDesc = MdwPlugin.getImageDescriptor("icons/doc.gif");
docItem.setImage(docImageDesc.createImage());
docItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IStorage storage = new DocumentStorage(workflowProject, new DocumentReference(processInstanceInfo.getOwnerId(), null));
final IStorageEditorInput input = new StorageEditorInput(storage);
final IWorkbenchPage page = MdwPlugin.getActivePage();
if (page != null) {
BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
public void run() {
try {
page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "View Document", workflowProject);
}
}
});
}
}
});
}
// instance hierarchy
MenuItem hierarchyItem = new MenuItem(menu, SWT.PUSH);
hierarchyItem.setText("Instance Hierarchy");
ImageDescriptor hierarchyImageDesc = MdwPlugin.getImageDescriptor("icons/hierarchy.gif");
hierarchyItem.setImage(hierarchyImageDesc.createImage());
hierarchyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
WorkflowProcess pv = new WorkflowProcess(processVersion);
pv.setProcessVO(processVersion.getProcessVO());
pv.setProcessInstance(processInstanceInfo);
new WorkflowElementActionHandler().showHierarchy(pv);
}
});
}
// delete
if (!selection.isEmpty() && !processVersion.getProject().isProduction() && processVersion.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION)) {
MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
deleteItem.setText("Delete...");
ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
deleteItem.setImage(deleteImageDesc.createImage());
deleteItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
ProcessInstanceVO pii = (ProcessInstanceVO) selection.getFirstElement();
if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete process instance ID: " + pii.getId() + " for workflow project '" + processVersion.getProject().getName() + "'?")) {
List<ProcessInstanceVO> instances = new ArrayList<>();
instances.add((ProcessInstanceVO) selection.getFirstElement());
handleDelete(instances);
}
} else {
if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete selected process instances for workflow project '" + processVersion.getProject().getName() + "'?")) {
List<ProcessInstanceVO> instances = new ArrayList<>();
for (Object instance : selection.toArray()) {
if (instance instanceof ProcessInstanceVO)
instances.add((ProcessInstanceVO) instance);
}
handleDelete(instances);
}
}
}
});
}
return menu;
}
use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method getSubProcessInstances.
public List<ProcessInstanceVO> getSubProcessInstances(WorkflowProcess parentProcess, Activity activity) {
try {
Long parentProcessInstanceId = parentProcess.getProcessInstance().getId();
if (activity.isHeterogeneousSubProcInvoke()) {
List<ProcessInstanceVO> insts = new ArrayList<>();
String procMapStr = activity.getAttribute(WorkAttributeConstant.PROCESS_MAP);
if (procMapStr != null && !procMapStr.isEmpty()) {
List<String[]> procMap = StringHelper.parseTable(procMapStr, ',', ';', 3);
for (String[] row : procMap) {
ProcessVO subProcessVO = new ProcessVO();
AssetVersionSpec spec = new AssetVersionSpec(row[1], row[2] == null ? "0" : row[2]);
AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
WorkflowProcess found = locator.getProcessVersion(spec);
if (found != null) {
subProcessVO.setProcessId(found.getId());
subProcessVO.setProcessName(found.getName());
insts.addAll(dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO()));
} else {
PluginMessages.log(new Exception("SubProcess not found: " + row[1] + " v" + row[2]));
}
}
}
return insts;
} else if (activity.isManualTask()) {
List<ProcessInstanceVO> insts = new ArrayList<>();
String procMapStr = activity.getAttribute(TaskAttributeConstant.SERVICE_PROCESSES);
if (procMapStr != null && !procMapStr.isEmpty()) {
Map<String, String> pMap = new HashMap<>();
pMap.put("owner", OwnerType.TASK_INSTANCE);
StringBuilder sb = new StringBuilder();
sb.append("(");
if (activity.getTaskInstances() != null) {
for (TaskInstanceVO taskInst : activity.getTaskInstances()) {
if (sb.length() > 1)
sb.append(",");
sb.append(taskInst.getTaskInstanceId().toString());
}
}
sb.append(")");
pMap.put("ownerIdList", sb.toString());
insts = dataAccess.getDesignerDataAccess().getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, parentProcess.getProcessVO(), null).getItems();
}
return insts;
} else {
ProcessVO subProcessVO = new ProcessVO();
String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
AssetVersionSpec spec = new AssetVersionSpec(subProcName, subProcVer == null ? "0" : subProcVer);
AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
WorkflowProcess subProc = locator.getProcessVersion(spec);
subProcessVO.setProcessId((subProc == null || subProc.getId() == null) ? 0L : subProc.getId());
subProcessVO.setProcessName(activity.getAttribute(WorkAttributeConstant.PROCESS_NAME));
// handle alias subprocs
String subprocAliasProcessId = activity.getAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID);
if (subprocAliasProcessId != null)
subProcessVO = this.getProcessVO(new Long(subprocAliasProcessId));
return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO());
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Load SubProcess Instances (P=" + parentProcess.getId() + ",A=" + activity.getId() + ")", project);
return Collections.emptyList();
}
}
use of com.centurylink.mdw.model.value.process.ProcessInstanceVO in project mdw-designer by CenturyLinkCloud.
the class SubProcessInstancesSection method createContextMenu.
private Menu createContextMenu(Shell shell) {
Menu menu = new Menu(shell, SWT.POP_UP);
StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement();
// view
MenuItem procInstItem = new MenuItem(menu, SWT.PUSH);
procInstItem.setText("View Subprocess Instance");
ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
procInstItem.setImage(imageDesc.createImage());
procInstItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
openSubProcessInstance(processInstanceInfo);
}
});
}
return menu;
}
Aggregations