use of com.centurylink.mdw.task.TaskTemplate in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method exportTaskTemplates.
public String exportTaskTemplates(Long packageId, ProgressMonitor monitor) throws DataAccessException, ActionCancelledException {
monitor.subTask("Loading package");
PackageVO packageVO = loadPackage(packageId, true);
monitor.progress(30);
if (monitor.isCanceled())
throw new ActionCancelledException();
if (monitor != null)
monitor.progress(5);
if (monitor != null)
monitor.subTask(EXPORTXML);
PackageDocument pkgDoc = PackageDocument.Factory.newInstance();
MDWPackage pkg = pkgDoc.addNewPackage();
pkg.setName(packageVO.getName());
pkg.setVersion(PackageVO.formatVersion(packageVO.getVersion()));
TaskTemplatesDocument.TaskTemplates templates = pkg.addNewTaskTemplates();
if (packageVO.getTaskTemplates() != null) {
for (TaskVO taskVO : packageVO.getTaskTemplates()) {
if (taskVO.getVersion() > 0) {
TaskTemplate templateDef = templates.addNewTask();
templateDef.setLogicalId(taskVO.getLogicalId());
templateDef.setVersion(RuleSetVO.formatVersion(taskVO.getVersion()));
templateDef.setAssetName(taskVO.getName());
templateDef.setName(taskVO.getTaskName());
if (taskVO.getTaskCategory() != null)
templateDef.setCategory(taskVO.getTaskCategory());
if (taskVO.getComment() != null)
templateDef.setDescription(taskVO.getComment());
if (taskVO.getAttributes() != null) {
for (AttributeVO attrVO : taskVO.getAttributes()) {
if (!"TaskDescription".equals(attrVO.getAttributeName())) {
Attribute attr = templateDef.addNewAttribute();
attr.setName(attrVO.getAttributeName());
attr.setStringValue(attrVO.getAttributeValue());
}
}
}
}
}
}
String xml = pkgDoc.xmlText(new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2));
if (monitor != null && monitor.isCanceled())
throw new ActionCancelledException();
if (monitor != null)
monitor.progress(40);
return xml;
}
Aggregations