use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class TableGenerator method generateData.
public TableData generateData(TableElement element, Filter filter) {
GetSites query = new GetSites(filter);
if (!element.getSortBy().isEmpty()) {
TableColumn sortBy = element.getSortBy().get(0);
query.setSortInfo(new SortInfo(sortBy.getSitePropertyName(), sortBy.isOrderAscending() ? SortDir.ASC : SortDir.DESC));
}
SiteResult sites = getDispatcher().execute(query);
return new TableData(element.getRootColumn(), sites.getData());
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class PointLayerGenerator method query.
@Override
public void query(DispatcherSync dispatcher, Filter effectiveFilter) {
GetSites query = queryFor(effectiveFilter, layer);
this.sites = dispatcher.execute(query).getData();
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteSite.
@Test
public void testDeleteSite() throws CommandException {
PagingResult<SiteDTO> sites = execute(GetSites.byId(3));
execute(new Delete(sites.getData().get(0)));
sites = execute(GetSites.byId(3));
Assert.assertEquals(0, sites.getData().size());
sites = execute(new GetSites());
Assert.assertNull(getById(sites.getData(), 3));
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class ProjectTest method deleteProject.
@Test
public void deleteProject() {
setUser(1);
long originalDatabaseVersion = lookupDbVersion(1);
int projectId = 2;
execute(RequestChange.delete("Project", projectId));
SchemaDTO schema = execute(new GetSchema());
assertThat(schema.getProjectById(projectId), nullValue());
// make sure it's gone from sites
Filter filter = new Filter();
filter.addRestriction(DimensionType.Site, 3);
SiteResult sites = execute(new GetSites(filter));
assertThat(sites.getData().get(0).getProject(), is(nullValue()));
// and doesn't show up in pivoting...
PivotSites pivot = new PivotSites();
Dimension projectDimension = new Dimension(DimensionType.Project);
pivot.setDimensions(projectDimension);
pivot.setFilter(filter);
PivotResult buckets = execute(pivot);
assertThat(buckets.getBuckets().size(), equalTo(1));
assertThat(buckets.getBuckets().get(0).getCategory(projectDimension), is(nullValue()));
// make sure the version number of the database is updated
assertThat(lookupDbVersion(1), not(equalTo(originalDatabaseVersion)));
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method testDatabasePaged.
@Test
public void testDatabasePaged() throws CommandException {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.getFilter().addRestriction(DimensionType.Database, 1);
cmd.setLimit(2);
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("rows", 2, result.getData().size());
}
Aggregations