@Override public ScreenModel.Show handleRequest(Database db, Tuple request, OutputStream csvDownload) throws Exception { logger.debug(this.getName()); FormModel<? extends Entity> model = this.getFormScreen(); FormController<?> controller = ((FormController<?>) this.getController()); List<String> fieldsToExport = controller.getVisibleColumnNames(); // TODO : remove entity name, capitals to small , and remove all _name fields // we need to rewrite rules to accomodate the 'all' QueryRule[] rules; try { rules = controller.rewriteAllRules(db, Arrays.asList(model.getRulesExclLimitOffset())); } catch (MolgenisModelException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new DatabaseException(e); } db.find( model.getController().getEntityClass(), new CsvWriter(csvDownload), fieldsToExport, rules); return ScreenModel.Show.SHOW_MAIN; }
@Override public ScreenModel.Show handleRequest(Database db, Tuple request, OutputStream xlsDownload) throws Exception { logger.debug(this.getName()); FormModel<? extends Entity> model = this.getFormScreen(); FormController<?> controller = ((FormController<?>) this.getController()); List<String> fieldsToExport = controller.getVisibleColumnNames(); // TODO : remove entity name, capitals to small , and remove all _name fields // we need to rewrite rules to accomodate the 'all' QueryRule[] rules; try { rules = controller.rewriteAllRules(db, Arrays.asList(model.getRulesExclLimitOffset())); } catch (MolgenisModelException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new DatabaseException(e); } // Comments from Despoina: // TODO : the actual xls headers/formatting // TODO : this needs different call or TODO just an extra if in abstractMolgenisServlet for the // different suffix (.xls) ? // This db.find() is rerouted by your Database implementation's find() to the one in the // appropriate mapper db.find( model.getController().getEntityClass(), new XlsWriter(xlsDownload), fieldsToExport, rules); return ScreenModel.Show.SHOW_MAIN; }