Search in sources :

Example 11 with ActionCancelledException

use of com.centurylink.mdw.common.utilities.timer.ActionCancelledException in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method exportPackages.

public String exportPackages(List<PackageVO> packages, int schemaVersion, boolean exportJson, boolean includeTaskTemplates, ProgressMonitor monitor) throws DataAccessException, ActionCancelledException, JSONException, XmlException {
    if (monitor != null)
        monitor.subTask("Loading package(s)...");
    List<PackageVO> loadedPackages = new ArrayList<>();
    for (PackageVO pkg : packages) {
        if (monitor != null)
            monitor.subTask("Loading " + pkg.getLabel() + "...");
        PackageVO packageVO = loadPackage(pkg.getId(), true);
        if (monitor != null)
            monitor.progress(30 / packages.size());
        if (monitor != null) {
            if (monitor.isCanceled())
                throw new ActionCancelledException();
            else
                monitor.subTask("Sorting processes and implementors");
        }
        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);
        }
        loadedPackages.add(packageVO);
    }
    if (monitor != null && monitor.isCanceled())
        throw new ActionCancelledException();
    if (monitor != null)
        monitor.progress(5);
    if (monitor != null)
        monitor.subTask(EXPORTXML);
    String export;
    if (exportJson) {
        ImporterExporterJson exporter = new ImporterExporterJson();
        export = exporter.exportPackages(loadedPackages);
    } else {
        ProcessExporter exporter = DataAccess.getProcessExporter(schemaVersion, oldNamespaces ? DesignerCompatibility.getInstance() : null);
        export = exporter.exportPackages(loadedPackages, includeTaskTemplates);
    }
    if (monitor != null)
        monitor.progress(25);
    for (PackageVO packageVO : loadedPackages) {
        packageVO.setExported(true);
        persister.persistPackage(packageVO, PersistType.UPDATE);
    }
    if (monitor != null)
        monitor.progress(15);
    return export;
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) HashMap(java.util.HashMap) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) ArrayList(java.util.ArrayList) ProcessExporter(com.centurylink.mdw.dataaccess.ProcessExporter) ImporterExporterJson(com.centurylink.mdw.dataaccess.file.ImporterExporterJson) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 12 with ActionCancelledException

use of com.centurylink.mdw.common.utilities.timer.ActionCancelledException 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;
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) HashMap(java.util.HashMap) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ProcessExporter(com.centurylink.mdw.dataaccess.ProcessExporter) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 13 with ActionCancelledException

use of com.centurylink.mdw.common.utilities.timer.ActionCancelledException in project mdw-designer by CenturyLinkCloud.

the class ImportProcessWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
    DesignerProxy designerProxy = getProject().getDesignerProxy();
    Importer importer = new Importer(designerProxy.getPluginDataAccess(), getShell());
    progressMonitor.progress(10);
    progressMonitor.subTask("Reading XML file");
    byte[] bytes = readFile(getPage().getFilePath());
    progressMonitor.progress(20);
    if (progressMonitor.isCanceled())
        throw new ActionCancelledException();
    progressMonitor.subTask("Performing Import");
    WorkflowProcess newProc = importer.importProcess(getPackage(), getProcess(), new String(bytes));
    setElement(newProc);
    progressMonitor.progress(30);
    designerProxy.toggleProcessLock(newProc, true);
    designerProxy.savePackage(newProc.getPackage());
}
Also used : DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Importer(com.centurylink.mdw.plugin.designer.Importer)

Aggregations

ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)13 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)6 ArrayList (java.util.ArrayList)6 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)5 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)5 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)4 Importer (com.centurylink.mdw.plugin.designer.Importer)4 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)3 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)3 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)3 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)3 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)3 IOException (java.io.IOException)3 ProgressMonitor (com.centurylink.mdw.common.utilities.timer.ProgressMonitor)2 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)2 NodeMetaInfo (com.centurylink.mdw.designer.utils.NodeMetaInfo)2 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)2 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)2 SwtProgressMonitor (com.centurylink.mdw.plugin.designer.SwtProgressMonitor)2