Search in sources :

Example 11 with ValidationException

use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method createNewProcess.

public void createNewProcess(final WorkflowProcess processVersion) {
    String progressMsg = "Creating '" + processVersion.getName() + "'";
    String errorMsg = "Create Process";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException {
            if (dataAccess.getDesignerDataModel().getNodeMetaInfo().getStartActivity() == null)
                throw new ValidationException("Please import the MDW Baseline Package corresponding to your MDW framework version.");
            Graph process = new Graph(processVersion.getName(), ProcessVisibilityConstant.PUBLIC, dataAccess.getDesignerDataModel().getNodeMetaInfo(), getIconFactory());
            process.setDescription(processVersion.getDescription());
            process.getProcessVO().setInRuleSet(processVersion.isInRuleSet());
            if (project.isFilePersist())
                process.getProcessVO().setRawFile(new File(project.getAssetDir() + "/" + processVersion.getPackage().getName() + "/" + processVersion.getName() + ".proc"));
            if (!processVersion.isInDefaultPackage())
                process.getProcessVO().setPackageName(processVersion.getPackage().getName());
            final FlowchartPage flowchartPage = FlowchartPage.newPage(mainFrame);
            flowchartPage.setProcess(process);
            saveProcess(processVersion, flowchartPage, PersistType.CREATE, 0, false, false);
            toggleProcessLock(processVersion, true);
            if (processVersion.isInRuleSet())
                dataAccess.getAllRuleSets(false).add(processVersion.getProcessVO());
            // update the process tree
            if (!processVersion.isInDefaultPackage()) {
                processVersion.getPackage().addProcess(processVersion);
                savePackage(processVersion.getPackage());
            } else {
                processVersion.getProject().getDefaultPackage().addProcess(processVersion);
            }
            // add to the mainFrame process list
            dataAccess.getDesignerDataModel().addProcess(processVersion.getProcessVO());
        }
    };
    designerRunner.run();
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) RemoteException(java.rmi.RemoteException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FlowchartPage(com.centurylink.mdw.designer.pages.FlowchartPage)

Example 12 with ValidationException

use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method renameProcess.

public void renameProcess(final WorkflowProcess processVersion, final String newName) {
    if (dataAccess.processNameExists(processVersion.getPackage().getPackageVO(), newName)) {
        Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
        MessageDialog.openError(shell, RENAME_ERROR, "Process name already exists: '" + newName + "'");
        return;
    }
    String version = "v" + processVersion.getVersionString();
    String progressMsg = "Renaming to '" + newName + "' " + version;
    String errorMsg = "Rename Process";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException, XmlException {
            try {
                if (dataAccess.getDesignerDataAccess().hasProcessInstances(processVersion.getId()))
                    throw new DataAccessException("Process " + processVersion.getLabel() + " has instances and cannot be renamed.\nPlease save as a new version.");
            } catch (DataAccessOfflineException ex) {
                final StringBuilder confirm = new StringBuilder();
                MdwPlugin.getDisplay().syncExec(new Runnable() {

                    public void run() {
                        String msg = "Cannot connect to server to check for instances.  Are you sure you want to rename?";
                        confirm.append(MessageDialog.openConfirm(MdwPlugin.getShell(), "Rename Process", msg));
                    }
                });
                if (!Boolean.valueOf(confirm.toString()))
                    return;
            }
            dataAccess.removeProcess(processVersion.getProcessVO());
            if (processVersion.isInRuleSet() && !project.isFilePersist()) {
                ProcessVO procVO = dataAccess.getDesignerDataAccess().getProcessDefinition(processVersion.getName(), processVersion.getVersion());
                procVO = dataAccess.getDesignerDataAccess().getProcess(procVO.getProcessId(), procVO);
                procVO.setName(newName);
                procVO.setVersion(1);
                new ProcessWorker().convert_to_designer(procVO);
                dataAccess.getDesignerDataAccess().updateProcess(procVO, 0, false);
                processVersion.setProcessVO(procVO);
            } else {
                processVersion.setName(newName);
                processVersion.getProcessVO().setVersion(1);
                processVersion.getProcessVO().setId(dataAccess.getDesignerDataAccess().renameProcess(processVersion.getId(), newName, 1));
            }
            dataAccess.getDesignerDataModel().addProcess(processVersion.getProcessVO());
        }
    };
    designerRunner.run();
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) Shell(org.eclipse.swt.widgets.Shell) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) XmlException(org.apache.xmlbeans.XmlException) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 13 with ValidationException

use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.

the class Importer method importProcess.

