Search in sources :

Example 11 with UserDatabaseDTO

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

the class DimensionPrunerTest method setupData.

@Before
public void setupData() {
    ActivityDTO dist = new ActivityDTO(1, "Distribution");
    IndicatorDTO nbMenages = new IndicatorDTO();
    nbMenages.setId(NB_MENAGES_INDICATOR_ID);
    nbMenages.setName("Nb Menages");
    dist.getIndicators().add(nbMenages);
    AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
    distFunding.setName("Funding Source");
    dist.getAttributeGroups().add(distFunding);
    ActivityDTO fairs = new ActivityDTO(2, "Faire");
    AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
    fairFunding.setName("Funding Source");
    fairs.getAttributeGroups().add(fairFunding);
    IndicatorDTO voucherValue = new IndicatorDTO();
    voucherValue.setId(VOUCHER_INDICATOR_ID);
    voucherValue.setName("Voucher Value");
    fairs.getIndicators().add(voucherValue);
    UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
    nfi.getActivities().add(dist);
    nfi.getActivities().add(fairs);
    this.schema = new SchemaDTO();
    schema.getDatabases().add(nfi);
    dispatcher.setResult(GetSchema.class, schema);
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) Before(org.junit.Before)

Example 12 with UserDatabaseDTO

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

the class ActivityTest method testActivity.

@Test
public void testActivity() throws CommandException {
    /*
         * Initial data load
         */
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO db = schema.getDatabaseById(1);
    /*
         * Create a new activity
         */
    LocationTypeDTO locType = schema.getCountryById(1).getLocationTypes().get(0);
    ActivityDTO act = new ActivityDTO();
    act.setName("Warshing the dishes");
    act.setLocationTypeId(locType.getId());
    act.setReportingFrequency(ActivityDTO.REPORT_MONTHLY);
    CreateResult cresult = execute(CreateEntity.Activity(db, act));
    int newId = cresult.getNewId();
    /*
         * Reload schema to verify the changes have stuck
         */
    schema = execute(new GetSchema());
    act = schema.getActivityById(newId);
    Assert.assertEquals("name", "Warshing the dishes", act.getName());
    Assert.assertEquals("locationType", locType.getName(), act.getLocationType().getName());
    Assert.assertEquals("reportingFrequency", ActivityDTO.REPORT_MONTHLY, act.getReportingFrequency());
    Assert.assertEquals("public", Published.NOT_PUBLISHED.getIndex(), act.getPublished());
}
Also used : CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) LocationTypeDTO(org.activityinfo.shared.dto.LocationTypeDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 13 with UserDatabaseDTO

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

the class CreateDatabaseTest method testCreate.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testCreate() throws CommandException {
    UserDatabaseDTO db = new UserDatabaseDTO();
    db.setName("RIMS");
    db.setFullName("Reintegration Management Information System");
    CreateResult cr = execute(new CreateEntity(db));
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO newdb = schema.getDatabaseById(cr.getNewId());
    assertNotNull(newdb);
    assertEquals(db.getName(), newdb.getName());
    assertEquals(db.getFullName(), newdb.getFullName());
    assertNotNull(newdb.getCountry());
    assertEquals("Alex", newdb.getOwnerName());
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 14 with UserDatabaseDTO

use of org.activityinfo.shared.dto.UserDatabaseDTO 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 15 with UserDatabaseDTO

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

the class ExportIntegrationTest method fullTest.

@Test
public void fullTest() throws Throwable {
    User user = new User();
    user.setId(1);
    user.setName("Alex");
    SchemaDTO schema = execute(new GetSchema());
    SiteExporter export = new SiteExporter(getDispatcherSync());
    for (UserDatabaseDTO db : schema.getDatabases()) {
        for (ActivityDTO activity : db.getActivities()) {
            export.export(activity, new Filter());
        }
    }
    File outputDir = new File("target/report-test/");
    outputDir.mkdirs();
    FileOutputStream fos = new FileOutputStream("target/report-test/ExportTest.xls");
    export.getBook().write(fos);
    fos.close();
}
Also used : SiteExporter(org.activityinfo.server.endpoint.export.SiteExporter) User(org.activityinfo.server.database.hibernate.entity.User) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) Filter(org.activityinfo.shared.command.Filter) FileOutputStream(java.io.FileOutputStream) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) File(java.io.File) Test(org.junit.Test)

Aggregations

UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)25 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)13 GetSchema (org.activityinfo.shared.command.GetSchema)10 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)10 Test (org.junit.Test)8 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 CreateEntity (org.activityinfo.shared.command.CreateEntity)3 Filter (org.activityinfo.shared.command.Filter)3 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)3 CountryDTO (org.activityinfo.shared.dto.CountryDTO)3 Date (java.util.Date)2 User (org.activityinfo.server.database.hibernate.entity.User)2 SiteResult (org.activityinfo.shared.command.result.SiteResult)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)2 LocationTypeDTO (org.activityinfo.shared.dto.LocationTypeDTO)2 LockedPeriodDTO (org.activityinfo.shared.dto.LockedPeriodDTO)2 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)2 SiteDTO (org.activityinfo.shared.dto.SiteDTO)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1