common packages folder added

This commit is contained in:
VINISTAN 2024-11-06 12:31:50 +05:30
parent 822ad32902
commit 639efae8ce
141 changed files with 682293 additions and 27 deletions

View File

@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock

View File

@ -0,0 +1,3 @@
## 1.0.0
- Initial version.

View File

@ -0,0 +1,39 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
## Features
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
```dart
const like = 'sample';
```
## Additional information
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.

View File

@ -0,0 +1,32 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
analyzer:
exclude:
- "lib/assets/**"
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

View File

@ -0,0 +1,41 @@
library;
export 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_electricity_production_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/p_indicators_repo.dart';
export 'src/domain/entities/competitive_report_entity.dart';
export 'src/domain/entities/country.dart';
export 'src/domain/entities/country_fact_entity.dart';
export 'src/domain/entities/country_leader_entity.dart';
export 'src/domain/entities/indicators/indicator_detail.dart';
export 'src/domain/entities/indicators/indicator_level_1_entity.dart';
export 'src/domain/entities/indicators/indicator_topic.dart';
// indicator
export 'src/domain/entities/indicators/indicators_level_2/economic/aircrafts_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/economic/gdp_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/economic/hotels_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/economic/inflation_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/economic/trade_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/environment/electricity_consumption_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/environment/electricity_production_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/environment/natural_reserves_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/environment/oil_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/environment/water_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/social/general_education_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/social/higher_education_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/social/hospitals_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/social/labor_force_entity.dart';
export 'src/domain/entities/indicators/indicators_level_2/social/population_entity.dart';
// ENTITIES
// misc
export 'src/domain/entities/language_locale.dart';
export 'src/domain/entities/publisher.dart';
export 'src/domain/entities/report_entity.dart';
export 'src/domain/entities/specific_detail_box_data.dart';
export 'src/domain/entities/trade_commodity_entity.dart';
// REPOS
// misc
export 'src/infrastructure/data/ext_competitive_reports_repo.dart';
export 'src/infrastructure/data/ext_country_facts_repo.dart';
export 'src/infrastructure/data/ext_country_leaders_repo.dart';
export 'src/infrastructure/data/ext_trade_commodity_repo.dart';

View File

@ -0,0 +1,101 @@
import 'package:external_repos/src/domain/entities/country.dart';
import 'package:external_repos/src/domain/entities/publisher.dart';
import 'package:json_annotation/json_annotation.dart';
part 'competitive_report_entity.g.dart';
@JsonSerializable()
class CompetitivenessReportEntity {
const CompetitivenessReportEntity({
required this.latestYear,
required this.latestRank,
required this.previousYear,
required this.previousRank,
required this.publisher,
required this.reportCode,
required this.nameEN,
required this.nameAR,
required this.descriptionEN,
required this.descriptionAR,
required this.firstArabCountry,
required this.firstGCCCountry,
required this.firstGloballyCountry,
});
final int latestYear;
final int latestRank;
final int? previousYear;
final int? previousRank;
final Publisher publisher;
final String reportCode;
final String nameEN;
final String nameAR;
final String descriptionEN;
final String descriptionAR;
final ISOCountry firstGloballyCountry;
final ISOCountry firstArabCountry;
final ISOCountry firstGCCCountry;
bool get hasPreviousEditionYearAndRank =>
previousRank != null && previousYear != null;
bool? get didRankImprove {
if (!hasPreviousEditionYearAndRank) return null;
if (latestRank == previousRank!) return null;
return latestRank < previousRank!;
}
bool matchSearch(String term) {
for (var e in [
publisher,
reportCode,
nameEN,
nameAR,
]) {
if (term.toLowerCase().contains(e.toString().toLowerCase())) return true;
if (e.toString().toLowerCase().contains(term.toLowerCase())) return true;
}
return false;
}
factory CompetitivenessReportEntity.fromJson(Map<String, dynamic> json) =>
_$CompetitivenessReportEntityFromJson(json);
Map<String, dynamic> toJson() => _$CompetitivenessReportEntityToJson(this);
@override
bool operator ==(covariant CompetitivenessReportEntity other) {
if (identical(this, other)) return true;
return other.latestYear == latestYear &&
other.latestRank == latestRank &&
other.previousYear == previousYear &&
other.previousRank == previousRank &&
other.publisher == publisher &&
other.reportCode == reportCode &&
other.nameEN == nameEN &&
other.nameAR == nameAR &&
other.descriptionEN == descriptionEN &&
other.descriptionAR == descriptionAR &&
other.firstGloballyCountry == firstGloballyCountry &&
other.firstArabCountry == firstArabCountry &&
other.firstGCCCountry == firstGCCCountry;
}
@override
int get hashCode {
return latestYear.hashCode ^
latestRank.hashCode ^
previousYear.hashCode ^
previousRank.hashCode ^
publisher.hashCode ^
reportCode.hashCode ^
nameEN.hashCode ^
nameAR.hashCode ^
descriptionEN.hashCode ^
descriptionAR.hashCode ^
firstGloballyCountry.hashCode ^
firstArabCountry.hashCode ^
firstGCCCountry.hashCode;
}
}

View File

