Search in sources :

Example 31 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class LocalSiteCreateTest method siteRemovePartnerConflict.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
    // FIRST U1 adds a new partner
    int databaseId = 1;
    PartnerDTO iom = new PartnerDTO();
    iom.setName("IOM");
    CreateResult result = executeRemotely(new AddPartner(databaseId, iom));
    iom.setId(result.getNewId());
    // Now U2 synchronizes, and adds a new site with this partner
    synchronizeFirstTime();
    SiteDTO site = new SiteDTO();
    site.setId(3343234);
    site.setActivityId(1);
    site.setPartner(iom);
    site.setDate1(new Date());
    site.setDate2(new Date());
    site.setLocationId(1);
    executeLocally(new CreateSite(site));
    // At T+3, U2 thinks better, removes IOM
    executeRemotely(new RemovePartner(databaseId, iom.getId()));
    // At T+4, U1 synchronizes, and IOM is removed, but site remains
    synchronize();
    // Verify that there is still a label for this partner
    SiteResult sites = executeLocally(GetSites.byId(site.getId()));
    assertThat(sites.getTotalLength(), equalTo(1));
    assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SiteResult(org.activityinfo.shared.command.result.SiteResult) RemovePartner(org.activityinfo.shared.command.RemovePartner) AddPartner(org.activityinfo.shared.command.AddPartner) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Date(java.util.Date) CreateSite(org.activityinfo.shared.command.CreateSite) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 32 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteDTOs method newSite.

public static SiteDTO newSite() {
    SiteDTO newSite = new SiteDTO();
    newSite.setId(new KeyGenerator().generateInt());
    newSite.setActivityId(1);
    newSite.setLocationId(1);
    newSite.setPartner(new PartnerDTO(1, "Foobar"));
    newSite.setReportingPeriodId(new KeyGenerator().generateInt());
    newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
    newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
    newSite.setIndicatorValue(1, 996.0);
    newSite.setIndicatorValue(2, null);
    newSite.setAttributeValue(1, true);
    newSite.setAttributeValue(2, false);
    newSite.setComments("huba huba");
    newSite.setProject(new ProjectDTO(1, "WoeiProject"));
    return newSite;
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) GregorianCalendar(java.util.GregorianCalendar) SiteDTO(org.activityinfo.shared.dto.SiteDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator)

Example 33 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteDTOs method validateNewSite.

public static void validateNewSite(SiteDTO secondRead) {
    SiteDTO newSite = newSite();
    Assert.assertEquals("site.location.name", LocationDTOs.newLocation().getName(), secondRead.getLocationName());
    Assert.assertEquals("site.location.axe", LocationDTOs.newLocation().getAxe(), secondRead.getLocationAxe());
    Assert.assertEquals("site.attribute[1]", true, secondRead.getAttributeValue(1));
    Assert.assertEquals("site.reportingPeriod[0].indicatorValue[0]", 996.0, secondRead.getIndicatorValue(1), 0.1);
    Assert.assertEquals("site.comments", newSite.getComments(), secondRead.getComments());
    Assert.assertEquals("site.partner", newSite.getPartner().getId(), secondRead.getPartner().getId());
}
Also used : SiteDTO(org.activityinfo.shared.dto.SiteDTO)

Example 34 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class SiteExporterTest method sheetNameTest.

@Test
public void sheetNameTest() {
    LocaleProxy.initialize();
    CountryDTO somalia = new CountryDTO(1, "Somalia");
    somalia.getLocationTypes().add(new LocationTypeDTO(1, "Village"));
    UserDatabaseDTO syli = new UserDatabaseDTO();
    syli.setName("SYLI");
    syli.setCountry(somalia);
    ActivityDTO activity = new ActivityDTO();
    activity.setId(1);
    activity.setDatabase(syli);
    activity.setName("Construction/Rehabilitation of Sec. Schools");
    activity.setLocationTypeId(1);
    ActivityDTO activity2 = new ActivityDTO();
    activity2.setId(2);
    activity2.setDatabase(syli);
    activity2.setName("Construction/Rehabilitation of Primary Schools");
    activity2.setLocationTypeId(1);
    ActivityDTO activity3 = new ActivityDTO();
    activity3.setId(3);
    activity3.setDatabase(syli);
    activity3.setName("Construction Rehabil (2)");
    activity3.setLocationTypeId(1);
    DispatcherSync dispatcher = createMock(DispatcherSync.class);
    expect(dispatcher.execute(isA(GetSites.class))).andReturn(new SiteResult(new ArrayList<SiteDTO>())).anyTimes();
    replay(dispatcher);
    Filter filter = new Filter();
    SiteExporter exporter = new SiteExporter(dispatcher);
    exporter.export(activity, filter);
    exporter.export(activity2, filter);
    exporter.export(activity3, filter);
    HSSFWorkbook book = exporter.getBook();
    assertThat(book.getSheetAt(0).getSheetName(), equalTo("SYLI - Construction Rehabilitat"));
    assertThat(book.getSheetAt(1).getSheetName(), equalTo("SYLI - Construction Rehabil (2)"));
    assertThat(book.getSheetAt(2).getSheetName(), equalTo("SYLI - Construction Rehabil 2"));
}
Also used : CountryDTO(org.activityinfo.shared.dto.CountryDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SiteResult(org.activityinfo.shared.command.result.SiteResult) Filter(org.activityinfo.shared.command.Filter) LocationTypeDTO(org.activityinfo.shared.dto.LocationTypeDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) DispatcherSync(org.activityinfo.server.command.DispatcherSync) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 35 with SiteDTO

use of org.activityinfo.shared.dto.SiteDTO in project activityinfo by bedatadriven.

the class TableGeneratorTest method dummySite.

public SiteDTO dummySite() {
    SiteDTO site = new SiteDTO();
    site.setId(1);
    site.setLocationName("tampa bay");
    site.setIndicatorValue(INDICATOR_ID, 1500d);
    site.setX(28.4);
    site.setY(1.2);
    return site;
}
Also used : SiteDTO(org.activityinfo.shared.dto.SiteDTO)

Aggregations

SiteDTO (org.activityinfo.shared.dto.SiteDTO)71 Test (org.junit.Test)32 GetSites (org.activityinfo.shared.command.GetSites)16 SiteResult (org.activityinfo.shared.command.result.SiteResult)11 CreateSite (org.activityinfo.shared.command.CreateSite)9 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)8 SortInfo (com.extjs.gxt.ui.client.data.SortInfo)7 ArrayList (java.util.ArrayList)7 CreateResult (org.activityinfo.shared.command.result.CreateResult)7 Date (java.util.Date)6 OnDataSet (org.activityinfo.server.database.OnDataSet)6 PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)6 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)6 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)5 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)5 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)5 UpdateSite (org.activityinfo.shared.command.UpdateSite)5 LocationDTO (org.activityinfo.shared.dto.LocationDTO)5 PointValue (org.activityinfo.shared.report.model.PointValue)5 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)4