Search in sources :

Example 1 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class DetailTab method setSite.

public void setSite(final SiteDTO site) {
    content.setText(I18N.CONSTANTS.loading());
    dispatcher.execute(new GetActivityForm(site.getActivityId()), new AsyncCallback<ActivityFormDTO>() {

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

        @Override
        public void onSuccess(ActivityFormDTO result) {
            render(result, site);
        }
    });
}
Also used : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 2 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class MonthlyReportsPanel method loadSite.

private void loadSite(final SiteDTO site) {
    this.currentSiteId = site.getId();
    this.grid.getStore().removeAll();
    MaskingAsyncMonitor monitor = new MaskingAsyncMonitor(this, I18N.CONSTANTS.loading());
    service.execute(new GetSchema(), monitor).thenDo(schema -> {
        service.execute(new GetActivityForm(site.getActivityId()), monitor).thenDo(activity -> {
            currentActivity = activity;
            populateGrid(site, schema);
        });
    });
}
Also used : MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 3 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class DefaultColumnModelProvider method fetchColumnModels.

@Override
public void fetchColumnModels(final Filter filter, final GroupingModel grouping, final AsyncCallback<ColumnModel> callback) {
    if (filter.isDimensionRestrictedToSingleCategory(DimensionType.Activity)) {
        final int activityId = filter.getRestrictedCategory(DimensionType.Activity);
        dispatcher.execute(new GetActivityForm(activityId)).then(new AsyncCallback<ActivityFormDTO>() {

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

            @Override
            public void onSuccess(ActivityFormDTO activity) {
                dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

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

                    @Override
                    public void onSuccess(SchemaDTO schema) {
                        callback.onSuccess(forSingleActivity(grouping, schema.getDatabaseById(activity.getDatabaseId()), activity));
                    }
                });
            }
        });
    } else {
        dispatcher.execute(new GetSchema()).then(new AsyncCallback<SchemaDTO>() {

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

            @Override
            public void onSuccess(SchemaDTO result) {
                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 : ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO)

Example 4 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class PrintDataEntryForm method print.

public void print(final int activityId) {
    setVisible(true);
    dispatcher.execute(new GetActivityForm(activityId), new MaskingAsyncMonitor(this, I18N.CONSTANTS.loading()), new AsyncCallback<ActivityFormDTO>() {

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

        @Override
        public void onSuccess(ActivityFormDTO result) {
            renderForm(result);
        }
    });
}
Also used : MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 5 with GetActivityForm

use of org.activityinfo.legacy.shared.command.GetActivityForm in project activityinfo by bedatadriven.

the class SiteDialogLauncher method editSite.

public void editSite(final SiteDTO site, final SiteDialogCallback callback) {
    dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

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

        @Override
        public void onSuccess(SchemaDTO schema) {
            final ActivityDTO activity = schema.getActivityById(site.getActivityId());
            if (!activity.getClassicView()) {
                promptUseNewEntry(activity);
                return;
            }
            // check whether the site has been locked
            // (this only applies to Once-reported activities because
            // otherwise the date criteria applies to the monthly report)
            LockedPeriodSet locks = new LockedPeriodSet(schema);
            if (activity.getReportingFrequency() == ActivityFormDTO.REPORT_ONCE) {
                if (locks.isLocked(site)) {
                    MessageBox.alert(I18N.CONSTANTS.lockedSiteTitle(), I18N.CONSTANTS.siteIsLocked(), null);
                    return;
                }
            }
            dispatcher.execute(new GetActivityForm(activity.getId())).then(new AsyncCallback<ActivityFormDTO>() {

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

                @Override
                public void onSuccess(ActivityFormDTO activity) {
                    SiteDialog dialog = new SiteDialog(dispatcher, locks, activity);
                    dialog.showExisting(site, callback);
                }
            });
        }
    });
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Aggregations

GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)16 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)10 Test (org.junit.Test)8 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)6 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 Delete (org.activityinfo.legacy.shared.command.Delete)3 AttributeGroupDTO (org.activityinfo.legacy.shared.model.AttributeGroupDTO)3 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)3 HashMap (java.util.HashMap)2 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)2 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StreamResult (javax.xml.transform.stream.StreamResult)1 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 UpdateEntity (org.activityinfo.legacy.shared.command.UpdateEntity)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)1