@ -0,0 +1,317 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'competitive_report_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CompetitivenessReportEntity _$CompetitivenessReportEntityFromJson(
Map<String, dynamic> json) =>
CompetitivenessReportEntity(
latestYear: (json['latestYear'] as num).toInt(),
latestRank: (json['latestRank'] as num).toInt(),
previousYear: (json['previousYear'] as num?)?.toInt(),
previousRank: (json['previousRank'] as num?)?.toInt(),
publisher: $enumDecode(_$PublisherEnumMap, json['publisher']),
reportCode: json['reportCode'] as String,
nameEN: json['nameEN'] as String,
nameAR: json['nameAR'] as String,
descriptionEN: json['descriptionEN'] as String,
descriptionAR: json['descriptionAR'] as String,
firstArabCountry:
$enumDecode(_$ISOCountryEnumMap, json['firstArabCountry']),
firstGCCCountry:
$enumDecode(_$ISOCountryEnumMap, json['firstGCCCountry']),
firstGloballyCountry:
$enumDecode(_$ISOCountryEnumMap, json['firstGloballyCountry']),
);
Map<String, dynamic> _$CompetitivenessReportEntityToJson(
CompetitivenessReportEntity instance) =>
<String, dynamic>{
'latestYear': instance.latestYear,
'latestRank': instance.latestRank,
'previousYear': instance.previousYear,
'previousRank': instance.previousRank,
'publisher': _$PublisherEnumMap[instance.publisher]!,
'reportCode': instance.reportCode,
'nameEN': instance.nameEN,
'nameAR': instance.nameAR,
'descriptionEN': instance.descriptionEN,
'descriptionAR': instance.descriptionAR,
'firstGloballyCountry':
_$ISOCountryEnumMap[instance.firstGloballyCountry]!,
'firstArabCountry': _$ISOCountryEnumMap[instance.firstArabCountry]!,
'firstGCCCountry': _$ISOCountryEnumMap[instance.firstGCCCountry]!,
};
const _$PublisherEnumMap = {
Publisher.bf: 'BF',
Publisher.bs: 'BS',
Publisher.iep: 'IEP',
Publisher.imd: 'IMD',
Publisher.insead: 'INSEAD',
Publisher.legatum: 'LEGATUM',
Publisher.openData: 'ODIN',
Publisher.spi: 'SPI',
Publisher.un: 'UN',
Publisher.unido: 'UNIDO',
Publisher.unsdsn: 'UNSDSN',
Publisher.wb: 'WB',
Publisher.wef: 'WEF',
Publisher.wipo: 'WIPO',
};
const _$ISOCountryEnumMap = {
ISOCountry.numeric533: 533,
ISOCountry.numeric4: 4,
ISOCountry.numeric24: 24,
ISOCountry.numeric660: 660,
ISOCountry.numeric248: 248,
ISOCountry.numeric8: 8,
ISOCountry.numeric20: 20,
ISOCountry.numeric784: 784,
ISOCountry.numeric32: 32,
ISOCountry.numeric51: 51,
ISOCountry.numeric16: 16,
ISOCountry.numeric10: 10,
ISOCountry.numeric260: 260,
ISOCountry.numeric28: 28,
ISOCountry.numeric36: 36,
ISOCountry.numeric40: 40,
ISOCountry.numeric31: 31,
ISOCountry.numeric108: 108,
ISOCountry.numeric56: 56,
ISOCountry.numeric204: 204,
ISOCountry.numeric854: 854,
ISOCountry.numeric50: 50,
ISOCountry.numeric100: 100,
ISOCountry.numeric48: 48,
ISOCountry.numeric44: 44,
ISOCountry.numeric70: 70,
ISOCountry.numeric652: 652,
ISOCountry.numeric654: 654,
ISOCountry.numeric112: 112,
ISOCountry.numeric84: 84,
ISOCountry.numeric60: 60,
ISOCountry.numeric68: 68,
ISOCountry.numeric535: 535,
ISOCountry.numeric76: 76,
ISOCountry.numeric52: 52,
ISOCountry.numeric96: 96,
ISOCountry.numeric64: 64,
ISOCountry.numeric74: 74,
ISOCountry.numeric72: 72,
ISOCountry.numeric140: 140,
ISOCountry.numeric124: 124,
ISOCountry.numeric166: 166,
ISOCountry.numeric756: 756,
ISOCountry.numeric152: 152,
ISOCountry.numeric156: 156,
ISOCountry.numeric384: 384,
ISOCountry.numeric120: 120,
ISOCountry.numeric180: 180,
ISOCountry.numeric178: 178,
ISOCountry.numeric184: 184,
ISOCountry.numeric170: 170,
ISOCountry.numeric174: 174,
ISOCountry.numeric132: 132,
ISOCountry.numeric188: 188,
ISOCountry.numeric192: 192,
ISOCountry.numeric531: 531,
ISOCountry.numeric162: 162,
ISOCountry.numeric136: 136,
ISOCountry.numeric196: 196,
ISOCountry.numeric203: 203,
ISOCountry.numeric276: 276,
ISOCountry.numeric262: 262,
ISOCountry.numeric212: 212,
ISOCountry.numeric208: 208,
ISOCountry.numeric214: 214,
ISOCountry.numeric12: 12,
ISOCountry.numeric218: 218,
ISOCountry.numeric818: 818,
ISOCountry.numeric232: 232,
ISOCountry.numeric732: 732,
ISOCountry.numeric724: 724,
ISOCountry.numeric233: 233,
ISOCountry.numeric231: 231,
ISOCountry.numeric246: 246,
ISOCountry.numeric242: 242,
ISOCountry.numeric238: 238,
ISOCountry.numeric250: 250,
ISOCountry.numeric234: 234,
ISOCountry.numeric583: 583,
ISOCountry.numeric266: 266,
ISOCountry.numeric826: 826,
ISOCountry.numeric268: 268,
ISOCountry.numeric831: 831,
ISOCountry.numeric288: 288,
ISOCountry.numeric292: 292,
ISOCountry.numeric324: 324,
ISOCountry.numeric312: 312,
ISOCountry.numeric270: 270,
ISOCountry.numeric624: 624,
ISOCountry.numeric226: 226,
ISOCountry.numeric300: 300,
ISOCountry.numeric308: 308,
ISOCountry.numeric304: 304,
ISOCountry.numeric320: 320,
ISOCountry.numeric254: 254,
ISOCountry.numeric316: 316,
ISOCountry.numeric328: 328,
ISOCountry.numeric344: 344,
ISOCountry.numeric334: 334,
ISOCountry.numeric340: 340,
ISOCountry.numeric191: 191,
ISOCountry.numeric332: 332,
ISOCountry.numeric348: 348,
ISOCountry.numeric360: 360,
ISOCountry.numeric833: 833,
ISOCountry.numeric356: 356,
ISOCountry.numeric86: 86,
ISOCountry.numeric372: 372,
ISOCountry.numeric364: 364,
ISOCountry.numeric368: 368,
ISOCountry.numeric352: 352,
ISOCountry.numeric376: 376,
ISOCountry.numeric380: 380,
ISOCountry.numeric388: 388,
ISOCountry.numeric832: 832,
ISOCountry.numeric400: 400,
ISOCountry.numeric392: 392,
ISOCountry.numeric398: 398,
ISOCountry.numeric404: 404,
ISOCountry.numeric417: 417,
ISOCountry.numeric116: 116,
ISOCountry.numeric296: 296,
ISOCountry.numeric659: 659,
ISOCountry.numeric410: 410,
ISOCountry.numeric153: 153,
ISOCountry.numeric414: 414,
ISOCountry.numeric418: 418,
ISOCountry.numeric422: 422,
ISOCountry.numeric430: 430,
ISOCountry.numeric434: 434,
ISOCountry.numeric662: 662,
ISOCountry.numeric438: 438,
ISOCountry.numeric144: 144,
ISOCountry.numeric426: 426,
ISOCountry.numeric440: 440,
ISOCountry.numeric442: 442,
ISOCountry.numeric428: 428,
ISOCountry.numeric446: 446,
ISOCountry.numeric663: 663,
ISOCountry.numeric504: 504,
ISOCountry.numeric492: 492,
ISOCountry.numeric498: 498,
ISOCountry.numeric450: 450,
ISOCountry.numeric462: 462,
ISOCountry.numeric484: 484,
ISOCountry.numeric584: 584,
ISOCountry.numeric807: 807,
ISOCountry.numeric466: 466,
ISOCountry.numeric470: 470,
ISOCountry.numeric104: 104,
ISOCountry.numeric499: 499,
ISOCountry.numeric496: 496,
ISOCountry.numeric580: 580,
ISOCountry.numeric508: 508,
ISOCountry.numeric478: 478,
ISOCountry.numeric500: 500,
ISOCountry.numeric474: 474,
ISOCountry.numeric480: 480,
ISOCountry.numeric454: 454,
ISOCountry.numeric458: 458,
ISOCountry.numeric175: 175,
ISOCountry.numeric516: 516,
ISOCountry.numeric540: 540,
ISOCountry.numeric562: 562,
ISOCountry.numeric574: 574,
ISOCountry.numeric566: 566,
ISOCountry.numeric558: 558,
ISOCountry.numeric570: 570,
ISOCountry.numeric528: 528,
ISOCountry.numeric578: 578,
ISOCountry.numeric524: 524,
ISOCountry.numeric520: 520,
ISOCountry.numeric554: 554,
ISOCountry.numeric512: 512,
ISOCountry.numeric586: 586,
ISOCountry.numeric591: 591,
ISOCountry.numeric612: 612,
ISOCountry.numeric604: 604,
ISOCountry.numeric608: 608,
ISOCountry.numeric585: 585,
ISOCountry.numeric598: 598,
ISOCountry.numeric616: 616,
ISOCountry.numeric630: 630,
ISOCountry.numeric408: 408,
ISOCountry.numeric620: 620,
ISOCountry.numeric600: 600,
ISOCountry.numeric275: 275,
ISOCountry.numeric258: 258,
ISOCountry.numeric634: 634,
ISOCountry.numeric638: 638,
ISOCountry.numeric642: 642,
ISOCountry.numeric643: 643,
ISOCountry.numeric646: 646,
ISOCountry.numeric682: 682,
ISOCountry.numeric729: 729,
ISOCountry.numeric686: 686,
ISOCountry.numeric702: 702,
ISOCountry.numeric239: 239,
ISOCountry.numeric744: 744,
ISOCountry.numeric90: 90,
ISOCountry.numeric694: 694,
ISOCountry.numeric222: 222,
ISOCountry.numeric674: 674,
ISOCountry.numeric706: 706,
ISOCountry.numeric666: 666,
ISOCountry.numeric688: 688,
ISOCountry.numeric728: 728,
ISOCountry.numeric678: 678,
ISOCountry.numeric740: 740,
ISOCountry.numeric703: 703,
ISOCountry.numeric705: 705,
ISOCountry.numeric752: 752,
ISOCountry.numeric748: 748,
ISOCountry.numeric534: 534,
ISOCountry.numeric690: 690,
ISOCountry.numeric760: 760,
ISOCountry.numeric796: 796,
ISOCountry.numeric148: 148,
ISOCountry.numeric768: 768,
ISOCountry.numeric764: 764,
ISOCountry.numeric762: 762,
ISOCountry.numeric772: 772,
ISOCountry.numeric795: 795,
ISOCountry.numeric626: 626,
ISOCountry.numeric776: 776,
ISOCountry.numeric780: 780,
ISOCountry.numeric788: 788,
ISOCountry.numeric792: 792,
ISOCountry.numeric798: 798,
ISOCountry.numeric158: 158,
ISOCountry.numeric834: 834,
ISOCountry.numeric800: 800,
ISOCountry.numeric804: 804,
ISOCountry.numeric581: 581,
ISOCountry.numeric858: 858,
ISOCountry.numeric840: 840,
ISOCountry.numeric860: 860,
ISOCountry.numeric336: 336,
ISOCountry.numeric670: 670,
ISOCountry.numeric862: 862,
ISOCountry.numeric92: 92,
ISOCountry.numeric850: 850,
ISOCountry.numeric704: 704,
ISOCountry.numeric548: 548,
ISOCountry.numeric876: 876,
ISOCountry.numeric882: 882,
ISOCountry.numeric887: 887,
ISOCountry.numeric710: 710,
ISOCountry.numeric894: 894,
ISOCountry.numeric716: 716,
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,144 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:external_repos/external_repos.dart';
import 'package:json_annotation/json_annotation.dart';
import 'country.dart';
part 'country_fact_entity.g.dart';
@JsonEnum()
enum FactCategory { demography, fdi, gdp, trade }
mixin Compare<CountryFactEntity> implements Comparable<CountryFactEntity> {
bool operator <=(CountryFactEntity other) => compareTo(other) <= 0;
bool operator >=(CountryFactEntity other) => compareTo(other) >= 0;
bool operator <(CountryFactEntity other) => compareTo(other) < 0;
bool operator >(CountryFactEntity other) => compareTo(other) > 0;
}
@JsonSerializable()
class CountryFactEntity with Compare<CountryFactEntity> {
const CountryFactEntity({
required this.year,
required this.country,
required this.valueEN,
required dynamic valueAR,
required this.nameEN,
}) : _valueAR = valueAR;
final ISOCountry country;
final int year;
final Object valueEN;
final Object? _valueAR;
Object get valueAR => _valueAR ?? valueEN;
final String nameEN;
String? get nameAR => _nameENtoNameAR[nameEN];
static const Map<String, String> _nameENtoNameAR = {
'Capital City': 'العاصمة',
'Foreign direct investment, net inflows (BoP, current US\$)':
'الاستثمار المباشر الأجنبي ، صافي التدفقات (BOP ، \$ الحالية)',
'Foreign direct investment, net outflows (BoP, current US\$)':
'الاستثمار الأجنبي المباشر ، صافي التدفقات الخارجية (BOP ، \$ الحالي)',
'Foreign direct investment, net (BoP, current US\$)':
'الاستثمار الأجنبي المباشر ، صافي (BOP ، دولار أمريكي الحالي)',
'Exports of goods and services (current US\$)':
'صادرات السلع والخدمات (الحالية \$)',
'Imports of goods and services (current US\$)':
'واردات السلع والخدمات (الحالية الأمريكية)',
'Surface area (sq. km)': 'مساحة السطح (متر مربع)',
'GDP per capita (current US\$)': 'الناتج المحلي الإجمالي للفرد (الحالي \$)',
'GDP (constant 2015 US\$)': 'الناتج المحلي الإجمالي (2015 \$ \$)',
'GDP (current US\$)': 'الناتج المحلي الإجمالي (الحالي دولار أمريكي)',
'Population, total': 'السكان ، المجموع',
'Population, male (% of total population)':
'السكان ، الذكور (? من إجمالي السكان)',
'Population Female (% Of Total Population)':
'عدد السكان (? من إجمالي السكان)',
'Unemployment, male (% of male labor force) (modeled ILO estimate)':
'البطالة ، الذكور (? من القوى العاملة الذكور) (تقدير منظمة العمل الدولية على غرار)',
'Unemployment, female (% of female labor force) (modeled ILO estimate)':
'البطالة ، أنثى (? من القوى العاملة الإناث) (تقدير منظمة العمل الدولية على غرار)',
};
static const Map<FactCategory, List<String>> _categoryToNameENs = {
FactCategory.demography: [
'Capital City',
'Surface area (sq. km)',
'Population, total',
'Population, male (% of total population)',
'Population Female (% Of Total Population)',
'Unemployment, male (% of male labor force) (modeled ILO estimate)',
'Unemployment, female (% of female labor force) (modeled ILO estimate)',
],
FactCategory.gdp: [
'GDP per capita (current US\$)',
'GDP (constant 2015 US\$)',
'GDP (current US\$)',
],
FactCategory.trade: [
'Exports of goods and services (current US\$)',
'Imports of goods and services (current US\$)',
],
FactCategory.fdi: [
'Foreign direct investment, net inflows (BoP, current US\$)',
'Foreign direct investment, net outflows (BoP, current US\$)',
'Foreign direct investment, net (BoP, current US\$)',
],
};
static const _priority = [
'Capital City',
'Population, total',
'Population, male (% of total population)',
'Population Female (% Of Total Population)',
'Unemployment, male (% of male labor force) (modeled ILO estimate)',
'Unemployment, female (% of female labor force) (modeled ILO estimate)',
'GDP per capita (current US\$)',
'GDP (constant 2015 US\$)',
'GDP (current US\$)',
'Exports of goods and services (current US\$)',
'Imports of goods and services (current US\$)',
'Foreign direct investment, net inflows (BoP, current US\$)',
'Foreign direct investment, net outflows (BoP, current US\$)',
'Foreign direct investment, net (BoP, current US\$)',
];
@override
int compareTo(CountryFactEntity other) => _priority.indexOf(nameEN).compareTo(
_priority.indexOf(other.nameEN),
);
factory CountryFactEntity.fromJson(
Map<String, dynamic> json,
) =>
_$CountryFactEntityFromJson(json);
Map<String, dynamic> toJson() => _$CountryFactEntityToJson(this);
FactCategory? get factCategory {
for (final m in _categoryToNameENs.entries) {
if (m.value.contains(nameEN)) return m.key;
}
return null;
}
@override
bool operator ==(covariant CountryFactEntity other) {
if (identical(this, other)) return true;
return other.country == country &&
other.year == year &&
other.valueEN == valueEN &&
other.nameEN == nameEN;
}
@override
int get hashCode {
return country.hashCode ^
year.hashCode ^
valueEN.hashCode ^
_valueAR.hashCode ^
nameEN.hashCode;
}
}

View File

@ -0,0 +1,278 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'country_fact_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CountryFactEntity _$CountryFactEntityFromJson(Map<String, dynamic> json) =>
CountryFactEntity(
year: (json['year'] as num).toInt(),
country: $enumDecode(_$ISOCountryEnumMap, json['country']),
valueEN: json['valueEN'] as Object,
valueAR: json['valueAR'],
nameEN: json['nameEN'] as String,
);
Map<String, dynamic> _$CountryFactEntityToJson(CountryFactEntity instance) =>
<String, dynamic>{
'country': _$ISOCountryEnumMap[instance.country]!,
'year': instance.year,
'valueEN': instance.valueEN,
'valueAR': instance.valueAR,
'nameEN': instance.nameEN,
};
const _$ISOCountryEnumMap = {
ISOCountry.numeric533: 533,
ISOCountry.numeric4: 4,
ISOCountry.numeric24: 24,
ISOCountry.numeric660: 660,
ISOCountry.numeric248: 248,
ISOCountry.numeric8: 8,
ISOCountry.numeric20: 20,
ISOCountry.numeric784: 784,
ISOCountry.numeric32: 32,
ISOCountry.numeric51: 51,
ISOCountry.numeric16: 16,
ISOCountry.numeric10: 10,
ISOCountry.numeric260: 260,
ISOCountry.numeric28: 28,
ISOCountry.numeric36: 36,
ISOCountry.numeric40: 40,
ISOCountry.numeric31: 31,
ISOCountry.numeric108: 108,
ISOCountry.numeric56: 56,
ISOCountry.numeric204: 204,
ISOCountry.numeric854: 854,
ISOCountry.numeric50: 50,
ISOCountry.numeric100: 100,
ISOCountry.numeric48: 48,
ISOCountry.numeric44: 44,
ISOCountry.numeric70: 70,
ISOCountry.numeric652: 652,
ISOCountry.numeric654: 654,
ISOCountry.numeric112: 112,
ISOCountry.numeric84: 84,
ISOCountry.numeric60: 60,
ISOCountry.numeric68: 68,
ISOCountry.numeric535: 535,
ISOCountry.numeric76: 76,
ISOCountry.numeric52: 52,
ISOCountry.numeric96: 96,
ISOCountry.numeric64: 64,
ISOCountry.numeric74: 74,
ISOCountry.numeric72: 72,
ISOCountry.numeric140: 140,
ISOCountry.numeric124: 124,
ISOCountry.numeric166: 166,
ISOCountry.numeric756: 756,
ISOCountry.numeric152: 152,
ISOCountry.numeric156: 156,
ISOCountry.numeric384: 384,
ISOCountry.numeric120: 120,
ISOCountry.numeric180: 180,
ISOCountry.numeric178: 178,
ISOCountry.numeric184: 184,
ISOCountry.numeric170: 170,
ISOCountry.numeric174: 174,
ISOCountry.numeric132: 132,
ISOCountry.numeric188: 188,
ISOCountry.numeric192: 192,
ISOCountry.numeric531: 531,
ISOCountry.numeric162: 162,
ISOCountry.numeric136: 136,
ISOCountry.numeric196: 196,
ISOCountry.numeric203: 203,
ISOCountry.numeric276: 276,
ISOCountry.numeric262: 262,
ISOCountry.numeric212: 212,
ISOCountry.numeric208: 208,
ISOCountry.numeric214: 214,
ISOCountry.numeric12: 12,
ISOCountry.numeric218: 218,
ISOCountry.numeric818: 818,
ISOCountry.numeric232: 232,
ISOCountry.numeric732: 732,
ISOCountry.numeric724: 724,
ISOCountry.numeric233: 233,
ISOCountry.numeric231: 231,
ISOCountry.numeric246: 246,
ISOCountry.numeric242: 242,
ISOCountry.numeric238: 238,
ISOCountry.numeric250: 250,
ISOCountry.numeric234: 234,
ISOCountry.numeric583: 583,
ISOCountry.numeric266: 266,
ISOCountry.numeric826: 826,
ISOCountry.numeric268: 268,
ISOCountry.numeric831: 831,
ISOCountry.numeric288: 288,
ISOCountry.numeric292: 292,
ISOCountry.numeric324: 324,
ISOCountry.numeric312: 312,
ISOCountry.numeric270: 270,
ISOCountry.numeric624: 624,
ISOCountry.numeric226: 226,
ISOCountry.numeric300: 300,
ISOCountry.numeric308: 308,
ISOCountry.numeric304: 304,
ISOCountry.numeric320: 320,
ISOCountry.numeric254: 254,
ISOCountry.numeric316: 316,
ISOCountry.numeric328: 328,
ISOCountry.numeric344: 344,
ISOCountry.numeric334: 334,
ISOCountry.numeric340: 340,
ISOCountry.numeric191: 191,
ISOCountry.numeric332: 332,
ISOCountry.numeric348: 348,
ISOCountry.numeric360: 360,
ISOCountry.numeric833: 833,
ISOCountry.numeric356: 356,
ISOCountry.numeric86: 86,
ISOCountry.numeric372: 372,
ISOCountry.numeric364: 364,
ISOCountry.numeric368: 368,
ISOCountry.numeric352: 352,
ISOCountry.numeric376: 376,
ISOCountry.numeric380: 380,
ISOCountry.numeric388: 388,
ISOCountry.numeric832: 832,
ISOCountry.numeric400: 400,
ISOCountry.numeric392: 392,
ISOCountry.numeric398: 398,
ISOCountry.numeric404: 404,
ISOCountry.numeric417: 417,
ISOCountry.numeric116: 116,
ISOCountry.numeric296: 296,
ISOCountry.numeric659: 659,
ISOCountry.numeric410: 410,
ISOCountry.numeric153: 153,
ISOCountry.numeric414: 414,
ISOCountry.numeric418: 418,
ISOCountry.numeric422: 422,
ISOCountry.numeric430: 430,
ISOCountry.numeric434: 434,
ISOCountry.numeric662: 662,
ISOCountry.numeric438: 438,
ISOCountry.numeric144: 144,
ISOCountry.numeric426: 426,
ISOCountry.numeric440: 440,
ISOCountry.numeric442: 442,
ISOCountry.numeric428: 428,
ISOCountry.numeric446: 446,
ISOCountry.numeric663: 663,
ISOCountry.numeric504: 504,
ISOCountry.numeric492: 492,
ISOCountry.numeric498: 498,
ISOCountry.numeric450: 450,
ISOCountry.numeric462: 462,
ISOCountry.numeric484: 484,
ISOCountry.numeric584: 584,
ISOCountry.numeric807: 807,
ISOCountry.numeric466: 466,
ISOCountry.numeric470: 470,
ISOCountry.numeric104: 104,
ISOCountry.numeric499: 499,
ISOCountry.numeric496: 496,
ISOCountry.numeric580: 580,
ISOCountry.numeric508: 508,
ISOCountry.numeric478: 478,
ISOCountry.numeric500: 500,
ISOCountry.numeric474: 474,
ISOCountry.numeric480: 480,
ISOCountry.numeric454: 454,
ISOCountry.numeric458: 458,
ISOCountry.numeric175: 175,
ISOCountry.numeric516: 516,
ISOCountry.numeric540: 540,
ISOCountry.numeric562: 562,
ISOCountry.numeric574: 574,
ISOCountry.numeric566: 566,
ISOCountry.numeric558: 558,
ISOCountry.numeric570: 570,
ISOCountry.numeric528: 528,
ISOCountry.numeric578: 578,
ISOCountry.numeric524: 524,
ISOCountry.numeric520: 520,
ISOCountry.numeric554: 554,
ISOCountry.numeric512: 512,
ISOCountry.numeric586: 586,
ISOCountry.numeric591: 591,
ISOCountry.numeric612: 612,
ISOCountry.numeric604: 604,
ISOCountry.numeric608: 608,
ISOCountry.numeric585: 585,
ISOCountry.numeric598: 598,
ISOCountry.numeric616: 616,
ISOCountry.numeric630: 630,
ISOCountry.numeric408: 408,
ISOCountry.numeric620: 620,
ISOCountry.numeric600: 600,
ISOCountry.numeric275: 275,
ISOCountry.numeric258: 258,
ISOCountry.numeric634: 634,
ISOCountry.numeric638: 638,
ISOCountry.numeric642: 642,
ISOCountry.numeric643: 643,
ISOCountry.numeric646: 646,
ISOCountry.numeric682: 682,
ISOCountry.numeric729: 729,
ISOCountry.numeric686: 686,
ISOCountry.numeric702: 702,
ISOCountry.numeric239: 239,
ISOCountry.numeric744: 744,
ISOCountry.numeric90: 90,
ISOCountry.numeric694: 694,
ISOCountry.numeric222: 222,
ISOCountry.numeric674: 674,
ISOCountry.numeric706: 706,
ISOCountry.numeric666: 666,
ISOCountry.numeric688: 688,
ISOCountry.numeric728: 728,
ISOCountry.numeric678: 678,
ISOCountry.numeric740: 740,
ISOCountry.numeric703: 703,
ISOCountry.numeric705: 705,
ISOCountry.numeric752: 752,
ISOCountry.numeric748: 748,
ISOCountry.numeric534: 534,
ISOCountry.numeric690: 690,
ISOCountry.numeric760: 760,
ISOCountry.numeric796: 796,
ISOCountry.numeric148: 148,
ISOCountry.numeric768: 768,
ISOCountry.numeric764: 764,
ISOCountry.numeric762: 762,
ISOCountry.numeric772: 772,
ISOCountry.numeric795: 795,
ISOCountry.numeric626: 626,
ISOCountry.numeric776: 776,
ISOCountry.numeric780: 780,
ISOCountry.numeric788: 788,
ISOCountry.numeric792: 792,
ISOCountry.numeric798: 798,
ISOCountry.numeric158: 158,
ISOCountry.numeric834: 834,
ISOCountry.numeric800: 800,
ISOCountry.numeric804: 804,
ISOCountry.numeric581: 581,
ISOCountry.numeric858: 858,
ISOCountry.numeric840: 840,
ISOCountry.numeric860: 860,
ISOCountry.numeric336: 336,
ISOCountry.numeric670: 670,
ISOCountry.numeric862: 862,
ISOCountry.numeric92: 92,
ISOCountry.numeric850: 850,
ISOCountry.numeric704: 704,
ISOCountry.numeric548: 548,
ISOCountry.numeric876: 876,
ISOCountry.numeric882: 882,
ISOCountry.numeric887: 887,
ISOCountry.numeric710: 710,
ISOCountry.numeric894: 894,
ISOCountry.numeric716: 716,
};

View File

@ -0,0 +1,62 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:json_annotation/json_annotation.dart';
import 'country.dart';
part 'country_leader_entity.g.dart';
@JsonSerializable()
class CountryLeaderEntity {
const CountryLeaderEntity({
required this.id,
required this.priorityScore,
required this.country,
required this.imgPath,
required this.nameEN,
required this.nameAR,
required this.designationEN,
required this.designationAR,
});
final int id;
final ISOCountry country;
final String? imgPath;
final String nameEN;
final String nameAR;
final String designationEN;
final String designationAR;
final int priorityScore;
factory CountryLeaderEntity.fromJson(
Map<String, dynamic> json,
) =>
_$CountryLeaderEntityFromJson(json);
Map<String, dynamic> toJson() => _$CountryLeaderEntityToJson(this);
@override
bool operator ==(covariant CountryLeaderEntity other) {
if (identical(this, other)) return true;
return other.id == id &&
other.country == country &&
other.imgPath == imgPath &&
other.nameEN == nameEN &&
other.nameAR == nameAR &&
other.designationEN == designationEN &&
other.designationAR == designationAR &&
other.priorityScore == priorityScore;
}
@override
int get hashCode {
return id.hashCode ^
country.hashCode ^
imgPath.hashCode ^
nameEN.hashCode ^
nameAR.hashCode ^
designationEN.hashCode ^
designationAR.hashCode ^
priorityScore.hashCode;
}
}

View File

@ -0,0 +1,285 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'country_leader_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CountryLeaderEntity _$CountryLeaderEntityFromJson(Map<String, dynamic> json) =>
CountryLeaderEntity(
id: (json['id'] as num).toInt(),
priorityScore: (json['priorityScore'] as num).toInt(),
country: $enumDecode(_$ISOCountryEnumMap, json['country']),
imgPath: json['imgPath'] as String?,
nameEN: json['nameEN'] as String,
nameAR: json['nameAR'] as String,
designationEN: json['designationEN'] as String,
designationAR: json['designationAR'] as String,
);
Map<String, dynamic> _$CountryLeaderEntityToJson(
CountryLeaderEntity instance) =>
<String, dynamic>{
'id': instance.id,
'country': _$ISOCountryEnumMap[instance.country]!,
'imgPath': instance.imgPath,
'nameEN': instance.nameEN,
'nameAR': instance.nameAR,
'designationEN': instance.designationEN,
'designationAR': instance.designationAR,
'priorityScore': instance.priorityScore,
};
const _$ISOCountryEnumMap = {
ISOCountry.numeric533: 533,
ISOCountry.numeric4: 4,
ISOCountry.numeric24: 24,
ISOCountry.numeric660: 660,
ISOCountry.numeric248: 248,
ISOCountry.numeric8: 8,
ISOCountry.numeric20: 20,
ISOCountry.numeric784: 784,
ISOCountry.numeric32: 32,
ISOCountry.numeric51: 51,
ISOCountry.numeric16: 16,
ISOCountry.numeric10: 10,
ISOCountry.numeric260: 260,
ISOCountry.numeric28: 28,
ISOCountry.numeric36: 36,
ISOCountry.numeric40: 40,
ISOCountry.numeric31: 31,
ISOCountry.numeric108: 108,
ISOCountry.numeric56: 56,
ISOCountry.numeric204: 204,
ISOCountry.numeric854: 854,
ISOCountry.numeric50: 50,
ISOCountry.numeric100: 100,
ISOCountry.numeric48: 48,
ISOCountry.numeric44: 44,
ISOCountry.numeric70: 70,
ISOCountry.numeric652: 652,
ISOCountry.numeric654: 654,
ISOCountry.numeric112: 112,
ISOCountry.numeric84: 84,
ISOCountry.numeric60: 60,
ISOCountry.numeric68: 68,
ISOCountry.numeric535: 535,
ISOCountry.numeric76: 76,
ISOCountry.numeric52: 52,
ISOCountry.numeric96: 96,
ISOCountry.numeric64: 64,
ISOCountry.numeric74: 74,
ISOCountry.numeric72: 72,
ISOCountry.numeric140: 140,
ISOCountry.numeric124: 124,
ISOCountry.numeric166: 166,
ISOCountry.numeric756: 756,
ISOCountry.numeric152: 152,
ISOCountry.numeric156: 156,
ISOCountry.numeric384: 384,
ISOCountry.numeric120: 120,
ISOCountry.numeric180: 180,
ISOCountry.numeric178: 178,
ISOCountry.numeric184: 184,
ISOCountry.numeric170: 170,
ISOCountry.numeric174: 174,
ISOCountry.numeric132: 132,
ISOCountry.numeric188: 188,
ISOCountry.numeric192: 192,
ISOCountry.numeric531: 531,
ISOCountry.numeric162: 162,
ISOCountry.numeric136: 136,
ISOCountry.numeric196: 196,
ISOCountry.numeric203: 203,
ISOCountry.numeric276: 276,
ISOCountry.numeric262: 262,
ISOCountry.numeric212: 212,
ISOCountry.numeric208: 208,
ISOCountry.numeric214: 214,
ISOCountry.numeric12: 12,
ISOCountry.numeric218: 218,
ISOCountry.numeric818: 818,
ISOCountry.numeric232: 232,
ISOCountry.numeric732: 732,
ISOCountry.numeric724: 724,
ISOCountry.numeric233: 233,
ISOCountry.numeric231: 231,
ISOCountry.numeric246: 246,
ISOCountry.numeric242: 242,
ISOCountry.numeric238: 238,
ISOCountry.numeric250: 250,
ISOCountry.numeric234: 234,
ISOCountry.numeric583: 583,
ISOCountry.numeric266: 266,
ISOCountry.numeric826: 826,
ISOCountry.numeric268: 268,
ISOCountry.numeric831: 831,
ISOCountry.numeric288: 288,
ISOCountry.numeric292: 292,
ISOCountry.numeric324: 324,
ISOCountry.numeric312: 312,
ISOCountry.numeric270: 270,
ISOCountry.numeric624: 624,
ISOCountry.numeric226: 226,
ISOCountry.numeric300: 300,
ISOCountry.numeric308: 308,
ISOCountry.numeric304: 304,
ISOCountry.numeric320: 320,
ISOCountry.numeric254: 254,
ISOCountry.numeric316: 316,
ISOCountry.numeric328: 328,
ISOCountry.numeric344: 344,
ISOCountry.numeric334: 334,
ISOCountry.numeric340: 340,
ISOCountry.numeric191: 191,
ISOCountry.numeric332: 332,
ISOCountry.numeric348: 348,
ISOCountry.numeric360: 360,
ISOCountry.numeric833: 833,
ISOCountry.numeric356: 356,
ISOCountry.numeric86: 86,
ISOCountry.numeric372: 372,
ISOCountry.numeric364: 364,
ISOCountry.numeric368: 368,
ISOCountry.numeric352: 352,
ISOCountry.numeric376: 376,
ISOCountry.numeric380: 380,
ISOCountry.numeric388: 388,
ISOCountry.numeric832: 832,
ISOCountry.numeric400: 400,
ISOCountry.numeric392: 392,
ISOCountry.numeric398: 398,
ISOCountry.numeric404: 404,
ISOCountry.numeric417: 417,
ISOCountry.numeric116: 116,
ISOCountry.numeric296: 296,
ISOCountry.numeric659: 659,
ISOCountry.numeric410: 410,
ISOCountry.numeric153: 153,
ISOCountry.numeric414: 414,
ISOCountry.numeric418: 418,
ISOCountry.numeric422: 422,
ISOCountry.numeric430: 430,
ISOCountry.numeric434: 434,
ISOCountry.numeric662: 662,
ISOCountry.numeric438: 438,
ISOCountry.numeric144: 144,
ISOCountry.numeric426: 426,
ISOCountry.numeric440: 440,
ISOCountry.numeric442: 442,
ISOCountry.numeric428: 428,
ISOCountry.numeric446: 446,
ISOCountry.numeric663: 663,
ISOCountry.numeric504: 504,
ISOCountry.numeric492: 492,
ISOCountry.numeric498: 498,
ISOCountry.numeric450: 450,
ISOCountry.numeric462: 462,
ISOCountry.numeric484: 484,
ISOCountry.numeric584: 584,
ISOCountry.numeric807: 807,
ISOCountry.numeric466: 466,
ISOCountry.numeric470: 470,
ISOCountry.numeric104: 104,
ISOCountry.numeric499: 499,
ISOCountry.numeric496: 496,
ISOCountry.numeric580: 580,
ISOCountry.numeric508: 508,
ISOCountry.numeric478: 478,
ISOCountry.numeric500: 500,
ISOCountry.numeric474: 474,
ISOCountry.numeric480: 480,
ISOCountry.numeric454: 454,
ISOCountry.numeric458: 458,
ISOCountry.numeric175: 175,
ISOCountry.numeric516: 516,
ISOCountry.numeric540: 540,
ISOCountry.numeric562: 562,
ISOCountry.numeric574: 574,
ISOCountry.numeric566: 566,
ISOCountry.numeric558: 558,
ISOCountry.numeric570: 570,
ISOCountry.numeric528: 528,
ISOCountry.numeric578: 578,
ISOCountry.numeric524: 524,
ISOCountry.numeric520: 520,
ISOCountry.numeric554: 554,
ISOCountry.numeric512: 512,
ISOCountry.numeric586: 586,
ISOCountry.numeric591: 591,
ISOCountry.numeric612: 612,
ISOCountry.numeric604: 604,
ISOCountry.numeric608: 608,
ISOCountry.numeric585: 585,
ISOCountry.numeric598: 598,
ISOCountry.numeric616: 616,
ISOCountry.numeric630: 630,
ISOCountry.numeric408: 408,
ISOCountry.numeric620: 620,
ISOCountry.numeric600: 600,
ISOCountry.numeric275: 275,
ISOCountry.numeric258: 258,
ISOCountry.numeric634: 634,
ISOCountry.numeric638: 638,
ISOCountry.numeric642: 642,
ISOCountry.numeric643: 643,
ISOCountry.numeric646: 646,
ISOCountry.numeric682: 682,
ISOCountry.numeric729: 729,
ISOCountry.numeric686: 686,
ISOCountry.numeric702: 702,
ISOCountry.numeric239: 239,
ISOCountry.numeric744: 744,
ISOCountry.numeric90: 90,
ISOCountry.numeric694: 694,
ISOCountry.numeric222: 222,
ISOCountry.numeric674: 674,
ISOCountry.numeric706: 706,
ISOCountry.numeric666: 666,
ISOCountry.numeric688: 688,
ISOCountry.numeric728: 728,
ISOCountry.numeric678: 678,
ISOCountry.numeric740: 740,
ISOCountry.numeric703: 703,
ISOCountry.numeric705: 705,
ISOCountry.numeric752: 752,
ISOCountry.numeric748: 748,
ISOCountry.numeric534: 534,
ISOCountry.numeric690: 690,
ISOCountry.numeric760: 760,
ISOCountry.numeric796: 796,
ISOCountry.numeric148: 148,
ISOCountry.numeric768: 768,
ISOCountry.numeric764: 764,
ISOCountry.numeric762: 762,
ISOCountry.numeric772: 772,
ISOCountry.numeric795: 795,
ISOCountry.numeric626: 626,
ISOCountry.numeric776: 776,
ISOCountry.numeric780: 780,
ISOCountry.numeric788: 788,
ISOCountry.numeric792: 792,
ISOCountry.numeric798: 798,
ISOCountry.numeric158: 158,
ISOCountry.numeric834: 834,
ISOCountry.numeric800: 800,
ISOCountry.numeric804: 804,
ISOCountry.numeric581: 581,
ISOCountry.numeric858: 858,
ISOCountry.numeric840: 840,
ISOCountry.numeric860: 860,
ISOCountry.numeric336: 336,
ISOCountry.numeric670: 670,
ISOCountry.numeric862: 862,
ISOCountry.numeric92: 92,
ISOCountry.numeric850: 850,
ISOCountry.numeric704: 704,
ISOCountry.numeric548: 548,
ISOCountry.numeric876: 876,
ISOCountry.numeric882: 882,
ISOCountry.numeric887: 887,
ISOCountry.numeric710: 710,
ISOCountry.numeric894: 894,
ISOCountry.numeric716: 716,
};

View File

@ -0,0 +1,160 @@
import 'package:external_repos/external_repos.dart';
import '../../../infrastructure/services/packages/list.dart';
enum IndicatorEnum {
// Economy series
gdpConstant(
topic: IndicatorTopic.economy,
titleEN: 'GDP (Constant)',
titleAR: 'الناتج المحلي الإجمالي (بالأسعار الثابتة)',
),
gdpGrowthConstant(
topic: IndicatorTopic.economy,
titleEN: 'GDP Growth (Constant)',
titleAR: 'نمو الناتج المحلي الإجمالي (بالأسعار الثابتة)',
),
inflationRate(
topic: IndicatorTopic.economy,
titleEN: 'Inflation Rate',
titleAR: 'معدل التضخم',
),
tradeValue(
topic: IndicatorTopic.economy,
titleEN: 'Trade Value',
titleAR: 'إجمالي التجارة',
),
aircraftMovement(
topic: IndicatorTopic.economy,
titleEN: 'Aircraft Movement',
titleAR: 'حركة الطائرات',
),
hotelGuests(
topic: IndicatorTopic.economy,
titleEN: 'Hotel Establishment Guests',
titleAR: 'زوار المنشآت الفندقية',
),
// Social series
population(
topic: IndicatorTopic.social,
titleEN: 'Population',
titleAR: 'عدد السكان',
),
laborForce(
topic: IndicatorTopic.social,
titleEN: 'Labor Force',
titleAR: 'إجمالي القوى العاملة',
),
hospitalsGovernment(
topic: IndicatorTopic.social,
titleEN: 'Hospitals (Government)',
titleAR: 'عدد المستشفيات (الحكومية)',
),
hospitalsPrivate(
topic: IndicatorTopic.social,
titleEN: 'Hospitals (Private)',
titleAR: 'عدد المستشفيات (الخاصة)',
),
studentsGeneral(
topic: IndicatorTopic.social,
titleEN: 'Students (General)',
titleAR: 'عدد الطلاب (التعليم العام)',
),
studentsHigher(
topic: IndicatorTopic.social,
titleEN: 'Students (Higher)',
titleAR: 'عدد الطلاب (التعليم العالى)',
),
// Environment series
exportOilQuantity(
topic: IndicatorTopic.environment,
titleEN: 'Quantity of Export of Oil',
titleAR: 'صادرات النفط خلال',
),
electricityProduction(
topic: IndicatorTopic.environment,
titleEN: 'Electricity Production',
titleAR: 'إنتاج الكهرباء',
),
electricityConsumption(
topic: IndicatorTopic.environment,
titleEN: 'Electricity Consumption',
titleAR: 'استهلاك الكهرباء',
),
desalinatedWaterProduction(
topic: IndicatorTopic.environment,
titleEN: 'Desalinated Water Production',
titleAR: 'إنتاج مياه التحلية',
),
crudeOilProduction(
topic: IndicatorTopic.environment,
titleEN: 'Crude Oil Production',
titleAR: 'إنتاج النفط الخام',
),
municipalWaste(
topic: IndicatorTopic.environment,
titleEN: 'Municipal Solid Waste',
titleAR: 'النفايات البلدية الصلبة',
),
nationalReservesArea(
topic: IndicatorTopic.environment,
titleEN: 'Area of National Reserves',
titleAR: 'مساحة المحميات الوطنية',
);
const IndicatorEnum({
required this.topic,
required this.titleEN,
required this.titleAR,
});
factory IndicatorEnum.fromJson(String name) {
final id = IndicatorEnum.values.firstWhereOrNull(
(e) => e.name == name,
);
if (id == null) throw name;
return id;
}
static IndicatorEnum fromEntity(Type t) {
final e = {
GdpEntity: IndicatorEnum.gdpConstant,
HospitalsEntity: IndicatorEnum.hospitalsGovernment,
WaterEntity: IndicatorEnum.desalinatedWaterProduction,
InflationEntity: IndicatorEnum.inflationRate,
TradeEntity: IndicatorEnum.tradeValue,
AircraftsEntity: IndicatorEnum.aircraftMovement,
HotelsEntity: IndicatorEnum.hotelGuests,
PopulationEntity: IndicatorEnum.population,
LaborForceEntity: IndicatorEnum.laborForce,
GeneralEducationEntity: IndicatorEnum.studentsGeneral,
HigherEducationEntity: IndicatorEnum.studentsHigher,
OilEntity: IndicatorEnum.exportOilQuantity,
ElectricityConsumptionEntity: IndicatorEnum.electricityProduction,
NaturalReservesEntity: IndicatorEnum.nationalReservesArea,
}[t];
if (e == null) throw t;
return e;
}
final IndicatorTopic topic;
final String titleEN;
final String titleAR;
// final bool isUnitPercentage;
bool matchSearch(String cleanedSearchTerm) {
if (cleanedSearchTerm.isEmpty) return true;
final regExp = RegExp(
r'[^\w\s]',
multiLine: true,
caseSensitive: false,
);
final cleanedTitle = titleEN.replaceAll(regExp, '').toLowerCase();
final cleanedTopic = topic.name.toLowerCase();
final criteria = cleanedTitle.contains(cleanedSearchTerm) ||
cleanedTopic.contains(cleanedSearchTerm);
return criteria;
}
String toJson() => name;
}

View File

@ -0,0 +1,68 @@
import 'package:external_repos/external_repos.dart';
import 'package:json_annotation/json_annotation.dart';
part 'indicator_level_1_entity.g.dart';
abstract class IndicatorEntity {
const IndicatorEntity(
this.id, {
required this.level1Data,
});
final IndicatorEnum id;
final IndicatorLevel1Data level1Data;
factory IndicatorEntity.fromJson(
Map<String, dynamic> map,
) {
final id = IndicatorEnum.fromJson(map['id']);
return switch (id) {
// economy
IndicatorEnum.gdpConstant ||
IndicatorEnum.gdpGrowthConstant =>
GdpEntity.fromJson(map),
IndicatorEnum.inflationRate => InflationEntity.fromJson(map),
IndicatorEnum.tradeValue => TradeEntity.fromJson(map),
IndicatorEnum.aircraftMovement => AircraftsEntity.fromJson(map),
IndicatorEnum.hotelGuests => HotelsEntity.fromJson(map),
// social
IndicatorEnum.population => PopulationEntity.fromJson(map),
IndicatorEnum.laborForce => LaborForceEntity.fromJson(map),
IndicatorEnum.hospitalsGovernment ||
IndicatorEnum.hospitalsPrivate =>
HospitalsEntity.fromJson(map),
IndicatorEnum.studentsGeneral => GeneralEducationEntity.fromJson(map),
IndicatorEnum.studentsHigher => HigherEducationEntity.fromJson(map),
// environment
IndicatorEnum.exportOilQuantity => OilEntity.fromJson(map),
IndicatorEnum.electricityProduction =>
ElectricityProductionEntity.fromJson(map),
IndicatorEnum.electricityConsumption =>
ElectricityConsumptionEntity.fromJson(map),
IndicatorEnum.desalinatedWaterProduction ||
IndicatorEnum.municipalWaste =>
WaterEntity.fromJson(map),
IndicatorEnum.crudeOilProduction => OilEntity.fromJson(map),
IndicatorEnum.nationalReservesArea => NaturalReservesEntity.fromJson(map),
};
}
}
@JsonSerializable()
class IndicatorLevel1Data {
const IndicatorLevel1Data({
required this.value,
required this.isPercentage,
required this.subtitle,
});
final num value;
final bool isPercentage;
final Translatable subtitle;
Map<String, dynamic> toJson() => _$IndicatorLevel1DataToJson(this);
factory IndicatorLevel1Data.fromJson(
Map<String, dynamic> data,
) =>
_$IndicatorLevel1DataFromJson(data);
}

View File

@ -0,0 +1,37 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'indicator_level_1_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
IndicatorLevel1Data _$IndicatorLevel1DataFromJson(Map<String, dynamic> json) =>
IndicatorLevel1Data(
value: json['value'] as num,
isPercentage: json['isPercentage'] as bool,
subtitle: _$recordConvert(
json['subtitle'],
($jsonValue) => (
ar: $jsonValue['ar'] as String,
en: $jsonValue['en'] as String,
),
),
);
Map<String, dynamic> _$IndicatorLevel1DataToJson(
IndicatorLevel1Data instance) =>
<String, dynamic>{
'value': instance.value,
'isPercentage': instance.isPercentage,
'subtitle': <String, dynamic>{
'ar': instance.subtitle.ar,
'en': instance.subtitle.en,
},
};
$Rec _$recordConvert<$Rec>(
Object? value,
$Rec Function(Map) convert,
) =>
convert(value as Map<String, dynamic>);

View File

@ -0,0 +1,13 @@
enum IndicatorTopic {
economy(nameAR: 'الاقتصاد', nameEN: 'Economy'),
social(nameAR: 'الاجتماعي', nameEN: 'Social'),
environment(nameAR: 'البيئة', nameEN: 'Environment');
const IndicatorTopic({
required this.nameEN,
required this.nameAR,
});
final String nameEN;
final String nameAR;
}

View File

@ -0,0 +1,142 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
// ignore: depend_on_referenced_packages
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class AircraftsEntity implements IndicatorEntity {
const AircraftsEntity({
required this.totalAircraftMovement,
required this.departures,
required this.arrivals,
required this.weeklyFlightsGraphData,
required this.topDestinations,
});
final SpecificDetailBoxData totalAircraftMovement;
final SpecificDetailBoxData departures;
final SpecificDetailBoxData arrivals;
/// weekly data not given
final Map<
Translatable,
({
num toUAE,
num fromUAE,
})> weeklyFlightsGraphData;
final ({
Map<Translatable, num> data,
Translatable subtitle,
})? topDestinations;
@override
IndicatorLevel1Data get level1Data => IndicatorLevel1Data(
value: totalAircraftMovement.value,
isPercentage: totalAircraftMovement.isValuePercentage,
subtitle: totalAircraftMovement.subtitle,
);
@override
IndicatorEnum get id => IndicatorEnum.aircraftMovement;
Map<String, dynamic> toJson() => {
'id': id.toJson(),
'totalAircraftMovement': totalAircraftMovement.toJson(),
'departures': departures.toJson(),
'arrivals': arrivals.toJson(),
'weeklyFlightsGraphData': weeklyFlightsGraphData.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
{
'fromUae': value.fromUAE,
'toUae': value.toUAE,
},
),
),
if (topDestinations != null)
'topDestinations': {
'data': topDestinations!.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': topDestinations!.subtitle.toJson(),
}
};
factory AircraftsEntity.fromJson(
Map<String, dynamic> map,
) =>
AircraftsEntity(
totalAircraftMovement: SpecificDetailBoxData.fromJson(
map['totalAircraftMovement'],
),
departures: SpecificDetailBoxData.fromJson(
map['departures'],
),
arrivals: SpecificDetailBoxData.fromJson(
map['arrivals'],
),
topDestinations: map['topDestinations'] == null
? null
: (
data: (map['topDestinations']['data'] as Map<String, dynamic>)
.map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
subtitle: (
en: map['topDestinations']['subtitle']['en'],
ar: map['topDestinations']['subtitle']['ar'],
),
),
weeklyFlightsGraphData: (map['weeklyFlightsGraphData'] as Map).map<
Translatable,
({
num toUAE,
num fromUAE,
})>(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
(
fromUAE: value['fromUae'],
toUAE: value['toUae'],
),
),
),
);
@override
bool operator ==(covariant AircraftsEntity other) {
if (identical(this, other)) return true;
final eq = const MapEquality().equals;
return other.totalAircraftMovement == totalAircraftMovement &&
other.departures == departures &&
other.arrivals == arrivals &&
eq(
other.weeklyFlightsGraphData,
weeklyFlightsGraphData,
) &&
other.topDestinations?.subtitle == topDestinations?.subtitle &&
eq(
other.topDestinations?.data,
topDestinations?.data,
);
}
@override
int get hashCode =>
totalAircraftMovement.hashCode ^ departures.hashCode ^ arrivals.hashCode;
}

