use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createExportActionGroup.
private ActionGroup createExportActionGroup() {
exportMenu = new MenuManager("Export", MdwPlugin.getImageDescriptor("icons/export.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.export");
return new ActionGroup() {
@Override
public void fillContextMenu(IMenuManager menu) {
exportMenu.removeAll();
IStructuredSelection selection = getSelection();
if (exportPackageApplies(selection))
exportMenu.add(exportPackageAction);
if (exportProcessApplies(selection))
exportMenu.add(exportProcessAction);
if (exportWorkflowAssetApplies(selection)) {
WorkflowAsset asset = (WorkflowAsset) selection.getFirstElement();
// menu item text and icon are dynamic
exportWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.to.file");
exportWorkflowAssetAction.setText(asset.getTitle() + " to File...");
exportWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
exportMenu.add(exportWorkflowAssetAction);
}
if (exportAttributesApplies(selection)) {
List<IAction> exportAttrsActions = getExportAttributeActions(selection);
if (!exportAttrsActions.isEmpty()) {
MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.export.attributes");
attributesMenu.removeAll();
for (IAction action : exportAttrsActions) attributesMenu.add(action);
exportMenu.add(attributesMenu);
}
}
if (exportTaskTemplatesApplies(selection))
exportMenu.add(exportTaskTemplateAction);
exportMenu.add(new Separator(OTHER));
IWorkbenchAction otherAction = ActionFactory.EXPORT.create(getViewSite().getWorkbenchWindow());
otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.other");
otherAction.setText(OTHER_DOT);
exportMenu.add(otherAction);
}
};
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ImportAssetWizard method performImportExport.
void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
DesignerProxy designerProxy = getProject().getDesignerProxy();
progressMonitor.progress(10);
progressMonitor.subTask("Reading file");
byte[] bytes = readFile(getPage().getFilePath());
progressMonitor.progress(20);
if (progressMonitor.isCanceled())
throw new ActionCancelledException();
progressMonitor.subTask("Performing Import");
File assetFile = new File(getPage().getFilePath());
WorkflowAsset existingAsset = getAsset();
if (// package selected, not asset
existingAsset == null)
existingAsset = getPackage().getAsset(assetFile.getName());
boolean binary;
RuleSetVO newRuleSet = new RuleSetVO();
if (existingAsset == null) {
newRuleSet.setName(assetFile.getName());
newRuleSet.setLanguage(RuleSetVO.getFormat(assetFile.getName()));
binary = newRuleSet.isBinary();
} else {
newRuleSet.setName(existingAsset.getName());
newRuleSet.setLanguage(existingAsset.getLanguage());
binary = existingAsset.isBinary();
// custom
newRuleSet.setAttributes(existingAsset.getAttributes());
// attributes
}
newRuleSet.setRaw(getProject().isFilePersist());
if (getProject().isFilePersist())
newRuleSet.setRawFile(new File(getProject().getAssetDir() + "/" + getPackage().getName() + "/" + newRuleSet.getName()));
if (binary) {
if (newRuleSet.isRaw())
newRuleSet.setRawContent(bytes);
else
newRuleSet.setRuleSet(RuleSetVO.encode(bytes));
} else
newRuleSet.setRuleSet(new String(bytes));
WorkflowAsset newAsset = WorkflowAssetFactory.createAsset(newRuleSet, getPackage());
// check db in case created in another session
RuleSetVO existing = getProject().getDesignerDataAccess().getRuleSet(getPackage().getId(), newRuleSet.getName());
progressMonitor.progress(10);
newAsset.setVersion(existing == null ? 1 : existing.getVersion() + 1);
newAsset.setComment(getPage().getComments());
newAsset.setPackage(getPackage());
newAsset.setId(Long.valueOf(-1));
newAsset.setCreateUser(getProject().getUser().getUsername());
newAsset.setLockingUser(getProject().getUser().getUsername());
designerProxy.saveWorkflowAsset(newAsset, getPage().isLocked());
getProject().getDataAccess().getDesignerDataModel().addRuleSet(newAsset.getRuleSetVO());
// update the tree
if (existingAsset != null) {
getPackage().removeAsset(existingAsset);
newAsset.getRuleSetVO().setPrevVersion(existingAsset.getRuleSetVO());
getProject().getUnpackagedWorkflowAssets().add(existingAsset);
existingAsset.setPackage(getProject().getDefaultPackage());
}
newAsset.getPackage().addAsset(newAsset);
designerProxy.savePackage(newAsset.getPackage());
setElement(newAsset);
progressMonitor.progress(30);
if (existingAsset != null)
WorkflowAssetFactory.deRegisterAsset(existingAsset);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class TestResultsFormatter method getXslFile.
private File getXslFile(String filename) throws IOException {
File stylesheet = null;
if (project.isFilePersist()) {
// prefer override (non-MDW testing package); fall back to MDW
// testing package
WorkflowPackage mdwTestingPackage = null;
WorkflowPackage otherTestingPackage = null;
for (WorkflowPackage pkg : project.getTopLevelPackages()) {
if (pkg.getName().equals("com.centurylink.mdw.testing"))
mdwTestingPackage = pkg;
else if (pkg.getName().endsWith(".testing"))
otherTestingPackage = pkg;
}
if (otherTestingPackage != null) {
WorkflowAsset asset = otherTestingPackage.getAsset(filename);
if (asset != null)
stylesheet = asset.getRawFile();
}
if (stylesheet == null && mdwTestingPackage != null) {
WorkflowAsset asset = mdwTestingPackage.getAsset(filename);
if (asset != null)
stylesheet = asset.getRawFile();
}
}
if (stylesheet == null) {
// fall back to template version in designer
URL localUrl = PluginUtil.getLocalResourceUrl("templates/xsl/" + filename);
try {
stylesheet = new File(new URI(localUrl.toString()));
} catch (URISyntaxException ex) {
throw new IOException(ex.getMessage(), ex);
}
}
return stylesheet;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class CopyDialog method nameAlreadyExists.
private boolean nameAlreadyExists(String name) {
WorkflowProject workflowProject = workflowElement.getProject();
PluginDataAccess dataAccess = workflowProject.getDataAccess();
if (workflowElement instanceof WorkflowProcess)
return dataAccess.processNameExists(targetPackage.getPackageVO(), name);
else if (workflowElement instanceof ExternalEvent)
return workflowProject.externalEventNameExists(name);
else if (workflowElement instanceof WorkflowAsset)
return targetPackage == null ? workflowProject.workflowAssetNameExists(name) : targetPackage.workflowAssetNameExists(name);
else
return false;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetEditor method fillTreeCombo.
private void fillTreeCombo() {
treeCombo.removeAll();
Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {
public int compare(WorkflowElement we1, WorkflowElement we2) {
return we1.getLabel().compareTo(we2.getLabel());
}
};
if (isProcess()) {
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (WorkflowProcess process : pkg.getProcesses()) {
CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
processItem.setText(process.getLabel());
processItem.setImage(process.getIconImage());
}
}
} else if (isTaskTemplate()) {
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
List<TaskTemplate> templatesForPkg = pkg.getTaskTemplates();
if (templatesForPkg != null && !templatesForPkg.isEmpty()) {
CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (TaskTemplate template : templatesForPkg) {
CTreeComboItem templateItem = new CTreeComboItem(packageItem, SWT.NONE);
templateItem.setText(template.getLabel());
templateItem.setImage(template.getIconImage());
}
}
}
} else {
List<WorkflowAsset> assets = getProject().getAssetList(assetTypes);
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 (Map.Entry<WorkflowPackage, List<WorkflowAsset>> pkgAssets : packageAssets.entrySet()) {
CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
packageItem.setText(pkgAssets.getKey().getName());
packageItem.setImage(pkgAssets.getKey().getIconImage());
List<WorkflowAsset> assetsForPkg = pkgAssets.getValue();
Collections.sort(assetsForPkg, comparator);
for (WorkflowAsset assetForPkg : assetsForPkg) {
CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
assetItem.setText(assetForPkg.getLabel());
assetItem.setImage(assetForPkg.getIconImage());
}
}
}
}
Aggregations