Search in sources :

Example 1 with UserDatabaseDTO

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

the class ConfigNavigator method loadDbList.

private void loadDbList(final AsyncCallback<List<Link>> callback, SchemaDTO result) {
    List<Link> list = new ArrayList<Link>();
    for (UserDatabaseDTO db : result.getDatabases()) {
        if (db.isDesignAllowed() || db.isManageUsersAllowed()) {
            Link link = Link.to(new DbPageState(DbConfigPresenter.PAGE_ID, db.getId())).labeled(db.getName()).withIcon(icons.database()).build();
            link.set("db", db);
            list.add(link);
        }
    }
    callback.onSuccess(list);
}
Also used : UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ArrayList(java.util.ArrayList) Link(org.activityinfo.client.page.common.nav.Link)

Example 2 with UserDatabaseDTO

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

the class DbListPresenter method onAdd.

public void onAdd() {
    final UserDatabaseDTO db = new UserDatabaseDTO();
    DatabaseForm form = new DatabaseForm(dispatcher);
    form.getBinding().bind(db);
    final FormDialogImpl dialog = new FormDialogImpl(form);
    dialog.setWidth(400);
    dialog.setHeight(200);
    dialog.setHeading(I18N.CONSTANTS.newDatabase());
    dialog.show(new FormDialogCallback() {

        @Override
        public void onValidated() {
            save(db, dialog);
        }
    });
}
Also used : FormDialogImpl(org.activityinfo.client.page.common.dialog.FormDialogImpl) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) DatabaseForm(org.activityinfo.client.page.config.form.DatabaseForm)

Example 3 with UserDatabaseDTO

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

the class LockedPeriodsPresenter method onCreate.

@Override
public void onCreate(CreateEvent event) {
    view.getCreatingMonitor().beforeRequest();
    final LockedPeriodDTO lockedPeriod = view.getValue();
    CreateLockedPeriod lockUserDatabase = new CreateLockedPeriod(lockedPeriod);
    if (lockedPeriod.getParent() instanceof ActivityDTO) {
        lockUserDatabase.setActivityId(lockedPeriod.getParent().getId());
    }
    if (lockedPeriod.getParent() instanceof ProjectDTO) {
        lockUserDatabase.setProjectId(lockedPeriod.getParent().getId());
    }
    if (lockedPeriod.getParent() instanceof UserDatabaseDTO) {
        lockUserDatabase.setUserDatabaseId(lockedPeriod.getParent().getId());
    }
    service.execute(lockUserDatabase, new AsyncCallback<CreateResult>() {

        @Override
        public void onFailure(Throwable caught) {
            view.getCreatingMonitor().onServerError();
            MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer() + "\n\n" + caught.getMessage(), null);
        }

        @Override
        public void onSuccess(CreateResult result) {
            // Update the Id for the child instance
            lockedPeriod.setId(result.getNewId());
            // Tell the view there's a new kid on the block
            view.create(lockedPeriod);
            // Actually add the lock to it's parent
            lockedPeriod.getParent().getLockedPeriods().add(lockedPeriod);
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) CreateLockedPeriod(org.activityinfo.shared.command.CreateLockedPeriod) LockedPeriodDTO(org.activityinfo.shared.dto.LockedPeriodDTO)

Example 4 with UserDatabaseDTO

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

the class ShareReportDialog method populateGrid.

private void populateGrid(SchemaDTO schema, ReportVisibilityResult visibility) {
    gridStore.removeAll();
    Set<Integer> indicators = currentReport.getIndicators();
    Map<Integer, ReportVisibilityDTO> databases = Maps.newHashMap();
    for (ReportVisibilityDTO model : visibility.getList()) {
        databases.put(model.getDatabaseId(), model);
    }
    for (UserDatabaseDTO db : schema.getDatabases()) {
        if (hasAny(db, indicators)) {
            if (databases.containsKey(db.getId())) {
                gridStore.add(databases.get(db.getId()));
            } else {
                ReportVisibilityDTO model = new ReportVisibilityDTO();
                model.setDatabaseId(db.getId());
                model.setDatabaseName(db.getName());
                gridStore.add(model);
            }
        }
    }
    if (gridStore.getCount() == 0) {
        MessageBox.alert(I18N.CONSTANTS.share(), "This report is still empty, so it can't yet be shared.", new Listener<MessageBoxEvent>() {

            @Override
            public void handleEvent(MessageBoxEvent be) {
                hide();
            }
        });
    }
}
Also used : ReportVisibilityDTO(org.activityinfo.shared.dto.ReportVisibilityDTO) MessageBoxEvent(com.extjs.gxt.ui.client.event.MessageBoxEvent) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO)

Example 5 with UserDatabaseDTO

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

the class DimensionPruner method getSelectedActivities.

private Set<ActivityDTO> getSelectedActivities(SchemaDTO schema) {
    Set<ActivityDTO> activities = Sets.newHashSet();
    Set<Integer> indicatorIds = Sets.newHashSet(model.getFilter().getRestrictions(DimensionType.Indicator));
    for (UserDatabaseDTO db : schema.getDatabases()) {
        for (ActivityDTO activity : db.getActivities()) {
            for (IndicatorDTO indicator : activity.getIndicators()) {
                if (indicatorIds.contains(indicator.getId())) {
                    activities.add(activity);
                }
            }
        }
    }
    return activities;
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Aggregations

UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)25 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)13 GetSchema (org.activityinfo.shared.command.GetSchema)10 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)10 Test (org.junit.Test)8 CreateResult (org.activityinfo.shared.command.result.CreateResult)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 CreateEntity (org.activityinfo.shared.command.CreateEntity)3 Filter (org.activityinfo.shared.command.Filter)3 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)3 CountryDTO (org.activityinfo.shared.dto.CountryDTO)3 Date (java.util.Date)2 User (org.activityinfo.server.database.hibernate.entity.User)2 SiteResult (org.activityinfo.shared.command.result.SiteResult)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)2 LocationTypeDTO (org.activityinfo.shared.dto.LocationTypeDTO)2 LockedPeriodDTO (org.activityinfo.shared.dto.LockedPeriodDTO)2 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)2 SiteDTO (org.activityinfo.shared.dto.SiteDTO)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1