Search in sources :

Example 26 with DataAccessException

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

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

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

the class DesignerProxy method renamePackage.

public void renamePackage(final WorkflowPackage packageToRename, final String newName) {
    if (packageToRename.isDefaultPackage())
        return;
    final WorkflowProject workflowProject = packageToRename.getProject();
    if (workflowProject.packageNameExists(newName)) {
        Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
        MessageDialog.openError(shell, RENAME_ERROR, "Package name already exists: '" + newName + "'");
        return;
    }
    String progressMsg = "Renaming package to '" + newName + "'";
    String errorMsg = "Rename Package";
    designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {

        public void perform() throws DataAccessException, RemoteException {
            packageToRename.getPackageVO().setId(dataAccess.getDesignerDataAccess().renamePackage(packageToRename.getId(), newName, 1));
        }
    };
    designerRunner.run();
    packageToRename.setName(newName);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) RemoteException(java.rmi.RemoteException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 29 with DataAccessException

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

the class RestfulServer method invokeResourceService.

public String invokeResourceService(String path) throws DataAccessException, IOException {
    String url = getMdwWebUrl() + (path.startsWith("/") ? "Services/" + path : "/Services/" + path);
    String response = null;
    try {
        HttpHelper httpHelper = getHttpHelper(url);
        httpHelper.setConnectTimeout(getConnectTimeout());
        httpHelper.setReadTimeout(getReadTimeout());
        response = httpHelper.get();
    } catch (SocketTimeoutException ex) {
        throw new IOException("Timeout after " + getReadTimeout() + " ms", ex);
    } catch (FileNotFoundException ex) {
        throw ex;
    } catch (IOException ex) {
        throw new IOException("Unable to connect to " + getMdwWebUrl(), ex);
    }
    if (response != null && (response.trim().startsWith("<xs:MDWStatusMessage") || response.trim().startsWith("<bpm:MDWStatusMessage"))) {
        try {
            MDWStatusMessageDocument msgDoc = MDWStatusMessageDocument.Factory.parse(response, Compatibility.namespaceOptions());
            throw new DataAccessException(msgDoc.getMDWStatusMessage().getStatusMessage());
        } catch (Exception ex) {
            throw new DataAccessException(-1, response, ex);
        }
    }
    return response;
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) FileNotFoundException(java.io.FileNotFoundException) MDWStatusMessageDocument(com.centurylink.mdw.bpm.MDWStatusMessageDocument) IOException(java.io.IOException) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) JSONException(org.json.JSONException) SocketTimeoutException(java.net.SocketTimeoutException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) XmlException(org.apache.xmlbeans.XmlException)

Example 30 with DataAccessException

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

the class PluginDataAccess method getTaskVariableMappings.

// TODO attribute overflow
public Map<String, List<String>> getTaskVariableMappings() throws DataAccessException {
    Map<String, List<String>> ownerVars = new TreeMap<>(PluginUtil.getStringComparator());
    DatabaseAccess db = new DatabaseAccess(workflowProject.getMdwDataSource().getJdbcUrlWithCredentials());
    try {
        db.openConnection();
        if (workflowProject.checkRequiredVersion(5, 2)) {
            String query = "select t.task_name, a.attribute_value \n " + "from task t, attribute a \n" + "where a.attribute_owner = 'TASK' \n" + "and t.task_id = a.attribute_owner_id \n" + "and a.attribute_name = 'Variables' \n" + "order by a.attribute_id desc";
            ResultSet rs = db.runSelect(query, null);
            while (rs.next()) {
                String taskName = rs.getString("task_name");
                if (!ownerVars.containsKey(taskName)) {
                    List<String> vars = new ArrayList<>();
                    String varString = rs.getString("attribute_value");
                    if (varString != null && varString.trim().length() > 0) {
                        for (String var : varString.split(";")) {
                            int first = var.indexOf(',');
                            int second = var.indexOf(',', first + 1);
                            int third = var.indexOf(',', second + 1);
                            if (!var.substring(second + 1, third).equals(TaskActivity.VARIABLE_DISPLAY_NOTDISPLAYED))
                                vars.add(first > 0 ? var.substring(0, first) : var);
                        }
                    }
                    Collections.sort(vars, PluginUtil.getStringComparator());
                    ownerVars.put(taskName, vars);
                }
            }
        } else {
            String query = "select t.task_name, v.variable_name \n " + "from task t, variable v, variable_mapping vm \n " + "where vm.mapping_owner = 'TASK' \n " + "and vm.mapping_owner_id = t.task_id \n " + "and v.variable_id = vm.variable_id \n " + "order by t.task_name, v.variable_name";
            ResultSet rs = db.runSelect(query, null);
            while (rs.next()) {
                String taskName = rs.getString("task_name");
                List<String> vars = ownerVars.get(taskName);
                if (vars == null) {
                    vars = new ArrayList<>();
                    ownerVars.put(taskName, vars);
                }
                String var = rs.getString("variable_name");
                if (!vars.contains(var))
                    vars.add(var);
            }
        }
    } catch (SQLException ex) {
        throw new DataAccessException(-1, ex.getMessage(), ex);
    } finally {
        db.closeConnection();
    }
    return ownerVars;
}
Also used : DatabaseAccess(com.centurylink.mdw.dataaccess.DatabaseAccess) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

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