Search in sources :

Example 26 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class ArtifactResourceListener method resourceChanged.

public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
        IResourceDelta rootDelta = event.getDelta();
        IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
        if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
            // the file has been changed
            final Display display = Display.getCurrent();
            if (display != null) {
                display.syncExec(new Runnable() {

                    public void run() {
                        byte[] newValue = PluginUtil.readFile(tempFile);
                        String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
                        if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
                            WorkflowProcess processVersion = null;
                            if (getElement() instanceof Activity) {
                                Activity activity = (Activity) getElement();
                                activity.setAttribute(valueProvider.getAttributeName(), attrVal);
                                processVersion = activity.getProcess();
                            } else {
                                processVersion = (WorkflowProcess) getElement();
                                processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
                            }
                            processVersion.fireDirtyStateChanged(true);
                            ProcessEditor processEditor = findProcessEditor(processVersion);
                            if (processEditor == null) {
                                try {
                                    processEditor = openProcessEditor(processVersion);
                                    IEditorPart tempFileEditor = findTempFileEditor(tempFile);
                                    if (tempFileEditor != null)
                                        processEditor.addActiveScriptEditor(tempFileEditor);
                                } catch (PartInitException ex) {
                                    PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
                                    return;
                                }
                            }
                            processVersion = processEditor.getProcess();
                            if (processVersion.isReadOnly()) {
                                WorkflowProject workflowProject = getElement().getProject();
                                PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
                                return;
                            }
                            if (getElement() instanceof Activity) {
                                Activity activity = (Activity) getElement();
                                // previously-opened process version
                                for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
                                    if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
                                        node.setAttribute(valueProvider.getAttributeName(), attrVal);
                                        ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
                                        element = new Activity(node, processVersion, actImpl);
                                    }
                                }
                                activity.fireDirtyStateChanged(true);
                            }
                            processEditor.dirtyStateChanged(true);
                            valueProvider.afterTempFileSaved();
                            // process editor is open
                            String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
                            String toggleMessage = "Don't show me this message again.";
                            IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
                            String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
                            if (!prefsStore.getBoolean(prefsKey)) {
                                MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
                                prefsStore.setValue(prefsKey, dialog.getToggleState());
                            }
                        }
                    }
                });
            }
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PartInitException(org.eclipse.ui.PartInitException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) IResourceDelta(org.eclipse.core.resources.IResourceDelta) Display(org.eclipse.swt.widgets.Display)

Example 27 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class BamEventComposer method createBamDataTable.

private void createBamDataTable() {
    if (attributesTableContainer != null) {
        if (dataTableDirtyStateListener != null)
            attributesTableContainer.removeDirtyStateListener(dataTableDirtyStateListener);
        attributesTableContainer.dispose();
    }
    // attributes
    TableT bamTable = null;
    if (bamPagelet != null) {
        try {
            bamTable = getBamPageletTable();
        } catch (BamPageletValidationException ex) {
            PluginMessages.uiError(ex, "BAM Pagelet");
        }
    }
    String label;
    if (bamTable != null && (bamTable.getNAME() != null || bamTable.getLABEL() != null)) {
        label = bamTable.getLABEL() == null ? bamTable.getNAME() : bamTable.getLABEL();
        bamTable.setLABEL(label);
        for (DropdownT dropdown : bamTable.getDROPDOWNList()) {
            if ("Variables".equalsIgnoreCase(dropdown.getSOURCE())) {
                WorkflowProcess processVersion = getProcess();
                if (processVersion != null) {
                    List<String> varNames = processVersion.getNonDocRefVariableNames();
                    // add process variable values
                    for (String var : varNames) {
                        OptionT option = dropdown.addNewOPTION();
                        option.setVALUE("#{" + var + "}");
                        option.setStringValue(var);
                    }
                }
            }
        }
    }
    attributesTableContainer = createAttributesTable(getWidth(), LAYOUT_COLS, bamTable);
    dataTableDirtyStateListener = new DirtyStateListener() {

        public void dirtyStateChanged(boolean dirty) {
            if (bamMessage != null) {
                bamMessage.setAttributes(attributesTableContainer.getAttributes());
                Event event = new Event();
                event.widget = attributesTableContainer.tableEditor.getTable();
                event.data = attributesTableContainer.getAttributes();
                fireModify(new ModifyEvent(event));
            }
        }
    };
    attributesTableContainer.addDirtyStateListener(dataTableDirtyStateListener);
    this.layout(true);
}
Also used : OptionT(noNamespace.OptionT) DirtyStateListener(com.centurylink.mdw.plugin.designer.DirtyStateListener) ModifyEvent(org.eclipse.swt.events.ModifyEvent) DropdownT(noNamespace.DropdownT) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableT(noNamespace.TableT) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 28 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method getAllProcessVersions.

/**
 * Returns all processes, regardless of packaging or version.
 */
public List<WorkflowProcess> getAllProcessVersions() {
    List<WorkflowProcess> allProcessVersions = new ArrayList<>();
    for (WorkflowProcess processVersion : getAllProcesses()) {
        if (processVersion.hasDescendantProcessVersions()) {
            for (WorkflowProcess descendant : processVersion.getDescendantProcessVersions()) allProcessVersions.add(descendant);
        } else {
            allProcessVersions.add(processVersion);
        }
    }
    Collections.sort(allProcessVersions);
    return allProcessVersions;
}
Also used : ArrayList(java.util.ArrayList) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 29 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class ProcessSearchQuery method run.

