Search in sources :

Example 21 with ActivityDTO

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

the class GetSchemaTest method testIndicators.

@Test
public void testIndicators() throws CommandException {
    // Alex
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    assertTrue("no indicators case", schema.getActivityById(2).getIndicators().size() == 0);
    ActivityDTO nfi = schema.getActivityById(1);
    assertThat("indicators are present", nfi.getIndicators().size(), equalTo(4));
    IndicatorDTO test = nfi.getIndicatorById(2);
    assertThat("property:name", test.getName(), equalTo("baches"));
    assertThat("property:units", test.getUnits(), equalTo("menages"));
    assertThat("property:aggregation", test.getAggregation(), equalTo(IndicatorDTO.AGGREGATE_SUM));
    assertThat("property:category", test.getCategory(), equalTo("outputs"));
    assertThat("property:listHeader", test.getListHeader(), equalTo("header"));
    assertThat("property:description", test.getDescription(), equalTo("desc"));
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 22 with ActivityDTO

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

use of org.activityinfo.shared.dto.ActivityDTO 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)

Example 24 with ActivityDTO

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

the class LocalGetSchemaHandlerIntTest method forUser.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void forUser() throws CommandException {
    // only has view access to databse 1
    setUser(4);
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    assertThat(schema.getDatabases().size(), equalTo(2));
    UserDatabaseDTO pearDb = schema.getDatabaseById(1);
    assertThat(pearDb.getAmOwner(), equalTo(false));
    assertThat(pearDb.isViewAllAllowed(), equalTo(false));
    assertThat(pearDb.isEditAllowed(), equalTo(false));
    assertThat(pearDb.isEditAllAllowed(), equalTo(true));
    ActivityDTO activity = schema.getActivityById(1);
    assertThat(activity.getAttributeGroups().size(), equalTo(3));
    AttributeGroupDTO group = activity.getAttributeGroupById(1);
    assertThat(group.getName(), equalTo("cause"));
    assertThat(group.getAttributes().size(), equalTo(2));
}
Also used : AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 25 with ActivityDTO

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

the class IndicatorTreePanel method loadSingleDatabase.

public void loadSingleDatabase(UserDatabaseDTO database) {
    store.removeAll();
    for (ActivityDTO activity : database.getActivities()) {
        store.add(activity, true);
        List<ModelData> models = createActivityChildren(activity);
        for (ModelData model : models) {
            if (model instanceof IndicatorGroup) {
                store.add(activity, model, true);
                store.add(model, createIndicatorList((IndicatorGroup) model), true);
            } else {
                store.add(activity, model, true);
            }
        }
    }
    tree.expandAll();
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) IndicatorGroup(org.activityinfo.shared.dto.IndicatorGroup) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Aggregations

ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)44 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)20 GetSchema (org.activityinfo.shared.command.GetSchema)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)13 Test (org.junit.Test)13 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)9 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)9 SiteDTO (org.activityinfo.shared.dto.SiteDTO)8 CreateResult (org.activityinfo.shared.command.result.CreateResult)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)5 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)5 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)4 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)3 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)3 HashMap (java.util.HashMap)3 MockEventBus (org.activityinfo.client.MockEventBus)3 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)3 UIConstants (org.activityinfo.client.i18n.UIConstants)3 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)3