Search in sources :

Example 1 with DimensionLabels

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

the class GetDimensionLabelsHandler method execute.

@Override
public void execute(GetDimensionLabels command, ExecutionContext context, final AsyncCallback<DimensionLabels> callback) {
    SqlQuery query = composeQuery(command);
    query.execute(context.getTransaction(), new SqlResultCallback() {

        @Override
        public void onSuccess(SqlTransaction tx, SqlResultSet results) {
            Map<Integer, String> labels = Maps.newHashMap();
            for (SqlResultSetRow row : results.getRows()) {
                labels.put(row.getInt("id"), row.getString("name"));
            }
            callback.onSuccess(new DimensionLabels(labels));
        }
    });
}
Also used : SqlResultSet(com.bedatadriven.rebar.sql.client.SqlResultSet) SqlQuery(com.bedatadriven.rebar.sql.client.query.SqlQuery) SqlResultCallback(com.bedatadriven.rebar.sql.client.SqlResultCallback) SqlTransaction(com.bedatadriven.rebar.sql.client.SqlTransaction) SqlResultSetRow(com.bedatadriven.rebar.sql.client.SqlResultSetRow) DimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels.DimensionLabels) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) Map(java.util.Map)

Example 2 with DimensionLabels

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

the class BaseGenerator method generateFilterDescriptions.

protected List<FilterDescription> generateFilterDescriptions(Filter filter, Set<DimensionType> excludeDims, User user) {
    List<FilterDescription> list = new ArrayList<FilterDescription>();
    Set<DimensionType> filterDims = filter.getRestrictedDimensions();
    filterDims.removeAll(excludeDims);
    for (DimensionType type : filterDims) {
        DimensionLabels labels = dispatcher.execute(new GetDimensionLabels(type, filter.getRestrictions(type)));
        list.add(new FilterDescription(type, labels.getLabels()));
    }
    return list;
}
Also used : DimensionType(org.activityinfo.legacy.shared.command.DimensionType) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) FilterDescription(org.activityinfo.legacy.shared.reports.content.FilterDescription) ArrayList(java.util.ArrayList) GetDimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels) DimensionLabels(org.activityinfo.legacy.shared.command.GetDimensionLabels.DimensionLabels)

Aggregations

GetDimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels)2 DimensionLabels (org.activityinfo.legacy.shared.command.GetDimensionLabels.DimensionLabels)2 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 DimensionType (org.activityinfo.legacy.shared.command.DimensionType)1 FilterDescription (org.activityinfo.legacy.shared.reports.content.FilterDescription)1