View File

@ -0,0 +1,193 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/external_repos.dart';
class GdpEntity implements IndicatorEntity {
final GdpDetails current;
final GdpDetails constant;
const GdpEntity({
required this.current,
required this.constant,
});
@override
IndicatorEnum get id => IndicatorEnum.gdpConstant;
@override
get level1Data => IndicatorLevel1Data(
value: current.gdp.value,
isPercentage: current.gdp.isValuePercentage,
subtitle: current.gdp.subtitle,
);
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'current': current.toJson(),
'constant': constant.toJson(),
};
factory GdpEntity.fromJson(Map<String, dynamic> map) => GdpEntity(
current: GdpDetails.fromJson(
map['current'],
),
constant: GdpDetails.fromJson(
map['constant'],
),
);
@override
bool operator ==(covariant GdpEntity other) {
if (identical(this, other)) return true;
return other.current == current && other.constant == constant;
}
@override
int get hashCode => current.hashCode ^ constant.hashCode;
}
/// used by [IndicatorEnum.gdpConstant]
/// and [IndicatorEnum.gdpGrowthConstant]
class GdpDetails {
const GdpDetails({
required this.gdp,
required this.gdpGrowthRate,
required this.nonOilGdp,
required this.nonOilGdpGrowthRate,
required this.topEconomicActivitiesByGrowthRate,
required this.gdpValueGraphData,
required this.topEconomicActivitiesByContribution,
});
final SpecificDetailBoxData gdp;
final SpecificDetailBoxData gdpGrowthRate;
final SpecificDetailBoxData nonOilGdp;
final SpecificDetailBoxData nonOilGdpGrowthRate;
final ({
Map<Translatable, num> data,
int year,
}) topEconomicActivitiesByGrowthRate;
final Map<int, ({num gdp, num nonOilGdp})> gdpValueGraphData;
final ({
Map<Translatable, num> data,
int year,
}) topEconomicActivitiesByContribution;
Map<String, dynamic> toJson() => {
'gdp': gdp.toJson(),
'gdpGrowthRate': gdpGrowthRate.toJson(),
'nonOilGdp': nonOilGdp.toJson(),
'nonOilGdpGrowthRate': nonOilGdpGrowthRate.toJson(),
'topEconomicActivitiesByGrowthRate': {
'data': topEconomicActivitiesByGrowthRate.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': topEconomicActivitiesByGrowthRate.year,
},
'gdpValueGraphData': gdpValueGraphData.map(
(key, value) => MapEntry(
key.toString(),
{
'gdp': value.gdp,
'nonOilGdp': value.nonOilGdp,
},
),
),
'topEconomicActivitiesByContribution': {
'data': topEconomicActivitiesByContribution.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': topEconomicActivitiesByContribution.year,
},
};
factory GdpDetails.fromJson(Map<String, dynamic> map) => GdpDetails(
gdp: SpecificDetailBoxData.fromJson(map['gdp']),
gdpGrowthRate: SpecificDetailBoxData.fromJson(
map['gdpGrowthRate'],
),
nonOilGdp: SpecificDetailBoxData.fromJson(
map['nonOilGdp'],
),
nonOilGdpGrowthRate: SpecificDetailBoxData.fromJson(
map['nonOilGdpGrowthRate'],
),
topEconomicActivitiesByGrowthRate: (
data: Map<Translatable, num>.from(
map['topEconomicActivitiesByGrowthRate']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(jsonDecode(key)),
value,
),
),
),
year: map['topEconomicActivitiesByGrowthRate']['year'],
),
gdpValueGraphData: Map<int, ({num gdp, num nonOilGdp})>.from(
map['gdpValueGraphData'].map(
(key, value) => MapEntry(
int.parse(key),
(
gdp: value['gdp'],
nonOilGdp: value['nonOilGdp'],
),
),
),
),
topEconomicActivitiesByContribution: (
data: Map<Translatable, num>.from(
map['topEconomicActivitiesByContribution']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['topEconomicActivitiesByContribution']['year'],
),
);
@override
bool operator ==(covariant GdpDetails other) {
if (identical(this, other)) return true;
final a = const MapEquality().equals;
return other.gdp == gdp &&
other.gdpGrowthRate == gdpGrowthRate &&
other.nonOilGdp == nonOilGdp &&
other.nonOilGdpGrowthRate == nonOilGdpGrowthRate &&
a(
other.topEconomicActivitiesByContribution.data,
topEconomicActivitiesByContribution.data,
) &&
other.topEconomicActivitiesByContribution.year ==
topEconomicActivitiesByContribution.year &&
a(
other.topEconomicActivitiesByGrowthRate.data,
topEconomicActivitiesByGrowthRate.data,
) &&
other.topEconomicActivitiesByGrowthRate.year ==
topEconomicActivitiesByGrowthRate.year;
}
@override
int get hashCode {
return gdp.hashCode ^
gdpGrowthRate.hashCode ^
nonOilGdp.hashCode ^
nonOilGdpGrowthRate.hashCode;
}
}

View File

@ -0,0 +1,255 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class HotelsEntity implements IndicatorEntity {
const HotelsEntity({
required this.hotelEstablishmentGuests,
required this.occupancyRate,
required this.averageLengthOfStay,
required this.averageDailyRate,
required this.guestArrival,
required this.guestNights,
required this.revenue,
required this.hotelAndHotelApartmentsGraphData,
});
final SpecificDetailBoxData occupancyRate;
final SpecificDetailBoxData averageLengthOfStay;
final SpecificDetailBoxData averageDailyRate;
final ({
num data,
Translatable subtitle,
}) hotelEstablishmentGuests;
final ({
Map<Translatable, num> data,
int year,
}) guestArrival;
final ({
Map<Translatable, num> data,
int year,
}) guestNights;
final ({
Map<Translatable, num> data,
int year,
}) revenue;
/// {year: {"Standard": 12}}
final Map<int, Map<Translatable, num>>? hotelAndHotelApartmentsGraphData;
@override
get level1Data => IndicatorLevel1Data(
subtitle: hotelEstablishmentGuests.subtitle,
isPercentage: false,
value: hotelEstablishmentGuests.data,
);
@override
get id => IndicatorEnum.hotelGuests;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'occupancyRate': occupancyRate.toJson(),
'averageLengthOfStay': averageLengthOfStay.toJson(),
'averageDailyRate': averageDailyRate.toJson(),
'hotelAndHotelApartmentsGraphData':
hotelAndHotelApartmentsGraphData?.map(
(key, value) => MapEntry(
key.toString(),
value.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
),
),
'hotelEstablishmentGuests': {
'data': hotelEstablishmentGuests.data,
'subtitle': hotelEstablishmentGuests.subtitle.toJson(),
},
'guestArrival': {
'data': guestArrival.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': guestArrival.year,
},
'guestNights': {
'data': guestNights.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': guestNights.year,
},
'revenue': {
'data': revenue.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': revenue.year,
},
};
factory HotelsEntity.fromJson(Map<String, dynamic> map) => HotelsEntity(
occupancyRate: SpecificDetailBoxData.fromJson(
map['occupancyRate'],
),
averageLengthOfStay: SpecificDetailBoxData.fromJson(
map['averageLengthOfStay'],
),
averageDailyRate: SpecificDetailBoxData.fromJson(
map['averageDailyRate'],
),
hotelAndHotelApartmentsGraphData:
map['hotelAndHotelApartmentsGraphData'] != null
? Map<int, Map<Translatable, num>>.from(
(map['hotelAndHotelApartmentsGraphData'] as Map).map(
(key, value) => MapEntry(
int.parse(key),
(value as Map).map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value as num,
),
),
),
),
)
: null,
hotelEstablishmentGuests: (
data: map['hotelEstablishmentGuests']['data'],
subtitle: TranslatableSerialization.fromJson(
map['hotelEstablishmentGuests']['subtitle'],
),
),
guestArrival: (
data: Map<Translatable, num>.from(
map['guestArrival']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['guestArrival']['year'],
),
guestNights: (
data: Map<Translatable, num>.from(
map['guestNights']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['guestNights']['year'],
),
revenue: (
data: Map<Translatable, num>.from(
map['revenue']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['revenue']['year'],
),
);
@override
bool operator ==(covariant HotelsEntity other) {
if (identical(this, other)) return true;
final mapEquals = const DeepCollectionEquality().equals;
var entries2 = <String, bool>{
'${other.occupancyRate} == $occupancyRate':
other.occupancyRate == occupancyRate,
'${other.averageLengthOfStay} == $averageLengthOfStay':
other.averageLengthOfStay == averageLengthOfStay,
'${other.averageDailyRate} == $averageDailyRate':
other.averageDailyRate == averageDailyRate,
'${other.hotelEstablishmentGuests} == $hotelEstablishmentGuests':
other.hotelEstablishmentGuests == hotelEstablishmentGuests,
'${other.guestArrival.year} == ${guestArrival.year}':
other.guestArrival.year == guestArrival.year,
'${other.guestNights.year} == ${guestNights.year}':
other.guestNights.year == guestNights.year,
'${other.revenue.year} == ${revenue.year}':
other.revenue.year == revenue.year,
'mapEquals(${other.hotelAndHotelApartmentsGraphData}, $hotelAndHotelApartmentsGraphData,)':
mapEquals(
other.hotelAndHotelApartmentsGraphData,
hotelAndHotelApartmentsGraphData,
),
'mapEquals(${other.guestArrival.data},${guestArrival.data},)': mapEquals(
other.guestArrival.data,
guestArrival.data,
),
'mapEquals(${other.guestNights.data},${guestNights.data},)': mapEquals(
other.guestNights.data,
guestNights.data,
),
'mapEquals(${other.revenue.data},${revenue.data},)': mapEquals(
other.revenue.data,
revenue.data,
),
}.entries;
for (var i = 0; i < entries2.length; i++) {
final e = entries2.elementAt(i);
if (e.value) continue;
print('${id.name} $i ${e.key}');
}
return other.occupancyRate == occupancyRate &&
other.averageLengthOfStay == averageLengthOfStay &&
other.averageDailyRate == averageDailyRate &&
mapEquals(
other.hotelAndHotelApartmentsGraphData,
hotelAndHotelApartmentsGraphData,
) &&
other.hotelEstablishmentGuests == hotelEstablishmentGuests &&
other.guestArrival.year == guestArrival.year &&
mapEquals(
other.guestArrival.data,
guestArrival.data,
) &&
other.guestNights.year == guestNights.year &&
mapEquals(
other.guestNights.data,
guestNights.data,
) &&
other.revenue.year == revenue.year &&
mapEquals(
other.revenue.data,
revenue.data,
);
}
@override
int get hashCode {
return occupancyRate.hashCode ^
averageLengthOfStay.hashCode ^
averageDailyRate.hashCode ^
hotelAndHotelApartmentsGraphData.hashCode;
}
}

View File

@ -0,0 +1,170 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import 'package:sdmx/sdmx.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class InflationEntity implements IndicatorEntity {
const InflationEntity({
required this.inflationRate,
required this.highestMainGroup,
required this.lowestMainGroup,
required this.inflationByMajorGroups,
required this.inflationTimeSeries,
required this.inflationBySubGroup,
});
final SpecificDetailBoxData inflationRate;
final SpecificDetailBoxData highestMainGroup;
final SpecificDetailBoxData lowestMainGroup;
final ({
Map<Translatable, num> data,
int year,
}) inflationByMajorGroups;
final ({
Map<QuarterTimePeriod, num> data,
int year,
}) inflationTimeSeries;
// subgroups not a dimension
final ({
Map<Translatable, num> data,
int year,
})? inflationBySubGroup;
@override
get level1Data => IndicatorLevel1Data(
value: inflationRate.value,
isPercentage: inflationRate.isValuePercentage,
subtitle: inflationRate.subtitle,
);
@override
IndicatorEnum get id => IndicatorEnum.inflationRate;
Map<String, dynamic> toJson() => {
'id': id.toJson(),
'inflationRate': inflationRate.toJson(),
'highestMainGroup': highestMainGroup.toJson(),
'lowestMainGroup': lowestMainGroup.toJson(),
'inflationByMajorGroups': {
'data': inflationByMajorGroups.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': inflationByMajorGroups.year,
},
'inflationTimeSeries': {
'data': inflationTimeSeries.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': inflationTimeSeries.year,
},
'inflationBySubGroup': inflationBySubGroup != null
? {
'data': inflationBySubGroup!.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'year': inflationBySubGroup!.year,
}
: null,
};
factory InflationEntity.fromJson(
Map<String, dynamic> map,
) =>
InflationEntity(
inflationRate: SpecificDetailBoxData.fromJson(
map['inflationRate'],
),
highestMainGroup: SpecificDetailBoxData.fromJson(
map['highestMainGroup'],
),
lowestMainGroup: SpecificDetailBoxData.fromJson(
map['lowestMainGroup'],
),
inflationByMajorGroups: (
data: Map<Translatable, num>.from(
map['inflationByMajorGroups']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['inflationByMajorGroups']['year'],
),
inflationTimeSeries: (
data: Map<QuarterTimePeriod, num>.from(
map['inflationTimeSeries']['data'].map(
(key, value) => MapEntry(
QuarterTimePeriod.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['inflationTimeSeries']['year'],
),
inflationBySubGroup: map['inflationBySubGroup'] != null
? (
data: Map<Translatable, num>.from(
map['inflationBySubGroup']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
year: map['inflationBySubGroup']['year'],
)
: null,
);
@override
bool operator ==(covariant InflationEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.inflationRate == inflationRate &&
other.highestMainGroup == highestMainGroup &&
other.lowestMainGroup == lowestMainGroup &&
mapEquals(
inflationByMajorGroups.data,
other.inflationByMajorGroups.data,
) &&
inflationByMajorGroups.year == other.inflationByMajorGroups.year &&
mapEquals(
inflationTimeSeries.data,
other.inflationTimeSeries.data,
) &&
inflationTimeSeries.year == other.inflationTimeSeries.year &&
mapEquals(
inflationBySubGroup?.data,
other.inflationBySubGroup?.data,
) &&
inflationBySubGroup?.year == other.inflationBySubGroup?.year;
}
@override
int get hashCode =>
inflationRate.hashCode ^
highestMainGroup.hashCode ^
lowestMainGroup.hashCode;
}

View File

@ -0,0 +1,193 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class TradeEntity implements IndicatorEntity {
const TradeEntity({
required this.totalTrade,
required this.totalImports,
required this.totalNonOilExport,
required this.totalReExport,
required this.topTradePartners,
required this.tradeTrendAnnually,
required this.topTradeCommodities,
});
@override
get id => IndicatorEnum.tradeValue;
final SpecificDetailBoxData totalTrade;
final SpecificDetailBoxData totalImports;
final SpecificDetailBoxData totalNonOilExport;
final SpecificDetailBoxData totalReExport;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) topTradePartners;
final ({
Map<
int,
({
num import,
num export,
num reExport,
})> data,
Translatable subtitle,
}) tradeTrendAnnually;
// how to calculate?
final ({
Map<Translatable, num> data,
Translatable subtitle,
})? topTradeCommodities;
@override
get level1Data => IndicatorLevel1Data(
value: totalTrade.value,
isPercentage: totalTrade.isValuePercentage,
subtitle: totalTrade.subtitle,
);
Map<String, dynamic> toJson() => {
'id': id.toJson(),
'totalTrade': totalTrade.toJson(),
'totalImports': totalImports.toJson(),
'totalNonOilExport': totalNonOilExport.toJson(),
'totalReExport': totalReExport.toJson(),
'topTradePartners': {
'data': topTradePartners.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': topTradePartners.subtitle.toJson(),
},
'tradeTrendAnnually': {
'data': tradeTrendAnnually.data.map(
(key, value) => MapEntry(
key.toString(),
{
'import': value.import,
'export': value.export,
'reExport': value.reExport,
},
),
),
'subtitle': tradeTrendAnnually.subtitle.toJson(),
},
'topTradeCommodities': topTradeCommodities != null
? {
'data': topTradeCommodities!.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': topTradeCommodities!.subtitle.toJson(),
}
: null,
};
factory TradeEntity.fromJson(Map<String, dynamic> map) => TradeEntity(
totalTrade: SpecificDetailBoxData.fromJson(
map['totalTrade'],
),
totalImports: SpecificDetailBoxData.fromJson(
map['totalImports'],
),
totalNonOilExport: SpecificDetailBoxData.fromJson(
map['totalNonOilExport'],
),
totalReExport: SpecificDetailBoxData.fromJson(
map['totalReExport'],
),
topTradePartners: (
data: Map<Translatable, num>.from(
map['topTradePartners']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
map['topTradePartners']['subtitle'],
),
),
tradeTrendAnnually: (
data: Map<int, ({num import, num export, num reExport})>.from(
map['tradeTrendAnnually']['data'].map(
(key, value) => MapEntry(
int.parse(key),
(
import: value['import'],
export: value['export'],
reExport: value['reExport'],
),
),
),
),
subtitle: TranslatableSerialization.fromJson(
map['tradeTrendAnnually']['subtitle']),
),
topTradeCommodities: map['topTradeCommodities'] != null
? (
data: Map<Translatable, num>.from(
map['topTradeCommodities']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
map['topTradeCommodities']['subtitle']),
)
: null,
);
@override
bool operator ==(covariant TradeEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.totalTrade == totalTrade &&
other.totalImports == totalImports &&
other.totalNonOilExport == totalNonOilExport &&
other.totalReExport == totalReExport &&
other.topTradePartners.subtitle == topTradePartners.subtitle &&
mapEquals(
other.topTradePartners.data,
topTradePartners.data,
) &&
other.tradeTrendAnnually.subtitle == tradeTrendAnnually.subtitle &&
mapEquals(
other.tradeTrendAnnually.data,
tradeTrendAnnually.data,
) &&
other.topTradeCommodities?.subtitle == topTradeCommodities?.subtitle &&
mapEquals(
other.topTradeCommodities?.data,
topTradeCommodities?.data,
);
}
@override
int get hashCode {
return totalTrade.hashCode ^
totalImports.hashCode ^
totalNonOilExport.hashCode ^
totalReExport.hashCode;
}
}

View File

@ -0,0 +1,158 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class ElectricityConsumptionEntity implements IndicatorEntity {
const ElectricityConsumptionEntity({
required this.consumption,
required this.consumptionGrowth,
required this.annualConsumption,
required this.electricityConsumptionByEmirate,
required this.electricityConsumptionBySector,
});
final SpecificDetailBoxData consumption;
final SpecificDetailBoxData consumptionGrowth;
final ({
Map<int, num> data,
Translatable subtitle,
}) annualConsumption;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) electricityConsumptionByEmirate;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) electricityConsumptionBySector;
@override
get level1Data => IndicatorLevel1Data(
value: consumption.value,
isPercentage: consumption.isValuePercentage,
subtitle: consumption.subtitle,
);
@override
get id => IndicatorEnum.electricityConsumption;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'consumption': consumption.toJson(),
'consumptionGrowth': consumptionGrowth.toJson(),
'annualConsumption': {
'data': annualConsumption.data.map(
(key, value) => MapEntry(
key.toString(),
value,
),
),
'subtitle': annualConsumption.subtitle.toJson(),
},
'electricityConsumptionByEmirate': {
'data': electricityConsumptionByEmirate.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': electricityConsumptionByEmirate.subtitle.toJson(),
},
'electricityConsumptionBySector': {
'data': electricityConsumptionBySector.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': electricityConsumptionBySector.subtitle.toJson(),
},
};
factory ElectricityConsumptionEntity.fromJson(
Map<String, dynamic> json,
) =>
ElectricityConsumptionEntity(
consumption: SpecificDetailBoxData.fromJson(
json['consumption'],
),
consumptionGrowth: SpecificDetailBoxData.fromJson(
json['consumptionGrowth'],
),
annualConsumption: (
data: Map<String, num>.from(
json['annualConsumption']['data'],
).map(
(key, value) => MapEntry(int.parse(key), value),
),
subtitle: TranslatableSerialization.fromJson(
json['annualConsumption']['subtitle']),
),
electricityConsumptionByEmirate: (
data: Map<Translatable, num>.from(
json['electricityConsumptionByEmirate']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['electricityConsumptionByEmirate']['subtitle'],
),
),
electricityConsumptionBySector: (
data: Map<Translatable, num>.from(
json['electricityConsumptionBySector']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['electricityConsumptionBySector']['subtitle'],
),
),
);
@override
bool operator ==(covariant ElectricityConsumptionEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.consumption == consumption &&
other.consumption == consumption &&
other.consumptionGrowth == consumptionGrowth &&
mapEquals(
other.annualConsumption.data,
annualConsumption.data,
) &&
other.annualConsumption.subtitle == annualConsumption.subtitle &&
mapEquals(
other.electricityConsumptionByEmirate.data,
electricityConsumptionByEmirate.data,
) &&
other.electricityConsumptionByEmirate.subtitle ==
electricityConsumptionByEmirate.subtitle &&
mapEquals(
other.electricityConsumptionBySector.data,
electricityConsumptionBySector.data,
) &&
other.electricityConsumptionBySector.subtitle ==
electricityConsumptionBySector.subtitle;
}
@override
int get hashCode => consumption.hashCode ^ consumptionGrowth.hashCode;
}

View File

@ -0,0 +1,158 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class ElectricityProductionEntity implements IndicatorEntity {
const ElectricityProductionEntity({
required this.production,
required this.productionGrowth,
required this.annualProduction,
required this.electricityProductionByEmirate,
required this.electricityProductionByEntity,
});
final SpecificDetailBoxData production;
final SpecificDetailBoxData productionGrowth;
final ({
Map<int, num> data,
Translatable subtitle,
}) annualProduction;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) electricityProductionByEmirate;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) electricityProductionByEntity;
@override
get level1Data => IndicatorLevel1Data(
value: production.value,
isPercentage: production.isValuePercentage,
subtitle: production.subtitle,
);
@override
get id => IndicatorEnum.electricityConsumption;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'production': production.toJson(),
'productionGrowth': productionGrowth.toJson(),
'annualProduction': {
'data': annualProduction.data.map(
(key, value) => MapEntry(
key.toString(),
value,
),
),
'subtitle': annualProduction.subtitle.toJson(),
},
'electricityProductionByEmirate': {
'data': electricityProductionByEmirate.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': electricityProductionByEmirate.subtitle.toJson(),
},
'electricityProductionByEntity': {
'data': electricityProductionByEntity.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': electricityProductionByEntity.subtitle.toJson(),
},
};
factory ElectricityProductionEntity.fromJson(
Map<String, dynamic> json,
) =>
ElectricityProductionEntity(
production: SpecificDetailBoxData.fromJson(
json['production'],
),
productionGrowth: SpecificDetailBoxData.fromJson(
json['productionGrowth'],
),
annualProduction: (
data: Map<String, num>.from(
json['annualProduction']['data'],
).map(
(key, value) => MapEntry(int.parse(key), value),
),
subtitle: TranslatableSerialization.fromJson(
json['annualConsumption']['subtitle']),
),
electricityProductionByEmirate: (
data: Map<Translatable, num>.from(
json['electricityProductionByEmirate']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['electricityConsumptionByEmirate']['subtitle'],
),
),
electricityProductionByEntity: (
data: Map<Translatable, num>.from(
json['electricityProductionByEntity']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['electricityConsumptionBySector']['subtitle'],
),
),
);
@override
bool operator ==(covariant ElectricityProductionEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.production == production &&
other.productionGrowth == productionGrowth &&
mapEquals(
other.annualProduction.data,
annualProduction.data,
) &&
other.annualProduction.subtitle == annualProduction.subtitle &&
mapEquals(
other.electricityProductionByEmirate.data,
electricityProductionByEmirate.data,
) &&
other.electricityProductionByEmirate.subtitle ==
electricityProductionByEmirate.subtitle &&
mapEquals(
other.electricityProductionByEntity.data,
electricityProductionByEntity.data,
) &&
other.electricityProductionByEntity.subtitle ==
electricityProductionByEntity.subtitle;
}
@override
int get hashCode =>
production.hashCode ^ production.hashCode ^ productionGrowth.hashCode;
}

View File

