public class Converter
{
public static ReportInfo convertToReportInfo(Report report)
{
ReportInfo reportInfo = new ReportInfo();
reportInfo.setId(report.getId());
reportInfo.setName(report.getName());
reportInfo.setDescription(report.getDescription());
reportInfo.setCsvExportEnabled(report.isCsvExportEnabled());
reportInfo.setExcelExportEnabled(report.isExcelExportEnabled());
reportInfo.setHtmlExportEnabled(report.isHtmlExportEnabled());
reportInfo.setPdfExportEnabled(report.isPdfExportEnabled());
reportInfo.setRtfExportEnabled(report.isRtfExportEnabled());
reportInfo.setTextExportEnabled(report.isTextExportEnabled());
reportInfo.setXlsExportEnabled(report.isXlsExportEnabled());
reportInfo.setHidden(report.isHidden());
if (report.isJXLSReport())
{
reportInfo.setDefaultExportType(ExportType.XLS);
}
else if (report.isHtmlExportEnabled() || report.isQueryReport() || report.isChartReport())
{
reportInfo.setDefaultExportType(ExportType.HTML);
}
else
{
reportInfo.setDefaultExportType(ExportType.PDF);
}
if (report.getParameters() != null && report.getParameters().size() > 0)
{
ArrayList<ReportParameterMap> reportParameters = new ArrayList<ReportParameterMap>(report.getParameters());
ParameterInfo[] parameters = new ParameterInfo[reportParameters.size()];
for (int x = 0; x < reportParameters.size(); x++)
{
ReportParameterMap reportParameter = (ReportParameterMap) reportParameters.get(x);
ParameterInfo parameter = new ParameterInfo();
parameter.setId(reportParameter.getReportParameter().getId());
parameter.setName(reportParameter.getReportParameter().getName());
parameter.setDescription(reportParameter.getReportParameter().getDescription());
parameters[x] = parameter;
}
reportInfo.setParameters(parameters);
}
return reportInfo;
}