use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method checkForDuplicates.
/**
* Returns true if duplicates found.
*/
private boolean checkForDuplicates(WorkflowPackage targetPackage, String[] elements) {
for (String element : elements) {
if (element.startsWith("Process~")) {
String processName = element.substring(8);
for (WorkflowProcess process : targetPackage.getProcesses()) {
if (process.getName().equals(processName)) {
String msg = PACAKGE + targetPackage.getName() + "' already contains version " + process.getVersionLabel() + " of process '" + process.getName() + "'";
MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Process", msg);
return true;
}
}
} else if (element.startsWith("ExternalEvent~")) {
String externalEventName = element.substring(14);
for (ExternalEvent externalEvent : targetPackage.getExternalEvents()) {
if (externalEvent.getName().equals(externalEventName)) {
String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an external event named '" + externalEvent.getName() + "'";
MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate External Event", msg);
return true;
}
}
} else if (element.startsWith("ActivityImpl~")) {
// TODO: dups okay?
} else if (element.startsWith("WorkflowAsset~")) {
String assetName = element.substring(14);
for (WorkflowAsset asset : targetPackage.getAssets()) {
if (asset.getName().equals(assetName)) {
String msg = PACAKGE + targetPackage.getName() + "' already contains " + " an definition document named '" + asset.getName() + "'";
MessageDialog.openError(getViewer().getControl().getShell(), "Duplicate Definition Doc", msg);
return true;
}
}
}
}
return false;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method handleDropWorkflowAsset.
private boolean handleDropWorkflowAsset(String assetInfo, WorkflowPackage targetPackage, int operation) {
if (!targetPackage.getProject().checkRequiredVersion(5, 0)) {
String msg = "Packaging of Definition Documents (such as scripts and pages) is only supported for MDWFramework 5.0 and later.";
MessageDialog.openError(getViewer().getControl().getShell(), "Package Def Doc", msg);
return false;
}
Long assetId = getWorkflowAssetId(assetInfo);
WorkflowProject workflowProject = targetPackage.getProject();
WorkflowPackage sourcePackage = workflowProject.getPackage(getPackageName(assetInfo));
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (operation == DND.DROP_COPY) {
WorkflowAsset existing = workflowProject.getAsset(assetId);
CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, existing.getName(), String.valueOf(existing.getVersion()), targetPackage);
if (copyDialog.open() == Dialog.OK) {
String newName = copyDialog.getNewName();
if (!existing.isLoaded())
existing.load();
WorkflowAsset newCopy;
try {
// try and use reflection to make it the correct type
Constructor<? extends WorkflowAsset> ctor = existing.getClass().getConstructor(existing.getClass());
newCopy = ctor.newInstance(existing);
} catch (Exception ex) {
PluginMessages.log(ex);
newCopy = new WorkflowAsset(existing);
}
newCopy.setName(newName);
newCopy.setVersion(1);
newCopy.setPackage(targetPackage);
try {
designerProxy.createNewWorkflowAsset(newCopy, true);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Copy " + existing.getTitle(), existing.getProject());
}
newCopy.addElementChangeListener(workflowProject);
newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
WorkflowAssetFactory.registerAsset(newCopy);
((TreeViewer) getViewer()).refresh(targetPackage, true);
return true;
}
return false;
} else if (operation == DND.DROP_MOVE) {
// don't allow multiple versions of the same asset in a package
if (!targetPackage.isDefaultPackage()) {
WorkflowAsset asset = workflowProject.getAsset(assetId);
if (targetPackage.getAsset(asset.getName()) != null) {
MessageDialog.openError(MdwPlugin.getShell(), "Asset Exists", "Asset '" + asset.getName() + "' already exists in package '" + targetPackage.getName() + "'.");
return false;
}
}
if (targetPackage.isDefaultPackage()) {
designerProxy.removeWorkflowAssetFromPackage(assetId, sourcePackage);
} else {
assetId = designerProxy.moveWorkflowAssetToPackage(assetId, targetPackage);
}
((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
WorkflowAssetFactory.registerAsset(workflowProject.getAsset(assetId));
return true;
} else {
return false;
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetAttributesSection method select.
public boolean select(Object toTest) {
// currently only definition docs supported
if (!(toTest instanceof WorkflowAsset))
return false;
WorkflowAsset asset = (WorkflowAsset) toTest;
if (!asset.getProject().isMdw5())
return false;
CustomAttributeVO customAttribute = asset.getCustomAttribute();
if (customAttribute == null || !customAttribute.hasDefinition())
return false;
if (customAttribute.hasRoles()) {
// check authorization
for (String role : customAttribute.getRoles()) {
if (asset.isUserAuthorized(role))
return true;
}
return false;
}
return true;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetLockSection method elementChanged.
public void elementChanged(ElementChangeEvent ece) {
if (ece.getElement().equals(workflowAsset)) {
if (ece.getChangeType().equals(ChangeType.PROPERTIES_CHANGE)) {
WorkflowAsset changedVersion = (WorkflowAsset) ece.getElement();
if (!lockUserPropertyEditor.getValue().equals(changedVersion.getLockingUser())) {
lockUserPropertyEditor.setValue(changedVersion.getLockingUser());
modDatePropertyEditor.setValue(changedVersion.getModifyDate());
lockButtonPropertyEditor.setLabel(changedVersion.isLockedToUser() ? "Unlock" : "Lock");
}
notifyLabelChange();
}
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset 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