Search in sources :

Example 46 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO 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 47 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO 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)

Example 48 with SiteDTO

use of org.activityinfo.legacy.shared.model.SiteDTO in project activityinfo by bedatadriven.

the class LocalSiteCreateTest method createNew.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() {
    synchronize();
    // create a new detached, client model
    SiteDTO newSite = SiteDTOs.newSite();
    LocationDTO location = LocationDTOs.newLocation();
    executeLocally(new CreateLocation(location));
    newSite.setLocation(location);
    // create command
    CreateSite cmd = new CreateSite(newSite);
    // execute the command
    CreateResult result = executeLocally(cmd);
    // let the client know the command has succeeded
    newSite.setId(result.getNewId());
    // try to retrieve what we've created FROM OUR CLIENT SIDE DATABASE
    SiteResult loadResult = executeLocally(GetSites.byId(newSite.getId()));
    Assert.assertEquals(1, loadResult.getData().size());
    SiteDTO secondRead = loadResult.getData().get(0);
    // confirm that the changes are there
    SiteDTOs.validateNewSite(secondRead);
    newRequest();
    // now Sync with the server
    synchronize();
    // Confirm that paging works client side
    GetSites pagingRequest = new GetSites();
    pagingRequest.setLimit(1);
    executeLocally(pagingRequest);
}
Also used : CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)48 Test (org.junit.Test)31 GetSites (org.activityinfo.legacy.shared.command.GetSites)16 SiteResult (org.activityinfo.legacy.shared.command.result.SiteResult)12 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)9 OnDataSet (org.activityinfo.server.database.OnDataSet)8 Date (java.util.Date)6 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)6 PointValue (org.activityinfo.legacy.shared.reports.model.PointValue)5 ArrayList (java.util.ArrayList)4 UpdateSite (org.activityinfo.legacy.shared.command.UpdateSite)4 TableColumn (org.activityinfo.legacy.shared.reports.model.TableColumn)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)3 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)3 TableData (org.activityinfo.legacy.shared.reports.content.TableData)3 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)2 Delete (org.activityinfo.legacy.shared.command.Delete)2 Filter (org.activityinfo.legacy.shared.command.Filter)2 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)2