Search in sources :

Example 6 with ProcessExporter

use of com.centurylink.mdw.dataaccess.ProcessExporter 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)

Aggregations

ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)6 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)5 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)5 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)5 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)4 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)4 ArrayList (java.util.ArrayList)4 NodeMetaInfo (com.centurylink.mdw.designer.utils.NodeMetaInfo)2 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)2 ExternalEventVO (com.centurylink.mdw.model.value.event.ExternalEventVO)2 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)2 HashMap (java.util.HashMap)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 ProcessPersister (com.centurylink.mdw.dataaccess.ProcessPersister)1 ImporterExporterJson (com.centurylink.mdw.dataaccess.file.ImporterExporterJson)1 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)1 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)1