Search in sources :

Example 31 with ActivityDTO

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

the class IndicatorGridPanel method setDatabase.

public void setDatabase(UserDatabaseDTO db) {
    setHeading(db.getName());
    store.removeAll();
    for (ActivityDTO activity : db.getActivities()) {
        store.add(activity);
        for (IndicatorGroup group : activity.groupIndicators()) {
            if (group.getName() == null) {
                for (IndicatorDTO indicator : group.getIndicators()) {
                    store.add(indicator);
                }
            } else {
                store.add(group);
                for (IndicatorDTO indicator : group.getIndicators()) {
                    store.add(indicator);
                }
            }
        }
    }
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) IndicatorGroup(org.activityinfo.shared.dto.IndicatorGroup) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 32 with ActivityDTO

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

the class EmbedDialog method show.

public void show(final DataEntryPlace place) {
    final String url = "http://www.activityinfo.org/embed.html?sites=" + FilterUrlSerializer.toUrlFragment(place.getFilter());
    dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

        @Override
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(SchemaDTO result) {
            Filter filter = place.getFilter();
            if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
                ActivityDTO singleActivity = result.getActivityById(filter.getRestrictedCategory(DimensionType.Activity));
                showPublished(singleActivity, url);
            } else if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                MessageBox.alert("foo", "not impl", null);
            }
        }
    });
}
Also used : Filter(org.activityinfo.shared.command.Filter) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 33 with ActivityDTO

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

the class SiteGridPanel method updateHeading.

private void updateHeading(final Filter filter) {
    setHeading(I18N.CONSTANTS.sitesHeader());
    dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(SchemaDTO result) {
            if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
                int activityId = filter.getRestrictedCategory(DimensionType.Activity);
                ActivityDTO activity = result.getActivityById(activityId);
                setHeading(activity.getDatabase().getName() + " - " + activity.getName());
            } else if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                int databaseId = filter.getRestrictedCategory(DimensionType.Database);
                UserDatabaseDTO db = result.getDatabaseById(databaseId);
                setHeading(db.getName());
            }
        }
    });
}
Also used : UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 34 with ActivityDTO

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

the class ColumnModelBuilder method addActivityColumn.

public ColumnModelBuilder addActivityColumn(final SchemaDTO schema) {
    ColumnConfig config = new ColumnConfig("activityId", I18N.CONSTANTS.activity(), 100);
    config.setRenderer(new GridCellRenderer<SiteDTO>() {

        @Override
        public Object render(SiteDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SiteDTO> store, Grid<SiteDTO> grid) {
            ActivityDTO activity = schema.getActivityById(model.getActivityId());
            return activity == null ? "" : activity.getName();
        }
    });
    columns.add(config);
    return this;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ColumnData(com.extjs.gxt.ui.client.widget.grid.ColumnData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 35 with ActivityDTO

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

the class DefaultColumnModelProvider method fetchColumnModels.

@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
    dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

        @Override
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(SchemaDTO result) {
            if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
                ActivityDTO singleActivity = result.getActivityById(filter.getRestrictedCategory(DimensionType.Activity));
                callback.onSuccess(forSingleActivity(grouping, singleActivity));
            } else if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Database)) {
                UserDatabaseDTO singleDatabase = result.getDatabaseById(filter.getRestrictedCategory(DimensionType.Database));
                callback.onSuccess(forSingleDatabase(grouping, singleDatabase));
            } else {
                callback.onSuccess(forMultipleDatabases(grouping, result));
            }
        }
    });
}
Also used : UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

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