use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetVersionsSection method createContextMenu.
private Menu createContextMenu(Shell shell) {
Menu menu = new Menu(shell, SWT.POP_UP);
final StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
// open
if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowAsset) {
final WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
MenuItem openItem = new MenuItem(menu, SWT.PUSH);
openItem.setText("Open");
openItem.setImage(workflowAsset.getIconImage());
openItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
openAsset(asset);
}
});
}
// view comments
if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowAsset) {
final WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
MenuItem viewCommentsItem = new MenuItem(menu, SWT.PUSH);
viewCommentsItem.setText("View Comments");
ImageDescriptor viewCommentsImageDesc = MdwPlugin.getImageDescriptor("icons/view.gif");
viewCommentsItem.setImage(viewCommentsImageDesc.createImage());
viewCommentsItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
openViewCommentsDialog(asset);
}
});
}
// delete
if (!selection.isEmpty() && !workflowAsset.getProject().isProduction() && workflowAsset.isUserAuthorized(UserRoleVO.ASSET_DESIGN) && (selection.size() == 1 && ((WorkflowAsset) selection.getFirstElement()).isLatestVersion() || MdwPlugin.getSettings().isAllowDeleteArchivedProcesses())) {
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() {
public void widgetSelected(SelectionEvent e) {
if (selection.size() >= 1 && selection.getFirstElement() instanceof WorkflowAsset) {
WorkflowAsset[] assets = new WorkflowAsset[selection.size()];
int idx = 0;
for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
assets[idx] = (WorkflowAsset) iter.next();
idx++;
}
WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
actionHandler.delete(assets);
boolean removedSelected = false;
for (WorkflowAsset a : assets) {
if (a.equals(workflowAsset))
removedSelected = true;
}
if (removedSelected) {
WorkflowAsset sel = null;
for (WorkflowAsset toSel : workflowAsset.getAllVersions()) {
if (!toSel.equals(workflowAsset)) {
sel = toSel;
break;
}
}
workflowAsset.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
setSelection(sel);
} else {
// just remove and refresh
for (WorkflowAsset a : assets) workflowAsset.getProject().removeWorkflowAsset(a);
setSelection(workflowAsset);
}
}
}
});
}
return menu;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetVersionsSection method drawWidgets.
public void drawWidgets(Composite composite, WorkflowElement selection) {
workflowAsset = (WorkflowAsset) selection;
tableEditor = new TableEditor(workflowAsset, TableEditor.TYPE_TABLE);
List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
ColumnSpec packageColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Package", "package");
packageColSpec.width = 160;
columnSpecs.add(packageColSpec);
ColumnSpec versionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Version", "version");
versionColSpec.width = 60;
columnSpecs.add(versionColSpec);
ColumnSpec idColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "ID", "id");
idColSpec.width = 65;
columnSpecs.add(idColSpec);
ColumnSpec createDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Created", "createDate");
createDateColSpec.width = 110;
columnSpecs.add(createDateColSpec);
ColumnSpec userColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "User", "user");
userColSpec.width = 75;
columnSpecs.add(userColSpec);
ColumnSpec commentsColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Comments", "comments");
commentsColSpec.width = 200;
columnSpecs.add(commentsColSpec);
ColumnSpec lockedToColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Locked To", "lockedTo");
lockedToColSpec.width = 75;
columnSpecs.add(lockedToColSpec);
ColumnSpec modDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Last Modified", "modDate");
modDateColSpec.width = 110;
columnSpecs.add(modDateColSpec);
tableEditor.setColumnSpecs(columnSpecs);
// tableEditor.setFillWidth(true);
tableEditor.setReadOnly(true);
tableEditor.setContentProvider(new AssetVersionContentProvider());
tableEditor.setLabelProvider(new AssetVersionLabelProvider());
tableEditor.addValueChangeListener(new ValueChangeListener() {
public void propertyValueChanged(Object newValue) {
openAsset((WorkflowAsset) newValue);
}
});
tableEditor.render(composite);
// right-click menu
tableEditor.getTable().addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
tableEditor.getTable().setMenu(createContextMenu(tableEditor.getTable().getShell()));
}
});
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method updateTreeAndProgressBar.
private synchronized void updateTreeAndProgressBar(boolean done) {
int completedCases = 0;
int erroredCases = 0;
int failedCases = 0;
int casePercents = 0;
boolean loadTest = testSuite.isLoadTest();
for (AutomatedTestCase testCase : testSuite.getTestCases()) {
String oldStatus = testCaseStatuses.get(testCase);
boolean statusChanged = done || oldStatus == null || !oldStatus.equals(testCase.getStatus());
if (statusChanged) {
testSuite.getProject().fireTestCaseStatusChange(testCase, testCase.getStatus());
testCaseStatuses.put(testCase, testCase.getStatus());
}
int casePercent = 0;
if (testCase.isFinished()) {
if (statusChanged && !done && testSuite.isCreateReplaceResults() && // only applies for VCS assets
testCase.isSuccess()) {
if (testCase.isLegacy()) {
// trigger
testCase.setTestCase(testCase.getTestCase());
// results
if (testCase.getLegacyExpectedResults() != null) {
for (LegacyExpectedResults legacyResults : testCase.getLegacyExpectedResults()) {
legacyResults.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, legacyResults);
testSuite.getProject().fireElementChangeEvent(ChangeType.ELEMENT_CREATE, legacyResults);
}
}
} else {
try {
// create asset from newly-created results and
// refresh process explorer (only for VCS assets)
String resAssetName = testCase.getTestCase().getCaseName() + RuleSetVO.getFileExtension(RuleSetVO.YAML);
if (testCase.isPostman() && testCase.getItemName() != null)
resAssetName = testCase.getItemName().replace('/', '_') + RuleSetVO.getFileExtension(RuleSetVO.YAML);
File resFile = new File(testSuite.getProject().getProjectDir() + "/" + testCase.getPackage().getVcsAssetPath() + "/" + resAssetName);
if (// may not exist if test case
resFile.exists()) // does not launch any
// processes
{
byte[] bytes = PluginUtil.readFile(resFile);
WorkflowAsset existing = testSuite.getProject().getAsset(testCase.getPackage().getName() + "/" + resAssetName);
if (existing == null) {
// create (waiting a second or two for the
// results file to have been created)
RuleSetVO newRuleSet = new RuleSetVO();
newRuleSet.setName(resAssetName);
newRuleSet.setLanguage(RuleSetVO.YAML);
newRuleSet.setRaw(true);
newRuleSet.setRawFile(resFile);
newRuleSet.setRawContent(bytes);
WorkflowAsset newAsset = WorkflowAssetFactory.createAsset(newRuleSet, testCase.getPackage());
newAsset.setPackage(testCase.getPackage());
newAsset.setId(new Long(-1));
newAsset.setCreateUser(testSuite.getProject().getUser().getUsername());
newAsset.setLockingUser(testSuite.getProject().getUser().getUsername());
designerProxy.saveWorkflowAsset(newAsset, true);
testSuite.getProject().getDataAccess().getDesignerDataModel().addRuleSet(newAsset.getRuleSetVO());
newAsset.getPackage().addAsset(newAsset);
designerProxy.savePackage(newAsset.getPackage());
newAsset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newAsset);
} else {
// increment version
existing.getRuleSetVO().setRawContent(bytes);
existing.setVersion(existing.getNextMinorVersion());
existing.setRevisionComment("Auto-created");
testSuite.getProject().getDesignerProxy().saveWorkflowAsset(existing, true);
existing.fireElementChangeEvent(ChangeType.VERSION_CHANGE, existing.getVersion());
}
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Create/Replace Test Results", testSuite.getProject());
}
}
}
updateExpectedResults(testCase);
if (loadTest) {
completedCases = testCase.getTestCase().getNumberPrepared();
casePercents = testCase.getTestCase().getNumberPrepared() * 100;
} else {
completedCases++;
casePercent = 100;
}
} else {
casePercent = testCase.getTotalSteps() == 0 ? 0 : (testCase.getStepsCompleted() * 100) / testCase.getTotalSteps();
}
if (!loadTest)
casePercents += casePercent;
if (testCase.isErrored()) {
if (loadTest)
erroredCases = testCase.getTestCase().getNumberPrepared();
else
erroredCases++;
} else if (testCase.isFailed()) {
if (loadTest)
failedCases = testCase.getTestCase().getNumberPrepared();
else
failedCases++;
}
if (statusChanged)
try {
testSuite.writeTestCaseResults(testCase);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Create/Replace Test Results", testSuite.getProject());
}
}
if (done) {
testSuite.setRunning(false);
updateCounterPanel(testSuite.getTestCases().size(), erroredCases, failedCases, true);
updateProgressBar(100, testSuite.hasErrors() || testSuite.hasFailures(), testSuite.isStopped());
} else {
int count = testSuite.getTestCases().size();
if (loadTest)
count = testSuite.getRunCount();
int totalPercents = count * 100;
if (counterData.completed < completedCases) {
updateCounterPanel(completedCases, erroredCases, failedCases, false);
float percentComplete = totalPercents == 0 ? 0 : (casePercents * 100) / totalPercents;
updateProgressBar(Math.round(percentComplete * 90 / 100) + 10, erroredCases + failedCases > 0, testSuite.isStopped());
}
}
refreshOutputFromSelection();
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class AssetLocator method getWorkflowAssetVersion.
private WorkflowAsset getWorkflowAssetVersion(String versionSpec, List<WorkflowAsset> assets) {
AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
WorkflowAsset match = null;
for (WorkflowAsset asset : assets) {
if (asset.getName().matches(spec.getName())) {
if (asset.getVersionString().equals(spec.getVersion())) {
match = asset;
break;
} else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && asset.meetsVersionSpec(spec.getVersion()))) && (match == null || asset.getVersion() > match.getVersion())) {
match = asset;
}
}
}
return match;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class AssetLocator method assetFromAttr.
public WorkflowElement assetFromAttr(String attrValue) {
if (attrValue == null || attrValue.isEmpty() || attrValue.startsWith("$") || attrValue.startsWith("#")) {
return null;
}
if (isProcess()) {
int slashIdx = attrValue.indexOf('/');
if (slashIdx <= 0) {
// prefer process in same package
WorkflowProcess proc = getElement().getPackage() == null ? null : getProcessVersion(attrValue, getElement().getPackage().getProcesses());
if (proc != null)
return proc;
else
return getProcessVersion(attrValue, getProject().getAllProcessVersions());
} else {
String pkgName = attrValue.substring(0, slashIdx);
WorkflowPackage pkg = getProject().getPackage(pkgName);
if (pkg == null)
return null;
else
return getProcessVersion(attrValue.substring(slashIdx + 1), pkg.getProcesses());
}
} else if (isTaskTemplate()) {
// no need to handle unqualified attrs
int slashIdx = attrValue.indexOf('/');
String pkgName = slashIdx <= 0 ? null : attrValue.substring(0, slashIdx);
WorkflowPackage pkg = pkgName == null ? null : getProject().getPackage(pkgName);
if (pkg == null)
return null;
else
return getTaskTemplateVersion(attrValue.substring(slashIdx + 1), pkg.getTaskTemplates());
} else {
int slashIdx = attrValue.indexOf('/');
if (slashIdx <= 0) {
// prefer asset in same package
WorkflowAsset pkgDoc = getElement().getPackage() == null ? null : getWorkflowAssetVersion(attrValue, getElement().getPackage().getAssets());
if (pkgDoc != null)
return pkgDoc;
else
return getWorkflowAssetVersion(attrValue, getProject().getAllWorkflowAssets());
} else {
String pkgName = attrValue.substring(0, slashIdx);
WorkflowPackage pkg = getProject().getPackage(pkgName);
if (pkg == null)
return null;
else
return getWorkflowAssetVersion(attrValue.substring(slashIdx + 1), pkg.getAssets());
}
}
}
Aggregations