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();
}
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();
}
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);
}
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;
}
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;
}
Aggregations