if (StringUtils.isEmpty(dataFactory.getQueryName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "queryName", dataFactory.getQueryName());
}
OpenERPConfiguration config = dataFactory.getConfig();
if (StringUtils.isEmpty(config.getHostName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "hostName", config.getHostName());
}
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "portNumber", Integer.toString(config.getPortNumber()));
if (StringUtils.isEmpty(config.getDatabaseName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "databaseName", config.getDatabaseName());
}
if (StringUtils.isEmpty(config.getUserName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "userName", config.getUserName());
}
if (StringUtils.isEmpty(config.getPassword()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE,
"password", PasswordEncryptionService.getInstance().encrypt(config.getPassword()));
}
if (StringUtils.isEmpty(config.getModelName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "modelName", config.getModelName());
}
if (config.getDataSource() != null)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "dataSource", config.getDataSource().name());
}
if (StringUtils.isEmpty(config.getCustomFunctionName()) == false)
{
configAttrs.setAttribute(OpenERPModule.NAMESPACE, "customFunctionName", config.getCustomFunctionName());
}
xmlWriter.writeTag(OpenERPModule.NAMESPACE, "config", configAttrs, XmlWriterSupport.CLOSE);
for (OpenERPFilterInfo filter : config.getFilters())
{
final AttributeList filterAttrs = new AttributeList();
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "modelPath", filter.getModelPath());
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "instanceNum", Integer.toString(filter.getInstanceNum()));
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "operator", filter.getOperator());
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "fieldName", filter.getFieldName());
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "comparator", filter.getComparator());
filterAttrs.setAttribute(OpenERPModule.NAMESPACE, "value", filter.getValue().toString());
xmlWriter.writeTag(OpenERPModule.NAMESPACE, "filter", filterAttrs, XmlWriterSupport.CLOSE);
}
for (OpenERPFieldInfo field : config.getSelectedFields())
{
writeFieldInfo(xmlWriter, field);
}
xmlWriter.writeCloseTag();