Skip to content

Commit

Permalink
string map instead of object map #528
Browse files Browse the repository at this point in the history
  • Loading branch information
julie-sullivan committed Feb 24, 2020
1 parent 781e09a commit 306d6c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,43 +104,6 @@ private Map<String, Class<?>> loadPropertiesMap() {
return internalPropertiesMap;
}

// @Deprecated
// public static <T> T of(Map<String, String> map, Class<T> clazz)
// throws NoSuchFieldException, IllegalAccessException, InstantiationException, InvocationTargetException {
// T query = clazz.newInstance();
// for (Map.Entry<String, String> entry : map.entrySet()) {
// String fieldName = entry.getKey();
// String value = entry.getValue();
// Field field = clazz.getField(fieldName);
//// Method method = clazz.getMethod("set" + fieldName);
// if (fieldName.equals("region")) {
//// method.invoke(Region.parseRegions()); ....
// List<Region> regions = Region.parseRegions(value);
// BeanUtils.setProperty(query, fieldName, regions);
// } else {
// switch (field.getType().toString()) {
// case "Boolean":
// Boolean bool = Boolean.parseBoolean(value);
//// method.invoke(bool);
// BeanUtils.setProperty(query, fieldName, bool);
// break;
// case "Integer":
// Integer intValue = Integer.parseInt(value);
// BeanUtils.setProperty(query, fieldName, intValue);
// break;
// case "List":
// List<String> valuesArray = Arrays.asList(value);
// BeanUtils.setProperty(query, fieldName, valuesArray);
// break;
// default:
// BeanUtils.setProperty(query, fieldName, value);
// break;
// }
// }
// }
// return query;
// }

/**
* Checks if values for query are legal, e.g. >= 0 and <= MAX Checks the following parameters:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import org.opencb.biodata.models.core.Region;
import org.opencb.cellbase.core.api.queries.GeneQuery;

import java.util.HashMap;
import java.util.Map;
import java.util.*;

import static org.junit.Assert.*;

Expand All @@ -44,7 +43,6 @@ public void testQuery() {
paramMap.put("annotationDrugsGene", "x,y");
paramMap.put("xxx", "");

// geneQuery.updateParams(paramMap);
geneQuery = new GeneQuery(paramMap);
assertEquals("1", geneQuery.getIds().get(0));

Expand Down Expand Up @@ -114,4 +112,5 @@ public void testCount() {
geneQuery.updateParams(paramMap);
assertFalse(geneQuery.getCount());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class GenericRestWSServer implements IWSServer {
protected Query query;
protected QueryOptions queryOptions;
protected ObjectMap params;
protected Map<String, Object> uriParams;
protected Map<String, String> uriParams;
protected UriInfo uriInfo;
protected HttpServletRequest httpServletRequest;
protected ObjectMapper jsonObjectMapper;
Expand Down Expand Up @@ -173,8 +173,8 @@ private void checkVersion() throws VersionException {
}
}

public Map<String, Object> convertMultiToMap(MultivaluedMap<String, String> m) {
Map<String, Object> map = new HashMap<String, Object>();
public Map<String, String> convertMultiToMap(MultivaluedMap<String, String> m) {
Map<String, String> map = new HashMap<String, String>();
if (m == null) {
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ public Response getAggregationStats(@DefaultValue("") @QueryParam("fields")
required = false, defaultValue = "0", dataType = "java.util.List", paramType = "query")
})
public Response getAll() throws CellbaseException {
GeneQuery geneQuery = new GeneQuery();
geneQuery.updateParams(uriParams);
GeneQuery geneQuery = new GeneQuery(uriParams);
CellBaseDataResult<Gene> queryResults = geneManager.search(geneQuery);
return createOkResponse(queryResults);
}
Expand Down

0 comments on commit 306d6c5

Please sign in to comment.