use of com.centurylink.mdw.designer.utils.ProcessWorker 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.ProcessWorker 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.ProcessWorker in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method exportPackage.
public String exportPackage(Long packageId, int schemaVersion, boolean includeTaskTemplates, ProgressMonitor monitor) throws DataAccessException, ActionCancelledException, XmlException {
if (monitor != null)
monitor.subTask("Loading package...");
PackageVO packageVO = loadPackage(packageId, true);
if (monitor != null)
monitor.progress(30);
if (monitor != null) {
if (monitor.isCanceled())
throw new ActionCancelledException();
else
monitor.subTask("Sorting processes and implementors");
}
// adding same logic as in PopupHandler export to get same result
for (ProcessVO processVO : packageVO.getProcesses()) new ProcessWorker().convert_to_designer(processVO);
if (packageVO.getRuleSets() != null) {
Map<String, CustomAttributeVO> customAttrs = new HashMap<>();
for (RuleSetVO ruleSet : packageVO.getRuleSets()) {
if (ruleSet.getLanguage() != null && !customAttrs.containsKey(ruleSet.getLanguage())) {
CustomAttributeVO custAttrVO = getCustomAttribute("RULE_SET", ruleSet.getLanguage());
if (custAttrVO != null)
customAttrs.put(ruleSet.getLanguage(), custAttrVO);
}
}
List<CustomAttributeVO> customAttributes = new ArrayList<>();
for (CustomAttributeVO customAttr : customAttrs.values()) customAttributes.add(customAttr);
packageVO.setCustomAttributes(customAttributes);
}
if (monitor != null && monitor.isCanceled())
throw new ActionCancelledException();
if (monitor != null)
monitor.progress(5);
if (monitor != null)
monitor.subTask(EXPORTXML);
ProcessExporter exporter = DataAccess.getProcessExporter(schemaVersion, oldNamespaces ? DesignerCompatibility.getInstance() : null);
String xml = exporter.exportPackage(packageVO, includeTaskTemplates);
if (monitor != null)
monitor.progress(25);
packageVO.setExported(true);
persister.persistPackage(packageVO, PersistType.UPDATE);
if (monitor != null)
monitor.progress(15);
return xml;
}
Aggregations