Search in sources :

Example 11 with GetSites

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());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with GetSites

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;
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SortInfo(com.extjs.gxt.ui.client.data.SortInfo)

Example 13 with 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();
}
Also used : Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) SortInfo(com.extjs.gxt.ui.client.data.SortInfo)

Example 14 with GetSites

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();
    }
}
Also used : StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) JsonGenerator(org.codehaus.jackson.JsonGenerator) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 15 with GetSites

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();
}
Also used : StringWriter(java.io.StringWriter) Filter(org.activityinfo.shared.command.Filter) GetSites(org.activityinfo.shared.command.GetSites) JsonGenerator(org.codehaus.jackson.JsonGenerator) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

GetSites (org.activityinfo.shared.command.GetSites)28 Test (org.junit.Test)18 SiteDTO (org.activityinfo.shared.dto.SiteDTO)16 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)10 SiteResult (org.activityinfo.shared.command.result.SiteResult)10 Filter (org.activityinfo.shared.command.Filter)8 OnDataSet (org.activityinfo.server.database.OnDataSet)5 StringWriter (java.io.StringWriter)2 GET (javax.ws.rs.GET)2 JsonGenerator (org.codehaus.jackson.JsonGenerator)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)1 CreateLocation (org.activityinfo.shared.command.CreateLocation)1 CreateSite (org.activityinfo.shared.command.CreateSite)1 Delete (org.activityinfo.shared.command.Delete)1 GenerateElement (org.activityinfo.shared.command.GenerateElement)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 PivotSites (org.activityinfo.shared.command.PivotSites)1