use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class GetSitesTest method testSeekSite.
@Test
@Ignore
public void testSeekSite() throws Exception {
setUser(DATABASE_OWNER);
GetSites cmd = new GetSites();
cmd.filter().onActivity(1);
cmd.setSortInfo(new SortInfo(IndicatorDTO.getPropertyName(1), SortDir.DESC));
cmd.setLimit(2);
cmd.setSeekToSiteId(1);
PagingLoadResult<SiteDTO> result = execute(cmd);
Assert.assertEquals("second page returned", 2, result.getOffset());
Assert.assertEquals("rows on this page", 1, result.getData().size());
Assert.assertEquals("correct site returned", 1, result.getData().get(0).getId());
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class SearchHandler method createGetSitesCommand.
private GetSites createGetSitesCommand(final Filter resultFilter) {
GetSites getSites = new GetSites();
getSites.setSortInfo(new SortInfo("DateEdited", SortDir.DESC));
getSites.setLimit(10);
getSites.setFilter(resultFilter);
return getSites;
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class SiteExporter method querySites.
private List<SiteDTO> querySites(ActivityDTO activity, Filter filter) {
Filter effectiveFilter = new Filter(filter);
effectiveFilter.addRestriction(DimensionType.Activity, activity.getId());
GetSites query = new GetSites();
query.setFilter(effectiveFilter);
query.setSortInfo(new SortInfo("date2", SortDir.DESC));
return dispatcher.execute(query).getData();
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class SitesResources method queryPoints.
@GET
@Path("/points")
public Response queryPoints(@QueryParam("activity") List<Integer> activityIds, @QueryParam("database") List<Integer> databaseIds, @QueryParam("callback") String callback) throws JsonGenerationException, IOException {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, activityIds);
filter.addRestriction(DimensionType.Database, databaseIds);
List<SiteDTO> sites = dispatcher.execute(new GetSites(filter)).getData();
StringWriter writer = new StringWriter();
JsonGenerator json = Jackson.createJsonFactory(writer);
writeGeoJson(sites, json);
if (Strings.isNullOrEmpty(callback)) {
return Response.ok(writer.toString()).type(MediaType.APPLICATION_JSON_TYPE).build();
} else {
return Response.ok(callback + "(" + writer.toString() + ");").type("application/javascript; charset=UTF-8").build();
}
}
use of org.activityinfo.shared.command.GetSites in project activityinfo by bedatadriven.
the class SitesResources method query.
@GET
@Produces(MediaType.APPLICATION_JSON)
public String query(@QueryParam("activity") List<Integer> activityIds, @QueryParam("database") List<Integer> databaseIds, @QueryParam("format") String format) throws IOException {
Filter filter = new Filter();
filter.addRestriction(DimensionType.Activity, activityIds);
filter.addRestriction(DimensionType.Database, databaseIds);
List<SiteDTO> sites = dispatcher.execute(new GetSites(filter)).getData();
StringWriter writer = new StringWriter();
JsonGenerator json = Jackson.createJsonFactory(writer);
writeJson(sites, json);
return writer.toString();
}
Aggregations