use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method handleSelectionChanged.
public void handleSelectionChanged(IStructuredSelection selection) {
String output = "";
if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowElement) {
selectedItem = (WorkflowElement) selection.getFirstElement();
if (selectedItem instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
if (testCase.isPostman() && testCase.getItemName() != null)
output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
} else if (selectedItem instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
output = "Results:\n-----------\n" + readFile(expectedResults.getActualResults());
} else if (selectedItem instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
output = "Results:\n-----------\n" + readFile(expectedResult.getActualResultFile());
}
} else {
selectedItem = null;
}
outputText.setText(output);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof WorkflowProject) {
final WorkflowProject workflowProject = (WorkflowProject) parentElement;
if (!workflowProject.isLoaded()) {
try {
IRunnableWithProgress loader = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
progressMonitor.start("Loading " + workflowProject.getLabel());
progressMonitor.progress(5);
try {
workflowProject.initialize(progressMonitor);
if (workflowProject.getDataAccess() != null) {
workflowProject.getTopLevelUserVisiblePackages(progressMonitor);
workflowProject.getArchivedUserVisiblePackagesFolder(progressMonitor);
progressMonitor.done();
}
} catch (Exception ex) {
throw new InvocationTargetException(ex);
}
}
};
ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(MdwPlugin.getShell());
progMonDlg.run(true, false, loader);
} catch (InvocationTargetException itx) {
if (itx.getCause() instanceof DataUnavailableException) {
PluginMessages.log(itx);
MessageDialog.openWarning(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
} else if (itx.getCause() instanceof DataAccessOfflineException) {
PluginMessages.log(itx);
MessageDialog.openError(MdwPlugin.getShell(), LOAD_WF_PROJECT, itx.getCause().getMessage());
return new WorkflowPackage[0];
} else {
PluginMessages.uiError(itx, LOAD_WF_PROJECT, workflowProject);
return new WorkflowPackage[0];
}
} catch (Exception ex) {
PluginMessages.uiError(ex, LOAD_WF_PROJECT, workflowProject);
return new WorkflowPackage[0];
}
}
if (workflowProject.getDataAccess() == null)
return new WorkflowPackage[0];
List<WorkflowPackage> topLevelPackages = workflowProject.getTopLevelUserVisiblePackages();
Folder archivedPackageFolder = workflowProject.getArchivedUserVisiblePackagesFolder();
int size = topLevelPackages.size();
boolean showArchived = isShowArchivedItems(workflowProject);
if (showArchived)
size++;
AutomatedTestSuite testSuite = workflowProject.getLegacyTestSuite();
if (testSuite != null && !testSuite.isEmpty())
size++;
Object[] objects = new Object[size];
for (int i = 0; i < topLevelPackages.size(); i++) objects[i] = topLevelPackages.get(i);
int cur = topLevelPackages.size();
if (showArchived) {
objects[cur] = archivedPackageFolder;
cur++;
}
if (testSuite != null && !testSuite.isEmpty())
objects[cur] = testSuite;
return objects;
} else if (parentElement instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) parentElement;
if (packageVersion.isArchived() && packageVersion.hasDescendantPackageVersions()) {
return packageVersion.getDescendantPackageVersions().toArray(new WorkflowPackage[0]);
} else {
List<WorkflowElement> elements = new ArrayList<>();
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_PROCESSES_IN_PEX))
elements.addAll(packageVersion.getProcesses());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_WORKFLOW_ASSETS_IN_PEX))
elements.addAll(packageVersion.getAssets());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_EVENT_HANDLERS_IN_PEX))
elements.addAll(packageVersion.getExternalEvents());
if (prefsStore.getBoolean(PreferenceConstants.PREFS_SHOW_ACTIVITY_IMPLEMENTORS_IN_PEX))
elements.addAll(packageVersion.getActivityImpls());
if (!prefsStore.getBoolean(PreferenceConstants.PREFS_FILTER_TASK_TEMPLATES_IN_PEX))
elements.addAll(packageVersion.getTaskTemplates());
elements.addAll(packageVersion.getChildFolders());
if (isSortPackageContentsAtoZ()) {
Collections.sort(elements, new Comparator<WorkflowElement>() {
public int compare(WorkflowElement e1, WorkflowElement e2) {
return e1.getLabel().compareToIgnoreCase(e2.getLabel());
}
});
}
return elements.toArray(new Object[0]);
}
} else if (parentElement instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) parentElement;
if (processVersion.hasDescendantProcessVersions()) {
return processVersion.getDescendantProcessVersions().toArray(new WorkflowProcess[0]);
} else {
return emptyARRAY;
}
} else if (parentElement instanceof Folder) {
Folder folder = (Folder) parentElement;
return folder.getChildren().toArray(new WorkflowElement[0]);
} else if (parentElement instanceof AutomatedTestSuite) {
AutomatedTestSuite testSuite = (AutomatedTestSuite) parentElement;
return testSuite.getTestCases().toArray(new AutomatedTestCase[0]);
} else if (parentElement instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) parentElement;
if (!testCase.isLegacy())
return emptyARRAY;
List<LegacyExpectedResults> expectedResults = testCase.getLegacyExpectedResults();
List<File> files = testCase.getFiles();
Object[] objects = new Object[expectedResults.size() + files.size()];
for (int i = 0; i < expectedResults.size(); i++) objects[i] = expectedResults.get(i);
for (int i = expectedResults.size(); i < objects.length; i++) objects[i] = files.get(i - expectedResults.size());
return objects;
} else {
return emptyARRAY;
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method isValidDrop.
public boolean isValidDrop(String elementInfo, Object target, int operation) {
if (target instanceof WorkflowElement && ((WorkflowElement) target).getPackage() != null) {
WorkflowPackage targetPackage = ((WorkflowElement) target).getPackage();
// not allowed for archived or read-only packages
if (targetPackage.isArchived() || targetPackage.isReadOnly())
return false;
String[] elements = elementInfo.split("#");
for (String element : elements) {
String itemInfo = element.substring(element.indexOf('~') + 1);
String workflowProjectName = getWorkflowProjectName(itemInfo);
String packageName = getPackageName(itemInfo);
String packageVersion = getPackageVersion(itemInfo);
if (operation == DND.DROP_MOVE) {
// only allow moves for elements in the same project
if (!targetPackage.getProject().getName().equals(workflowProjectName))
return false;
// don't allow drops into same package
if (targetPackage.getName().equals(packageName) && targetPackage.getVersionString().equals(packageVersion))
return false;
// default package and empty package are the same
if (targetPackage.isDefaultPackage() && packageName.equals(""))
return false;
} else if (operation == DND.DROP_COPY) {
// (exception: single process)
if (!targetPackage.getProject().getName().equals(workflowProjectName) && (!element.startsWith("Process") || elements.length != 1))
return false;
if (!element.startsWith("Process") && !element.startsWith("ExternalEvent") && !element.startsWith("ActivityImpl") && !element.startsWith("WorkflowAsset"))
return false;
}
}
return true;
} else {
return false;
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerView method handleSelectionChanged.
protected void handleSelectionChanged(IStructuredSelection selection) {
List<?> list = selection.toList();
if (list.size() == 0)
return;
ActionContext actionContext = new ActionContext(selection);
actionGroup.setContext(actionContext);
// show the properties for this item
Object item = list.get(0);
if (item instanceof WorkflowElement) {
WorkflowElement workflowElement = (WorkflowElement) item;
selectionProvider.setSelection(workflowElement);
// set the schema owner static qualifier
if (workflowElement.getProject() != null)
DBMappingUtil.setSchemaOwner(workflowElement.getProject().getMdwDataSource().getSchemaOwner());
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class ParameterizedCombo method fillParamCombo.
private void fillParamCombo(String[] types) {
paramCombo.removeAll();
Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {
public int compare(WorkflowElement we1, WorkflowElement we2) {
return we1.getName().compareTo(we2.getName());
}
};
List<WorkflowAsset> assets = workflowProject.getAssetList(Arrays.asList(types));
Map<WorkflowPackage, List<WorkflowAsset>> packageAssets = new TreeMap<>();
for (WorkflowAsset asset : assets) {
List<WorkflowAsset> assetsForPkg = packageAssets.get(asset.getPackage());
if (assetsForPkg == null) {
assetsForPkg = new ArrayList<>();
packageAssets.put(asset.getPackage(), assetsForPkg);
}
assetsForPkg.add(asset);
}
for (WorkflowPackage pkg : packageAssets.keySet()) {
CTreeComboItem packageItem = new CTreeComboItem(paramCombo, SWT.NONE);
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
List<WorkflowAsset> assetsForPkg = packageAssets.get(pkg);
Collections.sort(assetsForPkg, comparator);
for (WorkflowAsset assetForPkg : assetsForPkg) {
CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
assetItem.setText(assetForPkg.getName());
assetItem.setImage(assetForPkg.getIconImage());
}
}
}
Aggregations