Search in sources :

Example 1 with GetDimensionLabels

use of org.activityinfo.shared.command.GetDimensionLabels 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.shared.report.model.DimensionType) GetDimensionLabels(org.activityinfo.shared.command.GetDimensionLabels) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) ArrayList(java.util.ArrayList) GetDimensionLabels(org.activityinfo.shared.command.GetDimensionLabels) DimensionLabels(org.activityinfo.shared.command.GetDimensionLabels.DimensionLabels)

Example 2 with GetDimensionLabels

use of org.activityinfo.shared.command.GetDimensionLabels 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.shared.command.GetDimensionLabels.DimensionLabels) GetDimensionLabels(org.activityinfo.shared.command.GetDimensionLabels) Map(java.util.Map)

Aggregations

GetDimensionLabels (org.activityinfo.shared.command.GetDimensionLabels)2 DimensionLabels (org.activityinfo.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 FilterDescription (org.activityinfo.shared.report.content.FilterDescription)1 DimensionType (org.activityinfo.shared.report.model.DimensionType)1