@ -0,0 +1,110 @@
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class NaturalReservesEntity implements IndicatorEntity {
const NaturalReservesEntity({
required this.totalReservesArea,
required this.protectedAreaCount,
required this.totalProtectedMarineArea,
required this.totalProtectedTerrestrialArea,
required this.protectedAreaCountByAnnouncementYear,
});
final SpecificDetailBoxData totalReservesArea;
final SpecificDetailBoxData protectedAreaCount;
final SpecificDetailBoxData totalProtectedMarineArea;
final SpecificDetailBoxData totalProtectedTerrestrialArea;
final Map<
int,
({
int countByAnnouncementYear,
int protectedAreasCumulativeCount,
})> protectedAreaCountByAnnouncementYear;
@override
get level1Data => IndicatorLevel1Data(
value: totalReservesArea.value,
isPercentage: totalReservesArea.isValuePercentage,
subtitle: totalReservesArea.subtitle,
);
@override
get id => IndicatorEnum.nationalReservesArea;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'totalReservesArea': totalReservesArea.toJson(),
'protectedAreaCount': protectedAreaCount.toJson(),
'totalProtectedMarineArea': totalProtectedMarineArea.toJson(),
'totalProtectedTerrestrialArea': totalProtectedTerrestrialArea.toJson(),
'protectedAreaCountByAnnouncementYear':
protectedAreaCountByAnnouncementYear.map(
(key, value) => MapEntry(
key.toString(),
{
'countByAnnouncementYear': value.countByAnnouncementYear,
'protectedAreasCumulativeCount':
value.protectedAreasCumulativeCount,
},
),
),
};
factory NaturalReservesEntity.fromJson(Map<String, dynamic> map) =>
NaturalReservesEntity(
totalReservesArea: SpecificDetailBoxData.fromJson(
map['totalReservesArea'],
),
protectedAreaCount: SpecificDetailBoxData.fromJson(
map['protectedAreaCount'],
),
totalProtectedMarineArea: SpecificDetailBoxData.fromJson(
map['totalProtectedMarineArea'],
),
totalProtectedTerrestrialArea: SpecificDetailBoxData.fromJson(
map['totalProtectedTerrestrialArea'],
),
protectedAreaCountByAnnouncementYear: Map<
int,
({
int countByAnnouncementYear,
int protectedAreasCumulativeCount
})>.from(
map['protectedAreaCountByAnnouncementYear'].map(
(key, value) => MapEntry(
int.parse(key),
(
countByAnnouncementYear: value['countByAnnouncementYear'],
protectedAreasCumulativeCount:
value['protectedAreasCumulativeCount'],
),
),
),
),
);
@override
bool operator ==(covariant NaturalReservesEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.totalReservesArea == totalReservesArea &&
other.protectedAreaCount == protectedAreaCount &&
other.totalProtectedMarineArea == totalProtectedMarineArea &&
other.totalProtectedTerrestrialArea == totalProtectedTerrestrialArea &&
mapEquals(
other.protectedAreaCountByAnnouncementYear,
protectedAreaCountByAnnouncementYear,
);
}
@override
int get hashCode {
return totalReservesArea.hashCode ^
protectedAreaCount.hashCode ^
totalProtectedMarineArea.hashCode ^
totalProtectedTerrestrialArea.hashCode;
}
}

View File

@ -0,0 +1,203 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
/// used by [IndicatorEnum.crudeOilProduction]
/// and [IndicatorEnum.exportOilQuantity]
class OilEntity implements IndicatorEntity {
const OilEntity({
required this.crudeOilProduction,
required this.crudeOilExports,
required this.crudeOilProductionAndExportsAnnualTrend,
required this.refinedOilProducts,
required this.naturalGasProductionExportsAndImportsAnnualTrend,
});
final SpecificDetailBoxData crudeOilProduction;
final SpecificDetailBoxData crudeOilExports;
// inconsistent from qlik
final ({
Map<
int,
({
num exports,
num production,
})> data,
Translatable subtitle,
}) crudeOilProductionAndExportsAnnualTrend;
// products not yet added
final ({
Map<Translatable, num> data,
Translatable subtitle,
})? refinedOilProducts;
// imports missing
final ({
Map<
int,
({
num exports,
num imports,
num production,
})> data,
Translatable subtitle,
})? naturalGasProductionExportsAndImportsAnnualTrend;
@override
get id => IndicatorEnum.crudeOilProduction;
@override
get level1Data => IndicatorLevel1Data(
isPercentage: crudeOilProduction.isValuePercentage,
subtitle: crudeOilProduction.subtitle,
value: crudeOilProduction.value,
);
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'crudeOilProduction': crudeOilProduction.toJson(),
'crudeOilExports': crudeOilExports.toJson(),
'crudeOilProductionAndExportsAnnualTrend': {
'data': crudeOilProductionAndExportsAnnualTrend.data.map(
(key, value) => MapEntry(
key.toString(),
{
'exports': value.exports,
'production': value.production,
},
),
),
'subtitle': crudeOilProductionAndExportsAnnualTrend.subtitle.toJson(),
},
'refinedOilProducts': refinedOilProducts != null
? {
'data': refinedOilProducts!.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': refinedOilProducts!.subtitle.toJson(),
}
: null,
'naturalGasProductionExportsAndImportsAnnualTrend':
naturalGasProductionExportsAndImportsAnnualTrend != null
? {
'data': naturalGasProductionExportsAndImportsAnnualTrend!
.data
.map(
(key, value) => MapEntry(
key.toString(),
{
'exports': value.exports,
'imports': value.imports,
'production': value.production,
},
),
),
'subtitle':
naturalGasProductionExportsAndImportsAnnualTrend!
.subtitle
.toJson(),
}
: null,
};
factory OilEntity.fromJson(Map<String, dynamic> json) => OilEntity(
crudeOilProduction: SpecificDetailBoxData.fromJson(
json['crudeOilProduction'],
),
crudeOilExports: SpecificDetailBoxData.fromJson(
json['crudeOilExports'],
),
crudeOilProductionAndExportsAnnualTrend: (
data: Map<int, ({num exports, num production})>.from(
json['crudeOilProductionAndExportsAnnualTrend']['data'].map(
(key, value) => MapEntry(
int.parse(key),
(
exports: value['exports'],
production: value['production'],
),
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['crudeOilProductionAndExportsAnnualTrend']['subtitle'],
),
),
refinedOilProducts: json['refinedOilProducts'] != null
? (
data: Map<Translatable, num>.from(
json['refinedOilProducts']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(jsonDecode(key)),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['refinedOilProducts']['subtitle'],
),
)
: null,
naturalGasProductionExportsAndImportsAnnualTrend: json[
'naturalGasProductionExportsAndImportsAnnualTrend'] !=
null
? (
data:
Map<int, ({num exports, num imports, num production})>.from(
json['naturalGasProductionExportsAndImportsAnnualTrend']
['data']
.map(
(key, value) => MapEntry(
int.parse(key),
(
exports: value['exports'],
imports: value['imports'],
production: value['production'],
),
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['naturalGasProductionExportsAndImportsAnnualTrend']
['subtitle'],
),
)
: null,
);
@override
bool operator ==(covariant OilEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.crudeOilProduction == crudeOilProduction &&
other.crudeOilExports == crudeOilExports &&
mapEquals(
other.crudeOilProductionAndExportsAnnualTrend.data,
crudeOilProductionAndExportsAnnualTrend.data,
) &&
other.crudeOilProductionAndExportsAnnualTrend.subtitle ==
crudeOilProductionAndExportsAnnualTrend.subtitle &&
mapEquals(
other.refinedOilProducts?.data,
refinedOilProducts?.data,
) &&
other.refinedOilProducts?.subtitle == refinedOilProducts?.subtitle &&
mapEquals(
other.naturalGasProductionExportsAndImportsAnnualTrend?.data,
naturalGasProductionExportsAndImportsAnnualTrend?.data,
) &&
other.naturalGasProductionExportsAndImportsAnnualTrend?.subtitle ==
naturalGasProductionExportsAndImportsAnnualTrend?.subtitle;
}
@override
int get hashCode => crudeOilProduction.hashCode ^ crudeOilExports.hashCode;
}

View File

@ -0,0 +1,127 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class WaterEntity implements IndicatorEntity {
const WaterEntity({
required this.production,
required this.productionGrowth,
required this.annualProduction,
required this.qtyOfProducedWaterByEntity,
required this.municipalWaste,
});
final SpecificDetailBoxData production;
final SpecificDetailBoxData productionGrowth;
final SpecificDetailBoxData municipalWaste;
// data inconsistent with qlik
final ({
Map<int, num> data,
Translatable subtitle,
}) annualProduction;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) qtyOfProducedWaterByEntity;
@override
get level1Data => IndicatorLevel1Data(
value: production.value,
isPercentage: production.isValuePercentage,
subtitle: production.subtitle,
);
@override
get id => IndicatorEnum.desalinatedWaterProduction;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'production': production.toJson(),
'productionGrowth': productionGrowth.toJson(),
'municipalWaste': municipalWaste.toJson(),
'annualProduction': {
'data': annualProduction.data.map(
(key, value) => MapEntry(
key.toString(),
value,
),
),
'subtitle': annualProduction.subtitle.toJson(),
},
'qtyOfProducedWaterByEntity': {
'data': qtyOfProducedWaterByEntity.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': qtyOfProducedWaterByEntity.subtitle.toJson(),
},
};
factory WaterEntity.fromJson(Map<String, dynamic> json) => WaterEntity(
production: SpecificDetailBoxData.fromJson(
json['production'],
),
productionGrowth: SpecificDetailBoxData.fromJson(
json['productionGrowth'],
),
municipalWaste: SpecificDetailBoxData.fromJson(
json['municipalWaste'],
),
annualProduction: (
data: Map<String, num>.from(json['annualProduction']['data']).map(
(key, value) => MapEntry(
int.parse(key),
value,
),
),
subtitle: TranslatableSerialization.fromJson(
json['annualProduction']['subtitle']),
),
qtyOfProducedWaterByEntity: (
data: Map<Translatable, num>.from(
json['qtyOfProducedWaterByEntity']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['qtyOfProducedWaterByEntity']['subtitle'],
),
),
);
@override
bool operator ==(covariant WaterEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.production == production &&
other.productionGrowth == productionGrowth &&
other.municipalWaste == municipalWaste &&
other.annualProduction.subtitle == annualProduction.subtitle &&
mapEquals(
other.annualProduction.data,
annualProduction.data,
) &&
other.qtyOfProducedWaterByEntity.subtitle ==
qtyOfProducedWaterByEntity.subtitle &&
mapEquals(
other.qtyOfProducedWaterByEntity.data,
qtyOfProducedWaterByEntity.data,
);
}
@override
int get hashCode =>
production.hashCode ^ productionGrowth.hashCode ^ municipalWaste.hashCode;
}

View File

@ -0,0 +1,106 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
/// time periods are a year before
class GeneralEducationEntity implements IndicatorEntity {
const GeneralEducationEntity({
required this.students,
required this.institutions,
required this.teachers,
required this.studentsByGender,
required this.teachersByGender,
required this.institutionsByAcademicYear,
});
final SpecificDetailBoxData students;
final SpecificDetailBoxData institutions;
final SpecificDetailBoxData teachers;
final Map<String, num> institutionsByAcademicYear;
final ({num male, num female, String period}) studentsByGender;
final ({num male, num female, String period}) teachersByGender;
@override
get level1Data => IndicatorLevel1Data(
value: students.value,
isPercentage: students.isValuePercentage,
subtitle: students.subtitle,
);
@override
get id => IndicatorEnum.studentsGeneral;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'students': students.toJson(),
'institutions': institutions.toJson(),
'teachers': teachers.toJson(),
'institutionsByAcademicYear': institutionsByAcademicYear,
'studentsByGender': {
'male': studentsByGender.male,
'female': studentsByGender.female,
'period': studentsByGender.period,
},
'teachersByGender': {
'male': teachersByGender.male,
'female': teachersByGender.female,
'period': teachersByGender.period,
},
};
factory GeneralEducationEntity.fromJson(
Map<String, dynamic> json,
) =>
GeneralEducationEntity(
students: SpecificDetailBoxData.fromJson(
json['students'],
),
institutions: SpecificDetailBoxData.fromJson(
json['institutions'],
),
teachers: SpecificDetailBoxData.fromJson(
json['teachers'],
),
institutionsByAcademicYear: Map<String, num>.from(
json['institutionsByAcademicYear'],
),
studentsByGender: (
male: json['studentsByGender']['male'],
female: json['studentsByGender']['female'],
period: json['studentsByGender']['period'],
),
teachersByGender: (
male: json['teachersByGender']['male'],
female: json['teachersByGender']['female'],
period: json['teachersByGender']['period'],
),
);
@override
bool operator ==(covariant GeneralEducationEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.students == students &&
other.institutions == institutions &&
other.teachers == teachers &&
other.studentsByGender == studentsByGender &&
other.teachersByGender == teachersByGender &&
mapEquals(
other.institutionsByAcademicYear,
institutionsByAcademicYear,
);
}
@override
int get hashCode {
return students.hashCode ^
institutions.hashCode ^
teachers.hashCode ^
institutionsByAcademicYear.hashCode;
}
}

View File

@ -0,0 +1,137 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class HigherEducationEntity implements IndicatorEntity {
// time periods are (year-1) to year
const HigherEducationEntity({
required this.students,
required this.graduates,
required this.academicStaff,
required this.studentsByGender,
required this.academicStaffByGender,
required this.graduatedStudentsByFieldAndGender,
});
final SpecificDetailBoxData students;
final SpecificDetailBoxData graduates;
final SpecificDetailBoxData academicStaff;
final ({
num male,
num female,
String period,
}) studentsByGender;
final ({
num male,
num female,
String period,
}) academicStaffByGender;
final Map<
Translatable,
({
int male,
int female,
})> graduatedStudentsByFieldAndGender;
@override
get level1Data => IndicatorLevel1Data(
value: students.value,
isPercentage: students.isValuePercentage,
subtitle: students.subtitle,
);
@override
get id => IndicatorEnum.studentsHigher;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'students': students.toJson(),
'graduates': graduates.toJson(),
'academicStaff': academicStaff.toJson(),
'studentsByGender': {
'male': studentsByGender.male,
'female': studentsByGender.female,
'period': studentsByGender.period,
},
'academicStaffByGender': {
'male': academicStaffByGender.male,
'female': academicStaffByGender.female,
'period': academicStaffByGender.period,
},
'graduatedStudentsByFieldAndGender':
graduatedStudentsByFieldAndGender.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
{
'male': value.male,
'female': value.female,
},
),
),
};
factory HigherEducationEntity.fromJson(
Map<String, dynamic> json,
) =>
HigherEducationEntity(
students: SpecificDetailBoxData.fromJson(
json['students'],
),
graduates: SpecificDetailBoxData.fromJson(
json['graduates'],
),
academicStaff: SpecificDetailBoxData.fromJson(
json['academicStaff'],
),
studentsByGender: (
male: json['studentsByGender']['male'],
female: json['studentsByGender']['female'],
period: json['studentsByGender']['period'],
),
academicStaffByGender: (
male: json['academicStaffByGender']['male'],
female: json['academicStaffByGender']['female'],
period: json['academicStaffByGender']['period'],
),
graduatedStudentsByFieldAndGender:
Map<Translatable, ({int male, int female})>.from(
json['graduatedStudentsByFieldAndGender'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
(
male: value['male'],
female: value['female'],
),
),
),
),
);
@override
bool operator ==(covariant HigherEducationEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.students == students &&
other.graduates == graduates &&
other.academicStaff == academicStaff &&
other.studentsByGender == studentsByGender &&
other.academicStaffByGender == academicStaffByGender &&
mapEquals(
other.graduatedStudentsByFieldAndGender,
graduatedStudentsByFieldAndGender,
);
}
@override
int get hashCode =>
students.hashCode ^ graduates.hashCode ^ academicStaff.hashCode;
}

View File

@ -0,0 +1,214 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
/// used by both [IndicatorEnum.hospitalsGovernment]
/// and [IndicatorEnum.hospitalsPrivate]
class HospitalsEntity implements IndicatorEntity {
const HospitalsEntity({
required this.numHospitals,
required this.numPrivate,
required this.numGov,
required this.numClinicsAndCenters,
required this.numClinicsAndCentersGov,
required this.numClinicsAndCentersPrivate,
required this.healthcareProfessionalsBySpecialization,
required this.hospitalBedsBySector,
required this.patientsByPatientTypeAndSector,
});
final SpecificDetailBoxData numHospitals;
final SpecificDetailBoxData numPrivate;
final SpecificDetailBoxData numGov;
final SpecificDetailBoxData numClinicsAndCenters;
final SpecificDetailBoxData numClinicsAndCentersGov;
final SpecificDetailBoxData numClinicsAndCentersPrivate;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) healthcareProfessionalsBySpecialization;
final ({
Map<Translatable, num> data,
Translatable subtitle,
}) hospitalBedsBySector;
// no data
final ({
({
({int inpatients, int outpatients}) government,
({int inpatients, int outpatients}) private,
}) data,
Translatable subtitle,
})? patientsByPatientTypeAndSector;
@override
get level1Data => IndicatorLevel1Data(
value: numGov.value,
isPercentage: numGov.isValuePercentage,
subtitle: numGov.subtitle,
);
@override
get id => IndicatorEnum.hospitalsGovernment;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'numHospitals': numHospitals.toJson(),
'numPrivate': numPrivate.toJson(),
'numGov': numGov.toJson(),
'numClinicsAndCenters': numClinicsAndCenters.toJson(),
'numClinicsAndCentersGov': numClinicsAndCentersGov.toJson(),
'numClinicsAndCentersPrivate': numClinicsAndCentersPrivate.toJson(),
'healthcareProfessionalsBySpecialization': {
'data': healthcareProfessionalsBySpecialization.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': healthcareProfessionalsBySpecialization.subtitle.toJson(),
},
'hospitalBedsBySector': {
'data': hospitalBedsBySector.data.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
value,
),
),
'subtitle': hospitalBedsBySector.subtitle.toJson(),
},
'patientsByPatientTypeAndSector': patientsByPatientTypeAndSector != null
? {
'data': {
'government': {
'inpatients': patientsByPatientTypeAndSector!
.data.government.inpatients,
'outpatients': patientsByPatientTypeAndSector!
.data.government.outpatients,
},
'private': {
'inpatients':
patientsByPatientTypeAndSector!.data.private.inpatients,
'outpatients': patientsByPatientTypeAndSector!
.data.private.outpatients,
},
},
'subtitle': patientsByPatientTypeAndSector!.subtitle.toJson(),
}
: null,
};
factory HospitalsEntity.fromJson(
Map<String, dynamic> json,
) =>
HospitalsEntity(
numHospitals: SpecificDetailBoxData.fromJson(
json['numHospitals'],
),
numPrivate: SpecificDetailBoxData.fromJson(
json['numPrivate'],
),
numGov: SpecificDetailBoxData.fromJson(
json['numGov'],
),
numClinicsAndCenters: SpecificDetailBoxData.fromJson(
json['numClinicsAndCenters'],
),
numClinicsAndCentersGov: SpecificDetailBoxData.fromJson(
json['numClinicsAndCentersGov'],
),
numClinicsAndCentersPrivate: SpecificDetailBoxData.fromJson(
json['numClinicsAndCentersPrivate'],
),
healthcareProfessionalsBySpecialization: (
data: Map<Translatable, num>.from(
json['healthcareProfessionalsBySpecialization']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['healthcareProfessionalsBySpecialization']['subtitle']),
),
hospitalBedsBySector: (
data: Map<Translatable, num>.from(
json['hospitalBedsBySector']['data'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
value,
),
),
),
subtitle: TranslatableSerialization.fromJson(
json['hospitalBedsBySector']['subtitle'],
),
),
patientsByPatientTypeAndSector:
json['patientsByPatientTypeAndSector'] != null
? (
data: (
government: (
inpatients: json['patientsByPatientTypeAndSector']
['data']['government']['inpatients'],
outpatients: json['patientsByPatientTypeAndSector']
['data']['government']['outpatients'],
),
private: (
inpatients: json['patientsByPatientTypeAndSector']
['data']['private']['inpatients'],
outpatients: json['patientsByPatientTypeAndSector']
['data']['private']['outpatients'],
)
),
subtitle: TranslatableSerialization.fromJson(
json['patientsByPatientTypeAndSector']['subtitle']),
)
: null,
);
@override
bool operator ==(covariant HospitalsEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.numHospitals == numHospitals &&
other.numPrivate == numPrivate &&
other.numGov == numGov &&
other.numClinicsAndCenters == numClinicsAndCenters &&
other.numClinicsAndCentersGov == numClinicsAndCentersGov &&
other.numClinicsAndCentersPrivate == numClinicsAndCentersPrivate &&
other.healthcareProfessionalsBySpecialization.subtitle ==
healthcareProfessionalsBySpecialization.subtitle &&
mapEquals(
other.healthcareProfessionalsBySpecialization.data,
healthcareProfessionalsBySpecialization.data,
) &&
other.hospitalBedsBySector.subtitle == hospitalBedsBySector.subtitle &&
mapEquals(
other.hospitalBedsBySector.data,
hospitalBedsBySector.data,
) &&
other.patientsByPatientTypeAndSector == patientsByPatientTypeAndSector;
}
@override
int get hashCode {
return numHospitals.hashCode ^
numPrivate.hashCode ^
numGov.hashCode ^
numClinicsAndCenters.hashCode ^
numClinicsAndCentersGov.hashCode ^
numClinicsAndCentersPrivate.hashCode;
}
}

View File

@ -0,0 +1,154 @@
import 'dart:convert';
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class LaborForceEntity implements IndicatorEntity {
const LaborForceEntity({
required this.participationRateTotal,
required this.distributionByAge,
required this.participationRateMales,
required this.participationRateFemales,
required this.distributionByMaritalStatus,
required this.distributionByEducationLevel,
});
final SpecificDetailBoxData participationRateTotal;
final SpecificDetailBoxData participationRateMales;
final SpecificDetailBoxData participationRateFemales;
/// e.g. {"70-79": (male: 23, female: 23)}
final Map<Translatable, ({num male, num female})> distributionByMaritalStatus;
final Map<Translatable, ({num male, num female})> distributionByAge;
final Map<Translatable, ({num male, num female})>
distributionByEducationLevel;
@override
get level1Data => IndicatorLevel1Data(
value: participationRateTotal.value,
isPercentage: participationRateTotal.isValuePercentage,
subtitle: participationRateTotal.subtitle,
);
@override
get id => IndicatorEnum.laborForce;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'participationRateTotal': participationRateTotal.toJson(),
'participationRateMales': participationRateMales.toJson(),
'participationRateFemales': participationRateFemales.toJson(),
'distributionByMaritalStatus': distributionByMaritalStatus.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
{
'male': value.male,
'female': value.female,
},
),
),
'distributionByAge': distributionByAge.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
{
'male': value.male,
'female': value.female,
},
),
),
'distributionByEducationLevel': distributionByEducationLevel.map(
(key, value) => MapEntry(
jsonEncode(key.toJson()),
{
'male': value.male,
'female': value.female,
},
),
),
};
factory LaborForceEntity.fromJson(Map<String, dynamic> json) =>
LaborForceEntity(
participationRateTotal: SpecificDetailBoxData.fromJson(
json['participationRateTotal'],
),
participationRateMales: SpecificDetailBoxData.fromJson(
json['participationRateMales'],
),
participationRateFemales: SpecificDetailBoxData.fromJson(
json['participationRateFemales'],
),
distributionByMaritalStatus:
Map<Translatable, ({num male, num female})>.from(
json['distributionByMaritalStatus'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
(
male: value['male'],
female: value['female'],
),
),
),
),
distributionByAge: Map<Translatable, ({num male, num female})>.from(
json['distributionByAge'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
(
male: value['male'],
female: value['female'],
),
),
),
),
distributionByEducationLevel:
Map<Translatable, ({num male, num female})>.from(
json['distributionByEducationLevel'].map(
(key, value) => MapEntry(
TranslatableSerialization.fromJson(
jsonDecode(key),
),
(
male: value['male'],
female: value['female'],
),
),
),
),
);
@override
bool operator ==(covariant LaborForceEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
return other.participationRateTotal == participationRateTotal &&
other.participationRateMales == participationRateMales &&
other.participationRateFemales == participationRateFemales &&
mapEquals(
other.distributionByMaritalStatus,
distributionByMaritalStatus,
) &&
mapEquals(
other.distributionByAge,
distributionByAge,
) &&
mapEquals(
other.distributionByEducationLevel,
distributionByEducationLevel,
);
}
@override
int get hashCode =>
participationRateTotal.hashCode ^
participationRateMales.hashCode ^
participationRateFemales.hashCode;
}

View File

@ -0,0 +1,90 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:external_repos/src/domain/entities/specific_detail_box_data.dart';
import '../../indicator_detail.dart';
import '../../indicator_level_1_entity.dart';
class PopulationEntity implements IndicatorEntity {
const PopulationEntity({
required this.population,
required this.populationGrowth,
required this.genderDistribution,
});
final SpecificDetailBoxData population;
// // no data - also confidential
// /// e.g. {"70-79": (male: 23, female: 23)}
// final Map<Translatable, ({int male, int female})>? populationDistributionData;
final Map<int, int> populationGrowth;
final ({int male, int female}) genderDistribution;
@override
get level1Data => IndicatorLevel1Data(
value: population.value,
isPercentage: population.isValuePercentage,
subtitle: population.subtitle,
);
@override
get id => IndicatorEnum.population;
Map<String, dynamic> toJson() => <String, dynamic>{
'id': id.toJson(),
'population': population.toJson(),
'populationGrowth': populationGrowth.map(
(key, value) => MapEntry(
key.toString(),
value,
),
),
'genderDistribution': {
'male': genderDistribution.male,
'female': genderDistribution.female,
},
};
factory PopulationEntity.fromJson(Map<String, dynamic> map) =>
PopulationEntity(
population: SpecificDetailBoxData.fromJson(
map['population'],
),
populationGrowth: Map<String, int>.from(
map['populationGrowth'],
).map(
(key, value) => MapEntry(
int.parse(key),
value,
),
),
genderDistribution: (
male: map['genderDistribution']['male'],
female: map['genderDistribution']['female'],
),
);
@override
bool operator ==(covariant PopulationEntity other) {
if (identical(this, other)) return true;
final mapEquals = const MapEquality().equals;
var entries2 = <String, bool>{
'${other.population} == $population ': (other.population == population),
'${other.genderDistribution} == $genderDistribution ':
(other.genderDistribution == genderDistribution),
'mapEquals(${other.populationGrowth}, $populationGrowth)':
(mapEquals(other.populationGrowth, populationGrowth)),
}.entries;
for (var i = 0; i < entries2.length; i++) {
final e = entries2.elementAt(i);
if (e.value) continue;
print('${id.name} $i ${e.key}');
}
return other.population == population &&
other.genderDistribution == genderDistribution &&
mapEquals(other.populationGrowth, populationGrowth);
}
@override
int get hashCode => population.hashCode ^ populationGrowth.hashCode;
}

View File

@ -0,0 +1,80 @@
enum LanguageLocale {
enUS,
arAE;
static LanguageLocale fromName(
String string,
) =>
values.firstWhere(
(e) => e.name == string,
);
String toJson() => name;
@override
String toString() => name;
}
typedef Translatable = ({String en, String ar});
extension TranslatableSerialization on Translatable {
Map<String, dynamic> toJson() => {
'en': en,
'ar': ar,
};
static Translatable fromJson(Map<String, dynamic> data) => (
en: data['en'],
ar: data['ar'],
);
Translatable enbracket() => (
en: '($en)',
ar: '($ar)',
);
}
const _arabicAlphabet = [
'ا',
'ب',
'ج',
'د',
'ه',
'و',
'ز',
'ح',
'ط',
'ي',
'ك',
'ل',
'م',
'ن',
'س',
'ع',
'ف',
'ص',
'ق',
'ر',
'ش',
'ت',
'ث',
'خ',
'ذ',
'ض',
'ظ',
'غ',
];
int arabicComparator(String a, String b) {
int minLength = a.length < b.length ? a.length : b.length;
for (int i = 0; i < minLength; i++) {
int indexA = _arabicAlphabet.indexOf(a[i]);
int indexB = _arabicAlphabet.indexOf(b[i]);
if (indexA != indexB) {
return indexA - indexB;
}
}
return a.length - b.length; // Compare by length if all characters are equal
}

