use of org.activityinfo.legacy.shared.model.ReportVisibilityDTO in project activityinfo by bedatadriven.
the class ShareReportDialog method populateGrid.
private void populateGrid(IndicatorResult indicators, ReportVisibilityResult visibility) {
gridStore.removeAll();
Map<Integer, ReportVisibilityDTO> databases = Maps.newHashMap();
for (ReportVisibilityDTO model : visibility.getList()) {
databases.put(model.getDatabaseId(), model);
}
for (IndicatorDTO indicator : indicators.getIndicators()) {
if (!databases.containsKey(indicator.getDatabaseId())) {
ReportVisibilityDTO model = new ReportVisibilityDTO();
model.setDatabaseId(indicator.getDatabaseId());
model.setDatabaseName(indicator.getDatabaseName());
databases.put(indicator.getDatabaseId(), model);
}
}
for (ReportVisibilityDTO model : databases.values()) {
gridStore.add(model);
}
if (gridStore.getCount() == 0) {
MessageBox.alert(I18N.CONSTANTS.share(), I18N.CONSTANTS.emptyReportsCannotBeShared(), new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
hide();
}
});
}
}
use of org.activityinfo.legacy.shared.model.ReportVisibilityDTO in project activityinfo by bedatadriven.
the class UpdateReportVisibilityHandler method execute.
@Override
public void execute(UpdateReportVisibility command, ExecutionContext context, AsyncCallback<VoidResult> callback) {
SqlUpdate.delete(Tables.REPORT_VISIBILITY).where("reportid", command.getReportId()).execute(context.getTransaction());
for (ReportVisibilityDTO dto : command.getList()) {
SqlUpdate.delete(Tables.REPORT_VISIBILITY).where("reportid", command.getReportId()).where("databaseid", dto.getDatabaseId()).execute(context.getTransaction());
if (dto.isVisible()) {
SqlInsert.insertInto(Tables.REPORT_VISIBILITY).value("reportid", command.getReportId()).value("databaseid", dto.getDatabaseId()).value("defaultDashboard", dto.isDefaultDashboard()).execute(context.getTransaction());
}
}
callback.onSuccess(null);
}
use of org.activityinfo.legacy.shared.model.ReportVisibilityDTO in project activityinfo by bedatadriven.
the class ReportVisibilityTest method update.
@Test
public void update() {
setUser(1);
ReportVisibilityDTO db1 = new ReportVisibilityDTO();
db1.setDatabaseId(1);
db1.setVisible(true);
db1.setDefaultDashboard(true);
ReportVisibilityDTO db2 = new ReportVisibilityDTO();
db2.setDatabaseId(2);
db2.setVisible(false);
ReportVisibilityDTO db3 = new ReportVisibilityDTO();
db3.setDatabaseId(3);
db3.setVisible(true);
UpdateReportVisibility update = new UpdateReportVisibility(1, Arrays.asList(db1, db2, db3));
execute(update);
ReportVisibilityResult result = execute(new GetReportVisibility(1));
assertThat(result.getList().size(), equalTo(2));
// make sure we can still see the report
ReportsResult visibleToMe = execute(new GetReports());
assertThat(visibleToMe.getData().size(), equalTo(1));
// Bavon
setUser(2);
ReportsResult visibleToBavon = execute(new GetReports());
assertThat(visibleToBavon.getData().size(), equalTo(2));
assertThat(getById(visibleToBavon, 1).isDashboard(), equalTo(true));
assertThat(getById(visibleToBavon, 2).isDashboard(), equalTo(false));
// Stefan, no access to db
setUser(3);
ReportsResult visibleToStefan = execute(new GetReports());
assertThat(visibleToStefan.getData().size(), equalTo(0));
}
Aggregations