Search in sources :

Example 36 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method copyProcess.

public void copyProcess(final String originalName, final String originalVersion, final String newName, final WorkflowPackage targetPackage) {
    String progressMsg = "Creating process '" + newName + "'\nin package '" + targetPackage.getName() + "'";
    String errorMsg = "Create Process";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException {
            int dotIdx = originalVersion.indexOf('.');
            int major = Integer.parseInt(originalVersion.substring(0, dotIdx));
            int minor = Integer.parseInt(originalVersion.substring(dotIdx + 1));
            ProcessVO origProcVO = dataAccess.getDesignerDataAccess().getProcessDefinition(originalName, major * 1000 + minor);
            origProcVO = dataAccess.getDesignerDataAccess().getProcess(origProcVO.getProcessId(), origProcVO);
            new ProcessWorker().convert_to_designer(origProcVO);
            ProcessVO newProcVO = new ProcessVO(-1L, newName, origProcVO.getProcessDescription(), null);
            newProcVO.set(origProcVO.getAttributes(), origProcVO.getVariables(), origProcVO.getTransitions(), origProcVO.getSubProcesses(), origProcVO.getActivities());
            newProcVO.setVersion(1);
            newProcVO.setInRuleSet(origProcVO.isInRuleSet());
            WorkflowProcess newProcess = new WorkflowProcess(targetPackage.getProject(), newProcVO);
            newProcess.setPackage(targetPackage);
            Graph process = new Graph(newProcVO, dataAccess.getDesignerDataModel().getNodeMetaInfo(), getIconFactory());
            process.dirtyLevel = Graph.NEW;
            FlowchartPage flowchartPage = FlowchartPage.newPage(mainFrame);
            flowchartPage.setProcess(process);
            saveProcess(newProcess, flowchartPage, PersistType.CREATE, 0, false, false);
            toggleProcessLock(newProcess, true);
            // why?
            newProcess.getProcessVO().setVersion(1);
            dataAccess.getProcesses(false).add(newProcess.getProcessVO());
            targetPackage.addProcess(newProcess);
            newProcess.setPackage(targetPackage);
            if (!newProcess.isInDefaultPackage())
                savePackage(newProcess.getPackage());
        }
    };
    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) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RemoteException(java.rmi.RemoteException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FlowchartPage(com.centurylink.mdw.designer.pages.FlowchartPage)

Example 37 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method saveProcessWithProgress.

public void saveProcessWithProgress(final WorkflowProcess process, final FlowchartPage flowchartPage, final PersistType persistType, final int version, final boolean validate, final boolean keepLocked) {
    String progressMsg = SAVING + process.getName() + "'";
    String errorMsg = "Save Process";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {

        public void perform() throws ValidationException, DataAccessException, RemoteException {
            WorkflowProcess oldProcess = null;
            if (persistType == PersistType.NEW_VERSION) {
                RuleSetVO existing = null;
                if (process.isInRuleSet())
                    existing = dataAccess.getDesignerDataAccess().getRuleSet(process.getName(), RuleSetVO.PROCESS, version);
                if (existing != null)
                    throw new DataAccessException("\n" + process.getLabel() + ALREADY_EXISTS);
                process.getProcessVO().setProcessId(-1L);
                // preserve the old version for the process tree
                ProcessVO oldProcessVoStub = new ProcessVO();
                oldProcessVoStub.setProcessId(process.getId());
                oldProcessVoStub.setProcessName(process.getName());
                oldProcessVoStub.setVersion(process.getProcessVO().getVersion());
                oldProcess = new WorkflowProcess(process.getProject(), oldProcessVoStub);
                oldProcess.setPackage(process.getPackage());
                oldProcess.setTopLevelVersion(process.getTopLevelVersion());
                if (// temp attribute to avoid API
                project.isFilePersist())
                    // change
                    process.setAttribute("previousProcessVersion", oldProcess.getVersionString());
            }
            saveProcess(process, flowchartPage, persistType, version, validate, keepLocked);
            if (process.getTopLevelVersion() != null)
                process.getTopLevelVersion().setProcessVO(process.getProcessVO());
            if (persistType == PersistType.NEW_VERSION && process.isInRuleSet()) {
                RuleSetVO procRs = dataAccess.getRuleSet(process.getId());
                if (procRs == null)
                    dataAccess.getAllRuleSets(false).add(process.getProcessVO());
            }
        }
    };
    designerRunner.run();
}
Also used : ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RemoteException(java.rmi.RemoteException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 38 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException 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 39 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException 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 40 with DataAccessException

use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method renameWorkflowAsset.

public void renameWorkflowAsset(final WorkflowAsset asset, final String newName) {
    if (asset.getPackage().workflowAssetNameExists(newName)) {
        Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
        MessageDialog.openError(shell, RENAME_ERROR, "Name already exists: '" + newName + "'");
        return;
    }
    String progressMsg = "Renaming to '" + newName + "'";
    String errorMsg = "Rename Workflow Asset";
    if (!asset.isLoaded())
        asset.load();
    designerRunner = new DesignerRunner(progressMsg, errorMsg, asset.getProject()) {

        public void perform() throws DataAccessException, RemoteException {
            asset.setVersion(1);
            dataAccess.getDesignerDataModel().removeRuleSet(asset.getRuleSetVO(), false);
            dataAccess.getDesignerDataAccess().renameRuleSet(asset.getRuleSetVO(), newName);
            if (asset instanceof AutomatedTestCase) {
                if (project.isFilePersist())
                    ((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRawFile()));
                else
                    ((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRuleSetVO()));
            }
            // roughly the same as db time
            asset.setModifyDate(new Date());
            // hopefully
            cacheRefresh.fireRefresh(RuleSetVO.JAVA.equals(asset.getLanguage()));
            dataAccess.getDesignerDataModel().addRuleSet(asset.getRuleSetVO());
        }
    };
    designerRunner.run();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestCase(com.centurylink.mdw.designer.testing.TestCase) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) Date(java.util.Date)

Aggregations

DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)61 IOException (java.io.IOException)32 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)25 JSONException (org.json.JSONException)21 XmlException (org.apache.xmlbeans.XmlException)19 RemoteException (java.rmi.RemoteException)18 JSONObject (org.json.JSONObject)12 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)10 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)10 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)8 FileNotFoundException (java.io.FileNotFoundException)8 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 RestfulServer (com.centurylink.mdw.designer.utils.RestfulServer)6 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 Graph (com.centurylink.mdw.designer.display.Graph)4 SubGraph (com.centurylink.mdw.designer.display.SubGraph)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)4 File (java.io.File)4 MDWStatusMessageDocument (com.centurylink.mdw.bpm.MDWStatusMessageDocument)3