use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess 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.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method getUnpackagedDescendantProcesses.
/**
* Returns the descendant process versions for a top-level process version
* (includes the top-level version itself as a descendant).
*/
private List<WorkflowProcess> getUnpackagedDescendantProcesses(WorkflowProcess topLevelProcessVersion) {
List<WorkflowProcess> processVersions = new ArrayList<>();
// clone top-level process for first child
WorkflowProcess processVersion = new WorkflowProcess(topLevelProcessVersion);
// walk down the chain
while (processVersion != null) {
if (processVersion.getPackage() == null) {
processVersion.setTopLevelVersion(topLevelProcessVersion);
processVersions.add(processVersion);
}
processVersion = processVersion.getPreviousVersion();
}
// no need to sort
return processVersions;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findUnpackagedProcesses.
/**
* Gets the top-level unpackaged version for all processes. Side effect: if
* a version is later than than in any package, it's added to the default
* package. The results are populated with their unpackaged descendant
* process versions.
*/
private List<WorkflowProcess> findUnpackagedProcesses() {
List<WorkflowProcess> unpackagedProcesses = new ArrayList<>();
for (ProcessVO processVO : getDataAccess().getProcesses(false)) {
ProcessVO topUnpackaged = null;
ProcessVO toCheck = processVO;
// if process version is later than that in any package,
// it belongs in the top-level default package
boolean toCheckIsLatest = true;
for (WorkflowPackage pkg : getTopLevelPackages()) {
if (pkg.isDefaultPackage())
continue;
WorkflowProcess packaged = pkg.getProcess(processVO.getProcessName());
if (packaged != null && packaged.getVersion() >= toCheck.getVersion()) {
toCheckIsLatest = false;
break;
}
}
if (toCheckIsLatest) {
WorkflowProcess pv = new WorkflowProcess(this, toCheck);
getDefaultPackage().addProcess(pv);
pv.addElementChangeListener(this);
toCheck = toCheck.getPrevVersion();
}
// add the hierarchy of old unpackaged processes
while (toCheck != null) {
if (!isPackaged(toCheck)) {
topUnpackaged = toCheck;
break;
}
toCheck = toCheck.getPrevVersion();
}
if (topUnpackaged != null) {
WorkflowProcess processVersion = new WorkflowProcess(this, topUnpackaged);
processVersion.setDescendantProcessVersions(getUnpackagedDescendantProcesses(processVersion));
unpackagedProcesses.add(processVersion);
}
}
Collections.sort(unpackagedProcesses);
return unpackagedProcesses;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findTopLevelPackages.
/**
* Finds the list of top level packages (including the default if
* supported), populated with the appropriate processes, etc.
*/
private void findTopLevelPackages(ProgressMonitor progressMonitor) {
CodeTimer timer = new CodeTimer("findTopLevelPackages()");
topLevelPackages = new ArrayList<>();
topLevelUserVisiblePackages = new ArrayList<>();
activityImpls.clear();
for (PackageVO packageVO : getTopLevelPackageVOs(progressMonitor)) {
WorkflowPackage topLevelPackage = new WorkflowPackage(this, packageVO);
topLevelPackage.setProcesses(findProcesses(topLevelPackage));
topLevelPackage.setExternalEvents(findExternalEvents(topLevelPackage));
topLevelPackage.setActivityImpls(findActivityImplementors(topLevelPackage));
topLevelPackage.setAssets(findWorkflowAssets(topLevelPackage));
topLevelPackage.setTaskTemplates(findTaskTemplates(topLevelPackage));
topLevelPackages.add(topLevelPackage);
if (topLevelPackage.isVisible())
topLevelUserVisiblePackages.add(topLevelPackage);
// register as a listener so that i can pass on element change
// events
topLevelPackage.addElementChangeListener(this);
for (WorkflowProcess process : topLevelPackage.getProcesses()) process.addElementChangeListener(this);
}
Collections.sort(topLevelPackages);
Collections.sort(topLevelUserVisiblePackages);
File resultsFile = getFunctionTestResultsFile();
if (resultsFile.exists()) {
// update test case statuses
List<TestCase> testCases = new ArrayList<>();
for (WorkflowPackage pkg : topLevelPackages) {
for (WorkflowAsset asset : pkg.getAssets()) {
if (asset instanceof AutomatedTestCase)
testCases.add(((AutomatedTestCase) asset).getTestCase());
}
}
if (!testCases.isEmpty()) {
try {
TestResultsParser parser = new TestResultsParser(resultsFile, testCases);
if (resultsFile.getName().endsWith(".xml"))
parser.parseXml();
else
parser.parseJson(getAssetDir());
} catch (Exception ex) {
PluginMessages.uiError(ex, "Parse Test Results", this);
}
}
}
timer.stopAndLog();
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findProcesses.
/**
* Returns the process versions belonging to a package version.
*/
private List<WorkflowProcess> findProcesses(WorkflowPackage aPackage) {
List<WorkflowProcess> processVersions = new ArrayList<>();
for (ProcessVO processVO : getDataAccess().getAllProcesses(false)) {
if (aPackage.getPackageVO().containsProcess(processVO.getProcessId())) {
WorkflowProcess processVersion = new WorkflowProcess(this, processVO);
if (// vcs assets
!processVersions.contains(processVersion)) // would add
// same-versioned
// archived
// processes
{
processVersion.setPackage(aPackage);
processVersions.add(processVersion);
}
}
}
Collections.sort(processVersions);
return processVersions;
}
Aggregations