Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
"@queryPreview": {},
"searchByDOI": "Search by DOI",
"@searchByDOI": {},
"searchByTopic": "Search by topics",
"@searchByTopic":{},
"searchByTitle": "Search by title",
"@searchByTitle": {},
"searchByISSN": "Search by ISSN",
Expand All @@ -211,6 +213,8 @@
"@emptySearchQuery": {},
"journalSearchError": "An error occured while trying to search for journals.",
"@journalSearchError": {},
"selectTopicFirst": "Select a topic first!",
"@selectTopicFirst":{},
"moreOptions": "More options",
"@moreOptions": {},
"saveQuery": "Save this query",
Expand All @@ -229,6 +233,8 @@
"@category": {},
"publisher": "Publisher",
"@publisher": {},
"publisherWithValue": "Publisher: {name}",
"@publisherWithValue":{},
"publishedin": "Published in",
"@publishedin": {},
"subjects": "Subjects",
Expand Down
100 changes: 0 additions & 100 deletions lib/models/crossref_journals_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,42 +72,22 @@ class Message {
}

class Item {
int lastStatusCheckTime;
Counts counts;
Breakdowns breakdowns;
String publisher;
Map<String, double> coverage;
String title;
CoverageType coverageType;
Map<String, bool> flags;
List<String> issn;
List<IssnType> issnType;

Item({
required this.lastStatusCheckTime,
required this.counts,
required this.breakdowns,
required this.publisher,
required this.coverage,
required this.title,
required this.coverageType,
required this.flags,
required this.issn,
required this.issnType,
});

factory Item.fromJson(Map<String, dynamic> json, [String? queriedISSN]) =>
Item(
lastStatusCheckTime: json["last-status-check-time"] ?? 0,
counts: Counts.fromJson(json["counts"] ?? {}),
breakdowns: Breakdowns.fromJson(json["breakdowns"] ?? {}),
publisher: json["publisher"] ?? "Unknown",
coverage: Map.from(json["coverage"] ?? {})
.map((k, v) => MapEntry<String, double>(k, (v ?? 0).toDouble())),
title: json["title"] ?? "Untitled",
coverageType: CoverageType.fromJson(json["coverage-type"] ?? {}),
flags: Map.from(json["flags"] ?? {})
.map((k, v) => MapEntry<String, bool>(k, v ?? false)),
issn: (queriedISSN != null && json["ISSN"].contains(queriedISSN))
? <String>[queriedISSN]
: List<String>.from(json["ISSN"]?.map((x) => x) ?? []),
Expand All @@ -117,93 +97,13 @@ class Item {
);

Map<String, dynamic> toJson() => {
"last-status-check-time": lastStatusCheckTime,
"counts": counts.toJson(),
"breakdowns": breakdowns.toJson(),
"publisher": publisher,
"coverage":
Map.from(coverage).map((k, v) => MapEntry<String, dynamic>(k, v)),
"title": title,
"coverage-type": coverageType.toJson(),
"flags": Map.from(flags).map((k, v) => MapEntry<String, dynamic>(k, v)),
"ISSN": List<dynamic>.from(issn.map((x) => x)),
"issn-type": List<dynamic>.from(issnType.map((x) => x.toJson())),
};
}

class Breakdowns {
List<List<int>> doisByIssuedYear;

Breakdowns({
required this.doisByIssuedYear,
});

factory Breakdowns.fromJson(Map<String, dynamic> json) => Breakdowns(
doisByIssuedYear: List<List<int>>.from(
(json["dois-by-issued-year"] ?? [])
.map((x) => List<int>.from(x.map((x) => x ?? 0))),
),
);

Map<String, dynamic> toJson() => {
"dois-by-issued-year": List<dynamic>.from(
doisByIssuedYear.map((x) => List<dynamic>.from(x.map((x) => x)))),
};
}

class Counts {
int currentDois;
int backfileDois;
int totalDois;

Counts({
required this.currentDois,
required this.backfileDois,
required this.totalDois,
});

factory Counts.fromJson(Map<String, dynamic> json) => Counts(
currentDois: json["current-dois"] ?? 0,
backfileDois: json["backfile-dois"] ?? 0,
totalDois: json["total-dois"] ?? 0,
);

Map<String, dynamic> toJson() => {
"current-dois": currentDois,
"backfile-dois": backfileDois,
"total-dois": totalDois,
};
}

class CoverageType {
Map<String, double> all;
Map<String, double> backfile;
Map<String, double> current;

CoverageType({
required this.all,
required this.backfile,
required this.current,
});

factory CoverageType.fromJson(Map<String, dynamic> json) => CoverageType(
all: Map.from(json["all"] ?? {})
.map((k, v) => MapEntry<String, double>(k, (v ?? 0).toDouble())),
backfile: Map.from(json["backfile"] ?? {})
.map((k, v) => MapEntry<String, double>(k, (v ?? 0).toDouble())),
current: Map.from(json["current"] ?? {})
.map((k, v) => MapEntry<String, double>(k, (v ?? 0).toDouble())),
);

Map<String, dynamic> toJson() => {
"all": Map.from(all).map((k, v) => MapEntry<String, dynamic>(k, v)),
"backfile":
Map.from(backfile).map((k, v) => MapEntry<String, dynamic>(k, v)),
"current":
Map.from(current).map((k, v) => MapEntry<String, dynamic>(k, v)),
};
}

class IssnType {
String value;
Type type;
Expand Down
114 changes: 114 additions & 0 deletions lib/models/openalex_domain_models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
class OpenAlexDomain {
final String id;
final String shortId;
final String displayName;
final List<OpenAlexField> fields;

OpenAlexDomain({
required this.id,
required this.shortId,
required this.displayName,
required this.fields,
});

factory OpenAlexDomain.fromJson(Map<String, dynamic> json) {
final fullId = json['id'] ?? '';

return OpenAlexDomain(
id: fullId,
shortId: fullId.split('/').last,
displayName: json['display_name'] ?? '',
fields: (json['fields'] as List?)
?.map((f) => OpenAlexField.fromJson(f))
.toList() ??
[],
);
}
}

class OpenAlexField {
final String id;
final String shortId;
final String displayName;

OpenAlexField({
required this.id,
required this.shortId,
required this.displayName,
});

factory OpenAlexField.fromJson(Map<String, dynamic> json) {
final fullId = json['id'] ?? '';

return OpenAlexField(
id: fullId,
shortId: fullId.split('/').last,
displayName: json['display_name'] ?? '',
);
}
}

class OpenAlexSubfield {
final String id;
final String shortId;
final String displayName;
final List<OpenAlexTopic> topics;

OpenAlexSubfield({
required this.id,
required this.shortId,
required this.displayName,
required this.topics,
});

factory OpenAlexSubfield.fromJson(Map<String, dynamic> json) {
final fullId = json['id'] ?? '';

return OpenAlexSubfield(
id: fullId,
shortId: fullId.split('/').last,
displayName: json['display_name'] ?? '',
topics: (json['topics'] as List?)
?.map((t) => OpenAlexTopic.fromJson(t))
.toList() ??
[],
);
}
}

class OpenAlexTopic {
final String id;
final String displayName;

OpenAlexTopic({
required this.id,
required this.displayName,
});

factory OpenAlexTopic.fromJson(Map<String, dynamic> json) {
return OpenAlexTopic(
id: json['id'] ?? '',
displayName: json['display_name'] ?? '',
);
}
}

class TopicJournalResult {
final String title;
final String publisher;
final List<String> issn;

TopicJournalResult({
required this.title,
required this.publisher,
required this.issn,
});

factory TopicJournalResult.fromJson(Map<String, dynamic> json) {
return TopicJournalResult(
title: json['display_name'] ?? '',
publisher: json['host_organization_name'] ?? '',
issn: (json['issn'] as List?)?.cast<String>() ?? [],
);
}
}
Loading