use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method tagVersion.
public void tagVersion(WorkflowElement[] elements) {
final List<WorkflowPackage> packages = new ArrayList<WorkflowPackage>();
for (WorkflowElement element : elements) {
if (element instanceof WorkflowPackage)
packages.add((WorkflowPackage) element);
else
throw new UnsupportedOperationException("Invalid type for tagVersion: " + element.getClass().getName());
}
MdwListInputDialog dlg = new MdwListInputDialog(getShell(), "Tag Workflow Package(s)", "Enter tag to apply to package versions", packages);
if (dlg.open() == Dialog.CANCEL)
return;
final String tag = dlg.getInput();
if (tag == null)
return;
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
for (final WorkflowPackage pkg : packages) {
try {
DesignerProxy dp = pkg.getProject().getDesignerProxy();
dp.tagPackage(pkg, tag);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Tag Package", pkg.getProject());
break;
}
}
}
});
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy 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.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class ProcessLaunchConfiguration method launchProcess.
protected void launchProcess(WorkflowProcess process, String masterRequestId, String owner, Long ownerId, boolean synchronous, String responseVarName, Map<String, String> parameters, Long activityId, boolean showLogs, boolean liveView) {
List<VariableValue> variableValues = new ArrayList<>();
for (Map.Entry<String, String> var : parameters.entrySet()) {
VariableVO variableVO = process.getVariable(var.getKey());
if (var.getValue().length() > 0) {
VariableTypeVO varType = process.getProject().getDataAccess().getVariableType(variableVO.getVariableType());
variableValues.add(new VariableValue(variableVO, varType, var.getValue()));
}
}
DesignerProxy designerProxy = process.getProject().getDesignerProxy();
try {
if (showLogs || liveView) {
watch = true;
LogWatcher logWatcher = designerProxy.getLogWatcher(MdwPlugin.getDisplay());
if (logWatcher.isRunning()) {
MdwPlugin.getDisplay().syncExec(new Runnable() {
public void run() {
String message = "Live View is already monitoring an existing instance. Disconnect to monitor new instance?";
watch = MessageDialog.openConfirm(MdwPlugin.getDisplay().getActiveShell(), "Live View", message);
}
});
}
if (watch) {
logWatcher.shutdown();
logWatcher.setMasterRequestId(masterRequestId);
logWatcher.setProcess(process);
logWatcher.startup(liveView);
}
}
if (synchronous) {
String response = designerProxy.launchSynchronousProcess(process, masterRequestId, owner, ownerId, variableValues, responseVarName);
if (isWriteToConsole())
writeToConsole("Process Launch Response", response + "\n");
} else {
MDWStatusMessage statusMsg = designerProxy.launchProcess(process, masterRequestId, owner, ownerId, variableValues, activityId);
if (isWriteToConsole())
writeToConsole("Process Launch Response", statusMsg.getStatusMessage() + "\n");
}
} catch (Exception ex) {
showError(ex, "Launch Process", process.getProject());
}
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method handleDropExternalEvent.
private boolean handleDropExternalEvent(String externalEventInfo, WorkflowPackage targetPackage, int operation) {
Long externalEventId = getExternalEventId(externalEventInfo);
WorkflowProject workflowProject = targetPackage.getProject();
WorkflowPackage sourcePackage = workflowProject.getPackage(getPackageName(externalEventInfo));
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (operation == DND.DROP_COPY) {
ExternalEvent existing = workflowProject.getExternalEvent(externalEventId);
CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, existing.getName(), null, targetPackage);
if (copyDialog.open() == Dialog.OK) {
String newPattern = copyDialog.getNewName();
ExternalEvent newCopy = new ExternalEvent(existing);
newCopy.setName(newPattern);
newCopy.setPackage(targetPackage);
designerProxy.registerExternalEventHandler(newCopy);
newCopy.addElementChangeListener(workflowProject);
newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
((TreeViewer) getViewer()).refresh(targetPackage, true);
return true;
}
return false;
} else if (operation == DND.DROP_MOVE) {
if (targetPackage.isDefaultPackage()) {
designerProxy.removeExternalEventFromPackage(externalEventId, sourcePackage);
} else {
designerProxy.moveExternalEventToPackage(externalEventId, targetPackage);
}
((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
return true;
} else {
return false;
}
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method handleDropProcess.
/**
* @param processInfo
* @param targetPackage
* @param operation
* @return
*/
private boolean handleDropProcess(String processInfo, WorkflowPackage targetPackage, int operation) {
String processName = getProcessName(processInfo);
String version = getProcessVersion(processInfo);
WorkflowProject targetProject = targetPackage.getProject();
WorkflowPackage sourcePackage = targetProject.getPackage(getPackageName(processInfo));
DesignerProxy designerProxy = targetProject.getDesignerProxy();
if (operation == DND.DROP_COPY) {
String workflowProjectName = getWorkflowProjectName(processInfo);
WorkflowProcess existing = targetProject.getProcess(processName, version);
if (!targetPackage.getProject().getName().equals(workflowProjectName)) {
// copying from remote project
if (existing != null) {
MessageDialog.openError(getViewer().getControl().getShell(), "Copy Foreign Process", "' " + processName + " v" + version + "' already exists in workflow project '" + targetPackage.getProject().getLabel() + "'.");
return false;
}
WorkflowProject sourceProject = WorkflowProjectManager.getInstance().getWorkflowProject(workflowProjectName);
designerProxy.copyForeignProcess(processName, version, sourceProject, targetPackage);
WorkflowProcess newCopy = targetProject.getProcess(processName, "0.1");
if (newCopy != null) {
newCopy.addElementChangeListener(targetProject);
newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
}
((TreeViewer) getViewer()).refresh(targetPackage, true);
return true;
} else {
// is there a dirty editor open?
if (existing != null) {
IEditorPart editor = findOpenEditor(existing);
if (editor != null && editor.isDirty()) {
MessageDialog.openWarning(getViewer().getControl().getShell(), "Copy Process", "' " + processName + " v" + version + "' is currently open in an editor.\nPlease save or close before copying.");
return false;
}
}
CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, processName, version, targetPackage);
if (copyDialog.open() == Dialog.OK) {
String newName = copyDialog.getNewName();
designerProxy.copyProcess(processName, version, newName, targetPackage);
WorkflowProcess newCopy = targetProject.getProcess(newName, "0.1");
if (newCopy != null) {
newCopy.addElementChangeListener(targetProject);
newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
}
((TreeViewer) getViewer()).refresh(targetPackage, true);
return true;
}
}
return false;
} else if (operation == DND.DROP_MOVE) {
// don't allow multiple versions of the same process in a package
if (!targetPackage.isDefaultPackage() && targetPackage.getProcess(processName) != null) {
MessageDialog.openError(MdwPlugin.getShell(), "Process Exists", "Process '" + processName + "' already exists in package '" + targetPackage.getName() + "'.");
return false;
}
if (targetPackage.isDefaultPackage()) {
designerProxy.removeProcessFromPackage(processName, version, sourcePackage);
} else {
designerProxy.moveProcessToPackage(processName, version, targetPackage);
}
((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
if (sourcePackage != null)
((TreeViewer) getViewer()).refresh(sourcePackage.getProject(), true);
return true;
} else {
return false;
}
}
Aggregations