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