Skip to content

Commit

Permalink
feat(common): Tournament team participation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Nov 27, 2023
1 parent eaf98d4 commit 63ec7c7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
5 changes: 4 additions & 1 deletion wrestling_scoreboard_common/lib/src/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ export 'data/club.dart';
export 'data/data_object.dart';
export 'data/fight.dart';
export 'data/fight_action.dart';
export 'data/team_match/league.dart';
export 'data/lineup.dart';
export 'data/membership.dart';
export 'data/participant_state.dart';
export 'data/participation.dart';
export 'data/person.dart';
export 'data/team.dart';
export 'data/team_match/league.dart';
export 'data/team_match/league_team_participation.dart';
export 'data/team_match/league_weight_class.dart';
export 'data/team_match/team_match.dart';
export 'data/team_match/team_match_fight.dart';
export 'data/tournament/tournament.dart';
export 'data/tournament/tournament_fight.dart';
export 'data/tournament/tournament_person.dart';
export 'data/tournament/tournament_team_participation.dart';
export 'data/weight_class.dart';
export 'data/wrestling_event.dart';
18 changes: 18 additions & 0 deletions wrestling_scoreboard_common/lib/src/data/data_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ abstract class DataObject {
return FightAction.fromJson(json) as T;
case League:
return League.fromJson(json) as T;
case LeagueTeamParticipation:
return LeagueTeamParticipation.fromJson(json) as T;
case LeagueWeightClass:
return LeagueWeightClass.fromJson(json) as T;
case Lineup:
Expand All @@ -45,6 +47,14 @@ abstract class DataObject {
return TeamMatch.fromJson(json) as T;
case TeamMatchFight:
return TeamMatchFight.fromJson(json) as T;
case Tournament:
return Tournament.fromJson(json) as T;
case TournamentFight:
return TournamentFight.fromJson(json) as T;
case TournamentPerson:
return TournamentPerson.fromJson(json) as T;
case TournamentTeamParticipation:
return TournamentTeamParticipation.fromJson(json) as T;
case WeightClass:
return WeightClass.fromJson(json) as T;
default:
Expand All @@ -64,6 +74,8 @@ abstract class DataObject {
return (await FightAction.fromRaw(raw, getSingle)) as T;
case League:
return (await League.fromRaw(raw, getSingle)) as T;
case LeagueTeamParticipation:
return (await LeagueWeightClass.fromRaw(raw, getSingle)) as T;
case LeagueWeightClass:
return (await LeagueWeightClass.fromRaw(raw, getSingle)) as T;
case Lineup:
Expand All @@ -82,6 +94,12 @@ abstract class DataObject {
return (await TeamMatch.fromRaw(raw, getSingle)) as T;
case TeamMatchFight:
return (await TeamMatchFight.fromRaw(raw, getSingle)) as T;
case Tournament:
return (await Tournament.fromRaw(raw, getSingle)) as T;
case TournamentPerson:
return (await TournamentPerson.fromRaw(raw, getSingle)) as T;
case TournamentTeamParticipation:
return (await TournamentTeamParticipation.fromRaw(raw, getSingle)) as T;
case WeightClass:
return (await WeightClass.fromRaw(raw)) as T;
default:
Expand Down
30 changes: 12 additions & 18 deletions wrestling_scoreboard_common/lib/src/util/data_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ Future<int?> handleFromJson(Map<String, dynamic> json,
handleMany: handleMany,
handleSingleRaw: handleSingleRaw,
handleManyRaw: handleManyRaw);
case LeagueTeamParticipation:
return _handleFromJsonGeneric<LeagueTeamParticipation>(json,
handleSingle: handleSingle,
handleMany: handleMany,
handleSingleRaw: handleSingleRaw,
handleManyRaw: handleManyRaw);
case Lineup:
return _handleFromJsonGeneric<Lineup>(json,
handleSingle: handleSingle,
Expand Down Expand Up @@ -122,6 +128,12 @@ Future<int?> handleFromJson(Map<String, dynamic> json,
handleMany: handleMany,
handleSingleRaw: handleSingleRaw,
handleManyRaw: handleManyRaw);
case TournamentTeamParticipation:
return _handleFromJsonGeneric<TournamentTeamParticipation>(json,
handleSingle: handleSingle,
handleMany: handleMany,
handleSingleRaw: handleSingleRaw,
handleManyRaw: handleManyRaw);
case WeightClass:
return _handleFromJsonGeneric<WeightClass>(json,
handleSingle: handleSingle,
Expand Down Expand Up @@ -176,24 +188,6 @@ class ManyDataObject<T> {
ManyDataObject({required this.data, this.filterType, this.filterId});
}

const List<Type> dataObjectTypes = [
BoutConfig,
Club,
Fight,
FightAction,
League,
LeagueWeightClass,
Lineup,
Membership,
Participation,
ParticipantState,
Person,
Team,
TeamMatch,
TeamMatchFight,
WeightClass,
];

String getTableNameFromType(Type t) {
switch (t) {
case BoutConfig:
Expand Down

0 comments on commit 63ec7c7

Please sign in to comment.