Search in sources :

Example 11 with IndicatorDTO

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

the class SiteRendererTest method multipleGroupsRender.

@Test
public void multipleGroupsRender() {
    IndicatorDTO indicator1 = new IndicatorDTO();
    indicator1.setId(1);
    indicator1.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator1.setName("First indicator");
    indicator1.setCategory("First group");
    IndicatorDTO indicator2 = new IndicatorDTO();
    indicator2.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator2.setId(2);
    indicator2.setName("Second indicator");
    indicator2.setCategory("Second group");
    ActivityDTO activity = new ActivityDTO();
    activity.setId(1);
    activity.getIndicators().add(indicator1);
    activity.getIndicators().add(indicator2);
    SiteDTO site = new SiteDTO();
    site.setIndicatorValue(1, 1000d);
    site.setIndicatorValue(2, 2000d);
    String html = siteRenderer.renderSite(site, activity, false, true);
    assertTrue(html.contains(indicator1.getName()));
    assertTrue(html.contains(indicator2.getName()));
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) Test(org.junit.Test)

Example 12 with IndicatorDTO

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

the class LocalSchemaChangeTest method createIndicator.

@Test
public void createIndicator() {
    synchronizeFirstTime();
    SchemaDTO schema = executeLocally(new GetSchema());
    Map<String, Object> indicator = Maps.newHashMap();
    indicator.put("name", "New Indicator");
    indicator.put("units", "bricks");
    indicator.put("activityId", 2);
    CreateResult createResult = executeRemotely(new CreateEntity("Indicator", indicator));
    synchronize();
    schema = executeLocally(new GetSchema());
    IndicatorDTO createdIndicator = schema.getIndicatorById(createResult.getNewId());
    assertThat(createdIndicator, is(not(nullValue())));
    assertThat(createdIndicator.getName(), equalTo("New Indicator"));
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 13 with IndicatorDTO

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

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

the class IndicatorTreePanel method applySelection.

private void applySelection() {
    for (ModelData model : tree.getStore().getAllItems()) {
        if (model instanceof IndicatorDTO) {
            IndicatorDTO indicator = (IndicatorDTO) model;
            boolean selected = selection.contains(indicator.getId());
            setChecked(indicator, selected);
        }
    }
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO)

Example 15 with IndicatorDTO

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

the class DesignPresenter method fillStore.

private void fillStore(UIConstants messages) {
    for (ActivityDTO activity : db.getActivities()) {
        ActivityDTO activityNode = new ActivityDTO(activity);
        treeStore.add(activityNode, false);
        AttributeGroupFolder attributeFolder = new AttributeGroupFolder(messages.attributes());
        treeStore.add(activityNode, attributeFolder, false);
        for (AttributeGroupDTO group : activity.getAttributeGroups()) {
            if (group != null) {
                AttributeGroupDTO groupNode = new AttributeGroupDTO(group);
                treeStore.add(attributeFolder, groupNode, false);
                for (AttributeDTO attribute : group.getAttributes()) {
                    AttributeDTO attributeNode = new AttributeDTO(attribute);
                    treeStore.add(groupNode, attributeNode, false);
                }
            }
        }
        IndicatorFolder indicatorFolder = new IndicatorFolder(messages.indicators());
        treeStore.add(activityNode, indicatorFolder, false);
        for (IndicatorDTO indicator : activity.getIndicators()) {
            IndicatorDTO indicatorNode = new IndicatorDTO(indicator);
            treeStore.add(indicatorFolder, indicatorNode, false);
        }
    }
}
Also used : AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Aggregations

IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)28 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)9 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)7 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 Test (org.junit.Test)5 IndicatorGroup (org.activityinfo.shared.dto.IndicatorGroup)4 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)4 GetSchema (org.activityinfo.shared.command.GetSchema)2 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)2 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)2 MapContent (org.activityinfo.shared.report.content.MapContent)2 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)2 FieldBinding (com.extjs.gxt.ui.client.binding.FieldBinding)1 TreeGridDragSource (com.extjs.gxt.ui.client.dnd.TreeGridDragSource)1 TreeGridDropTarget (com.extjs.gxt.ui.client.dnd.TreeGridDropTarget)1 DNDEvent (com.extjs.gxt.ui.client.event.DNDEvent)1 DNDListener (com.extjs.gxt.ui.client.event.DNDListener)1 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1