Search in sources :

Example 6 with ActivityDTO

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

the class LockedPeriodSet method indexLocks.

private void indexLocks(UserDatabaseDTO db) {
    for (ActivityDTO activity : db.getActivities()) {
        addEnabled(activityLocks, activity.getId(), db.getLockedPeriods());
        addEnabled(activityLocks, activity.getId(), activity.getLockedPeriods());
    }
    for (ProjectDTO project : db.getProjects()) {
        addEnabled(projectLocks, project.getId(), project.getLockedPeriods());
    }
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 7 with ActivityDTO

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

the class ColumnModelBuilder method addActivityColumn.

public ColumnModelBuilder addActivityColumn(final UserDatabaseDTO database) {
    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 = database.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 8 with ActivityDTO

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

the class ColumnModelBuilder method addDatabaseColumn.

public ColumnModelBuilder addDatabaseColumn(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.getDatabase().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 9 with ActivityDTO

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

the class SearchPresenter method fromSitesList.

private List<RecentSiteModel> fromSitesList(List<SiteDTO> sites) {
    List<RecentSiteModel> result = new ArrayList<RecentSiteModel>();
    if (sites != null) {
        for (SiteDTO site : sites) {
            RecentSiteModel recent = null;
            if (schema != null) {
                ActivityDTO activity = schema.getActivityById(site.getActivityId());
                if (activity != null) {
                    recent = new RecentSiteModel(site);
                    recent.setActivityName(activity.getName());
                    recent.setActivityLink(PageStateSerializer.asLink(new DataEntryPlace(activity)));
                    recent.setDatabaseName(activity.getDatabase().getName() == null ? "[Database]" : activity.getDatabase().getName());
                }
            }
            if (recent != null) {
                result.add(recent);
            }
        }
    }
    return result;
}
Also used : DataEntryPlace(org.activityinfo.client.page.entry.place.DataEntryPlace) ArrayList(java.util.ArrayList) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 10 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO 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

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