public void write(final ReportWriterContext reportWriter,
final XmlWriter xmlWriter,
final DataFactory rawDataFactory)
throws IOException, ReportWriterException
{
final CdaDataFactory dataFactory = (CdaDataFactory) rawDataFactory;
final AttributeList rootAttrs = new AttributeList();
rootAttrs.addNamespaceDeclaration("data", CdaModule.NAMESPACE);
xmlWriter.writeTag(CdaModule.NAMESPACE, "cda-datasource", rootAttrs, XmlWriter.OPEN);
final AttributeList configAttrs = new AttributeList();
if (StringUtils.isEmpty(dataFactory.getBaseUrl()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "base-url", dataFactory.getBaseUrl());
}
if (StringUtils.isEmpty(dataFactory.getBaseUrlField()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "base-url-field", dataFactory.getBaseUrlField());
}
if (StringUtils.isEmpty(dataFactory.getSolution()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "solution", dataFactory.getSolution());
}
if (StringUtils.isEmpty(dataFactory.getPath()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "path", dataFactory.getPath());
}
if (StringUtils.isEmpty(dataFactory.getFile()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "file", dataFactory.getFile());
}
if (StringUtils.isEmpty(dataFactory.getUsername()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE, "username", dataFactory.getUsername());
}
if (StringUtils.isEmpty(dataFactory.getPassword()) == false)
{
configAttrs.setAttribute(CdaModule.NAMESPACE,
"password", PasswordEncryptionService.getInstance().encrypt(dataFactory.getPassword()));
}
configAttrs.setAttribute(CdaModule.NAMESPACE, "use-local-call", String.valueOf(dataFactory.isUseLocalCall()));
configAttrs.setAttribute(CdaModule.NAMESPACE, "is-sugar-mode", String.valueOf(dataFactory.isSugarMode()));
xmlWriter.writeTag(CdaModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);
final String[] queryNames = dataFactory.getQueryNames();
for (int i = 0; i < queryNames.length; i++)
{
final String queryName = queryNames[i];
final CdaQueryEntry query = dataFactory.getQueryEntry(queryName);
final AttributeList queryAttr = new AttributeList();
queryAttr.setAttribute(CdaModule.NAMESPACE, "query", query.getId());
queryAttr.setAttribute(CdaModule.NAMESPACE, "name", query.getName());
xmlWriter.writeTag(CdaModule.NAMESPACE, "query", queryAttr, XmlWriterSupport.OPEN);