View File

@ -0,0 +1,62 @@
import 'package:external_repos/src/infrastructure/services/packages/list.dart';
import 'package:json_annotation/json_annotation.dart';
@JsonEnum(valueField: 'shortCode')
enum Publisher {
bf(shortCode: 'BF', nameEN: 'Brand Finance'),
bs(shortCode: 'BS', nameEN: 'BertelsmannStiftung'),
iep(shortCode: 'IEP', nameEN: 'Institute for Economics & Peace'),
imd(
shortCode: 'IMD',
nameEN: 'International Institute for Management Development',
),
insead(
shortCode: 'INSEAD',
nameEN: 'Institut Europeen d\'Administration des Affaires',
),
legatum(shortCode: 'LEGATUM', nameEN: 'Legatum Institute'),
openData(shortCode: 'ODIN', nameEN: 'Open Data Inventory'),
spi(shortCode: 'SPI', nameEN: 'Social Progress Imperative'),
un(shortCode: 'UN', nameEN: 'United Nations'),
unido(
shortCode: 'UNIDO',
nameEN: 'United Nations Industrial Development Organization',
),
unsdsn(
shortCode: 'UNSDSN',
nameEN: 'UN Sustainable Development Solutions Network',
),
wb(shortCode: 'WB', nameEN: 'The World Bank'),
wef(shortCode: 'WEF', nameEN: 'World Economic Forum'),
wipo(shortCode: 'WIPO', nameEN: 'World Intellectual Property Organization');
const Publisher({
required this.shortCode,
required this.nameEN,
});
factory Publisher.fromShortCode(String shortCode) {
if (shortCode == 'Open Data') return Publisher.openData;
final firstWhere = values.firstWhereOrNull(
(e) => e.shortCode.toLowerCase() == shortCode.toLowerCase(),
);
if (firstWhere == null) throw shortCode;
return firstWhere;
}
factory Publisher.fromNameEN(String nameEN) => values.firstWhere(
(e) => e.nameEN.toLowerCase() == nameEN.toLowerCase(),
);
// String toJson() => name;
// factory Publisher.fromJson(String name) {
// final e = values.firstWhereOrNull(
// (e) => e.name == name,
// );
// if (name == 'ODIN') return Publisher.openData;
// if (e == null) throw name;
// return e;
// }
final String shortCode;
final String nameEN;
}

View File

@ -0,0 +1,37 @@
import 'package:external_repos/src/domain/entities/publisher.dart';
import 'package:json_annotation/json_annotation.dart';
part 'report_entity.g.dart';
@JsonSerializable()
class ReportEntity {
const ReportEntity({
required this.reportNameEN,
required this.reportNameAR,
required this.year,
required this.publisher,
});
final String reportNameEN;
final int? year;
final Publisher publisher;
final String reportNameAR;
factory ReportEntity.fromJson(
Map<String, dynamic> json,
) =>
_$ReportEntityFromJson(json);
Map<String, dynamic> toJson() => _$ReportEntityToJson(this);
@override
bool operator ==(covariant ReportEntity other) => identical(this, other)
? true
: other.reportNameEN == reportNameEN &&
other.year == year &&
other.publisher == publisher;
@override
int get hashCode =>
reportNameEN.hashCode ^ year.hashCode ^ publisher.hashCode;
}

View File

@ -0,0 +1,39 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'report_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ReportEntity _$ReportEntityFromJson(Map<String, dynamic> json) => ReportEntity(
reportNameEN: json['reportNameEN'] as String,
reportNameAR: json['reportNameAR'] as String,
year: (json['year'] as num?)?.toInt(),
publisher: $enumDecode(_$PublisherEnumMap, json['publisher']),
);
Map<String, dynamic> _$ReportEntityToJson(ReportEntity instance) =>
<String, dynamic>{
'reportNameEN': instance.reportNameEN,
'year': instance.year,
'publisher': _$PublisherEnumMap[instance.publisher]!,
'reportNameAR': instance.reportNameAR,
};
const _$PublisherEnumMap = {
Publisher.bf: 'BF',
Publisher.bs: 'BS',
Publisher.iep: 'IEP',
Publisher.imd: 'IMD',
Publisher.insead: 'INSEAD',
Publisher.legatum: 'LEGATUM',
Publisher.openData: 'ODIN',
Publisher.spi: 'SPI',
Publisher.un: 'UN',
Publisher.unido: 'UNIDO',
Publisher.unsdsn: 'UNSDSN',
Publisher.wb: 'WB',
Publisher.wef: 'WEF',
Publisher.wipo: 'WIPO',
};

View File

@ -0,0 +1,110 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:json_annotation/json_annotation.dart';
part 'specific_detail_box_data.g.dart';
@JsonEnum()
enum Improvement { none, positive, negative }
@JsonSerializable()
class SpecificDetailBoxData {
const SpecificDetailBoxData({
this.title2,
required this.subtitle,
required this.value,
this.isValuePercentage = false,
this.prevValue,
this.isPrevValuePercentage,
this.overrideImprovement,
this.prevValueSubtitle,
});
final Translatable? title2;
final Translatable subtitle;
final num value;
final bool isValuePercentage;
final num? prevValue;
final bool? isPrevValuePercentage;
@JsonKey(
includeFromJson: true,
includeToJson: true,
)
final Improvement? overrideImprovement;
final Translatable? prevValueSubtitle;
Improvement? get didImprove {
if (overrideImprovement != null) return overrideImprovement;
if (prevValue == null) return null;
final areBothUnits =
!isValuePercentage && !(isPrevValuePercentage ?? false);
final areBothRates = isValuePercentage && (isPrevValuePercentage ?? false);
if (areBothUnits || areBothRates) {
if (value > prevValue!) return Improvement.positive;
if (value < prevValue!) return Improvement.negative;
if (value == prevValue!) return Improvement.none;
}
final isPrevValueRateOfChange =
!isValuePercentage && (isPrevValuePercentage ?? false);
if (isPrevValueRateOfChange) {
if (prevValue! > 0) return Improvement.positive;
if (prevValue! < 0) return Improvement.negative;
if ((prevValue!) == 0) return Improvement.none;
}
return null;
}
factory SpecificDetailBoxData.fromJson(
Map<String, dynamic> json,
) =>
_$SpecificDetailBoxDataFromJson(json);
Map<String, dynamic> toJson() => _$SpecificDetailBoxDataToJson(this);
@override
bool operator ==(covariant SpecificDetailBoxData other) {
if (identical(this, other)) return true;
var entries2 = <String, bool>{
'${other.title2} == $title2': other.title2 == title2,
'${other.subtitle} == $subtitle': other.subtitle == subtitle,
'${other.value} == $value': other.value == value,
'${other.isValuePercentage} == $isValuePercentage':
other.isValuePercentage == isValuePercentage,
'${other.prevValue} == $prevValue': other.prevValue == prevValue,
'${other.isPrevValuePercentage} == $isPrevValuePercentage':
other.isPrevValuePercentage == isPrevValuePercentage,
'${other.overrideImprovement} == $overrideImprovement':
other.overrideImprovement == overrideImprovement,
'${other.prevValueSubtitle} == $prevValueSubtitle':
other.prevValueSubtitle == prevValueSubtitle,
}.entries;
for (var i = 0; i < entries2.length; i++) {
final e = entries2.elementAt(i);
if (e.value) continue;
print('sdpd $i ${e.key}');
}
return other.title2 == title2 &&
other.subtitle == subtitle &&
other.value == value &&
other.isValuePercentage == isValuePercentage &&
other.prevValue == prevValue &&
other.isPrevValuePercentage == isPrevValuePercentage &&
other.overrideImprovement == overrideImprovement &&
other.prevValueSubtitle == prevValueSubtitle;
}
@override
int get hashCode {
return title2.hashCode ^
subtitle.hashCode ^
value.hashCode ^
isValuePercentage.hashCode ^
prevValue.hashCode ^
isPrevValuePercentage.hashCode ^
overrideImprovement.hashCode ^
prevValueSubtitle.hashCode;
}
@override
String toString() {
return 'SpecificDetailBoxData(title2: $title2, subtitle: $subtitle, value: $value, isValuePercentage: $isValuePercentage, prevValue: $prevValue, isPrevValuePercentage: $isPrevValuePercentage, _overrideImprovement: $overrideImprovement, prevValueSubtitle: $prevValueSubtitle)';
}
}

View File

@ -0,0 +1,83 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'specific_detail_box_data.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
SpecificDetailBoxData _$SpecificDetailBoxDataFromJson(
Map<String, dynamic> json) =>
SpecificDetailBoxData(
title2: _$recordConvertNullable(
json['title2'],
($jsonValue) => (
ar: $jsonValue['ar'] as String,
en: $jsonValue['en'] as String,
),
),
subtitle: _$recordConvert(
json['subtitle'],
($jsonValue) => (
ar: $jsonValue['ar'] as String,
en: $jsonValue['en'] as String,
),
),
value: json['value'] as num,
isValuePercentage: json['isValuePercentage'] as bool? ?? false,
prevValue: json['prevValue'] as num?,
isPrevValuePercentage: json['isPrevValuePercentage'] as bool?,
overrideImprovement: $enumDecodeNullable(
_$ImprovementEnumMap, json['overrideImprovement']),
prevValueSubtitle: _$recordConvertNullable(
json['prevValueSubtitle'],
($jsonValue) => (
ar: $jsonValue['ar'] as String,
en: $jsonValue['en'] as String,
),
),
);
Map<String, dynamic> _$SpecificDetailBoxDataToJson(
SpecificDetailBoxData instance) =>
<String, dynamic>{
'title2': instance.title2 == null
? null
: <String, dynamic>{
'ar': instance.title2!.ar,
'en': instance.title2!.en,
},
'subtitle': <String, dynamic>{
'ar': instance.subtitle.ar,
'en': instance.subtitle.en,
},
'value': instance.value,
'isValuePercentage': instance.isValuePercentage,
'prevValue': instance.prevValue,
'isPrevValuePercentage': instance.isPrevValuePercentage,
'overrideImprovement': _$ImprovementEnumMap[instance.overrideImprovement],
'prevValueSubtitle': instance.prevValueSubtitle == null
? null
: <String, dynamic>{
'ar': instance.prevValueSubtitle!.ar,
'en': instance.prevValueSubtitle!.en,
},
};
$Rec? _$recordConvertNullable<$Rec>(
Object? value,
$Rec Function(Map) convert,
) =>
value == null ? null : convert(value as Map<String, dynamic>);
$Rec _$recordConvert<$Rec>(
Object? value,
$Rec Function(Map) convert,
) =>
convert(value as Map<String, dynamic>);
const _$ImprovementEnumMap = {
Improvement.none: 'none',
Improvement.positive: 'positive',
Improvement.negative: 'negative',
};

View File

@ -0,0 +1,51 @@
import 'package:external_repos/external_repos.dart';
import 'package:json_annotation/json_annotation.dart';
part 'trade_commodity_entity.g.dart';
@JsonEnum()
enum TradeDirection { import, export, reExport }
@JsonSerializable()
class TradeCommodityEntity {
const TradeCommodityEntity({
required this.year,
required this.country,
required this.name,
required this.cost,
required this.tradeDirection,
});
final int year;
final ISOCountry country;
final Translatable name;
final num cost;
final TradeDirection tradeDirection;
factory TradeCommodityEntity.fromJson(
Map<String, dynamic> json,
) =>
_$TradeCommodityEntityFromJson(json);
Map<String, dynamic> toJson() => _$TradeCommodityEntityToJson(this);
@override
bool operator ==(covariant TradeCommodityEntity other) {
if (identical(this, other)) return true;
return other.year == year &&
other.country == country &&
other.name == name &&
other.cost == cost &&
other.tradeDirection == tradeDirection;
}
@override
int get hashCode {
return year.hashCode ^
country.hashCode ^
name.hashCode ^
cost.hashCode ^
tradeDirection.hashCode;
}
}

View File

@ -0,0 +1,302 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'trade_commodity_entity.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TradeCommodityEntity _$TradeCommodityEntityFromJson(
Map<String, dynamic> json) =>
TradeCommodityEntity(
year: (json['year'] as num).toInt(),
country: $enumDecode(_$ISOCountryEnumMap, json['country']),
name: _$recordConvert(
json['name'],
($jsonValue) => (
ar: $jsonValue['ar'] as String,
en: $jsonValue['en'] as String,
),
),
cost: json['cost'] as num,
tradeDirection:
$enumDecode(_$TradeDirectionEnumMap, json['tradeDirection']),
);
Map<String, dynamic> _$TradeCommodityEntityToJson(
TradeCommodityEntity instance) =>
<String, dynamic>{
'year': instance.year,
'country': _$ISOCountryEnumMap[instance.country]!,
'name': <String, dynamic>{
'ar': instance.name.ar,
'en': instance.name.en,
},
'cost': instance.cost,
'tradeDirection': _$TradeDirectionEnumMap[instance.tradeDirection]!,
};
const _$ISOCountryEnumMap = {
ISOCountry.numeric533: 533,
ISOCountry.numeric4: 4,
ISOCountry.numeric24: 24,
ISOCountry.numeric660: 660,
ISOCountry.numeric248: 248,
ISOCountry.numeric8: 8,
ISOCountry.numeric20: 20,
ISOCountry.numeric784: 784,
ISOCountry.numeric32: 32,
ISOCountry.numeric51: 51,
ISOCountry.numeric16: 16,
ISOCountry.numeric10: 10,
ISOCountry.numeric260: 260,
ISOCountry.numeric28: 28,
ISOCountry.numeric36: 36,
ISOCountry.numeric40: 40,
ISOCountry.numeric31: 31,
ISOCountry.numeric108: 108,
ISOCountry.numeric56: 56,
ISOCountry.numeric204: 204,
ISOCountry.numeric854: 854,
ISOCountry.numeric50: 50,
ISOCountry.numeric100: 100,
ISOCountry.numeric48: 48,
ISOCountry.numeric44: 44,
ISOCountry.numeric70: 70,
ISOCountry.numeric652: 652,
ISOCountry.numeric654: 654,
ISOCountry.numeric112: 112,
ISOCountry.numeric84: 84,
ISOCountry.numeric60: 60,
ISOCountry.numeric68: 68,
ISOCountry.numeric535: 535,
ISOCountry.numeric76: 76,
ISOCountry.numeric52: 52,
ISOCountry.numeric96: 96,
ISOCountry.numeric64: 64,
ISOCountry.numeric74: 74,
ISOCountry.numeric72: 72,
ISOCountry.numeric140: 140,
ISOCountry.numeric124: 124,
ISOCountry.numeric166: 166,
ISOCountry.numeric756: 756,
ISOCountry.numeric152: 152,
ISOCountry.numeric156: 156,
ISOCountry.numeric384: 384,
ISOCountry.numeric120: 120,
ISOCountry.numeric180: 180,
ISOCountry.numeric178: 178,
ISOCountry.numeric184: 184,
ISOCountry.numeric170: 170,
ISOCountry.numeric174: 174,
ISOCountry.numeric132: 132,
ISOCountry.numeric188: 188,
ISOCountry.numeric192: 192,
ISOCountry.numeric531: 531,
ISOCountry.numeric162: 162,
ISOCountry.numeric136: 136,
ISOCountry.numeric196: 196,
ISOCountry.numeric203: 203,
ISOCountry.numeric276: 276,
ISOCountry.numeric262: 262,
ISOCountry.numeric212: 212,
ISOCountry.numeric208: 208,
ISOCountry.numeric214: 214,
ISOCountry.numeric12: 12,
ISOCountry.numeric218: 218,
ISOCountry.numeric818: 818,
ISOCountry.numeric232: 232,
ISOCountry.numeric732: 732,
ISOCountry.numeric724: 724,
ISOCountry.numeric233: 233,
ISOCountry.numeric231: 231,
ISOCountry.numeric246: 246,
ISOCountry.numeric242: 242,
ISOCountry.numeric238: 238,
ISOCountry.numeric250: 250,
ISOCountry.numeric234: 234,
ISOCountry.numeric583: 583,
ISOCountry.numeric266: 266,
ISOCountry.numeric826: 826,
ISOCountry.numeric268: 268,
ISOCountry.numeric831: 831,
ISOCountry.numeric288: 288,
ISOCountry.numeric292: 292,
ISOCountry.numeric324: 324,
ISOCountry.numeric312: 312,
ISOCountry.numeric270: 270,
ISOCountry.numeric624: 624,
ISOCountry.numeric226: 226,
ISOCountry.numeric300: 300,
ISOCountry.numeric308: 308,
ISOCountry.numeric304: 304,
ISOCountry.numeric320: 320,
ISOCountry.numeric254: 254,
ISOCountry.numeric316: 316,
ISOCountry.numeric328: 328,
ISOCountry.numeric344: 344,
ISOCountry.numeric334: 334,
ISOCountry.numeric340: 340,
ISOCountry.numeric191: 191,
ISOCountry.numeric332: 332,
ISOCountry.numeric348: 348,
ISOCountry.numeric360: 360,
ISOCountry.numeric833: 833,
ISOCountry.numeric356: 356,
ISOCountry.numeric86: 86,
ISOCountry.numeric372: 372,
ISOCountry.numeric364: 364,
ISOCountry.numeric368: 368,
ISOCountry.numeric352: 352,
ISOCountry.numeric376: 376,
ISOCountry.numeric380: 380,
ISOCountry.numeric388: 388,
ISOCountry.numeric832: 832,
ISOCountry.numeric400: 400,
ISOCountry.numeric392: 392,
ISOCountry.numeric398: 398,
ISOCountry.numeric404: 404,
ISOCountry.numeric417: 417,
ISOCountry.numeric116: 116,
ISOCountry.numeric296: 296,
ISOCountry.numeric659: 659,
ISOCountry.numeric410: 410,
ISOCountry.numeric153: 153,
ISOCountry.numeric414: 414,
ISOCountry.numeric418: 418,
ISOCountry.numeric422: 422,
ISOCountry.numeric430: 430,
ISOCountry.numeric434: 434,
ISOCountry.numeric662: 662,
ISOCountry.numeric438: 438,
ISOCountry.numeric144: 144,
ISOCountry.numeric426: 426,
ISOCountry.numeric440: 440,
ISOCountry.numeric442: 442,
ISOCountry.numeric428: 428,
ISOCountry.numeric446: 446,
ISOCountry.numeric663: 663,
ISOCountry.numeric504: 504,
ISOCountry.numeric492: 492,
ISOCountry.numeric498: 498,
ISOCountry.numeric450: 450,
ISOCountry.numeric462: 462,
ISOCountry.numeric484: 484,
ISOCountry.numeric584: 584,
ISOCountry.numeric807: 807,
ISOCountry.numeric466: 466,
ISOCountry.numeric470: 470,
ISOCountry.numeric104: 104,
ISOCountry.numeric499: 499,
ISOCountry.numeric496: 496,
ISOCountry.numeric580: 580,
ISOCountry.numeric508: 508,
ISOCountry.numeric478: 478,
ISOCountry.numeric500: 500,
ISOCountry.numeric474: 474,
ISOCountry.numeric480: 480,
ISOCountry.numeric454: 454,
ISOCountry.numeric458: 458,
ISOCountry.numeric175: 175,
ISOCountry.numeric516: 516,
ISOCountry.numeric540: 540,
ISOCountry.numeric562: 562,
ISOCountry.numeric574: 574,
ISOCountry.numeric566: 566,
ISOCountry.numeric558: 558,
ISOCountry.numeric570: 570,
ISOCountry.numeric528: 528,
ISOCountry.numeric578: 578,
ISOCountry.numeric524: 524,
ISOCountry.numeric520: 520,
ISOCountry.numeric554: 554,
ISOCountry.numeric512: 512,
ISOCountry.numeric586: 586,
ISOCountry.numeric591: 591,
ISOCountry.numeric612: 612,
ISOCountry.numeric604: 604,
ISOCountry.numeric608: 608,
ISOCountry.numeric585: 585,
ISOCountry.numeric598: 598,
ISOCountry.numeric616: 616,
ISOCountry.numeric630: 630,
ISOCountry.numeric408: 408,
ISOCountry.numeric620: 620,
ISOCountry.numeric600: 600,
ISOCountry.numeric275: 275,
ISOCountry.numeric258: 258,
ISOCountry.numeric634: 634,
ISOCountry.numeric638: 638,
ISOCountry.numeric642: 642,
ISOCountry.numeric643: 643,
ISOCountry.numeric646: 646,
ISOCountry.numeric682: 682,
ISOCountry.numeric729: 729,
ISOCountry.numeric686: 686,
ISOCountry.numeric702: 702,
ISOCountry.numeric239: 239,
ISOCountry.numeric744: 744,
ISOCountry.numeric90: 90,
ISOCountry.numeric694: 694,
ISOCountry.numeric222: 222,
ISOCountry.numeric674: 674,
ISOCountry.numeric706: 706,
ISOCountry.numeric666: 666,
ISOCountry.numeric688: 688,
ISOCountry.numeric728: 728,
ISOCountry.numeric678: 678,
ISOCountry.numeric740: 740,
ISOCountry.numeric703: 703,
ISOCountry.numeric705: 705,
ISOCountry.numeric752: 752,
ISOCountry.numeric748: 748,
ISOCountry.numeric534: 534,
ISOCountry.numeric690: 690,
ISOCountry.numeric760: 760,
ISOCountry.numeric796: 796,
ISOCountry.numeric148: 148,
ISOCountry.numeric768: 768,
ISOCountry.numeric764: 764,
ISOCountry.numeric762: 762,
ISOCountry.numeric772: 772,
ISOCountry.numeric795: 795,
ISOCountry.numeric626: 626,
ISOCountry.numeric776: 776,
ISOCountry.numeric780: 780,
ISOCountry.numeric788: 788,
ISOCountry.numeric792: 792,
ISOCountry.numeric798: 798,
ISOCountry.numeric158: 158,
ISOCountry.numeric834: 834,
ISOCountry.numeric800: 800,
ISOCountry.numeric804: 804,
ISOCountry.numeric581: 581,
ISOCountry.numeric858: 858,
ISOCountry.numeric840: 840,
ISOCountry.numeric860: 860,
ISOCountry.numeric336: 336,
ISOCountry.numeric670: 670,
ISOCountry.numeric862: 862,
ISOCountry.numeric92: 92,
ISOCountry.numeric850: 850,
ISOCountry.numeric704: 704,
ISOCountry.numeric548: 548,
ISOCountry.numeric876: 876,
ISOCountry.numeric882: 882,
ISOCountry.numeric887: 887,
ISOCountry.numeric710: 710,
ISOCountry.numeric894: 894,
ISOCountry.numeric716: 716,
};
$Rec _$recordConvert<$Rec>(
Object? value,
$Rec Function(Map) convert,
) =>
convert(value as Map<String, dynamic>);
const _$TradeDirectionEnumMap = {
TradeDirection.import: 'import',
TradeDirection.export: 'export',
TradeDirection.reExport: 'reExport',
};

View File

@ -0,0 +1,39 @@
import '../../../entities/indicators/indicators_level_2/economic/aircrafts_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TAircraftsRepo {
Future<AircraftsEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const AircraftsEntity(
totalAircraftMovement: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
departures: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
arrivals: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
weeklyFlightsGraphData: {},
topDestinations: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,88 @@
import '../../../entities/indicators/indicators_level_2/economic/gdp_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TGdpRepo {
Future<GdpEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const GdpEntity(
constant: GdpDetails(
gdp: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
gdpGrowthRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
nonOilGdp: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
nonOilGdpGrowthRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
topEconomicActivitiesByGrowthRate: (
data: {},
year: 2022,
),
gdpValueGraphData: {},
topEconomicActivitiesByContribution: (
data: {},
year: 2022,
),
),
current: GdpDetails(
gdp: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
gdpGrowthRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
nonOilGdp: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
nonOilGdpGrowthRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
topEconomicActivitiesByGrowthRate: (
data: {},
year: 2022,
),
gdpValueGraphData: {},
topEconomicActivitiesByContribution: (
data: {},
year: 2022,
),
),
),
);
}

View File

@ -0,0 +1,42 @@
import '../../../entities/indicators/indicators_level_2/economic/hotels_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class THotelsRepo {
Future<HotelsEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const HotelsEntity(
hotelEstablishmentGuests: (
data: 1,
subtitle: (
en: '',
ar: '',
),
),
occupancyRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
averageLengthOfStay: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
averageDailyRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
guestArrival: (data: {}, year: 2022),
guestNights: (data: {}, year: 2022),
revenue: (data: {}, year: 2022),
hotelAndHotelApartmentsGraphData: {},
),
);
}

View File

@ -0,0 +1,43 @@
import '../../../entities/indicators/indicators_level_2/economic/inflation_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TInflationRepo {
Future<InflationEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const InflationEntity(
inflationRate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
highestMainGroup: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
lowestMainGroup: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
inflationByMajorGroups: (
data: {},
year: 2022,
),
inflationTimeSeries: (
data: {},
year: 2022,
),
inflationBySubGroup: (
data: {},
year: 2022,
),
),
);
}

View File

@ -0,0 +1,59 @@
import '../../../entities/indicators/indicators_level_2/economic/trade_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TTradeRepo {
Future<TradeEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const TradeEntity(
totalTrade: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
totalImports: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
totalNonOilExport: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
totalReExport: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
topTradePartners: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
tradeTrendAnnually: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
topTradeCommodities: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,8 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/crops_entity.dart';
class TCropsRepo {
Future<CropsEntity> get() => Future.delayed(
Duration(seconds: 3),
() => CropsEntity(),
);
}

View File

@ -0,0 +1,45 @@
import '../../../entities/indicators/indicators_level_2/environment/electricity_consumption_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TElectricityConsumptionRepo {
Future<ElectricityConsumptionEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const ElectricityConsumptionEntity(
consumption: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
consumptionGrowth: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
annualConsumption: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
electricityConsumptionByEmirate: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
electricityConsumptionBySector: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,46 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/electricity_production_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TElectricityProductionRepo {
Future<ElectricityProductionEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const ElectricityProductionEntity(
production: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
productionGrowth: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
annualProduction: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
electricityProductionByEmirate: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
electricityProductionByEntity: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,8 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/fisheries_entity.dart';
class TFisheriesRepo {
Future<FisheriesEntity> get() => Future.delayed(
Duration(seconds: 3),
() => FisheriesEntity(),
);
}

View File

@ -0,0 +1,39 @@
import '../../../entities/indicators/indicators_level_2/environment/natural_reserves_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TNaturalReservesRepo {
Future<NaturalReservesEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const NaturalReservesEntity(
totalReservesArea: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
protectedAreaCount: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
totalProtectedMarineArea: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
totalProtectedTerrestrialArea: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
protectedAreaCountByAnnouncementYear: {},
),
);
}

View File

@ -0,0 +1,45 @@
import '../../../entities/indicators/indicators_level_2/environment/oil_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TOilRepo {
Future<OilEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const OilEntity(
crudeOilProduction: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
crudeOilExports: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
crudeOilProductionAndExportsAnnualTrend: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
refinedOilProducts: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
naturalGasProductionExportsAndImportsAnnualTrend: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,45 @@
import '../../../entities/indicators/indicators_level_2/environment/water_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TWaterRepo {
Future<WaterEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const WaterEntity(
production: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
productionGrowth: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
annualProduction: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
qtyOfProducedWaterByEntity: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
municipalWaste: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
),
);
}

View File

@ -0,0 +1,8 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/divorce_entity.dart';
class TDivorceRepo {
Future<DivorceEntity> get() => Future.delayed(
Duration(seconds: 3),
() => DivorceEntity(),
);
}

View File

@ -0,0 +1,42 @@
import '../../../entities/indicators/indicators_level_2/social/general_education_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TGeneralEducationRepo {
Future<GeneralEducationEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const GeneralEducationEntity(
students: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
institutions: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
teachers: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
studentsByGender: (
male: 1,
female: 1,
period: '',
),
teachersByGender: (
male: 1,
female: 1,
period: '',
),
institutionsByAcademicYear: {},
),
);
}

