Skip to content

Commit

Permalink
Merge pull request #501 from softwaremagico/498-when-creating-the-sen…
Browse files Browse the repository at this point in the history
…butsu-fights-using-the-wizard-the-button-order-by-ranking-is-hidden

Adding update instructions for database
  • Loading branch information
softwaremagico authored Oct 20, 2024
2 parents 95061b3 + 0ff865c commit 8c52a79
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.softwaremagico.kt.core.converters.models.FightConverterRequest;
import com.softwaremagico.kt.core.converters.models.TournamentConverterRequest;
import com.softwaremagico.kt.core.exceptions.ParticipantNotFoundException;
import com.softwaremagico.kt.core.exceptions.SenbatsuTournamentFightsException;
import com.softwaremagico.kt.core.exceptions.TournamentNotFoundException;
import com.softwaremagico.kt.core.exceptions.ValidateBadRequestException;
import com.softwaremagico.kt.core.managers.TeamsOrder;
Expand All @@ -42,6 +43,7 @@
import com.softwaremagico.kt.core.tournaments.SenbatsuTournamentHandler;
import com.softwaremagico.kt.core.tournaments.TournamentHandlerSelector;
import com.softwaremagico.kt.logger.ExceptionType;
import com.softwaremagico.kt.logger.KendoTournamentLogger;
import com.softwaremagico.kt.persistence.entities.Fight;
import com.softwaremagico.kt.persistence.entities.Group;
import com.softwaremagico.kt.persistence.entities.Participant;
Expand Down Expand Up @@ -222,15 +224,19 @@ public List<FightDTO> createFights(Integer tournamentId, TeamsOrder teamsOrder,
groupProvider.delete(tournament, level + 1);
final ITournamentManager selectedManager = tournamentHandlerSelector.selectManager(tournament.getType());
if (selectedManager != null) {
final List<Fight> createdFights = getProvider().saveAll(selectedManager.createFights(tournament, teamsOrder, level, createdBy));
tournamentProvider.markAsFinished(tournament, false);
final List<FightDTO> fightDTOS = convertAll(createdFights);
try {
return fightDTOS;
} finally {
new Thread(() ->
fightsAddedListeners.forEach(fightsAddedListener -> fightsAddedListener.created(fightDTOS, createdBy))
).start();
final List<Fight> createdFights = getProvider().saveAll(selectedManager.createFights(tournament, teamsOrder, level, createdBy));
tournamentProvider.markAsFinished(tournament, false);
final List<FightDTO> fightDTOS = convertAll(createdFights);
try {
return fightDTOS;
} finally {
new Thread(() ->
fightsAddedListeners.forEach(fightsAddedListener -> fightsAddedListener.created(fightDTOS, createdBy))
).start();
}
} catch (SenbatsuTournamentFightsException e) {
KendoTournamentLogger.warning(this.getClass(), e.getMessage());
}
}
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.softwaremagico.kt.core.exceptions;

/*-
* #%L
* Kendo Tournament Manager (Core)
* %%
* Copyright (C) 2021 - 2024 Softwaremagico
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/

import com.softwaremagico.kt.logger.ExceptionType;
import com.softwaremagico.kt.logger.LoggedException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(HttpStatus.BAD_REQUEST)
public class SenbatsuTournamentFightsException extends LoggedException {
private static final long serialVersionUID = -1399325226733756592L;

public SenbatsuTournamentFightsException(Class<?> clazz, String message) {
super(clazz, message, ExceptionType.SEVERE, HttpStatus.BAD_REQUEST);
}

public SenbatsuTournamentFightsException(Class<?> clazz, String message, ExceptionType exceptionType) {
super(clazz, message, exceptionType, HttpStatus.BAD_REQUEST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* #L%
*/

import com.softwaremagico.kt.core.exceptions.CustomTournamentFightsException;
import com.softwaremagico.kt.core.exceptions.InvalidChallengeDistanceException;
import com.softwaremagico.kt.core.exceptions.InvalidFightException;
import com.softwaremagico.kt.core.exceptions.SenbatsuTournamentFightsException;
import com.softwaremagico.kt.core.managers.TeamsOrder;
import com.softwaremagico.kt.core.providers.FightProvider;
import com.softwaremagico.kt.core.providers.GroupProvider;
Expand Down Expand Up @@ -60,7 +60,7 @@ public SenbatsuTournamentHandler(GroupProvider groupProvider, TeamProvider teamP

@Override
public List<Fight> createFights(Tournament tournament, TeamsOrder teamsOrder, Integer level, String createdBy) {
throw new CustomTournamentFightsException(this.getClass(), "This league cannot generate fights.");
throw new SenbatsuTournamentFightsException(this.getClass(), "This league cannot generate fights.");
}


Expand Down
50 changes: 50 additions & 0 deletions documents/UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,53 @@ alter table competitor_1_score_time
alter table competitor_2_score_time
alter column competitor2scoretime type int using competitor2scoretime::bigint;
```

# From version 2.14.X to 2.15.0

```
alter table public.tournament_extra_properties
drop constraint tournament_extra_properties_property_key_check;
alter table public.tournament_extra_properties
add constraint tournament_extra_properties_property_key_check
check ((property_key)::text = ANY
(ARRAY [('MAXIMIZE_FIGHTS'::character varying)::text, ('AVOID_DUPLICATES'::character varying)::text, ('KING_INDEX'::character varying)::text, ('KING_DRAW_RESOLUTION'::character varying)::text, ('DIPLOMA_NAME_HEIGHT'::character varying)::text, ('NUMBER_OF_WINNERS'::character varying)::text, ('LEAGUE_FIGHTS_ORDER_GENERATION'::character varying)::text, ('ODD_FIGHTS_RESOLVED_ASAP'::character varying)::text]));
```


# From version 2.15.X to 2.16.0

```
alter table public.tournaments
drop constraint tournaments_tournament_type_check;
alter table public.tournaments
add constraint tournaments_tournament_type_check
check ((tournament_type)::text = ANY
(ARRAY [('CHAMPIONSHIP'::character varying)::text, ('TREE'::character varying)::text, ('LEAGUE'::character varying)::text, ('LOOP'::character varying)::text, ('CUSTOM_CHAMPIONSHIP'::character varying)::text, ('KING_OF_THE_MOUNTAIN'::character varying)::text, ('CUSTOMIZED'::character varying)::text, ('BUBBLE_SORT'::character varying)::text]));
```

# From version 2.16.0 to 2.17.0


```
alter table public.tournaments
drop constraint tournaments_tournament_type_check;
alter table public.tournaments
add constraint tournaments_tournament_type_check
check ((tournament_type)::text = ANY
(ARRAY [('CHAMPIONSHIP'::character varying)::text, ('TREE'::character varying)::text, ('LEAGUE'::character varying)::text, ('LOOP'::character varying)::text, ('CUSTOM_CHAMPIONSHIP'::character varying)::text, ('KING_OF_THE_MOUNTAIN'::character varying)::text, ('CUSTOMIZED'::character varying)::text, ('SENBATSU'::character varying)::text, ('BUBBLE_SORT'::character varying)::text]));
alter table public.tournament_extra_properties
drop constraint tournament_extra_properties_property_key_check;
alter table public.tournament_extra_properties
add constraint tournament_extra_properties_property_key_check
check ((property_key)::text = ANY
(ARRAY [('MAXIMIZE_FIGHTS'::character varying)::text, ('AVOID_DUPLICATES'::character varying)::text, ('KING_INDEX'::character varying)::text, ('KING_DRAW_RESOLUTION'::character varying)::text, ('DIPLOMA_NAME_HEIGHT'::character varying)::text, ('NUMBER_OF_WINNERS'::character varying)::text, ('LEAGUE_FIGHTS_ORDER_GENERATION'::character varying)::text, ('ODD_FIGHTS_RESOLVED_ASAP'::character varying)::text, ('SENBATSU_CHALLENGE_DISTANCE'::character varying)::text]));
```

0 comments on commit 8c52a79

Please sign in to comment.