DataValueSet.fromJson constructor

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

Implementation

factory DataValueSet.fromJson(Map<String, dynamic> json) {
  final id =
      json['id'] ?? '${json['dataSet']}_${json['orgUnit']}_${json['period']}';

  final DataValueSetImportSummary? lastSyncSummary =
      DataValueSet.getDataValueSetImportSummary(json['lastSyncSummary']);

  final dataValues = json['dataValues'];

  return DataValueSet(
      id: id,
      name: json['name'] ?? id,
      created: json['created'],
      completeDate: json['completeDate'],
      lastUpdated: json['lastUpdated'],
      dirty: json['dirty'],
      synced: json['synced'],
      syncFailed: json['syncFailed'],
      lastSyncSummary: lastSyncSummary,
      lastSyncDate: json['lastSyncDate'],
      period: json['period'],
      orgUnit: json['orgUnit'],
      dataSet: json['dataSet'],
      dataValues: dataValues is List<DataValue>
          ? dataValues
          : List<dynamic>.from(dataValues ?? [])
              .map((dataValue) => DataValue.fromJson(
                  {...dataValue, 'dirty': json['dirty'], 'dataValueSet': id}))
              .toList());
}