Search in sources :

Example 1 with DesignerProxy

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;
                }
            }
        }
    });
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) MdwListInputDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwListInputDialog) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ArrayList(java.util.ArrayList) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException)

Example 2 with DesignerProxy

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);
}
Also used : DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) File(java.io.File) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 3 with DesignerProxy

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());
    }
}
Also used : VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) MDWStatusMessage(com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with DesignerProxy

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;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CopyDialog(com.centurylink.mdw.plugin.designer.dialogs.CopyDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Example 5 with DesignerProxy

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;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CopyDialog(com.centurylink.mdw.plugin.designer.dialogs.CopyDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)19 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)8 CoreException (org.eclipse.core.runtime.CoreException)6 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)5 File (java.io.File)5 IOException (java.io.IOException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)5 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)4 ArrayList (java.util.ArrayList)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)3 CopyDialog (com.centurylink.mdw.plugin.designer.dialogs.CopyDialog)3 ConnectException (java.net.ConnectException)3 IFile (org.eclipse.core.resources.IFile)3 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)2 Importer (com.centurylink.mdw.plugin.designer.Importer)2 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)2