View File

@ -0,0 +1,42 @@
import '../../../entities/indicators/indicators_level_2/social/higher_education_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class THigherEducationRepo {
Future<HigherEducationEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const HigherEducationEntity(
students: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
graduates: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
academicStaff: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
studentsByGender: (
male: 1,
female: 1,
period: '',
),
academicStaffByGender: (
male: 1,
female: 1,
period: '',
),
graduatedStudentsByFieldAndGender: {},
),
);
}

View File

@ -0,0 +1,82 @@
import '../../../entities/indicators/indicators_level_2/social/hospitals_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class THospitalsRepo {
Future<HospitalsEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const HospitalsEntity(
numHospitals: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
numPrivate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
numGov: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
numClinicsAndCenters: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
numClinicsAndCentersGov: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
numClinicsAndCentersPrivate: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
healthcareProfessionalsBySpecialization: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
hospitalBedsBySector: (
data: {},
subtitle: (
en: '',
ar: '',
),
),
patientsByPatientTypeAndSector: (
data: (
government: (
inpatients: 1,
outpatients: 1,
),
private: (
inpatients: 1,
outpatients: 1,
),
),
subtitle: (
en: '',
ar: '',
),
),
),
);
}

View File

@ -0,0 +1,34 @@
import '../../../entities/indicators/indicators_level_2/social/labor_force_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TLaborForceRepo {
Future<LaborForceEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const LaborForceEntity(
participationRateTotal: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
participationRateMales: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
participationRateFemales: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
distributionByAge: {},
distributionByMaritalStatus: {},
distributionByEducationLevel: {},
),
);
}

View File

@ -0,0 +1,8 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/marriage_entity.dart';
class TMarriageRepo {
Future<MarriageEntity> get() => Future.delayed(
Duration(seconds: 3),
() => MarriageEntity(),
);
}

View File

@ -0,0 +1,19 @@
import '../../../entities/indicators/indicators_level_2/social/population_entity.dart';
import '../../../entities/specific_detail_box_data.dart';
class TPopulationRepo {
Future<PopulationEntity> get() => Future.delayed(
Duration(seconds: 3),
() => const PopulationEntity(
population: SpecificDetailBoxData(
subtitle: (
en: '',
ar: '',
),
value: 1,
),
populationGrowth: {},
genderDistribution: (male: 1, female: 1),
),
);
}

View File

@ -0,0 +1,5 @@
import 'package:external_repos/external_repos.dart';
class TIndicatorsRepo {
Future<T> get<T extends IndicatorEntity>() => throw UnimplementedError();
}

View File

@ -0,0 +1,30 @@
import 'dart:async';
import 'package:external_repos/src/domain/entities/country.dart';
import 'package:external_repos/src/domain/entities/publisher.dart';
import '../entities/competitive_report_entity.dart';
class TExtCompetitiveReportsRepo {
Future<List<CompetitivenessReportEntity>> getAll() => Future.delayed(
Duration(seconds: 3),
() => List.generate(
10,
(i) => CompetitivenessReportEntity(
latestYear: 2020,
latestRank: 21,
previousYear: 2019,
previousRank: 90,
publisher: Publisher.wb,
reportCode: 'reportCode',
nameEN: 'nameEN $i',
nameAR: 'nameAR $i',
descriptionEN: 'descriptionEN $i',
descriptionAR: 'descriptionAR $i',
firstArabCountry: ISOCountry.numeric10,
firstGCCCountry: ISOCountry.numeric100,
firstGloballyCountry: ISOCountry.numeric104,
),
),
);
}

View File

@ -0,0 +1,13 @@
import 'dart:async';
import 'package:external_repos/src/domain/entities/country.dart';
import '../entities/country_fact_entity.dart';
class TExtCountryFactsRepo {
Future<Map<ISOCountry, List<CountryFactEntity>>> getAll() =>
throw UnimplementedError();
Future<List<CountryFactEntity>> getForCountry(ISOCountry country) =>
throw UnimplementedError();
}

View File

@ -0,0 +1,10 @@
import 'dart:async';
import 'package:external_repos/src/domain/entities/country.dart';
import '../entities/country_leader_entity.dart';
class TExtCountryLeadersRepo {
Future<Map<ISOCountry, List<CountryLeaderEntity>>> getAll() =>
throw UnimplementedError();
}

View File

@ -0,0 +1,10 @@
import 'dart:async';
import 'package:external_repos/src/domain/entities/country.dart';
import '../entities/trade_commodity_entity.dart';
class TExtTradeCommodityRepo {
Future<Map<ISOCountry, Map<TradeDirection, List<TradeCommodityEntity>>>>
getAll() => throw UnimplementedError();
}

View File

@ -0,0 +1,27 @@
import '../../domain/entities/competitive_report_entity.dart';
import '../../domain/repos/t_external_competitiveness_reports_repo.dart';
import '../models/informatica/reports_data_model.dart';
import '../services/informatica_api.dart';
class ExtCompetitiveReportsRepo implements TExtCompetitiveReportsRepo {
@override
Future<List<CompetitivenessReportEntity>> getAll() async {
final crmList = await InformaticaApi.reportsData();
final crmIds = crmList.map((e) => e.reportCode).toSet();
final List<List<ReportsDataModel>> groupedSameCrmDifferentYearList = [];
for (final crmId in crmIds) {
groupedSameCrmDifferentYearList.add(
crmList
.where(
(crm) => crm.reportCode == crmId,
)
.toList(),
);
}
return groupedSameCrmDifferentYearList
.map(
(e) => e.toReportModel(),
)
.toList();
}
}

View File

@ -0,0 +1,61 @@
import 'package:external_repos/src/infrastructure/services/informatica_api.dart';
import 'package:external_repos/src/infrastructure/services/packages/list.dart';
import '../../domain/entities/country.dart';
import '../../domain/entities/country_fact_entity.dart';
import '../../domain/repos/t_external_country_facts_repo.dart';
class ExtCountryFactsRepo implements TExtCountryFactsRepo {
@override
Future<Map<ISOCountry, List<CountryFactEntity>>> getAll() =>
InformaticaApi.countryIndicatorData().then(
(allCIMs) => allCIMs
.divideByKey(
(e) => ISOCountry.fromAlpha2(e.countryISO2Code),
)
.map(
(country, perCountryCIMs) {
final first = perCountryCIMs.first;
final isoCountry = ISOCountry.fromAlpha2(
first.countryISO2Code,
);
final capitalCityEntity = CountryFactEntity(
year: int.parse(first.year),
country: isoCountry,
valueEN: first.countryCapitalCityEN,
valueAR: first.countryCapitalCityAR,
nameEN: 'Capital City',
);
final entityList = [
...perCountryCIMs.map(
(e) => e.toCountryFactEntity(),
),
capitalCityEntity,
]..sort();
return MapEntry(country, entityList);
},
),
);
@override
Future<List<CountryFactEntity>> getForCountry(ISOCountry country) =>
InformaticaApi.countryIndicatorData(
country,
).then(
(cimList) {
final capitalCityEntity = CountryFactEntity(
year: int.parse(cimList.first.year),
country: country,
valueEN: cimList.first.countryCapitalCityEN,
valueAR: cimList.first.countryCapitalCityAR,
nameEN: 'Capital City',
);
return [
...cimList.map(
(e) => e.toCountryFactEntity(),
),
capitalCityEntity,
]..sort();
},
);
}

View File

@ -0,0 +1,33 @@
import 'package:external_repos/assets/cached_responses/sharepoint/lk_country_heads.dart';
import 'package:external_repos/src/infrastructure/services/packages/list.dart';
import '../../domain/entities/country.dart';
import '../../domain/entities/country_leader_entity.dart';
import '../../domain/repos/t_external_country_leaders_repo.dart';
import '../models/sharepoint/lk_country_heads_model.dart';
import '../services/sharepoint_fallback.dart';
/// currently hardcoded, source is sharepointTExternalCountryLeaders
class ExtCountryLeadersRepo implements TExtCountryLeadersRepo {
@override
Future<Map<ISOCountry, List<CountryLeaderEntity>>> getAll() async {
final leaders = await SharepointFallback.get(
lkCountryHeads,
fromObject: LKCountryHeadsModel.fromList,
);
final perCountryLeaders = leaders
.where(
(e) => (e.iso2Code as String).isNotEmpty,
)
.map(
(e) => e.toCountryLeaderEntity(),
)
.divideByKey((e) => e.country);
for (final key in perCountryLeaders.keys) {
perCountryLeaders[key]!.sort(
(a, b) => a.priorityScore.compareTo(b.priorityScore),
);
}
return perCountryLeaders;
}
}

View File

@ -0,0 +1,117 @@
import 'dart:async';
import 'package:sdmx/sdmx.dart';
import '../../domain/entities/country.dart';
import '../../domain/entities/trade_commodity_entity.dart';
import '../../domain/repos/t_external_trade_commodity_repo.dart';
class ExtTradeCommodityRepo implements TExtTradeCommodityRepo {
static final _unsupportedCountries = [
'Not Defined',
'Netherlands Antilles',
'Channel Islands',
'West Indies',
];
@override
Future<Map<ISOCountry, Map<TradeDirection, List<TradeCommodityEntity>>>>
getAll() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> importObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> exportObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> reExportObs;
await Future.wait([
() async {
const path =
'FCSA,DF_TRADE_IMP_SECT_YR,5.0.0/.A.......?startPeriod=2020&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
importObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_EXP_SECT_YR,5.0.0/.A.......?startPeriod=2020&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
exportObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_REXP_SECT_YR,5.0.0/.A.......?startPeriod=2020&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
reExportObs = sdmx.toObservationList();
}(),
]);
final imports = importObs.map(
(ob) {
if (ob.value is! num) return null;
if (_unsupportedCountries.contains(ob.dimensionsEN['Country'])) {
return null;
}
final country = ISOCountry.fromNameEN(ob.dimensionsEN['Country']!);
return TradeCommodityEntity(
year: ob.timePeriod.year,
country: country,
name: ob.dimensionsENToTranslatable['Harmonised System Section']!,
cost: ob.value,
tradeDirection: TradeDirection.import,
);
},
).whereType<TradeCommodityEntity>();
final exports = exportObs.map(
(ob) {
if (ob.value is! num) return null;
if (_unsupportedCountries.contains(ob.dimensionsEN['Country'])) {
return null;
}
final country = ISOCountry.fromNameEN(
ob.dimensionsEN['Country']!,
);
return TradeCommodityEntity(
year: ob.timePeriod.year,
country: country,
name: ob.dimensionsENToTranslatable['Harmonised System Section']!,
cost: ob.value,
tradeDirection: TradeDirection.export,
);
},
).whereType<TradeCommodityEntity>();
final reExports = reExportObs.map(
(ob) {
if (ob.value is! num) return null;
if (_unsupportedCountries.contains(ob.dimensionsEN['Country'])) {
return null;
}
final country = ISOCountry.fromNameEN(ob.dimensionsEN['Country']!);
return TradeCommodityEntity(
year: ob.timePeriod.year,
country: country,
name: ob.dimensionsENToTranslatable['Harmonised System Section']!,
cost: ob.value,
tradeDirection: TradeDirection.reExport,
);
},
).whereType<TradeCommodityEntity>();
final entries = ISOCountry.values.map(
(country) => MapEntry(
country,
{
TradeDirection.export: exports
.where(
(e) => e.country == country,
)
.toList(),
TradeDirection.import: imports
.where(
(e) => e.country == country,
)
.toList(),
TradeDirection.reExport: reExports
.where(
(e) => e.country == country,
)
.toList(),
},
),
);
return Map.fromEntries(entries);
}
}

View File

@ -0,0 +1,173 @@
// ignore_for_file: prefer_const_constructors
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/economic/aircrafts_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/economic/t_aircraft_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtAircraftsRepo implements TAircraftsRepo {
@override
Future<AircraftsEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> aircraftObs;
// late final Iterable<SimplifiedObservation<YearTimePeriod>> passengerObs;
await Future.wait(
[
// () async {
// const path =
// 'FCSA,DF_PASSENGER_MOV,1.6.0/.A....?startPeriod=2016&dimensionAtObservation=AllDimensions';
// final sdmx = await SDMXService.get<YearTimePeriod>(path);
// passengerObs = sdmx.toObservationList();
// }(),
() async {
const path =
'FCSA,DF_AIRCRAFT_MOV,1.6.0/.A....?startPeriod=2016&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
aircraftObs = sdmx.toObservationList();
}(),
],
);
final weeklyFlightsGraphData = aircraftObs
.divideByKey(
(e) => e.dimensionsEN['Time period'] as String,
)
.map(
(year, obs) => MapEntry(
(
en: year,
ar: year,
),
(
toUAE: obs
.filterEN(
{
'Type of Movement': ['Arrivals'],
'Reference area': ['UAE'],
},
)
.first
.value as num,
fromUAE: obs
.filterEN(
{
'Type of Movement': ['Departures'],
'Reference area': ['UAE'],
},
)
.first
.value as num,
),
),
);
final aircraftsEntity = AircraftsEntity(
totalAircraftMovement: _totalAircraftMovement(aircraftObs),
departures: _departures(aircraftObs),
arrivals: _arrivals(aircraftObs),
weeklyFlightsGraphData: weeklyFlightsGraphData,
topDestinations: null,
);
return aircraftsEntity;
}
SpecificDetailBoxData _totalAircraftMovement(
Iterable<SimplifiedObservation<YearTimePeriod>> aircraftObs,
) {
final val = aircraftObs.filterLatest.filterEN({
'Reference area': [
'UAE',
'Other Local Airports',
],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
final prevVal = aircraftObs.filterPrev.filterEN({
'Reference area': [
'UAE',
'Other Local Airports',
],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
return SpecificDetailBoxData(
subtitle: (
en: '(${aircraftObs.latestTimePeriod.year})',
ar: '(${aircraftObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(${aircraftObs.prevTimePeriod.year})',
ar: '(${aircraftObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _departures(
Iterable<SimplifiedObservation<YearTimePeriod>> aircraftObs,
) {
final val = aircraftObs.filterLatest.filterEN({
'Type of Movement': ['Departures'],
'Reference area': ['UAE'],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
final prevVal = aircraftObs.filterPrev.filterEN({
'Type of Movement': ['Departures'],
'Reference area': ['UAE'],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
return SpecificDetailBoxData(
subtitle: (
en: '(${aircraftObs.latestTimePeriod.year})',
ar: '(${aircraftObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(${aircraftObs.prevTimePeriod.year})',
ar: '(${aircraftObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _arrivals(
Iterable<SimplifiedObservation<YearTimePeriod>> aircraftObs,
) {
final val = aircraftObs.filterLatest.filterEN({
'Type of Movement': ['Arrivals'],
'Reference area': ['UAE'],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
final prevVal = aircraftObs.filterPrev.filterEN({
'Type of Movement': ['Arrivals'],
'Reference area': ['UAE'],
}).fold<num>(
0,
(prev, e) => prev + (e.value as num),
);
return SpecificDetailBoxData(
subtitle: (
en: '(${aircraftObs.latestTimePeriod.year})',
ar: '(${aircraftObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(${aircraftObs.prevTimePeriod.year})',
ar: '(${aircraftObs.prevTimePeriod.year})',
),
);
}
}

View File

@ -0,0 +1,279 @@
import 'dart:math';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/economic/gdp_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/economic/t_gdp_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtGdpRepo implements TGdpRepo {
@override
Future<GdpEntity> get() async {
return GdpEntity(
current: await getDetail(
'FCSA,DF_QGDP_CUR,1.8.0/.Q......?startPeriod=2016-Q1&dimensionAtObservation=AllDimensions',
),
constant: await getDetail(
'FCSA,DF_QGDP_CON,1.8.0/.Q......?startPeriod=2016-Q1&dimensionAtObservation=AllDimensions',
),
);
}
static Future<GdpDetails> getDetail(
final String path,
) async {
final sdmx = await SDMXService.get<QuarterTimePeriod>(path);
final valueObs = sdmx.toObservationList().filterEN({
'GDP Unit': ['Value'],
}).compressToAnnualByTakingAverageOf4QuartersAndDiscardingIncompleteYears(
combinationMethod: CombinationMethod.sum,
);
final growthRateObs = sdmx.toObservationList().filterEN({
'GDP Unit': ['Annual growth rate'],
}).compressToAnnualByTakingAverageOf4QuartersAndDiscardingIncompleteYears(
combinationMethod: CombinationMethod.average,
);
return GdpDetails(
gdp: _gdp(valueObs),
gdpGrowthRate: _gdpGrowthRate(growthRateObs),
nonOilGdp: _nonOilGdp(valueObs),
nonOilGdpGrowthRate: _nonOilGdpGrowthRate(growthRateObs),
topEconomicActivitiesByGrowthRate:
_topEconomicActivitiesByGrowthRateGraphData(growthRateObs),
gdpValueGraphData: _gdpValueGraphData(valueObs),
topEconomicActivitiesByContribution:
_topEconomicActivitiesByContributionGraphData(valueObs),
);
}
static ({
Map<Translatable, num> data,
int year,
}) _topEconomicActivitiesByGrowthRateGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final data = obs.filterLatest
.filterEN(
{},
removeWhere: {
'Measure': [
'Non-oil Gross Domestic Product',
'Gross Domestic Product',
],
},
)
.divideByKey(
(o) => o.dimensionsENToTranslatable['Measure']!,
)
.map(
(measure, measure4QtrObs) => MapEntry(
measure,
measure4QtrObs.first.value as num,
),
);
return (
data: data,
year: obs.latestTimePeriod.year,
);
}
static Map<int, ({num gdp, num nonOilGdp})> _gdpValueGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) =>
Map.fromEntries(
obs.timePeriods.map(
(year) {
final gdp = obs
.filterEN(
{
'Time period': [year.year.toString()],
'Measure': ['Gross Domestic Product'],
},
)
.first
.value *
pow(10, 6);
final nonOilGdp = obs
.filterEN(
{
'Time period': [year.year.toString()],
'Measure': ['Non-oil Gross Domestic Product'],
},
)
.first
.value *
pow(10, 6);
return MapEntry(
year.year,
(
gdp: gdp as num,
nonOilGdp: nonOilGdp as num,
),
);
},
),
);
static ({
Map<Translatable, num> data,
int year,
}) _topEconomicActivitiesByContributionGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final filteredObs = obs.filterLatest.filterEN(
{},
removeWhere: {
'Measure': [
'Non-oil Gross Domestic Product',
'Non-Financial Corporations',
'Gross Domestic Product',
],
},
);
final valPerMeasure = filteredObs
.divideByKey(
(o) => o.dimensionsENToTranslatable['Measure']!,
)
.map(
(measure, obs) => MapEntry(measure, obs.first.value as num),
);
final sumVals = valPerMeasure.values.calculateSum();
final data = valPerMeasure.map(
(measure, val) => MapEntry(
measure,
val.asPctOf(sumVals),
),
);
return (
data: data,
year: obs.latestTimePeriod.year,
);
}
static SpecificDetailBoxData _gdp(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final gdp = (obs.filterLatest
.filterEN({
'Measure': ['Gross Domestic Product'],
})
.first
.value as num) *
pow(10, 6);
final gdpPrev = (obs.filterPrev
.filterEN({
'Measure': ['Gross Domestic Product'],
})
.first
.value as num) *
pow(10, 6);
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year}) (AED)',
ar: '(${obs.latestTimePeriod.year}) (درهم)',
),
value: gdp,
prevValue: gdpPrev,
prevValueSubtitle: (
en: '(${obs.prevTimePeriod.year})',
ar: '(${obs.prevTimePeriod.year})',
),
);
}
static SpecificDetailBoxData _gdpGrowthRate(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final gdpGrowthRate = obs.filterLatest
.filterEN({
'Measure': ['Gross Domestic Product'],
})
.first
.value;
final gdpGrowthRatePrev = obs.filterPrev
.filterEN({
'Measure': ['Gross Domestic Product'],
})
.first
.value;
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year}) (AED)',
ar: '(${obs.latestTimePeriod.year}) (درهم)',
),
value: gdpGrowthRate,
isValuePercentage: true,
prevValue: gdpGrowthRatePrev,
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(${obs.prevTimePeriod.year})',
ar: '(${obs.prevTimePeriod.year})',
),
);
}
static SpecificDetailBoxData _nonOilGdp(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final gdp = (obs.filterLatest
.filterEN({
'Measure': ['Non-oil Gross Domestic Product'],
})
.first
.value as num) *
pow(10, 6);
final gdpPrev = (obs.filterPrev
.filterEN({
'Measure': ['Non-oil Gross Domestic Product'],
})
.first
.value as num) *
pow(10, 6);
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year}) (AED)',
ar: '(${obs.latestTimePeriod.year}) (درهم)',
),
value: gdp,
prevValue: gdpPrev,
prevValueSubtitle: (
en: '(${obs.prevTimePeriod.year})',
ar: '(${obs.prevTimePeriod.year})',
),
);
}
static SpecificDetailBoxData _nonOilGdpGrowthRate(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final gdpGrowthRate = obs.filterLatest
.filterEN({
'Measure': ['Non-oil Gross Domestic Product'],
})
.first
.value;
final gdpGrowthRatePrev = obs.filterPrev
.filterEN({
'Measure': ['Non-oil Gross Domestic Product'],
})
.first
.value;
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year}) (AED)',
ar: '(${obs.latestTimePeriod.year}) (درهم)',
),
value: gdpGrowthRate,
isValuePercentage: true,
prevValue: gdpGrowthRatePrev,
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(${obs.prevTimePeriod.year})',
ar: '(${obs.prevTimePeriod.year})',
),
);
}
}

View File

