use of com.centurylink.mdw.designer.utils.ValidationException 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();
}
use of com.centurylink.mdw.designer.utils.ValidationException 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();
}
use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.
the class Importer method importProcess.
public WorkflowProcess importProcess(final WorkflowPackage targetPackage, final WorkflowProcess targetProcess, final String xml) throws DataAccessException, RemoteException, XmlException, ValidationException {
CodeTimer timer = new CodeTimer("importProcess()");
ProcessVO importedProcessVO = null;
int schemaVersion = dataAccess.getSchemaVersion();
ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
importedProcessVO = importer.importProcess(xml);
if (targetProcess != null && !importedProcessVO.getName().equals(targetProcess.getName()))
throw new ValidationException("Process in XML (" + importedProcessVO.getName() + ") is not " + targetProcess.getName());
for (WorkflowProcess existing : targetPackage.getProject().getAllProcesses()) {
if (existing.getName().equals(importedProcessVO.getName())) {
if (existing.getVersion() == importedProcessVO.getVersion())
throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + ".");
if (existing.getVersion() > importedProcessVO.getVersion())
throw new ValidationException(existing.getLabel() + " already exists in " + targetPackage.getProject().getLabel() + " with a version greater than the imported process (v" + importedProcessVO.getVersionString() + ").");
}
}
// designer fix for backward compatibility
ProcessWorker worker = new ProcessWorker();
worker.convert_to_designer(importedProcessVO);
worker.convert_from_designer(importedProcessVO, syncNodeMetaInfo(dataAccess.getDesignerDataModel().getNodeMetaInfo(), importedProcessVO));
if (!importedProcessVO.isInRuleSet()) {
// fix pseudo variables
for (VariableVO varVO : importedProcessVO.getVariables()) varVO.setVariableId(null);
}
importedProcessVO.setPackageName(targetPackage.getName());
WorkflowProcess alreadyInPackage = null;
if (targetPackage.getProject().getProcess(importedProcessVO.getName()) == null)
dataAccess.getDesignerDataAccess().createProcess(importedProcessVO);
else {
alreadyInPackage = targetPackage.getProcess(importedProcessVO.getName());
dataAccess.getDesignerDataAccess().updateProcess(importedProcessVO, importedProcessVO.getVersion(), false);
}
ProcessVO reloaded = dataAccess.getDesignerDataAccess().getProcessDefinition(importedProcessVO.getProcessName(), importedProcessVO.getVersion());
importedProcessVO.setProcessId(reloaded.getProcessId());
if (targetPackage.getProject().getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion52)
updateSubProcessIdAttributes(importedProcessVO);
WorkflowProcess importedProcess = new WorkflowProcess(targetPackage.getProject(), importedProcessVO);
dataAccess.getProcesses(false).add(importedProcess.getProcessVO());
if (alreadyInPackage != null)
targetPackage.removeProcess(alreadyInPackage);
targetPackage.addProcess(importedProcess);
importedProcess.setPackage(targetPackage);
dataAccess.auditLog(Action.Import, importedProcess);
timer.stopAndLog();
return importedProcess;
}
use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.
the class PluginMessages method uiMessage.
public static void uiMessage(Shell shell, Throwable t, String message, String title, WorkflowProject project, int level) {
log(t);
if (t instanceof ValidationException || t.getCause() instanceof ValidationException) {
ValidationException valEx = t instanceof ValidationException ? (ValidationException) t : (ValidationException) t.getCause();
StringBuilder messageBuf = new StringBuilder();
valEx.fillInErrors(messageBuf, 3);
message = messageBuf.toString();
title = "Validation Error: " + title;
level = VALIDATION_MESSAGE;
}
if (message == null)
message = PluginMessages.getUserMessage(t);
boolean sendMessage = level >= getReportingLevel();
if (shell != null) {
MdwMessageDialog messageDialog = new MdwMessageDialog(shell, title, message, level);
messageDialog.open();
sendMessage = messageDialog.isReportMessage();
}
if (sendMessage)
PluginUtil.sendError(t, title, message, project, level);
}
use of com.centurylink.mdw.designer.utils.ValidationException in project mdw-designer by CenturyLinkCloud.
the class CacheRefresh method doRefresh.
public void doRefresh(boolean silent, final boolean includeDynamicJava) {
try {
if (silent) {
if (workflowProject.isUpdateServerCache()) {
// run as background job
new Job("MDW Cache Refresh: " + restfulServer.getMdwWebUrl()) {
protected IStatus run(IProgressMonitor monitor) {
try {
CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
timer.stopAndLog();
} catch (Exception ex) {
if (MdwPlugin.getSettings().isLogConnectErrors())
PluginMessages.log(ex);
}
return Status.OK_STATUS;
}
}.schedule();
}
} else {
String progressMsg = "Refreshing Caches and Properties for '" + workflowProject.getLabel() + "'";
String errorMsg = "Refresh Cache";
DesignerRunner designerRunner = new DesignerRunner(progressMsg, errorMsg, workflowProject) {
public void perform() throws ValidationException, DataAccessException, RemoteException {
try {
CodeTimer timer = new CodeTimer("CacheRefresh.doRefresh()");
refreshStatusMessage = restfulServer.refreshCache(workflowProject.isRemote(), workflowProject.isOldNamespaces(), includeDynamicJava);
timer.stopAndLog();
} catch (Exception ex) {
PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
}
}
};
designerRunner.run();
if (refreshStatusMessage == null) {
PluginMessages.uiError(workflowProject.getName() + " Refresh Caches and Properties failed. Make sure baseline event handlers are registered.", REFRESH_CACHES, workflowProject);
} else if (refreshStatusMessage.getMDWStatusMessage().getStatusCode() != 0) {
String message = refreshStatusMessage.getMDWStatusMessage().getStatusMessage();
PluginMessages.uiMessage(workflowProject.getName() + " Refresh Caches and Properties:\n" + message, "Refresh Caches", workflowProject, PluginMessages.INFO_MESSAGE);
}
}
} catch (Exception ex) {
if (!silent)
PluginMessages.uiError(ex, ex.getMessage(), REFRESH_CACHES, workflowProject);
}
}
Aggregations