DataSet.fromJson constructor

DataSet.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory DataSet.fromJson(Map<String, dynamic> json) {
  return DataSet(
      id: json['id'],
      name: json['name'],
      created: json['created'],
      shortName: json['shortName'],
      code: json['code'],
      displayName: json['displayName'],
      timelyDays: json['timelyDays'],
      formType: json['formType'],
      description: json['description'],
      dirty: json['dirty'],
      expiryDays: json['expiryDays'],
      openFuturePeriods: json['openFuturePeriods'],
      periodType: json['periodType'],
      translations: json['translations'],
      dataSetElements: List<dynamic>.from(json['dataSetElements'] ?? [])
          .map((dataSetElement) => DataSetElement.fromJson({
                ...dataSetElement,
                ...(dataSetElement['dataElement'] ?? {}),
                'id': dataSetElement['id'] ??
                    '${json['id']}_${dataSetElement['dataElement']?['id']}',
                'dataElementId': dataSetElement['dataElementId'] ??
                    dataSetElement['dataElement']?['id'],
                'dataSet': json['id'],
                'dirty': false
              }))
          .toList(),
      sections: List<dynamic>.from(json['sections'] ?? [])
          .map((section) => DataSetSection.fromJson({
                ...section,
                'id': '${json['id']}_${section['id']}',
                'dataSet': json['id'],
                'dirty': false
              }))
          .toList());
}