* the xml is written to this writer
* @see #CLIENT_DATA_SET_NAME
* @see #CLIENT_ID_PARAMETER_NAME
*/
public void exportClientToXML(Map<String, Object> parameters, boolean exportAuditInfo, Writer out) {
DataSet dataSet = null;
final boolean prevMode = OBContext.getOBContext().setInAdministratorMode(true);
try {
final OBCriteria<DataSet> obc = OBDal.getInstance().createCriteria(DataSet.class);
obc.add(Expression.eq("name", CLIENT_DATA_SET_NAME));
if (obc.list().size() == 0) {
throw new OBException("No dataset found with name " + CLIENT_DATA_SET_NAME);
}
dataSet = obc.list().get(0);
// read the client
final Client client = OBDal.getInstance().get(Client.class,
parameters.get(CLIENT_ID_PARAMETER_NAME));
// the export part may not be run as superuser
log.debug("Exporting dataset " + dataSet.getName());
final EntityXMLConverter exc = EntityXMLConverter.newInstance();
exc.setOptionExportClientOrganizationReferences(true);
exc.setOptionMinimizeXMLSize(true);
exc.setOptionIncludeChildren(false);
exc.setOptionIncludeReferenced(true);
exc.setOptionExportTransientInfo(false);
exc.setOptionExportAuditInfo(exportAuditInfo);
exc.setAddSystemAttributes(false);
exc.setOutput(out);
exc.setClient(client);
final List<DataSetTable> dts = dataSet.getDataSetTableList();
Collections.sort(dts, new DatasetTableComparator());
final Set<BaseOBObject> toExport = new LinkedHashSet<BaseOBObject>();
for (final DataSetTable dt : dts) {
final List<BaseOBObject> list = DataSetService.getInstance().getExportableObjects(dt, null,