public WorkflowProcess importProcess(final WorkflowPackage targetPackage, final WorkflowProcess targetProcess, final String xml) throws DataAccessException, RemoteException, XmlException, ValidationException {
    CodeTimer timer = new CodeTimer("importProcess()");
    ProcessVO importedProcessVO = null;
    int schemaVersion = dataAccess.getSchemaVersion();
    ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
    importedProcessVO = importer.importProcess(xml);
    if (targetProcess != null && !importedProcessVO.getName().equals(targetProcess.getName()))
        throw new ValidationException("Process in XML (" + importedProcessVO.getName() + ") is not " + targetProcess.getName());
    for (WorkflowProcess existing : targetPackage.getProject().getAllProcesses()) {
        if (existing.getName().equals(importedProcessVO.getName())) {
            if (existing.getVersion() == importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + ".");
            if (existing.getVersion() > importedProcessVO.getVersion())
                throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + " with a version greater than the imported process (v" + importedProcessVO.getVersionString() + ").");
        }
    }
    // designer fix for backward compatibility
    ProcessWorker worker = new ProcessWorker();
    worker.convert_to_designer(importedProcessVO);
    worker.convert_from_designer(importedProcessVO, syncNodeMetaInfo(dataAccess.getDesignerDataModel().getNodeMetaInfo(), importedProcessVO));
    if (!importedProcessVO.isInRuleSet()) {
        // fix pseudo variables
        for (VariableVO varVO : importedProcessVO.getVariables()) varVO.setVariableId(null);
    }
    importedProcessVO.setPackageName(targetPackage.getName());
    WorkflowProcess alreadyInPackage = null;
    if (targetPackage.getProject().getProcess(importedProcessVO.getName()) == null)
        dataAccess.getDesignerDataAccess().createProcess(importedProcessVO);
    else {
        alreadyInPackage = targetPackage.getProcess(importedProcessVO.getName());
        dataAccess.getDesignerDataAccess().updateProcess(importedProcessVO, importedProcessVO.getVersion(), false);
    }
    ProcessVO reloaded = dataAccess.getDesignerDataAccess().getProcessDefinition(importedProcessVO.getProcessName(), importedProcessVO.getVersion());
    importedProcessVO.setProcessId(reloaded.getProcessId());
    if (targetPackage.getProject().getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion52)
        updateSubProcessIdAttributes(importedProcessVO);
    WorkflowProcess importedProcess = new WorkflowProcess(targetPackage.getProject(), importedProcessVO);
    dataAccess.getProcesses(false).add(importedProcess.getProcessVO());
    if (alreadyInPackage != null)
        targetPackage.removeProcess(alreadyInPackage);
    targetPackage.addProcess(importedProcess);
    importedProcess.setPackage(targetPackage);
    dataAccess.auditLog(Action.Import, importedProcess);
    timer.stopAndLog();
    return importedProcess;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) ProcessImporter(com.centurylink.mdw.dataaccess.ProcessImporter) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 14 with ValidationException

use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.

the class PluginMessages method uiMessage.

public static void uiMessage(Shell shell, Throwable t, String message, String title, WorkflowProject project, int level) {
    log(t);
    if (t instanceof ValidationException || t.getCause() instanceof ValidationException) {
        ValidationException valEx = t instanceof ValidationException ? (ValidationException) t : (ValidationException) t.getCause();
        StringBuilder messageBuf = new StringBuilder();
        valEx.fillInErrors(messageBuf, 3);
        message = messageBuf.toString();
        title = "Validation Error: " + title;
        level = VALIDATION_MESSAGE;
    }
    if (message == null)
        message = PluginMessages.getUserMessage(t);
    boolean sendMessage = level >= getReportingLevel();
    if (shell != null) {
        MdwMessageDialog messageDialog = new MdwMessageDialog(shell, title, message, level);
        messageDialog.open();
        sendMessage = messageDialog.isReportMessage();
    }
    if (sendMessage)
        PluginUtil.sendError(t, title, message, project, level);
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) MdwMessageDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwMessageDialog)

Example 15 with ValidationException

use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.

the class CacheRefresh method doRefresh.

public void doRefresh(boolean silent, final boolean includeDynamicJava) {
    try {
        if (silent) {
            if (workflowProject.isUpdateServerCache()) {
                // run as background job
                new Job("MDW Cache Refresh: " + restfulServer.getMdwWebUrl()) {

                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                            refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                            timer.stopAndLog();
                        } catch (Exception ex) {
                            if (MdwPlugin.getSettings().isLogConnectErrors())
                                PluginMessages.log(ex);
                        }
                        return Status.OK_STATUS;
                    }
                }.schedule();
            }
        } else {
            String progressMsg = "Refreshing Caches and Properties for '" + workflowProject.getLabel() + "'";
            String errorMsg = "Refresh Cache";
            DesignerRunner designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {

                public void perform() throws ValidationException, DataAccessException, RemoteException {
                    try {
                        CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
                        refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
                        timer.stopAndLog();
                    } catch (Exception ex) {
                        PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
                    }
                }
            };
            designerRunner.run();
            if (refreshStatusMessage == null) {
                PluginMessages.uiError(workflowProject.getName() + " Refresh Caches and Properties failed.  Make sure baseline event handlers are registered.", REFRESH_CACHES, workflowProject);
            } else if (refreshStatusMessage.getMDWStatusMessage().getStatusCode() != 0) {
                String message = refreshStatusMessage.getMDWStatusMessage().getStatusMessage();
                PluginMessages.uiMessage(workflowProject.getName() + " Refresh Caches and Properties:\n" + message, "Refresh Caches", workflowProject, PluginMessages.INFO_MESSAGE);
            }
        }
    } catch (Exception ex) {
        if (!silent)
            PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) Job(org.eclipse.core.runtime.jobs.Job) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Aggregations

ValidationException (com.centurylink.mdw.designer.utils.ValidationException)16 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)10 RemoteException (java.rmi.RemoteException)9 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)7 Graph (com.centurylink.mdw.designer.display.Graph)5 SubGraph (com.centurylink.mdw.designer.display.SubGraph)5 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)5 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)4 FlowchartPage (com.centurylink.mdw.designer.pages.FlowchartPage)3 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)3 ProcessValidator (com.centurylink.mdw.designer.utils.ProcessValidator)2 XmlException (org.apache.xmlbeans.XmlException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Shell (org.eclipse.swt.widgets.Shell)2 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)1 MDWStatusMessage (com.centurylink.mdw.bpm.MDWStatusMessageDocument.MDWStatusMessage)1 StatusMessage (com.centurylink.mdw.common.service.types.StatusMessage)1 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1