-
Notifications
You must be signed in to change notification settings - Fork 12
Add serializer for DataType retrieval #36
base: gb-dev
Are you sure you want to change the base?
Changes from 4 commits
8b60750
be77f41
4dbaae6
5dd040b
4a4784e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.transmartproject.rest.marshallers | ||
|
||
import org.transmartproject.export.DataTypeRetrieved | ||
|
||
class DataTypeSerializationHelper extends AbstractHalOrJsonSerializationHelper<DataTypeRetrieved>{ | ||
|
||
final Class targetType = DataTypeRetrieved | ||
final String collectionName = 'dataTypeRetrieved' | ||
|
||
@Override | ||
Map<String, Object> convertToMap(DataTypeRetrieved dataTypeRetrieved) { | ||
def cohortInfoList = [] | ||
def cohortsMap = [:] | ||
dataTypeRetrieved.OntologyTermsMap.each { ID, terms -> | ||
terms.collect { term -> | ||
if (ID in cohortsMap.keySet()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you describe the desired control flow here? I am not sure if I get it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The frontend wants to know which concepts are in which cohort. Now a cohort can only contain one study, so the most logical thing to do would be to differentiate between studies. However in the near future cross studies will be added, which would result in this serialiser not functioning properly. So there needed to be a way to easily differentiate between the cohorts. This way it also supports multiple cohorts, which is also planned for the future. So based on (cohort)ID I create the structure for cohorts. |
||
cohortsMap[ID].add([subjects: term.patients.collect({ it.id }), conceptPath: term.fullName]) | ||
} else { | ||
cohortsMap[ID] = [[subjects: term.patients.collect({ it.id }), conceptPath: term.fullName]] | ||
} | ||
} | ||
} | ||
cohortsMap.each{ key, value -> | ||
cohortInfoList.add([concepts:value]) | ||
} | ||
def datatypeMap = [dataType:dataTypeRetrieved.dataType, | ||
dataTypeCode: dataTypeRetrieved.dataTypeCode, | ||
cohorts:cohortInfoList] | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it wrap the noPatients string in a JSON object here?
Why not return an empty Json object instead?