Search in sources :

Example 26 with PackageVO

use of com.centurylink.mdw.model.value.process.PackageVO 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 27 with PackageVO

use of com.centurylink.mdw.model.value.process.PackageVO in project mdw-designer by CenturyLinkCloud.

the class Exporter method exportPackage.

public String exportPackage(String packageName, boolean includeTaskTemplates, boolean isJson) throws DataAccessException, RemoteException, ActionCancelledException, XmlException, JSONException {
    int schemaVersion = dataAccess.getDatabaseSchemaVersion();
    PackageVO packageVo = dataAccess.getPackage(packageName);
    if (isJson) {
        List<PackageVO> packages = new ArrayList<>();
        packages.add(dataAccess.loadPackage(packageVo.getId(), true));
        ImporterExporterJson jsonExporter = new ImporterExporterJson();
        return jsonExporter.exportPackages(packages);
    } else {
        String xml = dataAccess.exportPackage(packageVo.getId(), schemaVersion, includeTaskTemplates, null);
        if (!isLocal()) {
            packageVo.setExported(true);
            dataAccess.savePackage(packageVo);
        }
        return xml;
    }
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) ImporterExporterJson(com.centurylink.mdw.dataaccess.file.ImporterExporterJson)

Aggregations

PackageVO (com.centurylink.mdw.model.value.process.PackageVO)27 ArrayList (java.util.ArrayList)18 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)11 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)8 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)7 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)6 IOException (java.io.IOException)6 JSONObject (org.json.JSONObject)6 PackageDocument (com.centurylink.mdw.bpm.PackageDocument)5 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)5 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)5 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)5 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)5 JSONException (org.json.JSONException)5 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)4 HashMap (java.util.HashMap)4 ProcessImporter (com.centurylink.mdw.dataaccess.ProcessImporter)3 ImporterExporterJson (com.centurylink.mdw.dataaccess.file.ImporterExporterJson)3 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)3