Search in sources :

Example 1 with ValidationException

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

the class DesignerPage method saveProcess.

/**
 * Saves and then reload the process graph
 */
public Graph saveProcess(Graph process, MainFrame frame, PersistType persistType, int version, boolean lock) throws ValidationException, DataAccessException, RemoteException {
    String processId = saveProcess(process, persistType, version, lock);
    if (processId == null)
        throw new ValidationException("Error in saving process");
    // load process again
    ProcessVO procdef = process.getProcessVO();
    if (persistType == PersistType.CREATE) {
        procdef.setProcessId(new Long(processId));
        procdef = loadProcess(procdef);
    } else if (persistType == PersistType.NEW_VERSION) {
        procdef = frame.dao.getProcess(new Long(processId), procdef);
        // procdef is overridden with the new version here
        new ProcessWorker().convert_to_designer(procdef);
        model.addProcess(procdef);
    } else {
        procdef = loadProcess(procdef);
    }
    process.reinit(procdef);
    return process;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 2 with ValidationException

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

the class DesignerPage method saveProcess.

/**
 * @param graph
 * @return process ID if saving is successful; null o/w
 */
private String saveProcess(Graph graph, PersistType persistType, int version, boolean lock) throws ValidationException {
    String processId = null;
    ProcessVO process = graph.getProcessVO();
    int currentVersion = process.getVersion();
    try {
        frame.log("Saving process " + process.getProcessName() + " ...");
        new ProcessWorker().convert_from_designer(process, model.getNodeMetaInfo());
        if (persistType == PersistType.CREATE) {
            processId = frame.dao.createProcess(process);
        } else {
            processId = frame.dao.updateProcess(process, version, lock);
            process.setVersion(currentVersion);
        // keep the version number
        }
        graph.setDirtyLevel(Graph.CLEAN);
        graph.setReadonly(true);
        graph.getProcessVO().clearDeletedTransitions();
    } catch (Exception e) {
        // TODO better not to convert back - keep the original
        new ProcessWorker().convert_to_designer(process);
        process.setVersion(currentVersion);
        e.printStackTrace();
        throw new ValidationException(e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
    }
    return processId;
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException)

Example 3 with ValidationException

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

the class DesignerProxy method moveWorkflowAssetToPackage.

public Long moveWorkflowAssetToPackage(final Long assetId, final WorkflowPackage targetPackage) {
    String progressMsg = "Moving Asset ID: " + assetId + TO_PKG + targetPackage.getName() + "'";
    String errorMsg = "Move Workflow Asset";
    final WorkflowProject workflowProject = targetPackage.getProject();
    final WorkflowAsset asset = workflowProject.getAsset(assetId);
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException {
            if (asset.isInDefaultPackage()) {
                dataAccess.getDesignerDataAccess().addRuleSetToPackage(asset.getRuleSetVO(), targetPackage.getPackageVO());
                WorkflowPackage defaultPackage = workflowProject.getDefaultPackage();
                defaultPackage.removeAsset(asset);
            } else {
                // id can change from repackaging for VCS assets
                Long newId = dataAccess.getDesignerDataAccess().addRuleSetToPackage(asset.getRuleSetVO(), targetPackage.getPackageVO());
                dataAccess.getDesignerDataAccess().removeRuleSetFromPackage(asset.getRuleSetVO(), asset.getPackage().getPackageVO());
                asset.setId(newId);
                asset.getPackage().removeAsset(asset);
            }
            targetPackage.addAsset(asset);
        }
    };
    designerRunner.run();
    return asset.getId();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 4 with ValidationException

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

the class DesignerProxy method saveProcess.

/**
 * Relies on classic designer page to update the processVO with the reloaded
 * data.
 */
public void saveProcess(WorkflowProcess process, FlowchartPage flowchartPage, PersistType persistType, int version, boolean validate, boolean lock) throws ValidationException, DataAccessException, RemoteException {
    CodeTimer timer = new CodeTimer("saveProcess()");
    Graph graph = flowchartPage.getProcess();
    graph.save_temp_vars();
    // refresh variable type cache since Designer Classic uses a single,
    // static cache
    // calls
    dataAccess.loadVariableTypes();
    if (validate)
        new ProcessValidator(process.getProcessVO()).validate(getNodeMetaInfo());
    if (!process.getProject().checkRequiredVersion(5, 5))
        flowchartPage.setProcessVersions(flowchartPage.getProcess(), // not
        !process.getProject().checkRequiredVersion(5, 2));
    // sure
    // why
    // this
    // was
    // ever
    // needed
    Map<String, String> overrideAttributes = null;
    if (process.getProcessVO() != null && process.getProject().isFilePersist() && process.overrideAttributesApplied())
        overrideAttributes = process.getProcessVO().getOverrideAttributes();
    Graph reloaded = null;
    try {
        reloaded = flowchartPage.saveProcess(graph, mainFrame, persistType, version, lock);
    } catch (ValidationException ex) {
        graph.setDirtyLevel(Graph.DIRTY);
        if (ex.getMessage() != null && ex.getMessage().contains(ORA_02292))
            throw new ValidationException("There are instances associated with this process version.\n       Please increment the version when saving.");
        else
            throw ex;
    }
    process.setProcessVO(reloaded.getProcessVO());
    flowchartPage.setProcess(reloaded);
    WorkflowPackage pkg = process.getPackage();
    if (pkg != null && !pkg.isDefaultPackage() && persistType == PersistType.NEW_VERSION) {
        if (project.isFilePersist()) {
            pkg.setVersion(pkg.getVersion() + 1);
            // exported not relevant for vcs
            pkg.setExported(false);
            // processes since pkg will be archived
            // anyway
            savePackage(pkg, true);
        } else {
            savePackage(pkg);
        }
    }
    if (process.getProject().isFilePersist() && version != 0 && persistType == PersistType.NEW_VERSION && overrideAttributes != null && !overrideAttributes.isEmpty() && MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_CARRY_FORWARD_OVERRIDE_ATTRS)) {
        if (!process.overrideAttributesApplied())
            throw new DataAccessException("Override attributes not applied");
        reloaded.getProcessVO().applyOverrideAttributes(overrideAttributes);
        getDesignerDataAccess().setOverrideAttributes(reloaded.getProcessVO());
    }
    cacheRefresh.fireRefresh(reloaded.getProcessVO().hasDynamicJavaActivity());
    timer.stopAndLog();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) ProcessValidator(com.centurylink.mdw.designer.utils.ProcessValidator) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 5 with ValidationException

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

the class DesignerRunner method run.

public RunnerResult run(boolean forked) {
    result = new RunnerResult();
    Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
    ProgressMonitorDialog progressMonitorDialog = new MdwProgressMonitorDialog(shell);
    try {
        // this is absolutely needed
        shell.setFocus();
        progressMonitorDialog.run(forked, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(progressMessage, IProgressMonitor.UNKNOWN);
                try {
                    perform();
                    result.setStatus(RunnerStatus.SUCCESS);
                } catch (Exception ex) {
                    result.setStatus(RunnerStatus.FAILURE);
                    throw new InvocationTargetException(ex);
                }
            }
        });
        return result;
    } catch (Exception ex) {
        int messageLevel = PluginMessages.isDataIntegrityException(ex) ? PluginMessages.DATA_INTEGRITY_MESSAGE : PluginMessages.ERROR_MESSAGE;
        PluginMessages.uiMessage(shell, ex, errorMessage, workflowProject, messageLevel);
        if (ex.getCause() instanceof ValidationException) {
            if (DesignerProxy.INCOMPATIBLE_INSTANCES.equals(ex.getCause().getMessage()) || (ex.getCause().getMessage() != null && ex.getCause().getMessage().contains(DesignerProxy.ALREADY_EXISTS)))
                result.setStatus(RunnerStatus.DISALLOW);
            else
                result.setStatus(RunnerStatus.INVALID);
        }
        return result;
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

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