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"));
}
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"));
}
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();
}
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));
}
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();
}
Aggregations