Source:
public QueryResponse getStudiesStats(@RequestParam(name = "species", required = false) List<String> species, @RequestParam(name = "type", required = false) List<String> types, @RequestParam(name = "structural", defaultValue = "false") boolean structural) { initializeQuery(); if (species != null && !species.isEmpty()) { getQueryOptions().put("species", species); } if (types != null && !types.isEmpty()) { getQueryOptions().put("type", types); } QueryResult<Map.Entry<String, Long>> resultSpecies, resultTypes; if (structural) { resultSpecies = archiveDgvaDbAdaptor.countStudiesPerSpecies(getQueryOptions()); resultTypes = archiveDgvaDbAdaptor.countStudiesPerType(getQueryOptions()); } else { resultSpecies = archiveEvaproDbAdaptor.countStudiesPerSpecies(getQueryOptions()); resultTypes = archiveEvaproDbAdaptor.countStudiesPerType(getQueryOptions()); } QueryResult combinedQueryResult = new QueryResult(); combinedQueryResult.setDbTime(resultSpecies.getDbTime() + resultTypes.getDbTime()); JsonNodeFactory factory = new JsonNodeFactory(true); ObjectNode root = factory.objectNode(); combinedQueryResult.addResult(root); combinedQueryResult.setNumTotalResults(combinedQueryResult.getNumResults()); ObjectNode speciesNode = factory.objectNode(); for (Map.Entry<String, Long> speciesCount : resultSpecies.getResult()) { speciesNode.put(speciesCount.getKey(), speciesCount.getValue()); } root.put("species", speciesNode); ObjectNode typesNode = factory.objectNode(); for (Map.Entry<String, Long> typesCount : resultTypes.getResult()) { typesNode.put(typesCount.getKey(), typesCount.getValue()); } root.put("type", typesNode); return setQueryResponse(combinedQueryResult); }

Target:
public QueryResponse getStudiesStats(@RequestParam(name = "species", required = false) List<String> species, @RequestParam(name = "type", required = false) List<String> types, @RequestParam(name = "structural", defaultValue = "false") boolean structural) { initializeQuery(); QueryOptions queryOptions = getQueryOptions(); if (species != null && !species.isEmpty()) { queryOptions.put("species", species); } if (types != null && !types.isEmpty()) { queryOptions.put("type", types); } QueryResult<Map.Entry<String, Long>> resultSpecies, resultTypes; if (structural) { resultSpecies = archiveDgvaDbAdaptor.countStudiesPerSpecies(queryOptions); resultTypes = archiveDgvaDbAdaptor.countStudiesPerType(queryOptions); } else { resultSpecies = archiveEvaproDbAdaptor.countStudiesPerSpecies(queryOptions); resultTypes = archiveEvaproDbAdaptor.countStudiesPerType(queryOptions); } QueryResult combinedQueryResult = new QueryResult(); combinedQueryResult.setDbTime(resultSpecies.getDbTime() + resultTypes.getDbTime()); JsonNodeFactory factory = new JsonNodeFactory(true); ObjectNode root = factory.objectNode(); combinedQueryResult.addResult(root); combinedQueryResult.setNumTotalResults(combinedQueryResult.getNumResults()); ObjectNode speciesNode = factory.objectNode(); for (Map.Entry<String, Long> speciesCount : resultSpecies.getResult()) { speciesNode.put(speciesCount.getKey(), speciesCount.getValue()); } root.put("species", speciesNode); ObjectNode typesNode = factory.objectNode(); for (Map.Entry<String, Long> typesCount : resultTypes.getResult()) { typesNode.put(typesCount.getKey(), typesCount.getValue()); } root.put("type", typesNode); return setQueryResponse(combinedQueryResult); }