use of org.activityinfo.analysis.table.TableViewModel in project activityinfo by bedatadriven.
the class ExportFormExecutor method execute.
@Override
public ExportResult execute(ExportFormJob descriptor) throws IOException {
TableModel tableModel = descriptor.getTableModel();
GeneratedResource export = storageProvider.create(XlsTableWriter.EXCEL_MIME_TYPE, "Export.xls");
TableViewModel viewModel = new TableViewModel(formSource, tableModel);
EffectiveTableModel effectiveTableModel = viewModel.getEffectiveTable().waitFor();
ColumnSet columnSet = effectiveTableModel.getColumnSet().waitFor();
XlsTableWriter writer = new XlsTableWriter();
writer.addSheet(effectiveTableModel, columnSet);
try (OutputStream out = export.openOutputStream()) {
writer.write(out);
}
return new ExportResult(export.getDownloadUri());
}
use of org.activityinfo.analysis.table.TableViewModel in project activityinfo by bedatadriven.
the class XlsTableWriterTest method export.
private HSSFWorkbook export(TableModel tableModel) throws IOException {
TableViewModel viewModel = new TableViewModel(formSource, tableModel);
EffectiveTableModel effectiveTableModel = viewModel.getEffectiveTable().waitFor();
if (effectiveTableModel.getRootFormState() != FormTree.State.VALID) {
throw new IllegalStateException("Root Form has state: " + effectiveTableModel.getRootFormState());
}
ColumnSet columnSet = effectiveTableModel.getColumnSet().waitFor();
XlsTableWriter writer = new XlsTableWriter();
writer.addSheet(effectiveTableModel, columnSet);
writer.write(new FileOutputStream("build/" + tableModel.getFormId().asString() + ".xls"));
return writer.getBook();
}
use of org.activityinfo.analysis.table.TableViewModel in project activityinfo by bedatadriven.
the class TableActivity method start.
@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
TableViewModel tableViewModel = new TableViewModel(formStore, initialModel(place.getFormId()));
view = new TableView(formStore, tableViewModel);
panel.setWidget(view);
modelSubscription = view.getTableModel().subscribe(this::saveModel);
}
Aggregations