@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
ExportParametersDTO exportParameters = (ExportParametersDTO) command;
List<String> f = new LinkedList<String>();
List<String> q = new LinkedList<String>();
addToTempQuery("names", exportParameters.getNames(), f, q,
!exportParameters.getAdvancedSyntax());
addToTempQuery("dept", exportParameters.getDept(), f, q,
!exportParameters.getAdvancedSyntax());
addToTempQuery("interests", exportParameters.getInterests(), f, q,
!exportParameters.getAdvancedSyntax());
addToTempQuery("media", exportParameters.getMedia(), f, q,
!exportParameters.getAdvancedSyntax());
String[] temp_query = new String[] {};
temp_query = q.toArray(temp_query);
String[] temp_fields = new String[] {};
temp_fields = f.toArray(temp_fields);
List<ResearcherPage> list = null;
try {
//TODO
// list = searchService.search(temp_fields, temp_query,
// exportParameters.getStatus(),
// exportParameters.getCreationStart(),
// exportParameters.getCreationEnd(),
// exportParameters.getStaffNoStart(),
// exportParameters.getStaffNoEnd(),
// exportParameters.getRpIdStart(),
// exportParameters.getRpIdEnd(),
// exportParameters.getDefaultOperator(), ResearcherPage.class);
} catch (Exception e) {
errors.reject("jsp.layout.hku.export.validation.notvalid.query");
return showForm(request, errors, getFormView());
}
// export all tab
List<IContainable> containables = new LinkedList<IContainable>();
if (exportParameters.getTabToExport() == null || exportParameters.getTabToExport().isEmpty()) {
containables = applicationService
.findAllContainables(RPPropertiesDefinition.class);
} else {
for(Integer tab : exportParameters.getTabToExport()) {
for(BoxResearcherPage box : applicationService.<BoxResearcherPage, TabResearcherPage>findPropertyHolderInTab(TabResearcherPage.class, tab)) {
containables.addAll(box.getMask());
applicationService.findOtherContainablesInBoxByConfiguration(box.getShortName(), containables);
}
}
}
if (exportParameters.getMainMode() == null) {
response.setContentType("application/excel");
response.addHeader("Content-Disposition",
"attachment; filename=rpdata.xls");
ImportExportUtils.exportData(list, applicationService,
response.getOutputStream(), containables);