use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method copyProcess.
public void copyProcess(final String originalName, final String originalVersion, final String newName, final WorkflowPackage targetPackage) {
String progressMsg = "Creating process '" + newName + "'\nin package '" + targetPackage.getName() + "'";
String errorMsg = "Create Process";
designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {
public void perform() throws ValidationException, DataAccessException, RemoteException {
int dotIdx = originalVersion.indexOf('.');
int major = Integer.parseInt(originalVersion.substring(0, dotIdx));
int minor = Integer.parseInt(originalVersion.substring(dotIdx + 1));
ProcessVO origProcVO = dataAccess.getDesignerDataAccess().getProcessDefinition(originalName, major * 1000 + minor);
origProcVO = dataAccess.getDesignerDataAccess().getProcess(origProcVO.getProcessId(), origProcVO);
new ProcessWorker().convert_to_designer(origProcVO);
ProcessVO newProcVO = new ProcessVO(-1L, newName, origProcVO.getProcessDescription(), null);
newProcVO.set(origProcVO.getAttributes(), origProcVO.getVariables(), origProcVO.getTransitions(), origProcVO.getSubProcesses(), origProcVO.getActivities());
newProcVO.setVersion(1);
newProcVO.setInRuleSet(origProcVO.isInRuleSet());
WorkflowProcess newProcess = new WorkflowProcess(targetPackage.getProject(), newProcVO);
newProcess.setPackage(targetPackage);
Graph process = new Graph(newProcVO, dataAccess.getDesignerDataModel().getNodeMetaInfo(), getIconFactory());
process.dirtyLevel = Graph.NEW;
FlowchartPage flowchartPage = FlowchartPage.newPage(mainFrame);
flowchartPage.setProcess(process);
saveProcess(newProcess, flowchartPage, PersistType.CREATE, 0, false, false);
toggleProcessLock(newProcess, true);
// why?
newProcess.getProcessVO().setVersion(1);
dataAccess.getProcesses(false).add(newProcess.getProcessVO());
targetPackage.addProcess(newProcess);
newProcess.setPackage(targetPackage);
if (!newProcess.isInDefaultPackage())
savePackage(newProcess.getPackage());
}
};
designerRunner.run();
}
use of com.centurylink.mdw.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method saveProcessWithProgress.
public void saveProcessWithProgress(final WorkflowProcess process, final FlowchartPage flowchartPage, final PersistType persistType, final int version, final boolean validate, final boolean keepLocked) {
String progressMsg = SAVING + process.getName() + "'";
String errorMsg = "Save Process";
designerRunner = new DesignerRunner(progressMsg, errorMsg, project) {
public void perform() throws ValidationException, DataAccessException, RemoteException {
WorkflowProcess oldProcess = null;
if (persistType == PersistType.NEW_VERSION) {
RuleSetVO existing = null;
if (process.isInRuleSet())
existing = dataAccess.getDesignerDataAccess().getRuleSet(process.getName(), RuleSetVO.PROCESS, version);
if (existing != null)
throw new DataAccessException("\n" + process.getLabel() + ALREADY_EXISTS);
process.getProcessVO().setProcessId(-1L);
// preserve the old version for the process tree
ProcessVO oldProcessVoStub = new ProcessVO();
oldProcessVoStub.setProcessId(process.getId());
oldProcessVoStub.setProcessName(process.getName());
oldProcessVoStub.setVersion(process.getProcessVO().getVersion());
oldProcess = new WorkflowProcess(process.getProject(), oldProcessVoStub);
oldProcess.setPackage(process.getPackage());
oldProcess.setTopLevelVersion(process.getTopLevelVersion());
if (// temp attribute to avoid API
project.isFilePersist())
// change
process.setAttribute("previousProcessVersion", oldProcess.getVersionString());
}
saveProcess(process, flowchartPage, persistType, version, validate, keepLocked);
if (process.getTopLevelVersion() != null)
process.getTopLevelVersion().setProcessVO(process.getProcessVO());
if (persistType == PersistType.NEW_VERSION && process.isInRuleSet()) {
RuleSetVO procRs = dataAccess.getRuleSet(process.getId());
if (procRs == null)
dataAccess.getAllRuleSets(false).add(process.getProcessVO());
}
}
};
designerRunner.run();
}
use of com.centurylink.mdw.common.exception.DataAccessException 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.common.exception.DataAccessException 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.common.exception.DataAccessException in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method renameWorkflowAsset.
public void renameWorkflowAsset(final WorkflowAsset asset, final String newName) {
if (asset.getPackage().workflowAssetNameExists(newName)) {
Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
MessageDialog.openError(shell, RENAME_ERROR, "Name already exists: '" + newName + "'");
return;
}
String progressMsg = "Renaming to '" + newName + "'";
String errorMsg = "Rename Workflow Asset";
if (!asset.isLoaded())
asset.load();
designerRunner = new DesignerRunner(progressMsg, errorMsg, asset.getProject()) {
public void perform() throws DataAccessException, RemoteException {
asset.setVersion(1);
dataAccess.getDesignerDataModel().removeRuleSet(asset.getRuleSetVO(), false);
dataAccess.getDesignerDataAccess().renameRuleSet(asset.getRuleSetVO(), newName);
if (asset instanceof AutomatedTestCase) {
if (project.isFilePersist())
((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRawFile()));
else
((AutomatedTestCase) asset).setTestCase(new TestCase(asset.getPackage().getName(), asset.getRuleSetVO()));
}
// roughly the same as db time
asset.setModifyDate(new Date());
// hopefully
cacheRefresh.fireRefresh(RuleSetVO.JAVA.equals(asset.getLanguage()));
dataAccess.getDesignerDataModel().addRuleSet(asset.getRuleSetVO());
}
};
designerRunner.run();
}
Aggregations