Search in sources :

Example 41 with GetSchema

use of org.activityinfo.shared.command.GetSchema 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 42 with GetSchema

use of org.activityinfo.shared.command.GetSchema 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)

Example 43 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class SiteHistoryTab method setSite.

// retrieve all needed data: sitehistoryresult, schema, and locations
public void setSite(final SiteDTO site) {
    renderLoading();
    dispatcher.execute(new GetSiteHistory(site.getId()), new AsyncCallback<GetSiteHistoryResult>() {

        @Override
        public void onFailure(Throwable caught) {
            renderNotAvailable(site);
        }

        @Override
        public void onSuccess(final GetSiteHistoryResult historyResult) {
            if (historyResult.hasHistories()) {
                dispatcher.execute(new GetLocations(historyResult.collectLocationIds()), new AsyncCallback<GetLocationsResult>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        renderNotAvailable(site);
                    }

                    @Override
                    public void onSuccess(final GetLocationsResult locationsResult) {
                        dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                renderNotAvailable(site);
                            }

                            @Override
                            public void onSuccess(SchemaDTO schema) {
                                render(schema, locationsResult.getLocations(), site, historyResult.getSiteHistories());
                            }
                        });
                    }
                });
            } else {
                renderNotAvailable(site);
            }
        }
    });
}
Also used : GetLocations(org.activityinfo.shared.command.GetLocations) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetLocationsResult(org.activityinfo.shared.command.GetLocations.GetLocationsResult) GetSiteHistory(org.activityinfo.shared.command.GetSiteHistory) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSiteHistoryResult(org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult)

Example 44 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class ClusteringOptionsWidget method loadForm.

public void loadForm(final MapLayer layer) {
    // mask();
    destroyForm();
    service.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

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

        @Override
        public void onSuccess(SchemaDTO schema) {
            buildForm(countriesForLayer(schema, layer));
        }
    });
}
Also used : GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 45 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class DimensionProxy method load.

@Override
protected void load(Object loadConfig, final AsyncCallback<ListLoadResult<DimensionModel>> callback) {
    final List<DimensionModel> list = Lists.newArrayList();
    list.add(new DimensionModel(DimensionType.Indicator, I18N.CONSTANTS.indicator()));
    list.add(new DimensionModel(DimensionType.Partner, I18N.CONSTANTS.partner()));
    list.add(new DimensionModel(DimensionType.Project, I18N.CONSTANTS.project()));
    list.add(new DimensionModel(DimensionType.Target, I18N.CONSTANTS.realizedOrTargeted()));
    list.add(new DimensionModel(DateUnit.YEAR));
    list.add(new DimensionModel(DateUnit.QUARTER));
    list.add(new DimensionModel(DateUnit.MONTH));
    list.add(new DimensionModel(DateUnit.WEEK_MON));
    if (model.getIndicators().isEmpty()) {
        callback.onSuccess(new BaseListLoadResult<DimensionModel>(list));
    } else {
        dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(SchemaDTO schema) {
                addGeographicDimensions(list, schema);
                list.addAll(DimensionModel.attributeGroupModels(schema, model.getIndicators()));
                callback.onSuccess(new BaseListLoadResult<DimensionModel>(list));
            }
        });
    }
}
Also used : BaseListLoadResult(com.extjs.gxt.ui.client.data.BaseListLoadResult) DimensionModel(org.activityinfo.client.report.editor.pivotTable.DimensionModel) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Aggregations

GetSchema (org.activityinfo.shared.command.GetSchema)65 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)56 Test (org.junit.Test)42 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 CreateEntity (org.activityinfo.shared.command.CreateEntity)5 Filter (org.activityinfo.shared.command.Filter)5 HashMap (java.util.HashMap)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 Delete (org.activityinfo.shared.command.Delete)4 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 BatchCommand (org.activityinfo.shared.command.BatchCommand)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2