@ -0,0 +1,303 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/economic/hotels_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/economic/t_hotels_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtHotelsRepo implements THotelsRepo {
@override
Future<HotelsEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> guestObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> hotelObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> ratingObs;
await Future.wait([
() async {
final sdmx = await SDMXService.get<YearTimePeriod>(
'FCSA,DF_GUEST_REGION,4.3.0/...A....?startPeriod=2016&dimensionAtObservation=AllDimensions',
);
guestObs = sdmx.toObservationList();
}(),
() async {
final sdmx = await SDMXService.get<YearTimePeriod>(
'FCSA,DF_HOT_INDICATOR,4.3.0/...A....?startPeriod=2016&dimensionAtObservation=AllDimensions',
);
hotelObs = sdmx.toObservationList();
}(),
() async {
final sdmx = await SDMXService.get<YearTimePeriod>(
'FCSA,DF_HOT_TYPE,4.3.0/...A....?startPeriod=2016&dimensionAtObservation=AllDimensions',
);
ratingObs = sdmx.toObservationList();
}(),
]);
return HotelsEntity(
hotelEstablishmentGuests: _hotelEstablishmentGuests(guestObs),
occupancyRate: _occupancyRate(hotelObs),
averageLengthOfStay: _averageLengthOfStay(
hotelObs,
),
averageDailyRate: _aveDailyRate(hotelObs),
guestArrival: _calcGuestArrivalGraphData(
guestObs,
),
guestNights: _calcGuestNightsGraphData(guestObs),
revenue: _revenueGraphData(hotelObs),
hotelAndHotelApartmentsGraphData: _hotelAndHotelApartments(ratingObs),
);
}
({
num data,
Translatable subtitle,
}) _hotelEstablishmentGuests(
Iterable<SimplifiedObservation<YearTimePeriod>> guestObs,
) {
final data = guestObs.filterLatest
.filterEN({
'Guest region': ['Total'],
'Hotel Indicator': ['Guest Arrival'],
})
.first
.value;
final subtitle = (
en: '(${guestObs.latestTimePeriod.year})',
ar: '(${guestObs.latestTimePeriod.year})',
);
return (
data: data,
subtitle: subtitle,
);
}
Map<int, Map<Translatable, num>> _hotelAndHotelApartments(
Iterable<SimplifiedObservation<YearTimePeriod>> ratingObs,
) {
final perYearObs = ratingObs.divideByKey(
(e) => int.parse(
e.dimensionsEN['Time period']!,
),
);
final perYearObsSortedEntries = perYearObs.entries.toList()
..sort(
(a, b) => b.key.compareTo(a.key),
);
final last2YearsEntries = [
perYearObsSortedEntries.reversed.secondLastItem,
perYearObsSortedEntries.reversed.last,
];
final entries = last2YearsEntries.map(
(yearObs) {
final value = yearObs.value
.filterEN(
{
'Hotel Indicator': ['Rooms'],
},
removeWhere: {
'Hotel Type': [
'Total Hotels and Hotel Apartments',
'Total Hotels',
'Total Hotel Apartments',
],
},
)
.divideByKey(
(obs) => obs.dimensionsENToTranslatable['Hotel Type']!,
)
.map(
(hotelType, obs) => MapEntry(
hotelType,
obs.first.value as num,
),
);
return MapEntry(yearObs.key, value);
},
);
return Map.fromEntries(entries);
}
({
Map<Translatable, num> data,
int year,
}) _revenueGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> hotelObs,
) {
final categories = {
'Other revenue',
'Food and beverage revenue',
'Room revenue',
};
final data = Map.fromEntries(
categories.map(
(e) {
final ob = hotelObs.filterEN({
'Hotel Indicator': [e],
}).first;
return MapEntry(
ob.dimensionsENToTranslatable['Hotel Indicator']!,
ob.value as num,
);
},
),
);
return (
data: data,
year: hotelObs.latestTimePeriod.year,
);
}
({Map<Translatable, num> data, int year}) _calcGuestArrivalGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> guestObs,
) {
final data = Map.fromEntries(
guestObs.filterLatest.filterEN(
{
'Hotel Indicator': ['Guest Arrival'],
},
removeWhere: {
'Guest region': ['Total'],
},
).map(
(e) => MapEntry(
e.dimensionsENToTranslatable['Guest region']!,
e.value as num,
),
),
);
return (
data: data,
year: guestObs.latestTimePeriod.year,
);
}
({Map<Translatable, num> data, int year}) _calcGuestNightsGraphData(
Iterable<SimplifiedObservation<YearTimePeriod>> guestObs,
) {
final data = Map.fromEntries(
guestObs.filterLatest.filterEN(
{
'Hotel Indicator': ['Guest nights'],
},
removeWhere: {
'Guest region': ['Total'],
},
).map(
(e) => MapEntry(
e.dimensionsENToTranslatable['Guest region']!,
e.value as num,
),
),
);
return (
data: data,
year: guestObs.latestTimePeriod.year,
);
}
SpecificDetailBoxData _aveDailyRate(
Iterable<SimplifiedObservation<YearTimePeriod>> hotelObs,
) {
final value = hotelObs.filterLatest
.filterEN({
'Hotel Indicator': ['Average room rate (ARR)'],
})
.first
.value as num;
final prevValue = hotelObs.filterPrev
.filterEN({
'Hotel Indicator': ['Average room rate (ARR)'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: value,
subtitle: (
en: '(${hotelObs.latestTimePeriod.year})',
ar: '(${hotelObs.latestTimePeriod.year})',
),
prevValue: prevValue.pctDifferenceFrom(value),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${hotelObs.prevTimePeriod.year})',
ar: '(مقابل ${hotelObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _occupancyRate(
Iterable<SimplifiedObservation<YearTimePeriod>> hotelObs,
) {
final totalRoomsLatest = hotelObs.filterLatest
.filterEN({
'Hotel Indicator': ['Total Available Rooms'],
})
.first
.value as num;
final occupiedRoomsLatest = hotelObs.filterLatest
.filterEN({
'Hotel Indicator': ['Total Occupaied Rooms'],
})
.first
.value as num;
final occupancyRateLatest = occupiedRoomsLatest.asPctOf(totalRoomsLatest);
final totalRoomsPrev = hotelObs.filterPrev
.filterEN({
'Hotel Indicator': ['Total Available Rooms'],
})
.first
.value as num;
final occupiedRoomsPrev = hotelObs.filterPrev
.filterEN({
'Hotel Indicator': ['Total Occupaied Rooms'],
})
.first
.value as num;
final occupancyRatePrev = occupiedRoomsPrev.asPctOf(totalRoomsPrev);
return SpecificDetailBoxData(
value: occupancyRateLatest,
isValuePercentage: true,
subtitle: (
en: '(${hotelObs.latestTimePeriod.year})',
ar: '(${hotelObs.latestTimePeriod.year})',
),
prevValue: occupancyRatePrev.pctDifferenceFrom(occupancyRateLatest),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${hotelObs.prevTimePeriod.year})',
ar: '(مقابل ${hotelObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _averageLengthOfStay(
Iterable<SimplifiedObservation<YearTimePeriod>> hotelObs,
) {
final value = hotelObs.filterLatest
.filterEN({
'Hotel Indicator': ['Length of Stay (Avg)'],
})
.first
.value as num;
final prevValue = hotelObs.filterPrev
.filterEN({
'Hotel Indicator': ['Length of Stay (Avg)'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: value,
subtitle: (
en: '(${hotelObs.latestTimePeriod.year})',
ar: '(${hotelObs.latestTimePeriod.year})',
),
prevValue: prevValue.pctDifferenceFrom(value),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${hotelObs.prevTimePeriod.year})',
ar: '(مقابل ${hotelObs.prevTimePeriod.year})',
),
);
}
}

View File

@ -0,0 +1,167 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/economic/inflation_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/economic/t_inflation_repo.dart';
import '../../../services/packages/list.dart';
class ExtInflationRepo implements TInflationRepo {
@override
Future<InflationEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> annualObs;
late final Iterable<SimplifiedObservation<QuarterTimePeriod>> qtrlyObs;
await Future.wait([
() async {
const path =
'FCSA,DF_CPI_ANN,3.2.0/CPI_ANNCHG21...A..?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
annualObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_CPI_Q,3.2.0/...Q..?startPeriod=2022-Q1&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<QuarterTimePeriod>(path);
qtrlyObs = sdmx.toObservationList();
}(),
]);
final inflationRate = SpecificDetailBoxData(
title2: (
en: 'General Index',
ar: 'الفهرس العام',
),
subtitle: (
en: annualObs.latestTimePeriod.year.toString(),
ar: annualObs.latestTimePeriod.year.toString(),
),
value: annualObs.filterLatest
.filterEN({
'CPI Division': ['All Items'],
})
.first
.value as num,
isValuePercentage: true,
);
return InflationEntity(
inflationRate: inflationRate,
highestMainGroup: _highestMainGroup(
annualObs.filterLatest,
),
lowestMainGroup: _lowestMainGroup(annualObs.filterLatest),
inflationByMajorGroups: _inflationByMajorGroups(annualObs),
inflationTimeSeries: _inflationTimeSeries(qtrlyObs),
inflationBySubGroup: null,
);
}
// Map<String, num> inflationBySubGroupGraphData(
// Iterable<SimplifiedObservation> annualObs.filterLatest,
// ) {
// annualObs.filterLatest.divideByKey(
// (ob) => ob.dimensions['CPI Division'],
// );
// return {
// 'Meat': 4.0,
// 'Vegetables': 3.8,
// 'Rent': 2.9,
// 'Utilities': 3.2,
// };
// }
({
Map<QuarterTimePeriod, num> data,
int year,
}) _inflationTimeSeries(
Iterable<SimplifiedObservation<QuarterTimePeriod>> qtrlyObs,
) {
final data = qtrlyObs
.divideByKey(
(e) => e.timePeriod,
)
.map(
(tp, obs) => MapEntry(
tp,
obs
.filterEN({
'CPI Division': ['All Items'],
})
.first
.value as num,
),
);
return (
data: data,
year: qtrlyObs.latestTimePeriod.year,
);
}
({
Map<Translatable, num> data,
int year,
}) _inflationByMajorGroups(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) =>
(
data: annualObs.filterLatest
.filterEN(
{},
removeWhere: {
'CPI Division': ['All Items'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['CPI Division']!,
)
.map(
(cat, obs) => MapEntry(cat, obs.first.value),
),
year: annualObs.latestTimePeriod.year
);
SpecificDetailBoxData _lowestMainGroup(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) {
final lowestOb = annualObs.filterLatest.filterEN(
{},
removeWhere: {
'CPI Division': ['All Items'],
},
).fold<SimplifiedObservation?>(
null,
(prev, ob) => ob.value < (prev?.value ?? double.infinity) ? ob : prev,
)!;
return SpecificDetailBoxData(
title2: lowestOb.dimensionsENToTranslatable['CPI Division']!,
subtitle: (
en: '(${annualObs.latestTimePeriod.year})',
ar: '(${annualObs.latestTimePeriod.year})',
),
value: lowestOb.value as num,
isValuePercentage: true,
);
}
SpecificDetailBoxData _highestMainGroup(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) {
final highestOb = annualObs.filterLatest.filterEN(
{},
removeWhere: {
'CPI Division': ['All Items'],
},
).fold<SimplifiedObservation?>(
null,
(prev, ob) =>
ob.value > (prev?.value ?? double.negativeInfinity) ? ob : prev,
)!;
return SpecificDetailBoxData(
title2: highestOb.dimensionsENToTranslatable['CPI Division']!,
subtitle: (
en: '(${annualObs.latestTimePeriod.year})',
ar: '(${annualObs.latestTimePeriod.year})',
),
value: highestOb.value as num,
isValuePercentage: true,
);
}
}

View File

@ -0,0 +1,321 @@
// ignore_for_file: prefer_const_constructors
import 'dart:isolate';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/economic/trade_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/economic/t_trade_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
typedef YearMonth = ({int year, int month});
class ExtTradeRepo implements TTradeRepo {
@override
Future<TradeEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> annualUAEObs;
late final Iterable<SimplifiedObservation<MonthTimePeriod>>
monthlyCountryTotalObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>>
annualCountryNonOilExportHSSObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>>
annualCountryReExportHSSObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>>
annualCountryImportHSSObs;
await Future.wait([
() async {
const path =
'FCSA,DF_TRADE_TOT_COUNTRY_MTH,5.0.0/.M.......?startPeriod=2020-01&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<MonthTimePeriod>(path);
monthlyCountryTotalObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_TOT_YR,5.0.0/.A.......?startPeriod=2017&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
annualUAEObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_IMP_SECT_YR,5.0.0/.A.......?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
annualCountryImportHSSObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_EXP_SECT_YR,5.0.0/.A.......?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
annualCountryNonOilExportHSSObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_TRADE_REXP_SECT_YR,5.0.0/.A.......?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
annualCountryReExportHSSObs = sdmx.toObservationList();
}(),
]);
return Isolate.run(
() => TradeEntity(
totalTrade: _totalTrade(monthlyCountryTotalObs),
totalImports: _totalImports(annualUAEObs),
totalNonOilExport: _totalNonOilExports(annualUAEObs),
totalReExport: _totalReExports(annualUAEObs),
topTradePartners: _topTradePartners(monthlyCountryTotalObs),
tradeTrendAnnually: _tradeTrendAnnually(
annualCountryImportHSSObs,
annualCountryNonOilExportHSSObs,
annualCountryReExportHSSObs,
),
topTradeCommodities: _topTradeCommodities(
annualCountryNonOilExportHSSObs,
annualCountryReExportHSSObs,
annualCountryImportHSSObs,
),
),
);
}
SpecificDetailBoxData _totalImports(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) {
final value = annualObs.filterLatest
.filterEN({
'Trade Type': ['Imports'],
})
.first
.value as num;
final prevValue = annualObs.filterPrev
.filterEN({
'Trade Type': ['Imports'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${annualObs.latestTimePeriod.year}) (AED)',
ar: '(${annualObs.latestTimePeriod.year}) (درهم)',
),
value: value,
prevValue: prevValue.pctDifferenceFrom(value),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${annualObs.prevTimePeriod.year})',
ar: '(مقابل ${annualObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _totalNonOilExports(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) {
final value = annualObs.filterLatest
.filterEN({
'Trade Type': ['Non-Oil Exports'],
})
.first
.value as num;
final prevValue = annualObs.filterPrev
.filterEN({
'Trade Type': ['Non-Oil Exports'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${annualObs.latestTimePeriod.year}) (AED)',
ar: '(${annualObs.latestTimePeriod.year}) (درهم)',
),
value: value,
prevValue: prevValue.pctDifferenceFrom(value),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${annualObs.prevTimePeriod.year})',
ar: '(مقابل ${annualObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _totalReExports(
Iterable<SimplifiedObservation<YearTimePeriod>> annualObs,
) {
final value = annualObs.filterLatest
.filterEN({
'Trade Type': ['Re-Exports'],
})
.first
.value as num;
final prevValue = annualObs.filterPrev
.filterEN({
'Trade Type': ['Re-Exports'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${annualObs.latestTimePeriod.year}) (AED)',
ar: '(${annualObs.latestTimePeriod.year}) (درهم)',
),
value: value,
prevValue: prevValue.pctDifferenceFrom(value),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${annualObs.prevTimePeriod.year})',
ar: '(مقابل ${annualObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _totalTrade(
Iterable<SimplifiedObservation<MonthTimePeriod>> monthlyCountryObs,
) {
final totalTrade = monthlyCountryObs.filterTillEndMonthLatestYear.sumValues;
final totalTradePrev =
monthlyCountryObs.filterTillEndMonthPrevYear.sumValues;
return SpecificDetailBoxData(
subtitle: (
en: '(${monthlyCountryObs.filterTillEndMonthLatestYear.toPeriodString()}) (AED)',
ar: '(${monthlyCountryObs.filterTillEndMonthLatestYear.toPeriodString()}) (درهم)',
),
value: totalTrade,
prevValue: totalTradePrev.pctDifferenceFrom(totalTrade),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${monthlyCountryObs.filterTillEndMonthPrevYear.toPeriodString()})',
ar: '(مقابل ${monthlyCountryObs.filterTillEndMonthPrevYear.toPeriodString()})',
),
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _topTradeCommodities(
Iterable<SimplifiedObservation<YearTimePeriod>>
annualCountryNonOilExportHSSObs,
Iterable<SimplifiedObservation<YearTimePeriod>> annualCountryReExportHSSObs,
Iterable<SimplifiedObservation<YearTimePeriod>> annualCountryImportHSSObs,
) {
final subtitle = (
en: '(${annualCountryNonOilExportHSSObs.latestTimePeriod.year}) (AED)',
ar: '(${annualCountryNonOilExportHSSObs.latestTimePeriod.year}) (درهم)',
);
final hssList = annualCountryNonOilExportHSSObs
.map(
(e) => e.dimensionsENToTranslatable['Harmonised System Section']!,
)
.toSet();
final entries = hssList.map(
(hss) {
final sum = [
annualCountryNonOilExportHSSObs,
annualCountryReExportHSSObs,
annualCountryImportHSSObs,
].map(
(obs) {
return obs.filterEN({
'Harmonised System Section': [hss.en],
}).sumValues;
},
).calculateSum();
return MapEntry(hss, sum);
},
);
final map = Map.fromEntries(entries);
return (
data: map,
subtitle: subtitle,
);
}
({
Map<int, ({num export, num import, num reExport})> data,
Translatable subtitle,
}) _tradeTrendAnnually(
Iterable<SimplifiedObservation<YearTimePeriod>> importObs,
Iterable<SimplifiedObservation<YearTimePeriod>> exportObs,
Iterable<SimplifiedObservation<YearTimePeriod>> reExportObs,
) {
final subtitle = (
en: '(${importObs.latestTimePeriod.year}) (AED)',
ar: '(${importObs.latestTimePeriod.year}) (درهم)',
);
final years = importObs.timePeriods.map(
(e) => e.year.toString(),
);
final data = Map.fromEntries(
years.map(
(year) {
final import = importObs.filterEN({
'Time period': [year],
}).fold<num>(
0,
(prev, e) => prev + (e.value is num ? e.value : 0),
);
final export = exportObs.filterEN({
'Time period': [year],
}).fold<num>(
0,
(prev, e) => prev + (e.value is num ? e.value : 0),
);
final reExport = reExportObs.filterEN({
'Time period': [year],
}).fold<num>(
0,
(prev, e) => prev + (e.value is num ? e.value : 0),
);
return MapEntry(
int.parse(year),
(
import: import,
reExport: reExport,
export: export,
),
);
},
),
);
return (
data: data,
subtitle: subtitle,
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _topTradePartners(
Iterable<SimplifiedObservation<MonthTimePeriod>> monthlyCountryObs,
) {
final latestYearNMonthObs = monthlyCountryObs.filterTillEndMonthLatestYear;
final subtitle = (
en: '(${latestYearNMonthObs.toPeriodString()}) (AED)',
ar: '(${latestYearNMonthObs.toPeriodString()}) (درهم)',
);
final countryObs = latestYearNMonthObs.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Country'],
)..removeWhere(
(key, value) => [
'Not Defined',
'Netherlands Antilles',
'Channel Islands',
'West Indies',
].contains(key!.en),
);
final data = countryObs.map(
(country, obs) => MapEntry(
country!,
obs.fold<num>(
0,
(prev, e) => prev + (e.value is num ? e.value : 0),
),
),
);
return (
data: data,
subtitle: subtitle,
);
}
}

View File

@ -0,0 +1,12 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/crops_entity.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/environment/t_crops_repo.dart';
class ExtCropsRepo implements TCropsRepo {
static const _path =
'FCSA,DF_CROP_EM,3.0.0/.A......?startPeriod=2015&dimensionAtObservation=AllDimensions';
@override
Future<CropsEntity> get() async {
return CropsEntity();
}
}

View File

@ -0,0 +1,168 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/environment/electricity_consumption_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/environment/t_electricity_consumption_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtElectricityConsumptionRepo implements TElectricityConsumptionRepo {
@override
Future<ElectricityConsumptionEntity> get() async {
const path =
'FCSA,DF_CE,5.3.0/A...............?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
final consumptionObs = sdmx.toObservationList();
final consumption = _calculateConsumption(consumptionObs);
return ElectricityConsumptionEntity(
consumption: consumption,
consumptionGrowth: _consumptionGrowth(consumptionObs, consumption.value),
annualConsumption: _annualConsumption(consumptionObs),
electricityConsumptionByEmirate:
_electricityConsumptionByEmirate(consumptionObs),
electricityConsumptionBySector:
_electricityConsumptionBySector(consumptionObs),
);
}
SpecificDetailBoxData _calculateConsumption(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final val = consumptionObs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Sector': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
ar: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
),
value: val,
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _electricityConsumptionBySector(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final data = consumptionObs.filterLatest
.filterEN(
{},
removeWhere: {
'Sector': ['Total'],
'Reference area': ['UAE'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Sector']!,
)
.map(
(year, ob) {
final totalConsumption = ob.first.value as num;
return MapEntry(year, totalConsumption);
},
);
return (
data: data,
subtitle: (
en: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
ar: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
),
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _electricityConsumptionByEmirate(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final data = consumptionObs.filterLatest
.filterEN(
{},
removeWhere: {
'Reference area': ['UAE'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Reference area']!,
)
.map(
(year, ob) {
final totalConsumption = ob.first.value as num;
return MapEntry(year, totalConsumption);
},
);
return (
data: data,
subtitle: (
en: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
ar: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
),
);
}
({
Map<int, num> data,
Translatable subtitle,
}) _annualConsumption(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final data = consumptionObs
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.map(
(year, ob) {
final totalConsumption = ob
.filterEN({
'Reference area': ['UAE'],
'Sector': ['Total'],
})
.first
.value as num;
return MapEntry(
int.parse(year),
totalConsumption,
);
},
);
return (
data: data,
subtitle: (
en: '(GWh)',
ar: '(GWh)',
),
);
}
SpecificDetailBoxData _consumptionGrowth(
Iterable<SimplifiedObservation<YearTimePeriod>> encObs,
num latestConsumptionValue,
) {
final prevValue = encObs.filterPrev
.filterEN({
'Reference area': ['UAE'],
'Sector': ['Total'],
})
.first
.value as num;
final growthRate = prevValue.pctDifferenceFrom(
latestConsumptionValue,
);
return SpecificDetailBoxData(
subtitle: (
en: '(vs. ${encObs.prevTimePeriod.year})',
ar: '(مقابل ${encObs.prevTimePeriod.year})',
),
value: growthRate,
isValuePercentage: true,
);
}
}

View File

@ -0,0 +1,168 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/electricity_production_entity.dart';
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/environment/t_electricity_production_repo.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtElectricityProductionRepo implements TElectricityProductionRepo {
@override
Future<ElectricityProductionEntity> get() async {
const path =
'FCSA,DF_GROSS_GEN,5.3.0/A...............?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
final productionObs = sdmx.toObservationList();
final production = _calculateProduction(productionObs);
return ElectricityProductionEntity(
production: production,
productionGrowth: _productionGrowth(productionObs, production.value),
annualProduction: _annualProduction(productionObs),
electricityProductionByEmirate:
_electricityProductionByEmirate(productionObs),
electricityProductionByEntity:
_electricityProductionByEntity(productionObs),
);
}
SpecificDetailBoxData _calculateProduction(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final val = consumptionObs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Entity Name': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
ar: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
),
value: val,
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _electricityProductionByEntity(
Iterable<SimplifiedObservation<YearTimePeriod>> productionObs,
) {
final data = productionObs.filterLatest
.filterEN(
{},
removeWhere: {
'Entity Name': ['UAE'],
'Reference area': ['UAE'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Entity Name']!,
)
.map(
(year, ob) {
final totalProduction = ob.first.value as num;
return MapEntry(year, totalProduction);
},
);
return (
data: data,
subtitle: (
en: '(${productionObs.latestTimePeriod.year}) (GWh)',
ar: '(${productionObs.latestTimePeriod.year}) (GWh)',
),
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _electricityProductionByEmirate(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final data = consumptionObs.filterLatest
.filterEN(
{},
removeWhere: {
'Reference area': ['UAE'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Reference area']!,
)
.map(
(year, ob) {
final totalConsumption = ob.first.value as num;
return MapEntry(year, totalConsumption);
},
);
return (
data: data,
subtitle: (
en: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
ar: '(${consumptionObs.latestTimePeriod.year}) (GWh)',
),
);
}
({
Map<int, num> data,
Translatable subtitle,
}) _annualProduction(
Iterable<SimplifiedObservation<YearTimePeriod>> consumptionObs,
) {
final data = consumptionObs
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.map(
(year, ob) {
final totalConsumption = ob
.filterEN({
'Reference area': ['UAE'],
'Entity Name': ['UAE'],
})
.first
.value as num;
return MapEntry(
int.parse(year),
totalConsumption,
);
},
);
return (
data: data,
subtitle: (
en: '(GWh)',
ar: '(GWh)',
),
);
}
SpecificDetailBoxData _productionGrowth(
Iterable<SimplifiedObservation<YearTimePeriod>> encObs,
num latestConsumptionValue,
) {
final prevValue = encObs.filterPrev
.filterEN({
'Reference area': ['UAE'],
'Entity Name': ['UAE'],
})
.first
.value as num;
final growthRate = prevValue.pctDifferenceFrom(
latestConsumptionValue,
);
return SpecificDetailBoxData(
subtitle: (
en: '(vs. ${encObs.prevTimePeriod.year})',
ar: '(مقابل ${encObs.prevTimePeriod.year})',
),
value: growthRate,
isValuePercentage: true,
);
}
}

View File

@ -0,0 +1,12 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/fisheries_entity.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/environment/t_fisheries_repo.dart';
class ExtFisheriesRepo implements TFisheriesRepo {
static const _path =
'FCSA,DF_FISH_CAUGHT,2.3.0/...A.....?startPeriod=2015&dimensionAtObservation=AllDimensions';
@override
Future<FisheriesEntity> get() async {
return FisheriesEntity();
}
}

View File

@ -0,0 +1,148 @@
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/environment/natural_reserves_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/environment/t_natural_reserves_repo.dart';
import '../../../services/packages/list.dart';
class ExtNaturalReservesRepo implements TNaturalReservesRepo {
@override
Future<NaturalReservesEntity> get() async {
const path =
'FCSA,DF_NR_PROTECT,5.8.0/...A...?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
final obs = sdmx.toObservationList();
return NaturalReservesEntity(
totalReservesArea: _totalReservesArea(obs),
protectedAreaCount: _protectedAreaCount(obs),
totalProtectedMarineArea: _totalProtectedMarineArea(obs),
totalProtectedTerrestrialArea: _totalProtectedTerrestrialArea(obs),
protectedAreaCountByAnnouncementYear:
_protectedAreaCountByAnnouncementYearGraphData(obs),
);
}
Map<
int,
({
int countByAnnouncementYear,
int protectedAreasCumulativeCount,
})> _protectedAreaCountByAnnouncementYearGraphData(
Iterable<SimplifiedObservation> obs,
) {
final yearlyNumbers = obs
.filterEN({
'Reference area': ['UAE'],
'Natural Reserve Type': ['Total'],
'Unit of measure': ['Number'],
})
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.entries
.toList();
final result = <int,
({
int countByAnnouncementYear,
int protectedAreasCumulativeCount,
})>{};
for (int i = 0; i < yearlyNumbers.length; i++) {
final e = yearlyNumbers[i];
final year = e.key;
final val = e.value.first.value;
final prevYear = (int.parse(year) - 1).toString();
final prevVal = yearlyNumbers
.firstWhereOrNull((yearlyNumber) => yearlyNumber.key == prevYear)
?.value
.first
.value;
if (prevVal == null) continue;
final deltaVal = val - prevVal;
result[int.parse(year)] = (
countByAnnouncementYear: deltaVal.toInt(),
protectedAreasCumulativeCount: val,
);
}
return result;
}
SpecificDetailBoxData _totalProtectedTerrestrialArea(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final value = obs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Natural Reserve Type': ['Terrestrial'],
'Unit of measure': ['Area Km2'],
})
.first
.value;
return SpecificDetailBoxData(
value: value,
subtitle: (
en: '(${obs.latestTimePeriod.year}) (Km2)',
ar: '(${obs.latestTimePeriod.year}) (Km2)',
),
);
}
SpecificDetailBoxData _totalProtectedMarineArea(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final value = obs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Natural Reserve Type': ['Marine'],
'Unit of measure': ['Area Km2'],
})
.first
.value;
return SpecificDetailBoxData(
value: value,
subtitle: (
en: '(${obs.latestTimePeriod.year}) (Km2)',
ar: '(${obs.latestTimePeriod.year}) (Km2)',
),
);
}
SpecificDetailBoxData _totalReservesArea(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final value = obs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Natural Reserve Type': ['Total'],
'Unit of measure': ['Area Km2'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year}) (Km2)',
ar: '(${obs.latestTimePeriod.year}) (Km2)',
),
value: value,
);
}
SpecificDetailBoxData _protectedAreaCount(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final value = obs.filterLatest
.filterEN({
'Reference area': ['UAE'],
'Natural Reserve Type': ['Total'],
'Unit of measure': ['Number'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: obs.latestTimePeriod.year.toString(),
ar: obs.latestTimePeriod.year.toString(),
),
value: value,
);
}
}

View File

@ -0,0 +1,177 @@
// ignore_for_file: prefer_const_constructors
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/environment/oil_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/environment/t_oil_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtOilRepo implements TOilRepo {
@override
Future<OilEntity> get() async {
const path =
'FCSA,DF_CO,4.1.0/.A..........?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
final obs = sdmx.toObservationList();
return OilEntity(
crudeOilProduction: _production(obs),
crudeOilExports: _exports(obs),
crudeOilProductionAndExportsAnnualTrend:
_crudeOilProductionAndExportsAnnualTrend(obs),
refinedOilProducts: null,
naturalGasProductionExportsAndImportsAnnualTrend: null,
// naturalGasProductionExportsAndImportsAnnualTrendGraphData,
);
}
SpecificDetailBoxData _exports(
List<SimplifiedObservation<YearTimePeriod>> obs,
) {
final val = obs.filterLatest
.filterEN({
'Oil and Gas Variables': ['Export'],
})
.first
.value as num;
final prevVal = obs.filterPrev
.filterEN({
'Oil and Gas Variables': ['Export'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${obs.latestTimePeriod.year}) (1000 b/d)',
ar: '(${obs.latestTimePeriod.year}) (1000 b/d)',
),
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${obs.prevTimePeriod.year})',
ar: '(مقابل ${obs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _production(
List<SimplifiedObservation<YearTimePeriod>> obs,
) {
final val = obs.filterLatest
.filterEN({
'Oil and Gas Variables': ['Production'],
})
.first
.value as num;
final prevVal = obs.filterPrev
.filterEN({
'Oil and Gas Variables': ['Production'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${obs.latestTimePeriod.year}) (1000 b/d)',
ar: '(${obs.latestTimePeriod.year}) (1000 b/d)',
),
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${obs.prevTimePeriod.year})',
ar: '(مقابل ${obs.prevTimePeriod.year})',
),
);
}
// Map<
// int,
// ({
// num exports,
// num imports,
// num production,
// })> naturalGasProductionExportsAndImportsAnnualTrend(
// Iterable<SimplifiedObservation> obs,
// ) {
// return obs
// .divideByKey(
// (ob) => ob.dimensionsEN['Time period']!,
// )
// .map(
// (year, obs) {
// final exports = obs
// .filterEN({
// 'Oil and Gas Variables': ['Export']
// })
// .first
// .value;
// final production = obs
// .filterEN({
// 'Oil and Gas Variables': ['Production']
// })
// .first
// .value;
// return MapEntry(
// int.parse(year),
// (
// exports: exports,
// imports: 1,
// production: production,
// ),
// );
// },
// );
// // return {
// // 2019: (exports: 500, imports: 200, production: 700),
// // 2020: (exports: 550, imports: 250, production: 750),
// // 2021: (exports: 600, imports: 300, production: 800),
// // 2022: (exports: 650, imports: 350, production: 850),
// // 2023: (exports: 700, imports: 400, production: 900),
// // };
// }
({
Map<int, ({num exports, num production})> data,
Translatable subtitle,
}) _crudeOilProductionAndExportsAnnualTrend(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final data = obs
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.map(
(year, obs) {
final exports = obs
.filterEN({
'Oil and Gas Variables': ['Export'],
})
.first
.value as num;
final production = obs
.filterEN({
'Oil and Gas Variables': ['Production'],
})
.first
.value as num;
return MapEntry(
int.parse(year),
(
exports: exports,
production: production,
),
);
},
);
return (
data: data,
subtitle: (
en: '(1000 b/d)',
ar: '(1000 b/d)',
),
);
}
}

View File

@ -0,0 +1,143 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/environment/water_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/environment/t_water_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtWaterRepo implements TWaterRepo {
@override
Future<WaterEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> waterObs;
// late final Iterable<SimplifiedObservation<YearTimePeriod>> municipalObs;
await Future.wait(
[
() async {
const path =
'FCSA,DF_PW_QUANTITY_PROD_WATER,5.7.0/.A..........?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
waterObs = sdmx.toObservationList();
}(),
// () async {
// const path =
// 'FCSA,DF_NONHAZARDOUS_WASTE,3.6.0/...A.MUNI.....?startPeriod=2018&dimensionAtObservation=AllDimensions';
// final sdmx = await SDMXService.get<YearTimePeriod>(path);
// municipalObs = sdmx.toObservationList();
// }(),
],
);
final municipalOb = await SDMXService.get<YearTimePeriod>(
'FCSA,DF_NONHAZARDOUS_WASTE,3.6.0/...A.MUNI.....?startPeriod=2018&dimensionAtObservation=AllDimensions',
).then(
(sdmx) => sdmx.toObservationList().filterLatest.filterEN({
'Waste Management': ['Total'],
}).first,
);
final production = _calculateProduction(waterObs);
return WaterEntity(
production: production,
productionGrowth: _productionGrowth(
waterObs,
production.value,
),
annualProduction: _annualProduction(waterObs),
qtyOfProducedWaterByEntity: _qtyOfProducedWaterByEntity(waterObs),
municipalWaste: SpecificDetailBoxData(
subtitle: municipalOb.dimensionsENToTranslatable['Unit of measure']!
.enbracket(),
value: municipalOb.value as num,
),
);
}
SpecificDetailBoxData _productionGrowth(
Iterable<SimplifiedObservation<YearTimePeriod>> waterObs,
num latestValue,
) {
final prevVal = waterObs.filterPrev
.filterEN({
'Entity': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: prevVal.pctDifferenceFrom(latestValue),
subtitle: (
en: waterObs.prevTimePeriod.year.toString(),
ar: waterObs.prevTimePeriod.year.toString(),
),
isValuePercentage: true,
);
}
SpecificDetailBoxData _calculateProduction(
Iterable<SimplifiedObservation<YearTimePeriod>> waterObs,
) =>
SpecificDetailBoxData(
subtitle: (
en: '(${waterObs.latestTimePeriod.year}) (MCM)',
ar: '(${waterObs.latestTimePeriod.year}) (MCM)',
),
value: waterObs.filterLatest
.filterEN({
'Entity': ['Total'],
})
.first
.value as num,
);
({
Map<Translatable, num> data,
Translatable subtitle,
}) _qtyOfProducedWaterByEntity(
Iterable<SimplifiedObservation<YearTimePeriod>> latestObs,
) {
final data = latestObs
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Entity']!,
)
.map(
(entity, ob) => MapEntry(
entity,
ob.first.value as num,
),
);
return (
data: data,
subtitle: (
en: '(${latestObs.latestTimePeriod.year}) (MCM)',
ar: '(${latestObs.latestTimePeriod.year}) (MCM)',
)
);
}
({
Map<int, num> data,
Translatable subtitle,
}) _annualProduction(
Iterable<SimplifiedObservation> obs,
) {
final val = obs
.filterEN({
'Entity': ['Total'],
})
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.map(
(year, ob) => MapEntry(
int.parse(year),
ob.first.value as num,
),
);
return (
data: val,
subtitle: (
en: 'MCM',
ar: 'MCM',
),
);
}
}

View File

@ -0,0 +1,62 @@
import 'package:external_repos/external_repos.dart';
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/crops_entity.dart';
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/electricity_production_entity.dart';
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/environment/fisheries_entity.dart';
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/divorce_entity.dart';
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/marriage_entity.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/economic/t_aircraft_repo.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/t_indicators_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_crops_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_electricity_production_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_fisheries_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_divorce_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_marriage_repo.dart';
import 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_population_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/economic/ext_aircraft_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/economic/ext_gdp_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/economic/ext_hotels_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/economic/ext_inflation_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/economic/ext_trade_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_electricity_consumption_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_natural_reserves_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_oil_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/environment/ext_water_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_general_education_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_higher_education_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_hospitals_repo.dart';
export 'package:external_repos/src/infrastructure/data/indicators_level_2/social/ext_labor_force_repo.dart';
class PIndicatorsRepo implements TIndicatorsRepo {
@override
Future<T> get<T extends IndicatorEntity>() async {
final result = await {
// economy
AircraftsEntity: TAircraftsRepo().get(),
GdpEntity: ExtGdpRepo().get(),
HotelsEntity: ExtHotelsRepo().get(),
InflationEntity: ExtInflationRepo().get(),
TradeEntity: ExtTradeRepo().get(),
// environment
CropsEntity: ExtCropsRepo().get(),
ElectricityConsumptionEntity: ExtElectricityConsumptionRepo().get(),
ElectricityProductionEntity: ExtElectricityProductionRepo().get(),
FisheriesEntity: ExtFisheriesRepo().get(),
NaturalReservesEntity: ExtNaturalReservesRepo().get(),
OilEntity: ExtOilRepo().get(),
WaterEntity: ExtWaterRepo().get(),
// social
DivorceEntity: ExtDivorceRepo().get(),
GeneralEducationEntity: ExtGeneralEducationRepo().get(),
HigherEducationEntity: ExtHigherEducationRepo().get(),
HospitalsEntity: ExtHospitalsRepo().get(),
LaborForceEntity: ExtLaborForceRepo().get(),
MarriageEntity: ExtMarriageRepo().get(),
PopulationEntity: ExtPopulationRepo().get(),
}[T];
if (result == null) {
throw '$T generic not passed or need to add example above';
}
return result as T;
}
}

View File

@ -0,0 +1,12 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/divorce_entity.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/social/t_divorce_repo.dart';
class ExtDivorceRepo implements TDivorceRepo {
static const _path =
'FCSA,DF_DV_NA,1.5.0/.A....?startPeriod=2015&dimensionAtObservation=AllDimensions';
@override
Future<DivorceEntity> get() async {
return DivorceEntity();
}
}

View File

@ -0,0 +1,217 @@
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/social/general_education_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/social/t_general_education_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtGeneralEducationRepo implements TGeneralEducationRepo {
@override
Future<GeneralEducationEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> stuObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> instObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> teachObs;
await Future.wait(
[
() async {
const path =
'FCSA,DF_EDU_STUD,1.3.0/...A.....?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
stuObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_EDU_INSTIT,1.3.0/...A.....?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
instObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_EDU_TEACH,1.3.0/...A.....?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
teachObs = sdmx.toObservationList();
}(),
],
);
return GeneralEducationEntity(
students: _students(stuObs),
institutions: _institutions(instObs),
teachers: _teachers(teachObs),
studentsByGender: _studentsByGender(stuObs),
teachersByGender: _teachersByGender(teachObs),
institutionsByAcademicYear: _instByYear(instObs),
);
}
SpecificDetailBoxData _teachers(
Iterable<SimplifiedObservation<YearTimePeriod>> teachObs,
) {
final val = teachObs.filterLatest
.filterEN({
'Gender': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
final prevVal = teachObs.filterPrev
.filterEN({
'Gender': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${teachObs.latestTimePeriod.year - 1}-${teachObs.latestTimePeriod.year})',
ar: '(${teachObs.latestTimePeriod.year - 1}-${teachObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${teachObs.prevTimePeriod.year - 1}-${teachObs.prevTimePeriod.year})',
ar: '(مقابل ${teachObs.prevTimePeriod.year - 1}-${teachObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _institutions(
Iterable<SimplifiedObservation<YearTimePeriod>> instObs,
) {
final val = instObs.filterLatest
.filterEN({
'Education Sector': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
final prevVal = instObs.filterPrev
.filterEN({
'Education Sector': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${instObs.latestTimePeriod.year - 1}-${instObs.latestTimePeriod.year})',
ar: '(${instObs.latestTimePeriod.year - 1}-${instObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${instObs.prevTimePeriod.year - 1}-${instObs.prevTimePeriod.year})',
ar: '(مقابل ${instObs.prevTimePeriod.year - 1}-${instObs.prevTimePeriod.year})',
),
);
}
SpecificDetailBoxData _students(
Iterable<SimplifiedObservation<YearTimePeriod>> stuObs,
) {
final val = stuObs.filterLatest
.filterEN({
'Gender': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
final prevVal = stuObs.filterPrev
.filterEN({
'Gender': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${stuObs.latestTimePeriod.year - 1}-${stuObs.latestTimePeriod.year})',
ar: '(${stuObs.latestTimePeriod.year - 1}-${stuObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${stuObs.prevTimePeriod.year - 1}-${stuObs.prevTimePeriod.year})',
ar: '(مقابل ${stuObs.prevTimePeriod.year - 1}-${stuObs.prevTimePeriod.year})',
),
);
}
Map<String, num> _instByYear(
Iterable<SimplifiedObservation> instObs,
) =>
instObs.divideByKey(
(ob) {
final year = int.parse(ob.dimensionsEN['Time period']!);
return '${year - 1}-$year';
},
).map(
(period, obs) => MapEntry(
period,
obs
.filterEN({
'Education Sector': ['Total'],
'Education Cycle': ['Total'],
})
.first
.value,
),
);
({
int female,
int male,
String period,
}) _teachersByGender(
Iterable<SimplifiedObservation<YearTimePeriod>> teachObs,
) {
final obs = teachObs.filterLatest.filterEN({
'Education Cycle': ['Total'],
});
final male = obs
.firstWhere(
(e) => e.dimensionsEN['Gender'] == 'Male',
)
.value;
final female = obs
.firstWhere(
(e) => e.dimensionsEN['Gender'] == 'Female',
)
.value;
return (
male: male,
female: female,
period: '${obs.latestTimePeriod.year - 1}-${obs.latestTimePeriod.year}',
);
}
({
int female,
int male,
String period,
}) _studentsByGender(
Iterable<SimplifiedObservation<YearTimePeriod>> stuObs,
) {
final obs = stuObs.filterLatest.filterEN({
'Education Cycle': ['Total'],
});
final male = obs
.firstWhere(
(e) => e.dimensionsEN['Gender'] == 'Male',
)
.value;
final female = obs
.firstWhere(
(e) => e.dimensionsEN['Gender'] == 'Female',
)
.value;
return (
male: male,
female: female,
period: '${obs.latestTimePeriod.year - 1}-${obs.latestTimePeriod.year}',
);
}
}

View File

@ -0,0 +1,192 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/social/higher_education_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/social/t_higher_education_repo.dart';
import '../../../services/packages/list.dart';
class ExtHigherEducationRepo implements THigherEducationRepo {
@override
Future<HigherEducationEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> stuObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> gradObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> teachObs;
await Future.wait(
[
() async {
const path =
'FCSA,DF_HE_STUDENTS_ARG,2.3.0/.A.......?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
stuObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_HE_GRADUATES,2.3.0/.A.......?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
gradObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_HE_HEIN,2.3.0/.A.......TA?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
teachObs = sdmx.toObservationList();
}(),
],
);
return HigherEducationEntity(
students: _students(stuObs),
graduates: _grads(gradObs),
academicStaff: _teachers(teachObs),
studentsByGender: _studentsByGender(stuObs),
academicStaffByGender: _teachByGender(teachObs),
graduatedStudentsByFieldAndGender: _gradByFieldGender(gradObs),
);
}
SpecificDetailBoxData _grads(
Iterable<SimplifiedObservation<YearTimePeriod>> gradObs,
) {
final val = gradObs.filterLatest
.filterEN({
'Major': ['Total: All fields of education'],
'Gender': ['Total'],
})
.first
.value;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${gradObs.latestTimePeriod.year - 1}-${gradObs.latestTimePeriod.year})',
ar: '(${gradObs.latestTimePeriod.year - 1}-${gradObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _teachers(
Iterable<SimplifiedObservation<YearTimePeriod>> teachObs,
) {
final val = teachObs.filterLatest
.filterEN({
'Gender': ['Total'],
})
.first
.value;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${teachObs.latestTimePeriod.year - 1}-${teachObs.latestTimePeriod.year})',
ar: '(${teachObs.latestTimePeriod.year - 1}-${teachObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _students(
Iterable<SimplifiedObservation<YearTimePeriod>> stuObs,
) {
final val = stuObs.filterLatest
.filterEN({
'Gender': ['Total'],
'Level of Education': ['Total'],
})
.first
.value;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${stuObs.latestTimePeriod.year - 1}-${stuObs.latestTimePeriod.year})',
ar: '(${stuObs.latestTimePeriod.year - 1}-${stuObs.latestTimePeriod.year})',
),
);
}
Map<
Translatable,
({
int female,
int male,
})> _gradByFieldGender(
Iterable<SimplifiedObservation> gradObs,
) =>
gradObs.filterLatest
.filterEN(
{},
removeWhere: {
'Major': ['Total: All fields of education'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Major']!,
)
.map(
(major, obs) {
final value = (
male: obs
.filterEN({
'Gender': ['Male'],
})
.first
.value
.toInt() as int,
female: obs
.filterEN({
'Gender': ['Female'],
})
.first
.value
.toInt() as int
);
return MapEntry(major, value);
},
);
({
int female,
int male,
String period,
}) _teachByGender(
Iterable<SimplifiedObservation<YearTimePeriod>> teachObs,
) =>
(
male: teachObs.filterLatest
.filterEN({
'Gender': ['Male'],
})
.first
.value,
female: teachObs.filterLatest
.filterEN({
'Gender': ['Female'],
})
.first
.value,
period:
'${teachObs.latestTimePeriod.year - 1}-${teachObs.latestTimePeriod.year}',
);
({
int female,
int male,
String period,
}) _studentsByGender(
Iterable<SimplifiedObservation<YearTimePeriod>> stuObs,
) =>
(
male: stuObs.filterLatest
.filterEN({
'Gender': ['Male'],
'Level of Education': ['Total'],
})
.first
.value,
female: stuObs.filterLatest
.filterEN({
'Gender': ['Female'],
'Level of Education': ['Total'],
})
.first
.value,
period:
'${stuObs.latestTimePeriod.year - 1}-${stuObs.latestTimePeriod.year}',
);
}

View File

@ -0,0 +1,326 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/social/hospitals_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/social/t_hospitals_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtHospitalsRepo implements THospitalsRepo {
@override
Future<HospitalsEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> professionObs;
await Future.wait(
[
() async {
const path =
'FCSA,DF_HEALTH_FACILITIES,3.1.0/...A....?startPeriod=2010&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
facilityObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_HEALTH_GENDER,3.1.0/...A....?startPeriod=2021&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
professionObs = sdmx.toObservationList();
}(),
],
);
return HospitalsEntity(
numHospitals: _numHospitals(facilityObs),
numPrivate: _numHospitalsPriv(facilityObs),
numGov: _numHospitalsGov(facilityObs),
numClinicsAndCenters: _cncTotal(facilityObs),
numClinicsAndCentersGov: _cncGov(facilityObs),
numClinicsAndCentersPrivate: _cncPrivate(facilityObs),
healthcareProfessionalsBySpecialization:
_healthcareProfessionalsBySpecialization(
professionObs,
),
hospitalBedsBySector: _hospitalBedsBySector(facilityObs),
patientsByPatientTypeAndSector: null,
);
}
SpecificDetailBoxData _numHospitals(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Total'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value as num;
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Total'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _numHospitalsGov(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Government'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value as num;
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Government'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _numHospitalsPriv(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Private'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value as num;
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Private'],
'Measure': ['Hospitals'],
'Reference area': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
value: val,
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _hospitalBedsBySector(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final gov = facilityObs.filterLatest
.filterEN({
'Sector': ['Government'],
'Measure': ['Beds'],
'Reference area': ['UAE'],
})
.first
.value as num;
final priv = facilityObs.filterLatest
.filterEN({
'Sector': ['Private'],
'Measure': ['Beds'],
'Reference area': ['UAE'],
})
.first
.value as num;
final total = gov + priv;
final data = {
(
en: 'Government',
ar: 'حكومة',
): gov,
(
en: 'Private',
ar: 'خاص',
): priv,
};
return (
data: data,
subtitle: (
en: 'Total - ${total.toStringWithCommas()} (${facilityObs.latestTimePeriod.year})',
ar: 'Total - ${total.toStringWithCommas()} (${facilityObs.latestTimePeriod.year})',
)
);
}
({
Map<Translatable, num> data,
Translatable subtitle,
}) _healthcareProfessionalsBySpecialization(
Iterable<SimplifiedObservation<YearTimePeriod>> proObs,
) {
final data = proObs.filterLatest
.filterEN({
'Sector': ['Total'],
'Reference area': ['UAE'],
})
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Measure']!,
)
.map(
(spec, obs) => MapEntry(
spec,
// fold gender
obs.fold<num>(
0,
(prev, e) => prev + e.value,
),
),
);
final total = data.values.calculateSum();
return (
data: data,
subtitle: (
en: 'Total - ${total.toStringWithCommas()} (${proObs.latestTimePeriod.year})',
ar: 'Total - ${total.toStringWithCommas()} (${proObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _cncTotal(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Total'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Total'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _cncGov(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Government'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Government'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
SpecificDetailBoxData _cncPrivate(
Iterable<SimplifiedObservation<YearTimePeriod>> facilityObs,
) {
final val = facilityObs.filterLatest
.filterEN({
'Sector': ['Private'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
final prevVal = facilityObs.filterPrev
.filterEN({
'Sector': ['Private'],
'Measure': ['Clinics and Health Centres'],
'Reference area': ['UAE'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${facilityObs.latestTimePeriod.year})',
ar: '(${facilityObs.latestTimePeriod.year})',
),
value: val,
prevValue: prevVal.pctDifferenceFrom(val),
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${facilityObs.latestTimePeriod.year})',
ar: '(مقابل ${facilityObs.latestTimePeriod.year})',
),
);
}
}

View File

@ -0,0 +1,203 @@
import 'package:external_repos/src/domain/entities/language_locale.dart';
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/social/labor_force_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/social/t_labor_force_repo.dart';
import '../../../services/packages/list.dart';
class ExtLaborForceRepo implements TLaborForceRepo {
@override
Future<LaborForceEntity> get() async {
late final Iterable<SimplifiedObservation<YearTimePeriod>> educationObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> ageObs;
late final Iterable<SimplifiedObservation<YearTimePeriod>> maritalObs;
await Future.wait(
[
() async {
const path =
'FCSA,DF_LFEP_AGE,2.0.0/.A...............?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
ageObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_LFEP_ED,2.0.0/.A...............?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
educationObs = sdmx.toObservationList();
}(),
() async {
const path =
'FCSA,DF_LFPR_MAR,2.0.0/.A...............?startPeriod=2019&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
maritalObs = sdmx.toObservationList();
}(),
],
);
final participationRateTotal = SpecificDetailBoxData(
subtitle: (
en: '(${maritalObs.latestTimePeriod.year})',
ar: '(${maritalObs.latestTimePeriod.year})',
),
value: maritalObs.filterLatest
.filterEN({
'Citizenship': ['Total'],
'Gender': ['Total'],
'Marital': ['Total'],
})
.first
.value as num,
isValuePercentage: true,
);
final maleParticipationRate = SpecificDetailBoxData(
subtitle: (
en: '(${maritalObs.latestTimePeriod.year})',
ar: '(${maritalObs.latestTimePeriod.year})',
),
value: maritalObs.filterLatest
.filterEN({
'Citizenship': ['Total'],
'Gender': ['Male'],
'Marital': ['Total'],
})
.first
.value as num,
isValuePercentage: true,
);
final femaleParticipationRate = SpecificDetailBoxData(
subtitle: (
en: '(${maritalObs.latestTimePeriod.year})',
ar: '(${maritalObs.latestTimePeriod.year})',
),
isValuePercentage: true,
value: maritalObs.filterLatest
.filterEN({
'Citizenship': ['Total'],
'Gender': ['Female'],
'Marital': ['Total'],
})
.first
.value as num,
);
return LaborForceEntity(
participationRateTotal: participationRateTotal,
participationRateMales: maleParticipationRate,
participationRateFemales: femaleParticipationRate,
distributionByAge: _calculateDistributionByAge(ageObs),
distributionByMaritalStatus:
_calculateDistributionByMaritalStatus(maritalObs),
distributionByEducationLevel:
_calculateDistributionByEducationLevel(educationObs),
);
}
Map<Translatable, ({num female, num male})>
_calculateDistributionByMaritalStatus(
Iterable<SimplifiedObservation> obs,
) =>
obs.filterLatest
.filterEN(
{
'Citizenship': ['Total'],
},
removeWhere: {
'Marital': ['Total'],
'Gender': ['Total'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Marital']!,
)
.map(
(maritalStatus, ob) => MapEntry(
maritalStatus,
(
male: ob
.filterEN({
'Gender': ['Male'],
})
.first
.value as num,
female: ob
.filterEN({
'Gender': ['Female'],
})
.first
.value as num,
),
),
);
Map<Translatable, ({num female, num male})> _calculateDistributionByAge(
Iterable<SimplifiedObservation<YearTimePeriod>> ageObs,
) =>
ageObs.filterLatest
.filterEN(
{
'Citizenship': ['Total'],
},
removeWhere: {
'Age': ['Total'],
'Gender': ['Total'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Age']!,
)
.map(
(maritalStatus, ob) => MapEntry(
maritalStatus,
(
male: ob
.filterEN({
'Gender': ['Male'],
})
.first
.value as num,
female: ob
.filterEN({
'Gender': ['Female'],
})
.first
.value as num,
),
),
);
Map<Translatable, ({num female, num male})>
_calculateDistributionByEducationLevel(
Iterable<SimplifiedObservation> obs,
) =>
obs.filterLatest
.filterEN(
{
'Citizenship': ['Total'],
},
removeWhere: {
'Education': ['Total'],
'Gender': ['Total'],
},
)
.divideByKey(
(ob) => ob.dimensionsENToTranslatable['Education']!,
)
.map(
(maritalStatus, ob) => MapEntry(
maritalStatus,
(
male: ob
.filterEN({
'Gender': ['Male'],
})
.first
.value as num,
female: ob
.filterEN({
'Gender': ['Female'],
})
.first
.value as num,
),
),
);
}

View File

@ -0,0 +1,12 @@
import 'package:external_repos/src/domain/entities/indicators/indicators_level_2/social/marriage_entity.dart';
import 'package:external_repos/src/domain/repos/indicators_level_2/social/t_marriage_repo.dart';
class ExtMarriageRepo implements TMarriageRepo {
static const _path =
'FCSA,DF_MR_NA,1.4.0/.A....?startPeriod=2015&dimensionAtObservation=AllDimensions';
@override
Future<MarriageEntity> get() async {
return MarriageEntity();
}
}

View File

@ -0,0 +1,82 @@
import 'package:sdmx/sdmx.dart';
import '../../../../domain/entities/indicators/indicators_level_2/social/population_entity.dart';
import '../../../../domain/entities/specific_detail_box_data.dart';
import '../../../../domain/repos/indicators_level_2/social/t_population_repo.dart';
import '../../../services/packages/list.dart';
import '../../../services/packages/num_abbreviation.dart';
class ExtPopulationRepo implements TPopulationRepo {
@override
Future<PopulationEntity> get() async {
const path =
'FCSA,DF_POP,2.6.0/POP...A...?startPeriod=2015&dimensionAtObservation=AllDimensions';
final sdmx = await SDMXService.get<YearTimePeriod>(path);
final obs = sdmx.toObservationList();
final popGrowth = obs
.divideByKey(
(ob) => ob.dimensionsEN['Time period']!,
)
.map(
(year, obs) => MapEntry(
int.parse(year),
obs
.filterEN({
'Gender': ['Total'],
})
.first
.value as int,
),
);
final genderDistribution = (
male: obs.filterLatest
.filterEN({
'Gender': ['Male'],
})
.first
.value as int,
female: obs.filterLatest
.filterEN({
'Gender': ['Female'],
})
.first
.value as int,
);
return PopulationEntity(
population: _population(obs),
populationGrowth: popGrowth,
genderDistribution: genderDistribution,
);
}
SpecificDetailBoxData _population(
Iterable<SimplifiedObservation<YearTimePeriod>> obs,
) {
final pop = obs.filterLatest
.filterEN({
'Gender': ['Total'],
})
.first
.value as num;
final popPrev = obs.filterPrev
.filterEN({
'Gender': ['Total'],
})
.first
.value as num;
return SpecificDetailBoxData(
subtitle: (
en: '(${obs.latestTimePeriod.year})',
ar: '(${obs.latestTimePeriod.year})',
),
value: pop,
prevValue: popPrev.pctDifferenceFrom(pop),
overrideImprovement: Improvement.none,
isPrevValuePercentage: true,
prevValueSubtitle: (
en: '(vs. ${obs.prevTimePeriod.year})',
ar: '(مقابل ${obs.prevTimePeriod.year})',
),
);
}
}

View File

@ -0,0 +1,45 @@
class BilateralTradeUAEModel {
const BilateralTradeUAEModel({
required this.countryNameAR,
required this.l1SectionDescAR,
required this.year,
required this.countryISO3Code,
required this.countryISO2Code,
required this.l1SectionCode,
required this.countryNameEN,
required this.l1SectionDescEN,
required this.latest,
required this.exportValue,
required this.importValue,
required this.reExportValue,
});
factory BilateralTradeUAEModel.fromObject(Map<String, dynamic> data) =>
BilateralTradeUAEModel(
countryNameAR: data['CountryNameAR'] ?? '',
l1SectionDescAR: data['L1SectionDescAR'] ?? '',
year: data['Year'] ?? '',
countryISO3Code: data['CountryISO3Code'] ?? '',
countryISO2Code: data['CountryISO2Code'] ?? '',
l1SectionCode: data['L1SectionCode'] ?? '',
countryNameEN: data['CountryNameEN'] ?? '',
l1SectionDescEN: data['L1SectionDescEN'] ?? '',
latest: data['Latest'] ?? '',
exportValue: data['ExportValue'] ?? '',
importValue: data['ImportValue'] ?? '',
reExportValue: data['ReExportValue'] ?? '',
);
final String countryNameAR;
final String l1SectionDescAR;
final String year;
final String countryISO3Code;
final String countryISO2Code;
final String l1SectionCode;
final String countryNameEN;
final String l1SectionDescEN;
final String latest;
final String exportValue;
final String importValue;
final String reExportValue;
}

Some files were not shown because too many files have changed in this diff Show More