mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 06:40:53 +00:00
use UUID as id for LeaderboardGroup which now implements WithID; preparing for the use of this UUID by Event in persistence to reference LeaderboardGroups
This commit is contained in:
1 parent
dba45e080c
commit
db05658286
14 files changed
+93
-82
No files matched your search
@@ -47,6 +47,7 @@ import com.sap.sailing.domain.common.racelog.tracking.TypeBasedServiceFinderFact
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroupResolver;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardRegistry;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.ScoringScheme;
|
||||
@@ -85,7 +86,7 @@ import com.sap.sailing.server.masterdata.DataImportLockWithProgress;
|
||||
*
|
||||
*/
|
||||
public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetcher, RegattaRegistry, RaceFetcher,
|
||||
LeaderboardRegistry, TrackerManager {
|
||||
LeaderboardRegistry, LeaderboardGroupResolver, TrackerManager {
|
||||
@Override
|
||||
Regatta getRegatta(RegattaName regattaName);
|
||||
|
||||
@@ -222,16 +223,10 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
*/
|
||||
Map<String, LeaderboardGroup> getLeaderboardGroups();
|
||||
|
||||
/**
|
||||
* @param groupName The name of the requested leaderboard group
|
||||
* @return The leaderboard group with the name <code>groupName</code>, or <code>null</code> if theres no such group
|
||||
*/
|
||||
LeaderboardGroup getLeaderboardGroupByName(String groupName);
|
||||
|
||||
/**
|
||||
* Creates a new group with the name <code>groupName</code>, the description <code>desciption</code> and the
|
||||
* leaderboards with the names in <code>leaderboardNames</code> and saves it in the database.
|
||||
*
|
||||
* @param id TODO
|
||||
* @param groupName
|
||||
* The name of the new group
|
||||
* @param description
|
||||
@@ -240,10 +235,11 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* @param leaderboardNames
|
||||
* The names of the leaderboards, which should be contained by the new group.<br />
|
||||
* If there isn't a leaderboard with one of these names an {@link IllegalArgumentException} is thrown.
|
||||
*
|
||||
* @return The new leaderboard group
|
||||
*/
|
||||
LeaderboardGroup addLeaderboardGroup(String groupName, String description, boolean displayGroupsInReverseOrder,
|
||||
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
|
||||
LeaderboardGroup addLeaderboardGroup(UUID id, String groupName, String description,
|
||||
boolean displayGroupsInReverseOrder, List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
|
||||
|
||||
/**
|
||||
* Removes the group with the name <code>groupName</code> from the service and the database.
|
||||
|
||||
+4
-4
@@ -1796,9 +1796,9 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeaderboardGroup addLeaderboardGroup(String groupName, String description,
|
||||
boolean displayGroupsInReverseOrder, List<String> leaderboardNames,
|
||||
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
|
||||
public LeaderboardGroup addLeaderboardGroup(UUID id, String groupName,
|
||||
String description, boolean displayGroupsInReverseOrder,
|
||||
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
|
||||
ArrayList<Leaderboard> leaderboards = new ArrayList<>();
|
||||
for (String leaderboardName : leaderboardNames) {
|
||||
Leaderboard leaderboard = leaderboardsByName.get(leaderboardName);
|
||||
@@ -1808,7 +1808,7 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
leaderboards.add(leaderboard);
|
||||
}
|
||||
}
|
||||
LeaderboardGroup result = new LeaderboardGroupImpl(groupName, description, displayGroupsInReverseOrder,
|
||||
LeaderboardGroup result = new LeaderboardGroupImpl(id, groupName, description, displayGroupsInReverseOrder,
|
||||
leaderboards);
|
||||
if (overallLeaderboardScoringSchemeType != null) {
|
||||
// create overall leaderboard and its discards settings
|
||||
|
||||
+5
-2
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
@@ -9,6 +10,7 @@ import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class CreateLeaderboardGroup extends AbstractLeaderboardGroupOperation<LeaderboardGroup> {
|
||||
private static final long serialVersionUID = -5028997286564650805L;
|
||||
private final UUID id;
|
||||
private final String description;
|
||||
private final boolean displayGroupsInReverseOrder;
|
||||
private final List<String> leaderboardNames;
|
||||
@@ -18,6 +20,7 @@ public class CreateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Le
|
||||
public CreateLeaderboardGroup(String leaderboardGroupName, String description, boolean displayGroupsInReverseOrder, List<String> leaderboardNames,
|
||||
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
|
||||
super(leaderboardGroupName);
|
||||
this.id = UUID.randomUUID();
|
||||
this.description = description;
|
||||
this.displayGroupsInReverseOrder = displayGroupsInReverseOrder;
|
||||
this.leaderboardNames = leaderboardNames;
|
||||
@@ -40,8 +43,8 @@ public class CreateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Le
|
||||
@Override
|
||||
public LeaderboardGroup internalApplyTo(RacingEventService toState) {
|
||||
// TODO see bug 729: try to move addLeaderboardGroup implementation here and synthesize and apply this operation there
|
||||
return toState.addLeaderboardGroup(getLeaderboardGroupName(), description, displayGroupsInReverseOrder, leaderboardNames,
|
||||
overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
|
||||
return toState.addLeaderboardGroup(id, getLeaderboardGroupName(), description, displayGroupsInReverseOrder,
|
||||
leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -163,10 +163,10 @@ public class ImportMasterDataOperation extends
|
||||
overallLeaderboardDiscardThresholds = rule.getDiscardIndexResultsStartingWithHowManyRaces();
|
||||
overallLeaderboardScoringSchemeType = metaLeaderboard.getScoringScheme().getType();
|
||||
}
|
||||
leaderboardGroup = toState.addLeaderboardGroup(leaderboardGroup.getName(),
|
||||
leaderboardGroup.getDescription(), leaderboardGroup.isDisplayGroupsInReverseOrder(),
|
||||
leaderboardNames, overallLeaderboardDiscardThresholds,
|
||||
overallLeaderboardScoringSchemeType);
|
||||
leaderboardGroup = toState.addLeaderboardGroup(leaderboardGroup.getId(),
|
||||
leaderboardGroup.getName(), leaderboardGroup.getDescription(),
|
||||
leaderboardGroup.isDisplayGroupsInReverseOrder(), leaderboardNames,
|
||||
overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
|
||||
creationCount.addOneLeaderboardGroup(leaderboardGroup.getName());
|
||||
} else {
|
||||
leaderboardGroup = existingLeaderboardGroup;
|
||||
|
||||
Reference in new issue
Block a user