public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
    if (getScopedProjects().isEmpty() && getSelectedPackage() != null)
        getScopedProjects().add(getSelectedPackage().getProject());
    if (getScopedProjects().isEmpty()) {
        String msg = "No MDW projects in search scope.";
        showError(msg, "MDW Search", null);
        return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, msg, null);
    }
    for (WorkflowProject project : getScopedProjects()) {
        if (getSearchType().equals(SearchType.ENTITY_BY_NAME)) {
            for (WorkflowProcess process : project.getAllProcessVersions()) {
                String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                if ((getPattern().equals("*") || name.indexOf(getPattern()) >= 0) && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
                    getSearchResults().addMatchingElement(process);
            }
        } else if (getSearchType().equals(SearchType.ENTITY_BY_ID)) {
            WorkflowProcess process = project.getProcess(new Long(getPattern()));
            if (process == null && project.isRemote() && project.isFilePersist()) {
                // could be archived process for remote VCS
                try {
                    ProcessVO procVO = project.getDesignerProxy().getDesignerDataAccess().getProcessDefinition(new Long(getPattern()));
                    process = new WorkflowProcess(project, procVO);
                } catch (Exception ex) {
                    PluginMessages.log(ex);
                }
            }
            if (process != null && (getSelectedPackage() == null || (process.getPackage() != null && process.getPackage().equals(getSelectedPackage()))))
                getSearchResults().addMatchingElement(process);
        } else if (getSearchType().equals(SearchType.CONTAINING_ENTITY)) {
            try {
                for (WorkflowProcess process : project.getDesignerProxy().getProcessesUsingActivityImpl(containedEntityId, containedEntityName)) {
                    String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                    if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
                        getSearchResults().addMatchingElement(process);
                }
            } catch (DataAccessException ex) {
                showError(ex, "Find Processes", project);
            }
        } else if (getSearchType().equals(SearchType.INVOKING_ENTITY)) {
            try {
                WorkflowProcess invoked = project.getProcess(getInvokedEntityId());
                for (WorkflowProcess process : project.getDesignerProxy().findCallingProcesses(invoked)) {
                    String name = isCaseSensitive() ? process.getName() : process.getName().toLowerCase();
                    if (getPattern().equals("*") || name.indexOf(getPattern()) >= 0)
                        getSearchResults().addMatchingElement(process);
                }
            } catch (Exception ex) {
                showError(ex, "Calling Processes", project);
            }
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_ENTITY_ID)) {
            Map<String, String> criteria = new HashMap<String, String>();
            criteria.put("processId", getPattern());
            searchInstances(project, criteria);
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_ID)) {
            Map<String, String> criteria = new HashMap<String, String>();
            criteria.put("id", getPattern());
            searchInstances(project, criteria);
        } else if (getSearchType().equals(SearchType.INSTANCE_BY_MRI)) {
            Map<String, String> criteria = new HashMap<String, String>();
            if (isCaseSensitive())
                criteria.put("masterRequestId", getPattern());
            else
                criteria.put("masterRequestIdIgnoreCase", getPattern());
            searchInstances(project, criteria);
        } else {
            showError("Unsupported search type: " + getSearchType(), "MDW Search", null);
        }
    }
    if (getSearchResults().getMatchingElements().size() == 0)
        return new Status(IStatus.WARNING, MdwPlugin.getPluginId(), 0, "No matching elements found", null);
    else
        return Status.OK_STATUS;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) HashMap(java.util.HashMap) Map(java.util.Map) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 30 with WorkflowProcess

use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.

the class ProcessSearchQuery method searchInstances.

private void searchInstances(final WorkflowProject project, Map<String, String> criteria) {
    try {
        List<ProcessInstanceVO> instances = project.getDesignerProxy().getProcessInstances(criteria);
        for (ProcessInstanceVO instanceInfo : instances) {
            Long processId = instanceInfo.getProcessId();
            if (project.getProcess(processId) == null && instanceInfo.getOwner().equals(OwnerType.PROCESS_INSTANCE)) {
                Map<String, String> newCrit = new HashMap<String, String>();
                newCrit.put("id", instanceInfo.getOwnerId().toString());
                instanceInfo = project.getDesignerProxy().getProcessInstances(newCrit).get(0);
                processId = instanceInfo.getProcessId();
            }
            if (processId != null) {
                WorkflowProcess processVersion = project.getProcess(processId);
                if (// can
                processVersion == null && project.isFilePersist()) // happen
                // for
                // non-vcs
                // processes
                // or
                // Archived
                // processes
                {
                    ProcessVO processVO = new ProcessVO();
                    processVO.setProcessId(instanceInfo.getProcessId());
                    processVersion = new WorkflowProcess(project, processVO);
                    processVersion.setName(instanceInfo.getProcessName());
                    processVersion.setVersion(RuleSetVO.parseVersion(instanceInfo.getProcessVersion()));
                    processVO = project.getDataAccess().loadProcess(processVersion);
                    if (// otherwise retrieval will be
                    processVO != null)
                        // just-in-time
                        processVersion.setProcessVO(processVO);
                }
                if (processVersion != null) {
                    WorkflowProcess instance = new WorkflowProcess(processVersion);
                    instance.setProcessInstance(instanceInfo);
                    if (!getSearchResults().getMatchingElements().contains(instance))
                        getSearchResults().addMatchingElement(instance);
                }
            }
        }
    } catch (Exception ex) {
        showError(ex, "Retrieve Process Instances", project);
    }
}
Also used : HashMap(java.util.HashMap) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)85 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)28 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)21 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)21 PartInitException (org.eclipse.ui.PartInitException)20 ArrayList (java.util.ArrayList)17 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)11 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)10 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)9 IEditorPart (org.eclipse.ui.IEditorPart)9 ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)8 IFile (org.eclipse.core.resources.IFile)8 CoreException (org.eclipse.core.runtime.CoreException)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 IOException (java.io.IOException)7 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)6 Activity (com.centurylink.mdw.plugin.designer.model.Activity)6