Search in sources :

Example 16 with GetSites

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

Example 17 with GetSites

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();
}
Also used : GetSites(org.activityinfo.shared.command.GetSites)

Example 18 with GetSites

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));
}
Also used : Delete(org.activityinfo.shared.command.Delete) GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Test(org.junit.Test)

Example 19 with GetSites

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)));
}
Also used : PivotSites(org.activityinfo.shared.command.PivotSites) Filter(org.activityinfo.shared.command.Filter) SiteResult(org.activityinfo.shared.command.result.SiteResult) PivotResult(org.activityinfo.shared.command.PivotSites.PivotResult) GetSites(org.activityinfo.shared.command.GetSites) Dimension(org.activityinfo.shared.report.model.Dimension) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 20 with GetSites

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());
}
Also used : GetSites(org.activityinfo.shared.command.GetSites) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Test(org.junit.Test)

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