Search in sources :

Example 21 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method testDatabase.

@Test
public void testDatabase() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites legacyCmd = new GetSites();
    GetSites newCmd = new GetSites();
    legacyCmd.filter().addRestriction(DimensionType.Database, 2);
    legacyCmd.setLegacyFetch(true);
    newCmd.filter().addRestriction(DimensionType.Database, 2);
    newCmd.setLegacyFetch(false);
    PagingLoadResult<SiteDTO> legacyResult = execute(legacyCmd);
    PagingLoadResult<SiteDTO> newResult = execute(newCmd);
    Assert.assertEquals("rows", 3, legacyResult.getData().size());
    Assert.assertNotNull("activityId", legacyResult.getData().get(0).getActivityId());
    Assert.assertEquals("rows", 3, newResult.getData().size());
    Assert.assertNotNull("activityId", newResult.getData().get(0).getActivityId());
    GetSites newMonthlyCmd = new GetSites();
    newMonthlyCmd.filter().addRestriction(DimensionType.Database, 2);
    newMonthlyCmd.setLegacyFetch(false);
    newMonthlyCmd.setFetchAllReportingPeriods(true);
    PagingLoadResult<SiteDTO> newMonthlyResult = execute(newMonthlyCmd);
    Assert.assertEquals("rows", 5, newMonthlyResult.getData().size());
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 22 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method testAll.

@Test
public void testAll() throws CommandException {
    setUser(DATABASE_OWNER);
    GetSites cmd = new GetSites();
    PagingLoadResult<SiteDTO> result = execute(cmd);
    Assert.assertEquals("rows", 8, result.getData().size());
    Assert.assertNotNull("activityId", result.getData().get(0).getActivityId());
}
Also used : GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Example 23 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method linkedSites.

@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSites() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Activity, 1);
    cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(2));
    SiteDTO site1 = result.getData().get(0);
    SiteDTO site2 = result.getData().get(1);
    System.out.println(site1.getProperties());
    System.out.println(site2.getProperties());
    assertThat(site1.getId(), equalTo(1));
    assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
    assertThat(site1.getActivityId(), equalTo(1));
    assertThat((Double) site1.getIndicatorValue(1), equalTo(1500d));
    assertThat(site2.getId(), equalTo(2));
    assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
    assertThat(site2.getActivityId(), equalTo(1));
    assertThat((Double) site2.getIndicatorValue(1), equalTo(400d));
}
Also used : SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 24 with GetSites

use of org.activityinfo.legacy.shared.command.GetSites in project activityinfo by bedatadriven.

the class GetSitesTest method linkedSitesFilteredByIndicator.

@Test
@OnDataSet("/dbunit/sites-linked.db.xml")
public void linkedSitesFilteredByIndicator() {
    setUser(1);
    GetSites cmd = new GetSites();
    cmd.filter().addRestriction(DimensionType.Indicator, 1);
    cmd.setSortInfo(new SortInfo("locationName", SortDir.ASC));
    SiteResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(2));
    SiteDTO site1 = result.getData().get(0);
    SiteDTO site2 = result.getData().get(1);
    System.out.println(site1.getProperties());
    System.out.println(site2.getProperties());
    assertThat(site1.getId(), equalTo(1));
    assertThat(site1.getLocationName(), equalTo("Penekusu Kivu"));
    assertThat(site1.getActivityId(), equalTo(1));
    assertThat((Double) site1.getIndicatorValue(1), equalTo(1500d));
    assertThat(site2.getId(), equalTo(2));
    assertThat(site2.getLocationName(), equalTo("Penekusu Kivu 2"));
    assertThat(site2.getActivityId(), equalTo(1));
    assertThat((Double) site2.getIndicatorValue(1), equalTo(400d));
}
Also used : SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) GetSites(org.activityinfo.legacy.shared.command.GetSites) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) SortInfo(com.extjs.gxt.ui.client.data.SortInfo) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

GetSites (org.activityinfo.legacy.shared.command.GetSites)24 Test (org.junit.Test)19 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)16 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)10 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)9 OnDataSet (org.activityinfo.server.database.OnDataSet)5 Filter (org.activityinfo.legacy.shared.command.Filter)4 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 FormTree (org.activityinfo.model.formTree.FormTree)2 ImportModel (org.activityinfo.ui.client.component.importDialog.model.ImportModel)2 PastedTable (org.activityinfo.ui.client.component.importDialog.model.source.PastedTable)2 ValidatedRowTable (org.activityinfo.ui.client.component.importDialog.model.validation.ValidatedRowTable)2 Ignore (org.junit.Ignore)2 Delete (org.activityinfo.legacy.shared.command.Delete)1 TableData (org.activityinfo.legacy.shared.reports.content.TableData)1 AdminDimension (org.activityinfo.legacy.shared.reports.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.legacy.shared.reports.model.DateDimension)1 Dimension (org.activityinfo.legacy.shared.reports.model.Dimension)1 TableColumn (org.activityinfo.legacy.shared.reports.model.TableColumn)1