Commit 2541d182 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

refs #1662 using SortedSet instead of List for break variables and measure...

refs #1662 using SortedSet instead of List for break variables and measure types since order influences output
parent 8bb6cb8f
......@@ -8,6 +8,7 @@ import com.nesstar.api.VariableGroup;
import com.nesstar.api.cube.Cube;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public final class ResourceExtractor {
......@@ -45,7 +46,7 @@ public final class ResourceExtractor {
return variable;
}
public static List<Variable> getVariables(List<String> variableIds, Server server) throws MissingResourceException {
public static List<Variable> getVariables(Collection<String> variableIds, Server server) throws MissingResourceException {
String[] varIdArray = variableIds.toArray(new String[variableIds.size()]);
return getVariables(varIdArray, server);
}
......
package com.nesstar.rest.resources;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
......@@ -52,10 +48,10 @@ public class TabulateResource extends AbstractResource {
@GET
@Timed
public Object tabulate(@QueryParam("breakVar") final List<String> breakVariables,
public Object tabulate(@QueryParam("breakVar") final SortedSet<String> breakVariables,
@QueryParam("msrVar") final String measureVariable,
@QueryParam("wgtVar") final List<String> weightVariables,
@QueryParam("msrType") final List<String> measureTypes,
@QueryParam("msrType") final SortedSet<String> measureTypes,
@QueryParam("caseSubset") final String caseSubset,
@PathParam("studyId") final String studyId,
@Context final HttpServletRequest request) {
......@@ -87,14 +83,15 @@ public class TabulateResource extends AbstractResource {
}, serverHandler);
}
private Statistic[] getMeasureTypes(List<String> measureTypes) {
private Statistic[] getMeasureTypes(Collection<String> measureTypes) {
Statistic[] toReturn;
if (measureTypes.isEmpty()) {
toReturn = new Statistic[] { Statistic.COUNT };
} else {
toReturn = new Statistic[measureTypes.size()];
for (int i = 0, measureTypesSize = measureTypes.size(); i < measureTypesSize; i++) {
String measureType = measureTypes.get(i);
Iterator<String> it = measureTypes.iterator();
for (int i = 0; it.hasNext(); i++) {
String measureType = it.next();
toReturn[i] = Statistic.valueOf(measureType);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment