Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Change name of DataTypeRetrieved to Datatypes for frontend consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarvanerp committed Nov 11, 2016
1 parent 5dd040b commit 4a4784e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ExportController {
}

/**GET request on /export/datatypes
* Returns datatypes and patient number of given concepts.
* Returns datatypes and list with subjects of given concepts.
*
*/
def datatypes() throws NoSuchResourceException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.transmartproject.rest.marshallers

import org.transmartproject.export.DataTypeRetrieved
import org.transmartproject.export.Datatypes

class DataTypeSerializationHelper extends AbstractHalOrJsonSerializationHelper<DataTypeRetrieved>{
class DataTypeSerializationHelper extends AbstractHalOrJsonSerializationHelper<Datatypes>{

final Class targetType = DataTypeRetrieved
final String collectionName = 'dataTypeRetrieved'
final Class targetType = Datatypes
final String collectionName = 'datatypes'

@Override
Map<String, Object> convertToMap(DataTypeRetrieved dataTypeRetrieved) {
Map<String, Object> convertToMap(Datatypes datatypes) {
def cohortInfoList = []
def cohortsMap = [:]
dataTypeRetrieved.OntologyTermsMap.each { ID, terms ->
datatypes.OntologyTermsMap.each { ID, terms ->
terms.collect { term ->
if (ID in cohortsMap.keySet()) {
cohortsMap[ID].add([subjects: term.patients.collect({ it.id }), conceptPath: term.fullName])
Expand All @@ -23,8 +23,8 @@ class DataTypeSerializationHelper extends AbstractHalOrJsonSerializationHelper<
cohortsMap.each{ key, value ->
cohortInfoList.add([concepts:value])
}
def datatypeMap = [dataType:dataTypeRetrieved.dataType,
dataTypeCode: dataTypeRetrieved.dataTypeCode,
def datatypeMap = [dataType:datatypes.dataType,
dataTypeCode: datatypes.dataTypeCode,
cohorts:cohortInfoList]
}

Expand Down
3 changes: 1 addition & 2 deletions test/functional/org/transmartproject/rest/ExportTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class ExportTests extends ResourceTestCase{
String version = "v1"


private static final String JSON_CONCEPTS_DATATYPES_URI = "%5B%7B%22conceptKeys%22%3A+%5B%22%5C%5C%5C%5Ci2b2+main%5C%5Cfoo%5C%5Cstudy1%5C%5Cbar%5C%5C%22%5D%7D%2C+%7B%22conceptKeys%22%3A+%5B%22%5C%5C%5C%5Ci2b2+main%5C%5Cfoo%5C%5Cstudy2%5C%5Clong+path%5C%5C%22%2C+%22%5C%5C%5C%5Ci2b2+main%5C%5Cfoo%5C%5Cstudy2%5C%5Csex%5C%5C%22%5D%7D%5D"

private static final String JSON_CONCEPTS_DATATYPES_URI = "%7B%22cohorts%22%3A%20%5B%7B%22conceptKeys%22%3A%20%5B%22%5C%5C%5C%5Ci2b2%20main%5C%5Cfoo%5C%5Cstudy1%5C%5Cbar%5C%5C%22%5D%7D%2C%20%7B%22conceptKeys%22%3A%20%5B%22%5C%5C%5C%5Ci2b2%20main%5C%5Cfoo%5C%5Cstudy2%5C%5Clong%20path%5C%5C%22%2C%20%22%5C%5C%5C%5Ci2b2%20main%5C%5Cfoo%5C%5Cstudy2%5C%5Csex%5C%5C%22%5D%7D%5D%7D"
void testDataTypes() {
get("${baseURL}$version/export/datatypes", { concepts=JSON_CONCEPTS_DATATYPES_URI })
assertStatus 200
Expand Down

0 comments on commit 4a4784e

Please sign in to comment.