Merge branch 'master' into bug2115

This commit is contained in:
Simon Pamies committed 2014-08-06 07:03:25 +02:00
commit ed7ad9a412
62 files changed
+497 -337

No files matched your search

@@ -66,11 +66,11 @@ public class TestLeaderboardGroupFilteringRetrievalProcessor {
private Map<String, LeaderboardGroup> getGroupsInService() {
Map<String, LeaderboardGroup> groups = new HashMap<>();
groups.put("LG1", new LeaderboardGroupImpl("LG1", "", false, new ArrayList<Leaderboard>()));
groups.put("LG2", new LeaderboardGroupImpl("LG2", "", false, new ArrayList<Leaderboard>()));
groups.put("LG3", new LeaderboardGroupImpl("LG3", "", false, new ArrayList<Leaderboard>()));
groups.put("LG4", new LeaderboardGroupImpl("LG4", "", false, new ArrayList<Leaderboard>()));
groups.put("LG5", new LeaderboardGroupImpl("LG5", "", false, new ArrayList<Leaderboard>()));
groups.put("LG1", new LeaderboardGroupImpl("LG1", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.put("LG2", new LeaderboardGroupImpl("LG2", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.put("LG3", new LeaderboardGroupImpl("LG3", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.put("LG4", new LeaderboardGroupImpl("LG4", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.put("LG5", new LeaderboardGroupImpl("LG5", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
return groups;
}
@@ -86,11 +86,11 @@ public class TestLeaderboardGroupFilteringRetrievalProcessor {
private Collection<LeaderboardGroup> getExpectedRetrievedGroups() {
Collection<LeaderboardGroup> groups = new HashSet<>();
groups.add(new LeaderboardGroupImpl("LG1", "", false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG2", "", false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG3", "", false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG4", "", false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG5", "", false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG1", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG2", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG3", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG4", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
groups.add(new LeaderboardGroupImpl("LG5", "", /* displayName */ null, false, new ArrayList<Leaderboard>()));
return groups;
}
@@ -713,6 +713,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
// migration: leaderboard groups that don't yet have a UUID receive a random one
}
String description = (String) o.get(FieldNames.LEADERBOARD_GROUP_DESCRIPTION.name());
String displayName = (String) o.get(FieldNames.LEADERBOARD_GROUP_DISPLAY_NAME.name());
boolean displayGroupsInReverseOrder = false; // default value
Object displayGroupsInReverseOrderObj = o.get(FieldNames.LEADERBOARD_GROUP_DISPLAY_IN_REVERSE_ORDER.name());
if (displayGroupsInReverseOrderObj != null) {
@@ -734,7 +735,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
}
}
logger.info("loaded leaderboard group "+name);
LeaderboardGroupImpl result = new LeaderboardGroupImpl(uuid, name, description, displayGroupsInReverseOrder, leaderboards);
LeaderboardGroupImpl result = new LeaderboardGroupImpl(uuid, name, description, displayName, displayGroupsInReverseOrder, leaderboards);
Object overallLeaderboardIdOrName = o.get(FieldNames.LEADERBOARD_GROUP_OVERALL_LEADERBOARD.name());
if (overallLeaderboardIdOrName != null) {
final DBObject dbOverallLeaderboard;
@@ -71,7 +71,8 @@ public enum FieldNames {
LEADERBOARD_SCORE_CORRECTION_COMMENT, LEADERBOARD_COLUMN_FACTORS,
// leaderboard group
LEADERBOARD_GROUP_UUID, LEADERBOARD_GROUP_NAME, LEADERBOARD_GROUP_DESCRIPTION, LEADERBOARD_GROUP_LEADERBOARDS, LEADERBOARD_GROUP_OVERALL_LEADERBOARD,
LEADERBOARD_GROUP_UUID, LEADERBOARD_GROUP_NAME, LEADERBOARD_GROUP_DESCRIPTION,
LEADERBOARD_GROUP_DISPLAY_NAME, LEADERBOARD_GROUP_LEADERBOARDS, LEADERBOARD_GROUP_OVERALL_LEADERBOARD,
LEADERBOARD_GROUP_DISPLAY_IN_REVERSE_ORDER,
// race ID to regatta name
@@ -442,6 +442,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
dbLeaderboardGroup.put(FieldNames.LEADERBOARD_GROUP_UUID.name(), leaderboardGroup.getId());
dbLeaderboardGroup.put(FieldNames.LEADERBOARD_GROUP_NAME.name(), leaderboardGroup.getName());
dbLeaderboardGroup.put(FieldNames.LEADERBOARD_GROUP_DESCRIPTION.name(), leaderboardGroup.getDescription());
dbLeaderboardGroup.put(FieldNames.LEADERBOARD_GROUP_DISPLAY_NAME.name(), leaderboardGroup.getDisplayName());
dbLeaderboardGroup.put(FieldNames.LEADERBOARD_GROUP_DISPLAY_IN_REVERSE_ORDER.name(), leaderboardGroup.isDisplayGroupsInReverseOrder());
final Leaderboard overallLeaderboard = leaderboardGroup.getOverallLeaderboard();
if (overallLeaderboard != null) {
@@ -10,4 +10,6 @@ public interface LeaderboardGroupBase extends Renamable, WithID {
String getDescription();
void setDescriptiom(String description);
boolean hasOverallLeaderboard();
String getDisplayName();
void setDisplayName(String displayName);
}
@@ -11,12 +11,14 @@ public abstract class LeaderboardGroupBaseImpl implements LeaderboardGroupBase {
private UUID id;
private String name;
private String displayName;
private String description;
public LeaderboardGroupBaseImpl(UUID id, String name, String description) {
public LeaderboardGroupBaseImpl(UUID id, String name, String description, String displayName) {
this.id = id;
this.name = name;
this.description = description;
this.displayName = displayName;
}
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
@@ -51,4 +53,14 @@ public abstract class LeaderboardGroupBaseImpl implements LeaderboardGroupBase {
this.name = name;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
@@ -6,8 +6,8 @@ public class StrippedLeaderboardGroupImpl extends LeaderboardGroupBaseImpl {
private static final long serialVersionUID = 7263952130620919924L;
private final boolean hasOverallLeaderboard;
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, boolean hasOverallLeaderboard) {
super(id, name, description);
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, String displayName, boolean hasOverallLeaderboard) {
super(id, name, description, displayName);
this.hasOverallLeaderboard = hasOverallLeaderboard;
}
@@ -55,7 +55,7 @@ public abstract class AbstractTracTracLiveTest extends StoredTrackBasedTest {
private IRaceSubscriber raceSubscriber;
private final Collection<Receiver> receivers;
@Rule public Timeout AbstractTracTracLiveTestTimeout = new Timeout(2 * 60 * 1000);
@Rule public Timeout AbstractTracTracLiveTestTimeout = new Timeout(3 * 60 * 1000);
protected AbstractTracTracLiveTest() throws URISyntaxException, MalformedURLException {
receivers = new HashSet<Receiver>();
@@ -21,10 +21,10 @@ public class EventLeaderboardGroupLinkTest {
@Test
public void testLivelinessAndIteratorStabilityOfUnmodifiableLeaderboardGroupCollection() {
Event e = new EventImpl("E", null, null, "Venue", /* public */ true, UUID.randomUUID());
LeaderboardGroupImpl lg1 = new LeaderboardGroupImpl("lg1", "LG1", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg2 = new LeaderboardGroupImpl("lg2", "LG2", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg3 = new LeaderboardGroupImpl("lg3", "LG3", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg4 = new LeaderboardGroupImpl("lg4", "LG4", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg1 = new LeaderboardGroupImpl("lg1", "LG1", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg2 = new LeaderboardGroupImpl("lg2", "LG2", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg3 = new LeaderboardGroupImpl("lg3", "LG3", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
LeaderboardGroupImpl lg4 = new LeaderboardGroupImpl("lg4", "LG4", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard>emptyList());
e.addLeaderboardGroup(lg1);
Iterable<LeaderboardGroup> lgs = e.getLeaderboardGroups();
Iterator<LeaderboardGroup> iter = lgs.iterator();
@@ -909,8 +909,8 @@ public class LeaderboardScoringAndRankingTest extends AbstractLeaderboardTest {
false);
assertEquals(16, leaderboardHighPoint.getCompetitorsFromBestToWorst(later).size());
assertEquals(new Double(16), leaderboardHighPoint.getTotalPoints(competitors[0], later));
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("ESS", "ESS", /* displayGroupsInReverseOrder */ false,
Arrays.asList(new Leaderboard[] { leaderboardHighPoint10LastBreaksTie }));
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("ESS", "ESS", /* displayName */ null,
/* displayGroupsInReverseOrder */ false, Arrays.asList(new Leaderboard[] { leaderboardHighPoint10LastBreaksTie }));
LeaderboardGroupMetaLeaderboard leaderboardHighPointESSOverall = new LeaderboardGroupMetaLeaderboard(
leaderboardGroup, new HighPointExtremeSailingSeriesOverall(), new ThresholdBasedResultDiscardingRuleImpl(/* discarding thresholds */ new int[0]));
assertEquals(16, leaderboardHighPointESSOverall.getCompetitorsFromBestToWorst(later).size());
@@ -966,7 +966,7 @@ public class LeaderboardScoringAndRankingTest extends AbstractLeaderboardTest {
false);
assertTrue(leaderboard3.getCompetitorsFromBestToWorst(later).indexOf(c[3]) <
leaderboard3.getCompetitorsFromBestToWorst(later).indexOf(c[0])); // c3 better than c0; won last race
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("Leaderboard Group", "Leaderboard Group", false, Arrays.asList(leaderboard1,
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("Leaderboard Group", "Leaderboard Group", /* displayName */ null, false, Arrays.asList(leaderboard1,
leaderboard2, leaderboard3));
leaderboardGroup.setOverallLeaderboard(new LeaderboardGroupMetaLeaderboard(leaderboardGroup, new HighPointExtremeSailingSeriesOverall(),
new ThresholdBasedResultDiscardingRuleImpl(new int[0])));
@@ -1019,8 +1019,8 @@ public class LeaderboardScoringAndRankingTest extends AbstractLeaderboardTest {
assertEquals(4, leaderboard2.getTotalPoints(c[9], later), 0.000000001);
assertEquals(3, leaderboard2.getTotalPoints(c[11], later), 0.000000001);
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("Leaderboard Group ESS Overall", "Leaderboard Group", false,
Arrays.asList(leaderboard1, leaderboard2));
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("Leaderboard Group ESS Overall", "Leaderboard Group", /* displayName */ null,
false, Arrays.asList(leaderboard1, leaderboard2));
leaderboardGroup.setOverallLeaderboard(new LeaderboardGroupMetaLeaderboard(leaderboardGroup, new HighPointExtremeSailingSeriesOverall(),
new ThresholdBasedResultDiscardingRuleImpl(new int[0])));
leaderboardGroup.getOverallLeaderboard().setSuppressed(c[c.length-1], true);
@@ -92,9 +92,9 @@ public class OfflineSerializationTest extends AbstractSerializationTest {
DomainFactory receiverDomainFactory = new DomainFactoryImpl();
Event e = new EventImpl("Event Name", MillisecondsTimePoint.now(), MillisecondsTimePoint.now().plus(
Duration.ONE_DAY.times(10)), "At Home", /* is public */true, UUID.randomUUID());
LeaderboardGroup lg1 = new LeaderboardGroupImpl("LG1", "LG1 Description", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard> emptyList());
LeaderboardGroup lg1 = new LeaderboardGroupImpl("LG1", "LG1 Description", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard> emptyList());
e.addLeaderboardGroup(lg1);
LeaderboardGroup lg2 = new LeaderboardGroupImpl("LG2", "LG2 Description", /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard> emptyList());
LeaderboardGroup lg2 = new LeaderboardGroupImpl("LG2", "LG2 Description", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Collections.<Leaderboard> emptyList());
e.addLeaderboardGroup(lg2);
Event deserialized = cloneBySerialization(e, receiverDomainFactory);
assertEquals(Util.size(e.getLeaderboardGroups()), Util.size(deserialized.getLeaderboardGroups()));
@@ -118,7 +118,7 @@ public class OfflineSerializationTest extends AbstractSerializationTest {
@Test
public void testSerializingOverallLeaderboardWithFactorOnColumn() throws ClassNotFoundException, IOException {
Leaderboard leaderboard = new FlexibleLeaderboardImpl("Test Leaderboard", new ThresholdBasedResultDiscardingRuleImpl(new int[] { 3, 5 }), new HighPoint(), new CourseAreaImpl("Alpha", UUID.randomUUID()));
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("LeaderboardGroup", "Test Leaderboard Group", /* displayGroupsInReverseOrder */ false, Arrays.asList(new Leaderboard[] { leaderboard }));
LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl("LeaderboardGroup", "Test Leaderboard Group", /* displayName */ null, /* displayGroupsInReverseOrder */ false, Arrays.asList(new Leaderboard[] { leaderboard }));
final LeaderboardGroupMetaLeaderboard overallLeaderboard = new LeaderboardGroupMetaLeaderboard(leaderboardGroup, new HighPoint(), new ThresholdBasedResultDiscardingRuleImpl(new int[0]));
leaderboardGroup.setOverallLeaderboard(overallLeaderboard);
final double FACTOR = 2.0;
@@ -31,8 +31,9 @@ public class LeaderboardGroupImpl extends LeaderboardGroupBaseImpl implements Le
/**
* Creates a new leaderboard group with a new UUID as its ID.
*/
public LeaderboardGroupImpl(String name, String description, boolean displayGroupsInReverseOrder, List<? extends Leaderboard> leaderboards) {
this(UUID.randomUUID(), name, description, displayGroupsInReverseOrder, leaderboards);
public LeaderboardGroupImpl(String name, String description, String displayName,
boolean displayGroupsInReverseOrder, List<? extends Leaderboard> leaderboards) {
this(UUID.randomUUID(), name, description, displayName, displayGroupsInReverseOrder, leaderboards);
}
private synchronized void writeObject(ObjectOutputStream oos) throws IOException {
@@ -42,8 +43,9 @@ public class LeaderboardGroupImpl extends LeaderboardGroupBaseImpl implements Le
/**
* Use this constructor when loading or deserializing a leaderboard group and the ID is known and is provided to the constructor.
*/
public LeaderboardGroupImpl(UUID id, String name, String description, boolean displayGroupsInReverseOrder, List<? extends Leaderboard> leaderboards) {
super(id, name, description);
public LeaderboardGroupImpl(UUID id, String name, String description, String displayName,
boolean displayGroupsInReverseOrder, List<? extends Leaderboard> leaderboards) {
super(id, name, description, displayName);
this.displayGroupsInReverseOrder = displayGroupsInReverseOrder;
this.leaderboards = new ArrayList<Leaderboard>(leaderboards);
this.listeners = new HashSet<LeaderboardGroupListener>();
@@ -15,7 +15,7 @@ import com.sap.sailing.gwt.home.client.place.start.StartPlace;
public class PlaceNavigatorImpl implements PlaceNavigator {
private final PlaceController placeController;
private final static String DEFAULT_SAPSAILING_SERVER = "dev.sapsailing.com"; // www.sapsailing.com
private final static String DEFAULT_SAPSAILING_SERVER = "newhome.sapsailing.com"; // www.sapsailing.com
protected PlaceNavigatorImpl(PlaceController placeController) {
super();
@@ -59,16 +59,18 @@ public class EventActivity extends AbstractActivity {
clientFactory.getSailingService().getRegattaStructureForEvent(event.id, new AsyncCallback<List<RaceGroupDTO>>() {
@Override
public void onSuccess(List<RaceGroupDTO> raceGroups) {
for(LeaderboardGroupDTO leaderboardGroupDTO: event.getLeaderboardGroups()) {
final long clientTimeWhenResponseWasReceived = System.currentTimeMillis();
if (leaderboardGroupDTO.getAverageDelayToLiveInMillis() != null) {
timerForClientServerOffset.setLivePlayDelayInMillis(leaderboardGroupDTO.getAverageDelayToLiveInMillis());
if(raceGroups.size() > 0) {
for(LeaderboardGroupDTO leaderboardGroupDTO: event.getLeaderboardGroups()) {
final long clientTimeWhenResponseWasReceived = System.currentTimeMillis();
if (leaderboardGroupDTO.getAverageDelayToLiveInMillis() != null) {
timerForClientServerOffset.setLivePlayDelayInMillis(leaderboardGroupDTO.getAverageDelayToLiveInMillis());
}
timerForClientServerOffset.adjustClientServerOffset(clientTimeWhenRequestWasSent, leaderboardGroupDTO.getCurrentServerTime(), clientTimeWhenResponseWasReceived);
}
timerForClientServerOffset.adjustClientServerOffset(clientTimeWhenRequestWasSent, leaderboardGroupDTO.getCurrentServerTime(), clientTimeWhenResponseWasReceived);
createEventView(event, raceGroups, panel);
} else {
createEventWithoutRegattasView(event, panel);
}
view = clientFactory.createEventView(event, raceGroups, eventPlace.getLeaderboardIdAsNameString(), timerForClientServerOffset);
panel.setWidget(view.asWidget());
}
@Override
@@ -77,9 +79,7 @@ public class EventActivity extends AbstractActivity {
}
});
} else {
// no leaderboard groups defined yet -> show a teaser page
EventWithoutRegattasView view = clientFactory.createEventWithoutRegattasView(event);
panel.setWidget(view.asWidget());
createEventWithoutRegattasView(event, panel);
}
}
@@ -90,6 +90,17 @@ public class EventActivity extends AbstractActivity {
});
}
private void createEventView(EventDTO event, List<RaceGroupDTO> raceGroups, AcceptsOneWidget panel) {
view = clientFactory.createEventView(event, raceGroups, eventPlace.getLeaderboardIdAsNameString(), timerForClientServerOffset);
panel.setWidget(view.asWidget());
}
private void createEventWithoutRegattasView(EventDTO event, AcceptsOneWidget panel) {
// no leaderboard groups defined yet -> show a teaser page
EventWithoutRegattasView view = clientFactory.createEventWithoutRegattasView(event);
panel.setWidget(view.asWidget());
}
protected void loadAndUpdateEventRaceStatesLog() {
final long clientTimeWhenRequestWasSent = System.currentTimeMillis();
UUID eventUUID = UUID.fromString(eventPlace.getEventUuidAsString());
@@ -10,7 +10,7 @@ public interface EventPageNavigator {
void goToRegattas();
void goToSchedule();
void goToMedia();
void goToRegattaRaces(RaceGroupDTO raceGroup, StrippedLeaderboardDTO leaderboard);
void goToRegattaRaces(LeaderboardGroupDTO leaderboardGroup, StrippedLeaderboardDTO leaderboard, RaceGroupDTO raceGroup);
void openRaceViewer(StrippedLeaderboardDTO leaderboard, RaceDTO race);
void openLeaderboardViewer(LeaderboardGroupDTO leaderboardGroup, StrippedLeaderboardDTO leaderboard);
}
@@ -28,7 +28,7 @@ import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.Util.Triple;
import com.sap.sse.gwt.client.player.Timer;
public class TabletAndDesktopEventView extends Composite implements EventView, EventPageNavigator {
@@ -47,19 +47,13 @@ public class TabletAndDesktopEventView extends Composite implements EventView, E
@UiField EventSponsors eventSponsors;
private final List<Widget> pageElements;
private final Map<String, Pair<StrippedLeaderboardDTO, LeaderboardGroupDTO>> leaderboardsWithLeaderboardGroup;
public TabletAndDesktopEventView(SailingServiceAsync sailingService, EventDTO event, List<RaceGroupDTO> raceGroups, String leaderboardName,
Timer timerForClientServerOffset) {
leaderboardsWithLeaderboardGroup = new HashMap<String, Pair<StrippedLeaderboardDTO, LeaderboardGroupDTO>>();
for(LeaderboardGroupDTO leaderboardGroup: event.getLeaderboardGroups()) {
for(StrippedLeaderboardDTO leaderboard: leaderboardGroup.getLeaderboards()) {
leaderboardsWithLeaderboardGroup.put(leaderboard.name, new Pair<StrippedLeaderboardDTO, LeaderboardGroupDTO>(leaderboard, leaderboardGroup));
}
}
Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> regattaStructure = getRegattaStructure(event, raceGroups);
eventHeader = new EventHeader(event, this);
eventRegattaList = new EventRegattaList(event, raceGroups, leaderboardsWithLeaderboardGroup, timerForClientServerOffset, this);
eventRegattaList = new EventRegattaList(event, regattaStructure, timerForClientServerOffset, this);
eventRegattaRaces = new EventRegattaRaces(event, timerForClientServerOffset, this);
eventOverview = new EventOverview(event);
eventSchedule = new EventSchedule(event);
@@ -69,40 +63,27 @@ public class TabletAndDesktopEventView extends Composite implements EventView, E
pageElements = Arrays.asList(new Widget[] { eventOverview, eventRegattaList, eventRegattaRaces, eventMedia, eventSchedule });
int leaderboardsCount = raceGroups.size();
if(leaderboardsCount == 0) {
Window.alert("There is no data available for this event.");
Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO> selectedRegatta = null;
if(leaderboardName != null) {
selectedRegatta = regattaStructure.get(leaderboardName);
}
// in case we only have one regatta/leaderboard we go directly to the 'races' page
if(selectedRegatta == null && regattaStructure.size() == 1) {
selectedRegatta = regattaStructure.get(0);
}
if(selectedRegatta != null) {
goToRegattaRaces(selectedRegatta.getC(), selectedRegatta.getB(), selectedRegatta.getA());
} else {
RaceGroupDTO selectedRaceGroup = null;
// find the preselected leaderboard (if one exist)
if (leaderboardName != null) {
for (RaceGroupDTO raceGroup : raceGroups) {
if(raceGroup.getName().equals(leaderboardName)) {
selectedRaceGroup = raceGroup;
break;
}
}
}
// in case we only have one regatta/leaderboard we go directly to the 'races' page
if(selectedRaceGroup == null && leaderboardsCount == 1) {
selectedRaceGroup = raceGroups.get(0);
}
if(selectedRaceGroup != null) {
goToRegattaRaces(selectedRaceGroup, leaderboardsWithLeaderboardGroup.get(selectedRaceGroup.getName()).getA());
} else {
goToRegattas();
}
if(event.getSponsorImageURLs() != null && event.getSponsorImageURLs().size() > 0) {
eventSponsors.setVisible(false);
eventSponsors.setEventSponsors(event.getSponsorImageURLs());
} else {
eventSponsors.setVisible(false);
eventSponsors.setEventSponsors(null);
}
goToRegattas();
}
if(event.getSponsorImageURLs() != null && event.getSponsorImageURLs().size() > 0) {
eventSponsors.setVisible(false);
eventSponsors.setEventSponsors(event.getSponsorImageURLs());
} else {
eventSponsors.setVisible(false);
eventSponsors.setEventSponsors(null);
}
}
@@ -124,8 +105,8 @@ public class TabletAndDesktopEventView extends Composite implements EventView, E
}
@Override
public void goToRegattaRaces(RaceGroupDTO raceGroup, StrippedLeaderboardDTO leaderboard) {
eventRegattaRaces.setRacesFromRaceGroup(raceGroup, leaderboard);
public void goToRegattaRaces(LeaderboardGroupDTO leaderboardGroup, StrippedLeaderboardDTO leaderboard, RaceGroupDTO raceGroup) {
eventRegattaRaces.setRaces(leaderboardGroup, leaderboard, raceGroup);
eventHeader.setDataNavigationType("compact");
setVisibleEventElement(eventRegattaRaces);
}
@@ -185,4 +166,20 @@ public class TabletAndDesktopEventView extends Composite implements EventView, E
}
}
private Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> getRegattaStructure(EventDTO event, List<RaceGroupDTO> raceGroups) {
Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> result = new HashMap<>();
Map<String, RaceGroupDTO> raceGroupsMap = new HashMap<>();
for (RaceGroupDTO raceGroup: raceGroups) {
raceGroupsMap.put(raceGroup.getName(), raceGroup);
}
for (LeaderboardGroupDTO leaderboardGroup : event.getLeaderboardGroups()) {
for(StrippedLeaderboardDTO leaderboard: leaderboardGroup.getLeaderboards()) {
String leaderboardName = leaderboard.name;
result.put(leaderboardName, new Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>(raceGroupsMap.get(leaderboardName),
leaderboard, leaderboardGroup));
}
}
return result;
}
}
@@ -85,11 +85,11 @@
padding-bottom: 0.666666666666667em;
}
.regatta_intro_phases_phase {
display: inline-block;
display: block;
margin-right: 1.333333333333333em;
padding: 0.133333333333333em 1.333333333333333em 0.133333333333333em 0;
min-height: 2.666666666666667em;
border-right: 1px solid #ccc;
}
.regatta_intro_phases_phase_name {
font-size: 0.866666666666667em;
@@ -9,6 +9,7 @@ import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.HeadingElement;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.StyleInjector;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Event;
@@ -16,6 +17,7 @@ import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.home.client.place.event.EventPageNavigator;
import com.sap.sailing.gwt.home.client.shared.LongNamesUtil;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
@@ -29,15 +31,12 @@ public class Regatta extends Composite {
interface RegattaUiBinder extends UiBinder<Widget, Regatta> {
}
@SuppressWarnings("unused")
private final EventDTO event;
private final Timer timerForClientServerOffset;
private final EventPageNavigator pageNavigator;
private StrippedLeaderboardDTO leaderboard;
private RaceGroupDTO raceGroup;
private final List<RegattaPhase> phasesElements;
@SuppressWarnings("unused")
private LeaderboardGroupDTO leaderboardGroup;
@UiField DivElement regattaDiv;
@@ -80,6 +79,8 @@ public class Regatta extends Composite {
// competitorWithRank3 = new RegattaCompetitor(3, null);
RegattaResources.INSTANCE.css().ensureInjected();
StyleInjector.injectAtEnd("@media (min-width: 50em) { "+RegattaResources.INSTANCE.largeCss().getText()+"}");
initWidget(uiBinder.createAndBindUi(this));
if(isNavigatable) {
@@ -94,7 +95,7 @@ public class Regatta extends Composite {
registerEvents();
}
public void setData(RaceGroupDTO raceGroup, StrippedLeaderboardDTO leaderboard, LeaderboardGroupDTO leaderboardGroup) {
public void setData(LeaderboardGroupDTO leaderboardGroup, StrippedLeaderboardDTO leaderboard, RaceGroupDTO raceGroup) {
this.raceGroup = raceGroup;
this.leaderboard = leaderboard;
this.leaderboardGroup = leaderboardGroup;
@@ -113,8 +114,8 @@ public class Regatta extends Composite {
String regattaDisplayName = leaderboard.displayName != null ? leaderboard.displayName : leaderboard.name;
regattaNameHeading1.setInnerText(regattaDisplayName);
regattaNameHeading2.setInnerText(regattaDisplayName);
if(raceGroup.leaderboardGroupName != null) {
leaderboardGroupName.setInnerText(raceGroup.leaderboardGroupName);
if(leaderboardGroup.getName() != null) {
leaderboardGroupName.setInnerText(LongNamesUtil.shortenLeaderboardGroupName(event.getName(), leaderboardGroup.getName()));
leaderboardGroupName.setAttribute("data-labeltype", "group1");
} else {
leaderboardGroupName.getStyle().setDisplay(Display.NONE);
@@ -132,14 +133,16 @@ public class Regatta extends Composite {
// clear first
regattaPhasesPanel.removeAllChildren();
phasesElements.clear();
if(raceGroup.getSeries().size() == 0) {
regattaPhasesInfoDiv.getStyle().setDisplay(Display.NONE);
} else {
for(RaceGroupSeriesDTO series: raceGroup.getSeries()) {
RegattaPhase regattaPhase = new RegattaPhase(series, leaderboard, timerForClientServerOffset);
regattaPhasesPanel.appendChild(regattaPhase.getElement());
phasesElements.add(regattaPhase);
if(raceGroup != null) {
if(raceGroup.getSeries().size() == 0) {
regattaPhasesInfoDiv.getStyle().setDisplay(Display.NONE);
} else {
for(RaceGroupSeriesDTO series: raceGroup.getSeries()) {
RegattaPhase regattaPhase = new RegattaPhase(series, leaderboard, timerForClientServerOffset);
regattaPhasesPanel.appendChild(regattaPhase.getElement());
phasesElements.add(regattaPhase);
}
}
}
@@ -160,7 +163,7 @@ public class Regatta extends Composite {
Event.setEventListener(regattaImageWithLink, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
pageNavigator.goToRegattaRaces(raceGroup, leaderboard);
pageNavigator.goToRegattaRaces(leaderboardGroup, leaderboard, raceGroup);
}
});
@@ -168,7 +171,7 @@ public class Regatta extends Composite {
Event.setEventListener(regattaNameLink, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
pageNavigator.goToRegattaRaces(raceGroup, leaderboard);
pageNavigator.goToRegattaRaces(leaderboardGroup, leaderboard, raceGroup);
}
});
}
@@ -0,0 +1,33 @@
.regatta_intro_phases_phase {
display: inline-block;
border-right: 1px solid #ccc;
}
.regatta {}
.regatta_intro {}
.regatta_intro_image {}
.regatta_intro_header {}
.regatta_intro_header_name {}
.regatta_intro_header_namelink:hover,
.regatta_intro_header_namelink:focus {}
.regatta_intro_header_details {}
.regatta_intro_header_details_item {}
.regatta_intro_header_details_item_value {}
.regatta_intro_header_details_label {}
.regatta_intro_phases {}
.regatta_intro_phases_phase_name {}
.regatta_intro_phases_phase_races {}
.regatta_intro_phases_phase_races_race {}
.regatta_intro_phases_leaderboardlink {}
.regatta_intro_scheduled {}
.regatta_intro_results {}
.regatta_intro_results_competitor {}
.regatta_intro_results_competitor_name {}
.regatta_intro_fleets {}
.regatta_intro_fleets_fleet {}
.regatta_intro_fleets_fleet:last-child {}
.regatta_intro_fleets_fleet_item {}
.regatta_intro_fleets_fleet_itemfirst {}
.regatta_intro_fleets_fleet_item_value {}
.regatta_intro_fleets_fleet_item_flag {}
.regatta_intro_fleets_fleet_live {}
.regatta_intro_details_itemhideoncompact {}
@@ -3,13 +3,20 @@ package com.sap.sailing.gwt.home.client.place.event.regatta;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.CssResource.Shared;
public interface RegattaResources extends ClientBundle {
public static final RegattaResources INSTANCE = GWT.create(RegattaResources.class);
@Source("com/sap/sailing/gwt/home/client/place/event/regatta/Regatta.css")
LocalCss css();
public interface MinWidth50emCss extends LocalCss {
}
@Source("com/sap/sailing/gwt/home/client/place/event/regatta/RegattaLarge.css")
MinWidth50emCss largeCss();
@Shared
public interface LocalCss extends CssResource {
String regatta();
String regatta_intro_details_itemhideoncompact();
@@ -1,23 +1,30 @@
package com.sap.sailing.gwt.home.client.place.event.regattalist;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.home.client.HomeResources;
import com.sap.sailing.gwt.home.client.place.event.EventPageNavigator;
import com.sap.sailing.gwt.home.client.place.event.regatta.Regatta;
import com.sap.sailing.gwt.home.client.shared.LongNamesUtil;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.Util.Triple;
import com.sap.sse.gwt.client.player.Timer;
public class EventRegattaList extends Composite {
@@ -27,24 +34,86 @@ public class EventRegattaList extends Composite {
}
@UiField DivElement regattaGroupsNavigationPanel;
@UiField DivElement regattaListNavgiationDiv;
@UiField DivElement regattaListNavigationDiv;
@UiField DivElement regattaListItemsDiv;
@UiField AnchorElement allRegattasLink;
@UiField AnchorElement filterNoLeaderboardGroupsAnchor;
public EventRegattaList(EventDTO event, List<RaceGroupDTO> raceGroups,
Map<String, Pair<StrippedLeaderboardDTO, LeaderboardGroupDTO>> leaderboardsWithLeaderboardGroup,
private final EventDTO event;
private final Map<String, List<Regatta>> regattaElementsByLeaderboardGroup;
public EventRegattaList(EventDTO event, Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> regattaStructure,
Timer timerForClientServerOffset, EventPageNavigator pageNavigator) {
this.event = event;
EventRegattaListResources.INSTANCE.css().ensureInjected();
initWidget(uiBinder.createAndBindUi(this));
regattaListNavgiationDiv.getStyle().setDisplay(Display.NONE);
for (RaceGroupDTO raceGroup: raceGroups) {
Regatta regatta = new Regatta(event, true, timerForClientServerOffset, pageNavigator);
Pair<StrippedLeaderboardDTO, LeaderboardGroupDTO> leaderboardWithLeaderboardGroup = leaderboardsWithLeaderboardGroup.get(raceGroup.getName());
if(leaderboardWithLeaderboardGroup != null) {
regatta.setData(raceGroup, leaderboardWithLeaderboardGroup.getA(), leaderboardWithLeaderboardGroup.getB());
regattaListItemsDiv.appendChild(regatta.getElement());
regattaElementsByLeaderboardGroup = new HashMap<>();
boolean hasMultipleLeaderboardGroups = event.getLeaderboardGroups().size() > 1;
if(hasMultipleLeaderboardGroups) {
// fill the navigation panel
registerFilterLeaderboardGroupEvent(filterNoLeaderboardGroupsAnchor, null);
for(LeaderboardGroupDTO leaderboardGroup: event.getLeaderboardGroups()) {
AnchorElement filterLeaderboardGroupAnchor = Document.get().createAnchorElement();
filterLeaderboardGroupAnchor.setClassName(HomeResources.INSTANCE.mainCss().navbar_button());
filterLeaderboardGroupAnchor.setHref("javascript:;");
String leaderboardGroupName = LongNamesUtil.shortenLeaderboardGroupName(event.getName(), leaderboardGroup.getName());
filterLeaderboardGroupAnchor.setInnerText(leaderboardGroupName);
regattaGroupsNavigationPanel.appendChild(filterLeaderboardGroupAnchor);
registerFilterLeaderboardGroupEvent(filterLeaderboardGroupAnchor, leaderboardGroup);
}
} else {
regattaListNavigationDiv.getStyle().setDisplay(Display.NONE);
}
for (LeaderboardGroupDTO leaderboardGroup : event.getLeaderboardGroups()) {
for (StrippedLeaderboardDTO leaderboard : leaderboardGroup.getLeaderboards()) {
Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO> r = regattaStructure.get(leaderboard.name);
if (r != null) {
Regatta regatta = new Regatta(event, true, timerForClientServerOffset, pageNavigator);
regatta.setData(r.getC(), r.getB(), r.getA());
regattaListItemsDiv.appendChild(regatta.getElement());
List<Regatta> regattaElements = regattaElementsByLeaderboardGroup.get(leaderboardGroup.getName());
if (regattaElements == null) {
regattaElements = new ArrayList<Regatta>();
regattaElementsByLeaderboardGroup.put(leaderboardGroup.getName(), regattaElements);
}
regattaElements.add(regatta);
}
}
}
}
private void registerFilterLeaderboardGroupEvent(AnchorElement filterLeaderboardGroupAnchor, final LeaderboardGroupDTO leaderboardGroup) {
Event.sinkEvents(filterLeaderboardGroupAnchor, Event.ONCLICK);
Event.setEventListener(filterLeaderboardGroupAnchor, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
filterRegattaListByLeaderboardGroup(leaderboardGroup);
}
});
}
private void filterRegattaListByLeaderboardGroup(LeaderboardGroupDTO leaderboardGroup) {
if (leaderboardGroup != null) {
// hide all regattas of the not selected leaderboardgroup
for (LeaderboardGroupDTO lg : event.getLeaderboardGroups()) {
boolean isVisible = leaderboardGroup.getName().equals(lg.getName());
List<Regatta> regattaElements = regattaElementsByLeaderboardGroup.get(lg.getName());
for (Regatta regatta : regattaElements) {
regatta.setVisible(isVisible);
}
}
} else {
// make all regattas visible
for (LeaderboardGroupDTO lg : event.getLeaderboardGroups()) {
List<Regatta> regattaElements = regattaElementsByLeaderboardGroup.get(lg.getName());
for (Regatta regatta : regattaElements) {
regatta.setVisible(true);
}
}
}
}
@@ -8,11 +8,10 @@
<g:HTMLPanel>
<!-- A list of regattas-->
<div class="{local_res.css.eventregattalist}">
<div ui:field="regattaListNavgiationDiv" class="{local_res.css.eventregattalist_navigation} {res.mainCss.navbar}">
<div ui:field="regattaListNavigationDiv" class="{local_res.css.eventregattalist_navigation} {res.mainCss.navbar}">
<div class="{res.mainCss.grid}">
<div class="{res.mediaCss.small12} {res.mediaCss.columns}">
<a ui:field="allRegattasLink" href="#" class="{res.mainCss.navbar_button} {res.mainCss.navbar_buttonactive}"><ui:text from='{i18n.eventRegattaListAllBoatClasses}'/></a>
<div ui:field="regattaGroupsNavigationPanel" />
<div ui:field="regattaGroupsNavigationPanel" class="{res.mediaCss.small12} {res.mediaCss.columns}">
<a ui:field="filterNoLeaderboardGroupsAnchor" href="javascript:;" class="{res.mainCss.navbar_button} {res.mainCss.navbar_buttonactive}"><ui:text from='{i18n.eventRegattaListAllBoatClasses}'/></a>
</div>
</div>
</div>
@@ -1,26 +0,0 @@
package com.sap.sailing.gwt.home.client.place.event.regattalist;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.UIObject;
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
public class EventRegattaListNavigationButton extends UIObject {
private static EventRegattaListNavigationButtonUiBinder uiBinder = GWT.create(EventRegattaListNavigationButtonUiBinder.class);
interface EventRegattaListNavigationButtonUiBinder extends UiBinder<DivElement, EventRegattaListNavigationButton> {
}
@UiField AnchorElement regattaGroupLink;
public EventRegattaListNavigationButton(LeaderboardGroup leaderboardGroup) {
EventRegattaListResources.INSTANCE.css().ensureInjected();
setElement(uiBinder.createAndBindUi(this));
regattaGroupLink.setInnerText(leaderboardGroup.getName());
}
}
@@ -1,8 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:s="urn:import:com.sap.sailing.gwt.home.client.shared">
<ui:with field="i18n" type="com.sap.sailing.gwt.home.client.i18n.TextMessages"/>
<ui:with field="res" type="com.sap.sailing.gwt.home.client.HomeResources" />
<a ui:field="regattaGroupLink" class="{res.mainCss.navbar_button}"></a>
</ui:UiBinder>
@@ -13,6 +13,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.home.client.place.event.EventPageNavigator;
import com.sap.sailing.gwt.home.client.place.event.regatta.Regatta;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupSeriesDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
@@ -46,12 +47,12 @@ public class EventRegattaRaces extends Composite {
initWidget(uiBinder.createAndBindUi(this));
}
public void setRacesFromRaceGroup(RaceGroupDTO raceGroup, StrippedLeaderboardDTO leaderboard) {
public void setRaces(LeaderboardGroupDTO leaderboardGroup, StrippedLeaderboardDTO leaderboard, RaceGroupDTO raceGroup) {
// clear all existing child elements first
regattaPhasesPanel.getElement().removeAllChildren();
phaseElements.clear();
regatta.setData(raceGroup, leaderboard, null);
regatta.setData(leaderboardGroup, leaderboard, raceGroup);
int regattaPhases = raceGroup.getSeries().size();
if(regattaPhases > 1) {
@@ -3,6 +3,7 @@
font-size: 1rem;
text-align: center;
width: 100%;
height: 24em;
}
.eventteaser {
font-size: 15px;
@@ -52,7 +53,6 @@
.eventsoverviewrecent {
font-size: 15px;
font-size: 1rem;
padding-top: 2em;
}
.eventsoverviewrecent_year {
border-bottom: 1px solid #ccc;
@@ -38,4 +38,22 @@ public class LongNamesUtil {
}
return builder.toSafeHtml();
}
/**
* Temp -> remove as soon as we have a display name for a leaderboardGroup
*/
public static String shortenLeaderboardGroupName(String eventName, String leaderboardGroupName) {
String result = leaderboardGroupName;
if (result.startsWith(eventName) && !eventName.equals(leaderboardGroupName)) {
result = result.substring(eventName.length(), result.length());
result = result.trim();
if (result.startsWith("-") || result.startsWith("/")) {
result = result.substring(1, result.length());
result = result.trim();
}
}
return result;
}
}
@@ -3,6 +3,7 @@
font-size: 1rem;
text-align: center;
width: 100%;
height: 24em;
}
.eventteaser {
font-size: 15px;
@@ -492,6 +492,13 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
return group.description.length() <= 100 ? group.description : group.description.substring(0, 98) + "...";
}
};
TextColumn<LeaderboardGroupDTO> groupDisplayNameColumn = new TextColumn<LeaderboardGroupDTO>() {
@Override
public String getValue(LeaderboardGroupDTO group) {
return group.getDisplayName() == null ? "" :
group.getDisplayName().length() <= 100 ? group.getDisplayName() : group.getDisplayName().substring(0, 98) + "...";
}
};
TextColumn<LeaderboardGroupDTO> hasOverallLeaderboardColumn = new TextColumn<LeaderboardGroupDTO>() {
@Override
public String getValue(LeaderboardGroupDTO group) {
@@ -533,6 +540,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
groupsTable.setWidth("100%");
groupsTable.addColumn(groupNameColumn, stringMessages.name());
groupsTable.addColumn(groupDescriptionColumn, stringMessages.description());
groupsTable.addColumn(groupDisplayNameColumn, stringMessages.displayName());
groupsTable.addColumn(hasOverallLeaderboardColumn, stringMessages.useOverallLeaderboard());
groupsTable.addColumn(groupActionsColumn, stringMessages.actions());
groupsTable.addColumnSortHandler(leaderboardGroupsListHandler);
@@ -629,8 +637,8 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
private void createNewGroup(final LeaderboardGroupDescriptor newGroup) {
sailingService.createLeaderboardGroup(newGroup.getName(), newGroup.getDescription(),
newGroup.isDisplayLeaderboardsInReverseOrder(), newGroup.getOverallLeaderboardDiscardThresholds(),
newGroup.getOverallLeaderboardScoringSchemeType(), new MarkedAsyncCallback<LeaderboardGroupDTO>(
newGroup.getDisplayName(), newGroup.isDisplayLeaderboardsInReverseOrder(),
newGroup.getOverallLeaderboardDiscardThresholds(), newGroup.getOverallLeaderboardScoringSchemeType(), new MarkedAsyncCallback<LeaderboardGroupDTO>(
new AsyncCallback<LeaderboardGroupDTO>() {
@Override
public void onFailure(Throwable t) {
@@ -654,6 +662,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
leaderboardNames.add(leaderboardDTO.name);
}
sailingService.updateLeaderboardGroup(oldGroupName, updateDescriptor.getName(), updateDescriptor.getDescription(),
updateDescriptor.getDisplayName(),
leaderboardNames, updateDescriptor.getOverallLeaderboardDiscardThresholds(),
updateDescriptor.getOverallLeaderboardScoringSchemeType(), new MarkedAsyncCallback<Void>(
new AsyncCallback<Void>() {
@@ -670,6 +679,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
if (oldGroupName.equals(group.getName())) {
groupToUpdate.setName(updateDescriptor.getName());
groupToUpdate.description = updateDescriptor.getDescription();
groupToUpdate.setDisplayName(updateDescriptor.getDisplayName());
groupToUpdate.displayLeaderboardsInReverseOrder = updateDescriptor.isDisplayLeaderboardsInReverseOrder();
groupToUpdate.setOverallLeaderboardDiscardThresholds(updateDescriptor.getOverallLeaderboardDiscardThresholds());
groupToUpdate.setOverallLeaderboardScoringSchemeType(updateDescriptor.getOverallLeaderboardScoringSchemeType());
@@ -696,6 +706,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
leaderboardNames.add(leaderboardDTO.name);
}
sailingService.updateLeaderboardGroup(group.getName(), group.getName(), group.description,
group.getDisplayName(),
leaderboardNames, group.getOverallLeaderboardDiscardThresholds(),
group.getOverallLeaderboardScoringSchemeType(), new MarkedAsyncCallback<Void>(
new AsyncCallback<Void>() {
@@ -9,7 +9,7 @@ public class LeaderboardGroupCreateDialog extends LeaderboardGroupDialog {
public LeaderboardGroupCreateDialog(Collection<LeaderboardGroupDTO> existingGroups,
StringMessages stringMessages, DialogCallback<LeaderboardGroupDescriptor> callback) {
super(new LeaderboardGroupDTO(/* ID */ null), stringMessages,
super(new LeaderboardGroupDTO(/* ID */ null, /* displayName */ null), stringMessages,
callback, existingGroups);
nameEntryField = createTextBox(null, 50);
nameEntryField.ensureDebugId("NameTextBox");
@@ -17,6 +17,9 @@ public class LeaderboardGroupCreateDialog extends LeaderboardGroupDialog {
descriptionEntryField = createTextArea(null);
descriptionEntryField.ensureDebugId("DescriptionTextArea");
displayNameEntryField = createTextBox("");
displayNameEntryField.ensureDebugId("DisplayNameTextArea");
displayLeaderboardsInReverseOrderCheckBox.setValue(false);
useOverallLeaderboardCheckBox.setValue(false);
}
@@ -27,6 +27,7 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
protected StringMessages stringMessages;
protected TextBox nameEntryField;
protected TextArea descriptionEntryField;
protected TextBox displayNameEntryField;
protected CheckBox displayLeaderboardsInReverseOrderCheckBox;
protected CheckBox useOverallLeaderboardCheckBox;
private Panel overallLeaderboardConfigPanel;
@@ -36,16 +37,18 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
public static class LeaderboardGroupDescriptor {
private final String name;
private final String description;
private final String displayName;
private final boolean displayLeaderboardsInReverseOrder;
private final boolean useOverallLeaderboard;
private final int[] overallLeaderboardDiscardThresholds;
private final ScoringSchemeType overallLeaderboardScoringSchemeType;
public LeaderboardGroupDescriptor(String name, String description, boolean displayLeaderboardsInReverseOrder,
boolean useOverallLeaderboard, int[] overallLeaderboardDiscardThresholds,
ScoringSchemeType overallLeaderboardScoringSchemeType) {
public LeaderboardGroupDescriptor(String name, String description, String displayName,
boolean displayLeaderboardsInReverseOrder, boolean useOverallLeaderboard,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
super();
this.name = name;
this.description = description;
this.displayName = displayName;
this.displayLeaderboardsInReverseOrder = displayLeaderboardsInReverseOrder;
this.useOverallLeaderboard = useOverallLeaderboard;
this.overallLeaderboardDiscardThresholds = overallLeaderboardDiscardThresholds;
@@ -57,6 +60,9 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
public String getDescription() {
return description;
}
public String getDisplayName() {
return displayName;
}
public boolean isDisplayLeaderboardsInReverseOrder() {
return displayLeaderboardsInReverseOrder;
}
@@ -152,10 +158,10 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
@Override
protected LeaderboardGroupDescriptor getResult() {
return new LeaderboardGroupDescriptor(nameEntryField.getText(), descriptionEntryField.getText(),
displayNameEntryField.getText().trim().isEmpty() ? null : displayNameEntryField.getText(),
displayLeaderboardsInReverseOrderCheckBox.getValue(),
useOverallLeaderboardCheckBox.getValue(),
useOverallLeaderboardCheckBox.getValue() ? overallLeaderboardDiscardThresholdBoxes.getDiscardThresholds() : null,
useOverallLeaderboardCheckBox.getValue() ? AbstractLeaderboardDialog.getSelectedScoringSchemeType(
useOverallLeaderboardCheckBox.getValue() ? overallLeaderboardDiscardThresholdBoxes.getDiscardThresholds() : null, useOverallLeaderboardCheckBox.getValue() ? AbstractLeaderboardDialog.getSelectedScoringSchemeType(
overallLeaderboardScoringSchemeListBox, stringMessages) : null);
}
@@ -173,6 +179,9 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
descriptionEntryField.setVisibleLines(6);
descriptionEntryField.getElement().getStyle().setProperty("resize", "none");
panel.add(descriptionEntryField);
panel.add(new Label(stringMessages.displayName()));
displayNameEntryField.getElement().getStyle().setProperty("resize", "none");
panel.add(displayNameEntryField);
panel.add(displayLeaderboardsInReverseOrderCheckBox);
panel.add(useOverallLeaderboardCheckBox);
useOverallLeaderboardCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@@ -13,6 +13,7 @@ public class LeaderboardGroupEditDialog extends LeaderboardGroupDialog {
getOverallLeaderboardScoringSchemeListBox().setEnabled(!group.hasOverallLeaderboard());
nameEntryField = createTextBox(group.getName(), 50);
descriptionEntryField = createTextArea(group.description);
displayNameEntryField = createTextBox(group.getDisplayName());
displayLeaderboardsInReverseOrderCheckBox.setValue(group.displayLeaderboardsInReverseOrder);
displayLeaderboardsInReverseOrderCheckBox.setEnabled(false);
useOverallLeaderboardCheckBox.setValue(group.hasOverallLeaderboard());
@@ -258,12 +258,12 @@ public interface SailingService extends RemoteService {
void removeLeaderboardGroups(Set<String> groupNames);
LeaderboardGroupDTO createLeaderboardGroup(String groupName, String description,
LeaderboardGroupDTO createLeaderboardGroup(String groupName, String description, String displayName,
boolean displayGroupsInReverseOrder, int[] overallLeaderboardDiscardThresholds,
ScoringSchemeType overallLeaderboardScoringSchemeType);
void updateLeaderboardGroup(String oldName, String newName, String description, List<String> leaderboardNames,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
void updateLeaderboardGroup(String oldName, String newName, String description, String newDisplayName,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
CompetitorsRaceDataDTO getCompetitorsRaceData(RegattaAndRaceIdentifier race, List<CompetitorDTO> competitors, Date from, Date to,
long stepSizeInMs, DetailType detailType, String leaderboardGroupName, String leaderboardName) throws NoWindException;
@@ -354,7 +354,7 @@ public interface SailingService extends RemoteService {
CourseAreaDTO createCourseArea(UUID eventId, String courseAreaName);
List<Util.Pair<String, String>> getLeaderboardsNamesOfMetaleaderboard(String metaLeaderboardName);
List<Util.Pair<String, String>> getLeaderboardsNamesOfMetaLeaderboard(String metaLeaderboardName);
Util.Pair<String, LeaderboardType> checkLeaderboardName(String leaderboardName);
@@ -303,22 +303,16 @@ public interface SailingServiceAsync {
/**
* Creates a new group with the name <code>groupname</code>, the description <code>description</code> and an empty list of leaderboards.<br/>
* @param displayName TODO
* @param displayGroupsInReverseOrder TODO
*/
void createLeaderboardGroup(String groupName, String description,
boolean displayGroupsInReverseOrder, int[] overallLeaderboardDiscardThresholds,
ScoringSchemeType overallLeaderboardScoringSchemeType, AsyncCallback<LeaderboardGroupDTO> callback);
String displayName, boolean displayGroupsInReverseOrder,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType, AsyncCallback<LeaderboardGroupDTO> callback);
/**
* Updates the data of the group with the name <code>oldName</code>.
*
* @param oldName The old name of the group
* @param newName The new name of the group
* @param description The new description of the group
* @param leaderboardNames The list of names of the new leaderboards of the group
*/
void updateLeaderboardGroup(String oldName, String newName, String description,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType, AsyncCallback<Void> callback);
void updateLeaderboardGroup(String oldName, String newName, String description, String newDisplayName,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds,
ScoringSchemeType overallLeaderboardScoringSchemeType, AsyncCallback<Void> callback);
void setRaceIsKnownToStartUpwind(RegattaAndRaceIdentifier raceIdentifier, boolean raceIsKnownToStartUpwind,
@@ -477,7 +471,7 @@ public interface SailingServiceAsync {
void getLeaderboardDataEntriesForAllRaceColumns(String leaderboardName, Date date, DetailType detailType,
AsyncCallback<List<Util.Triple<String, List<CompetitorDTO>, List<Double>>>> callback);
void getLeaderboardsNamesOfMetaleaderboard(String metaLeaderboardName,
void getLeaderboardsNamesOfMetaLeaderboard(String metaLeaderboardName,
AsyncCallback<List<Util.Pair<String, String>>> callback);
void checkLeaderboardName(String leaderboardName, AsyncCallback<Util.Pair<String, LeaderboardType>> callback);
@@ -150,7 +150,7 @@ public class MultiLeaderboardPanel extends AbstractLazyComponent<LeaderboardSett
}
private void readAndUpdateLeaderboardsOfMetaleaderboard() {
sailingService.getLeaderboardsNamesOfMetaleaderboard(metaLeaderboardName, new AsyncCallback<List<Util.Pair<String, String>>>() {
sailingService.getLeaderboardsNamesOfMetaLeaderboard(metaLeaderboardName, new AsyncCallback<List<Util.Pair<String, String>>>() {
@Override
public void onSuccess(List<Util.Pair<String, String>> leaderboardNamesAndDisplayNames) {
@@ -2752,17 +2752,17 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
}
@Override
public List<com.sap.sse.common.Util.Pair<String, String>> getLeaderboardsNamesOfMetaleaderboard(String metaLeaderboardName) {
public List<com.sap.sse.common.Util.Pair<String, String>> getLeaderboardsNamesOfMetaLeaderboard(String metaLeaderboardName) {
Leaderboard leaderboard = getService().getLeaderboardByName(metaLeaderboardName);
if (leaderboard == null) {
throw new IllegalArgumentException("Couldn't find leaderboard named "+metaLeaderboardName);
}
if(!(leaderboard instanceof MetaLeaderboard)) {
if (!(leaderboard instanceof MetaLeaderboard)) {
throw new IllegalArgumentException("The leaderboard "+metaLeaderboardName + " is not a metaleaderboard");
}
List<com.sap.sse.common.Util.Pair<String, String>> result = new ArrayList<com.sap.sse.common.Util.Pair<String, String>>();
MetaLeaderboard metaLeaderboard = (MetaLeaderboard) leaderboard;
for(Leaderboard containedLeaderboard: metaLeaderboard.getLeaderboards()) {
for (Leaderboard containedLeaderboard: metaLeaderboard.getLeaderboards()) {
result.add(new com.sap.sse.common.Util.Pair<String, String>(containedLeaderboard.getName(),
containedLeaderboard.getDisplayName() != null ? containedLeaderboard.getDisplayName() : containedLeaderboard.getName()));
}
@@ -2947,7 +2947,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
}
private LeaderboardGroupDTO convertToLeaderboardGroupDTO(LeaderboardGroup leaderboardGroup, boolean withGeoLocationData) {
LeaderboardGroupDTO groupDTO = new LeaderboardGroupDTO(leaderboardGroup.getId(), leaderboardGroup.getName(), leaderboardGroup.getDescription());
LeaderboardGroupDTO groupDTO = new LeaderboardGroupDTO(leaderboardGroup.getId(), leaderboardGroup.getName(),
leaderboardGroup.getDisplayName(), leaderboardGroup.getDescription());
groupDTO.displayLeaderboardsInReverseOrder = leaderboardGroup.isDisplayGroupsInReverseOrder();
for (Leaderboard leaderboard : leaderboardGroup.getLeaderboards()) {
groupDTO.leaderboards.add(createStrippedLeaderboardDTO(leaderboard, withGeoLocationData));
@@ -2981,19 +2982,20 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
}
@Override
public LeaderboardGroupDTO createLeaderboardGroup(String groupName, String description, boolean displayGroupsInReverseOrder,
public LeaderboardGroupDTO createLeaderboardGroup(String groupName, String description, String displayName,
boolean displayGroupsInReverseOrder,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
CreateLeaderboardGroup createLeaderboardGroupOp = new CreateLeaderboardGroup(groupName, description, displayGroupsInReverseOrder,
new ArrayList<String>(), overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
CreateLeaderboardGroup createLeaderboardGroupOp = new CreateLeaderboardGroup(groupName, description, displayName,
displayGroupsInReverseOrder, new ArrayList<String>(), overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
return convertToLeaderboardGroupDTO(getService().apply(createLeaderboardGroupOp), false);
}
@Override
public void updateLeaderboardGroup(String oldName, String newName, String description, List<String> leaderboardNames,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
public void updateLeaderboardGroup(String oldName, String newName, String newDescription, String newDisplayName,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
getService().apply(
new UpdateLeaderboardGroup(oldName, newName, description, leaderboardNames,
overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType));
new UpdateLeaderboardGroup(oldName, newName, newDescription, newDisplayName,
leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType));
}
@Override
@@ -3223,7 +3225,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
private LeaderboardGroupBaseDTO convertToLeaderboardGroupBaseDTO(LeaderboardGroupBase leaderboardGroupBase) {
return new LeaderboardGroupBaseDTO(leaderboardGroupBase.getId(), leaderboardGroupBase.getName(),
leaderboardGroupBase.getDescription(), leaderboardGroupBase.hasOverallLeaderboard());
leaderboardGroupBase.getDescription(), leaderboardGroupBase.getDisplayName(),
leaderboardGroupBase.hasOverallLeaderboard());
}
private void copyEventBaseFieldsToDTO(EventBase event, EventBaseDTO eventDTO) {
@@ -8,17 +8,19 @@ public class LeaderboardGroupBaseDTO extends NamedDTO {
private static final long serialVersionUID = -9023865026348923430L;
private UUID id;
public String description;
private String displayName;
private boolean hasOverallLeaderboard;
LeaderboardGroupBaseDTO() {} // for deserialization
public LeaderboardGroupBaseDTO(UUID id, String name) {
public LeaderboardGroupBaseDTO(UUID id, String name, String displayName) {
super(name);
this.id = id;
this.displayName = displayName;
}
public LeaderboardGroupBaseDTO(UUID id, String name, String description, boolean hasOverallLeaderboard) {
this(id, name);
public LeaderboardGroupBaseDTO(UUID id, String name, String description, String displayName, boolean hasOverallLeaderboard) {
this(id, name, displayName);
this.description = description;
this.hasOverallLeaderboard = hasOverallLeaderboard;
}
@@ -27,6 +29,14 @@ public class LeaderboardGroupBaseDTO extends NamedDTO {
return id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public boolean isHasOverallLeaderboard() {
return hasOverallLeaderboard;
}
@@ -38,25 +38,26 @@ public class LeaderboardGroupDTO extends LeaderboardGroupBaseDTO {
* <p>
* The additional data (start dates and places for the races) will be initialized but empty.
*/
public LeaderboardGroupDTO(UUID id) {
this(id, "");
public LeaderboardGroupDTO(UUID id, String displayName) {
this(id, "", displayName);
}
public LeaderboardGroupDTO(UUID id, String name) {
this(id, name, "");
public LeaderboardGroupDTO(UUID id, String name, String displayName) {
this(id, name, displayName, "");
}
public LeaderboardGroupDTO(UUID id, String name, String description) {
this(id, name, description, new ArrayList<StrippedLeaderboardDTO>());
public LeaderboardGroupDTO(UUID id, String name, String displayName, String description) {
this(id, name, description, displayName, new ArrayList<StrippedLeaderboardDTO>());
}
/**
* Creates a new LeaderboardGroupDTO with the given parameters as attributes.<br />
* All parameters can be <code>null</code> but then the attributes will also be <code>null</code>.<br />
* The additional data (start dates and places for the races) will be initialized but empty.
* @param displayName TODO
*/
private LeaderboardGroupDTO(UUID id, String name, String description, List<StrippedLeaderboardDTO> leaderboards) {
super(id, name);
private LeaderboardGroupDTO(UUID id, String name, String description, String displayName, List<StrippedLeaderboardDTO> leaderboards) {
super(id, name, displayName);
currentServerTime = new Date();
this.description = description;
this.leaderboards = leaderboards;
@@ -94,7 +94,7 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
}
private LeaderboardGroup createLeaderboardGroup(String name) {
return new LeaderboardGroupImpl(name, "Description for "+name, /* displayInReverseOrder */ false, Collections.<Leaderboard>emptyList());
return new LeaderboardGroupImpl(name, "Description for "+name, /* displayName */ null, /* displayInReverseOrder */ false, Collections.<Leaderboard>emptyList());
}
@Test
@@ -96,7 +96,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
leaderboards.add(leaderboard);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, /* displayName */ null, false, leaderboards);
final Leaderboard overallLeaderboard = new LeaderboardGroupMetaLeaderboard(leaderboardGroup,
new HighPointExtremeSailingSeriesOverall(), new ThresholdBasedResultDiscardingRuleImpl(new int[0]));
leaderboardGroup.setOverallLeaderboard(overallLeaderboard);
@@ -146,8 +146,9 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
racingEventService.addLeaderboard(leaderboard);
LeaderboardGroup leaderboardGroup = racingEventService.addLeaderboardGroup(UUID.randomUUID(), groupName, groupDescription, false, Arrays.asList(leaderboardNames),
new int[0], ScoringSchemeType.HIGH_POINT_ESS_OVERALL);
LeaderboardGroup leaderboardGroup = racingEventService.addLeaderboardGroup(UUID.randomUUID(), groupName, groupDescription,
"The LG Display Name", false,
Arrays.asList(leaderboardNames), new int[0], ScoringSchemeType.HIGH_POINT_ESS_OVERALL);
final Leaderboard overallLeaderboard = leaderboardGroup.getOverallLeaderboard();
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup);
racingEventService.apply(new UpdateLeaderboardScoreCorrection(overallLeaderboard.getName(), "Leaderboard 3",
@@ -202,7 +203,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
leaderboards.add(leaderboard);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, /* displayName */ null, false, leaderboards);
final Leaderboard overallLeaderboard = new LeaderboardGroupMetaLeaderboard(leaderboardGroup,
new HighPointExtremeSailingSeriesOverall(), new ThresholdBasedResultDiscardingRuleImpl(new int[0]));
leaderboardGroup.setOverallLeaderboard(overallLeaderboard);
@@ -258,7 +259,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
leaderboards.add(leaderboard);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, /* displayName */ null, false, leaderboards);
final Leaderboard overallLeaderboard = new LeaderboardGroupMetaLeaderboard(leaderboardGroup,
new HighPointExtremeSailingSeriesOverall(), new ThresholdBasedResultDiscardingRuleImpl(new int[0]));
leaderboardGroup.setOverallLeaderboard(overallLeaderboard);
@@ -300,7 +301,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
leaderboard = new FlexibleLeaderboardImpl(leaderboardNames[2], new ThresholdBasedResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces),
new LowPoint(), null);
leaderboards1.add(leaderboard);
final LeaderboardGroup leaderboardGroup1 = new LeaderboardGroupImpl(groupName1, groupDescription1, false, leaderboards1);
final LeaderboardGroup leaderboardGroup1 = new LeaderboardGroupImpl(groupName1, groupDescription1, /* displayName */ null, false, leaderboards1);
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup1);
final String groupName2 = "Leaderboard Group 2";
@@ -312,7 +313,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
leaderboard = new FlexibleLeaderboardImpl(leaderboardNames[3], new ThresholdBasedResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces),
new LowPoint(), null);
leaderboards2.add(leaderboard);
final LeaderboardGroup leaderboardGroup2 = new LeaderboardGroupImpl(groupName2, groupDescription2, false, leaderboards2);
final LeaderboardGroup leaderboardGroup2 = new LeaderboardGroupImpl(groupName2, groupDescription2, /* displayName */ null, false, leaderboards2);
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup2);
// the leaderboard named leaderboardNames[2] occurs in both groups
@@ -335,6 +336,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
final String groupName = "Leaderboard Group";
final String groupDescription = "A leaderboard group";
final String groupDisplayName = "Some short name";
final ArrayList<Leaderboard> leaderboards = new ArrayList<>();
Leaderboard leaderboard = new FlexibleLeaderboardImpl(leaderboardNames[0], new ThresholdBasedResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces),
@@ -350,7 +352,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
leaderboards.add(leaderboard);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, groupDisplayName, false, leaderboards);
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup);
final LeaderboardGroup loadedLeaderboardGroup = domainObjectFactory.loadLeaderboardGroup(groupName, /* regattaRegistry */ null,
@@ -358,6 +360,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
Assert.assertEquals(groupName, loadedLeaderboardGroup.getName());
Assert.assertEquals(groupDescription, loadedLeaderboardGroup.getDescription());
Assert.assertEquals(groupDisplayName, loadedLeaderboardGroup.getDisplayName());
int c = 0;
for (Leaderboard board : leaderboardGroup.getLeaderboards()) {
@@ -382,7 +385,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
new LowPoint(), null);
leaderboards.add(leaderboard);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup leaderboardGroup = new LeaderboardGroupImpl(groupName, groupDescription, /* displayName */ null, false, leaderboards);
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup);
final String[] ungroupedLeaderboardNames = {"Ungrouped Leaderboard 0", "Ungrouped Leaderboard 1", "Ungrouped Leaderboard 2"};
@@ -435,7 +438,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
final RaceColumn race = leaderboard.addRaceColumn(columnName, false);
leaderboards.add(leaderboard);
final LeaderboardGroup group = new LeaderboardGroupImpl(groupName, groupDescription, false, leaderboards);
final LeaderboardGroup group = new LeaderboardGroupImpl(groupName, groupDescription, /* displayName */ null, false, leaderboards);
mongoObjectFactory.storeLeaderboardGroup(group);
//Name change test
@@ -42,7 +42,7 @@ public class EventDataJsonSerializerTest {
protected final Venue expectedVenue = new VenueImpl("Expected Venue");
protected final URL expectedOfficialWebsiteURL;
protected final URL expectedLogoImageURL;
protected final LeaderboardGroup expectedLeaderbaordGroup = mock(LeaderboardGroup.class);
protected final LeaderboardGroup expectedLeaderboardGroup = mock(LeaderboardGroup.class);
protected JsonSerializer<Venue> venueSerializer;
protected EventBaseJsonSerializer serializer;
@@ -74,11 +74,12 @@ public class EventDataJsonSerializerTest {
serializer = new EventBaseJsonSerializer(new VenueJsonSerializer(new CourseAreaJsonSerializer()), new LeaderboardGroupBaseJsonSerializer());
deserializer = new EventBaseJsonDeserializer(new VenueJsonDeserializer(new CourseAreaJsonDeserializer(DomainFactory.INSTANCE)), new LeaderboardGroupBaseJsonDeserializer());
when(expectedLeaderbaordGroup.getId()).thenReturn(UUID.randomUUID());
when(expectedLeaderbaordGroup.getName()).thenReturn("LG");
when(expectedLeaderbaordGroup.getDescription()).thenReturn("LG Description");
when(expectedLeaderbaordGroup.hasOverallLeaderboard()).thenReturn(false);
doReturn(Collections.<LeaderboardGroup>singleton(expectedLeaderbaordGroup)).when(event).getLeaderboardGroups();
when(expectedLeaderboardGroup.getId()).thenReturn(UUID.randomUUID());
when(expectedLeaderboardGroup.getName()).thenReturn("LG");
when(expectedLeaderboardGroup.getDescription()).thenReturn("LG Description");
when(expectedLeaderboardGroup.getDisplayName()).thenReturn("LG Display Name");
when(expectedLeaderboardGroup.hasOverallLeaderboard()).thenReturn(false);
doReturn(Collections.<LeaderboardGroup>singleton(expectedLeaderboardGroup)).when(event).getLeaderboardGroups();
}
@Test
@@ -118,10 +119,11 @@ public class EventDataJsonSerializerTest {
assertEquals(expectedName, deserializedEvent.getName());
assertEquals(expectedStartDate, deserializedEvent.getStartDate());
assertEquals(expectedEndDate, deserializedEvent.getEndDate());
assertEquals(expectedLeaderbaordGroup.getName(), deserializedEvent.getLeaderboardGroups().iterator().next().getName());
assertEquals(expectedLeaderbaordGroup.getDescription(), deserializedEvent.getLeaderboardGroups().iterator().next().getDescription());
assertEquals(expectedLeaderbaordGroup.getId(), deserializedEvent.getLeaderboardGroups().iterator().next().getId());
assertEquals(expectedLeaderbaordGroup.hasOverallLeaderboard(), deserializedEvent.getLeaderboardGroups().iterator().next().hasOverallLeaderboard());
assertEquals(expectedLeaderboardGroup.getName(), deserializedEvent.getLeaderboardGroups().iterator().next().getName());
assertEquals(expectedLeaderboardGroup.getDescription(), deserializedEvent.getLeaderboardGroups().iterator().next().getDescription());
assertEquals(expectedLeaderboardGroup.getDisplayName(), deserializedEvent.getLeaderboardGroups().iterator().next().getDisplayName());
assertEquals(expectedLeaderboardGroup.getId(), deserializedEvent.getLeaderboardGroups().iterator().next().getId());
assertEquals(expectedLeaderboardGroup.hasOverallLeaderboard(), deserializedEvent.getLeaderboardGroups().iterator().next().hasOverallLeaderboard());
}
@Test
@@ -24,7 +24,7 @@ public class ControlPointDeserializer implements JsonDeserializer<ControlPoint>
@Override
public ControlPoint deserialize(JSONObject object) throws JsonDeserializationException {
String classFieldValue = object.get(BaseControlPointJsonSerializer.FIELD_CLASS).toString();
String classFieldValue = (String) object.get(BaseControlPointJsonSerializer.FIELD_CLASS);
ControlPoint controlPoint = null;
if (classFieldValue.equals(ControlPointWithTwoMarks.class.getSimpleName())) {
@@ -32,7 +32,7 @@ public class GateDeserializer implements JsonDeserializer<ControlPointWithTwoMar
Mark leftMark = markDeserializer.deserialize(jsonLeftMark);
Mark rightMark = markDeserializer.deserialize(jsonRightMark);
String gateName = object.get(BaseControlPointJsonSerializer.FIELD_NAME).toString();
String gateName = (String) object.get(BaseControlPointJsonSerializer.FIELD_NAME);
ControlPointWithTwoMarks controlPoint = factory.createControlPointWithTwoMarks(leftMark, rightMark, gateName);
return controlPoint;
@@ -17,7 +17,7 @@ public class BoatClassJsonDeserializer implements JsonDeserializer<BoatClass> {
}
public BoatClass deserialize(JSONObject object) throws JsonDeserializationException {
String name = object.get(BoatClassJsonSerializer.FIELD_NAME).toString();
String name = (String) object.get(BoatClassJsonSerializer.FIELD_NAME);
if (object.containsKey(BoatClassJsonSerializer.FIELD_TYPICALLY_STARTS_UPWIND)) {
boolean typicallyStartsUpwind = Boolean.parseBoolean(object.get(BoatClassJsonSerializer.FIELD_TYPICALLY_STARTS_UPWIND).toString());
@@ -18,7 +18,7 @@ public class BoatJsonDeserializer implements JsonDeserializer<DynamicBoat> {
}
public DynamicBoat deserialize(JSONObject object) throws JsonDeserializationException {
String name = object.get(BoatJsonSerializer.FIELD_NAME).toString();
String name = (String) object.get(BoatJsonSerializer.FIELD_NAME);
final Object sailID = object.get(BoatJsonSerializer.FIELD_SAIL_ID);
String sailId = sailID == null ? null : sailID.toString();
BoatClass boatClass = null;
@@ -21,7 +21,7 @@ public class CourseAreaJsonDeserializer implements JsonDeserializer<CourseArea>
public CourseArea deserialize(JSONObject object)
throws JsonDeserializationException {
String name = object.get(CourseAreaJsonSerializer.FIELD_NAME).toString();
String name = (String) object.get(CourseAreaJsonSerializer.FIELD_NAME);
Serializable id = (Serializable) object.get(CourseAreaJsonSerializer.FIELD_ID);
return factory.getOrCreateCourseArea((UUID) Helpers.tryUuidConversion(id), name);
@@ -30,7 +30,7 @@ public class EventBaseJsonDeserializer implements JsonDeserializer<EventBase> {
public EventBase deserialize(JSONObject object) throws JsonDeserializationException {
UUID id = UUID.fromString((String) object.get(EventBaseJsonSerializer.FIELD_ID));
String name = object.get(EventBaseJsonSerializer.FIELD_NAME).toString();
String name = (String) object.get(EventBaseJsonSerializer.FIELD_NAME);
String description = (String) object.get(EventBaseJsonSerializer.FIELD_DESCRIPTION);
String officialWebsiteURLAsString = (String) object.get(EventBaseJsonSerializer.FIELD_OFFICIAL_WEBSITE_URL);
String logoImageURLAsString = (String) object.get(EventBaseJsonSerializer.FIELD_LOGO_IMAGE_URL);
@@ -11,22 +11,21 @@ import com.sap.sailing.server.gateway.serialization.impl.FleetJsonSerializer;
public class FleetDeserializer implements JsonDeserializer<Fleet> {
private JsonDeserializer<Color> colorDeserializer;
public FleetDeserializer(JsonDeserializer<Color> colorDeserializer) {
this.colorDeserializer = colorDeserializer;
}
private JsonDeserializer<Color> colorDeserializer;
public FleetDeserializer(JsonDeserializer<Color> colorDeserializer) {
this.colorDeserializer = colorDeserializer;
}
public Fleet deserialize(JSONObject object) throws JsonDeserializationException {
Color color = null;
if (object.containsKey(FleetJsonSerializer.FIELD_COLOR)) {
color = colorDeserializer.deserialize(Helpers.getNestedObjectSafe(object, FleetJsonSerializer.FIELD_COLOR));
}
String name = (String) object.get(FleetJsonSerializer.FIELD_NAME);
Number ordering = (Number) object.get(FleetJsonSerializer.FIELD_ORDERING);
return new FleetImpl(name, ordering.intValue(), color);
}
public Fleet deserialize(JSONObject object)
throws JsonDeserializationException {
Color color = null;
if (object.containsKey(FleetJsonSerializer.FIELD_COLOR)) {
color = colorDeserializer.deserialize(Helpers.getNestedObjectSafe(object, FleetJsonSerializer.FIELD_COLOR));
}
String name = object.get(FleetJsonSerializer.FIELD_NAME).toString();
Number ordering = (Number) object.get(FleetJsonSerializer.FIELD_ORDERING);
return new FleetImpl(name, ordering.intValue(), color);
}
}
@@ -18,10 +18,12 @@ public class LeaderboardGroupBaseJsonDeserializer implements JsonDeserializer<Le
public LeaderboardGroupBase deserialize(JSONObject object) throws JsonDeserializationException {
UUID id = UUID.fromString((String) object.get(EventBaseJsonSerializer.FIELD_ID));
String name = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_NAME).toString();
String description = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DESCRIPTION).toString();
String hasOverallLeaderboard = object.get(LeaderboardGroupBaseJsonSerializer.FIELD_HAS_OVERALL_LEADERBOARD).toString();
LeaderboardGroupBase result = new StrippedLeaderboardGroupImpl(id, name, description, hasOverallLeaderboard == null ? false : Boolean.valueOf(hasOverallLeaderboard));
String name = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_NAME);
String description = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DESCRIPTION);
String displayName = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DISPLAY_NAME);
Boolean hasOverallLeaderboard = (Boolean) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_HAS_OVERALL_LEADERBOARD);
LeaderboardGroupBase result = new StrippedLeaderboardGroupImpl(id, name, description, displayName,
hasOverallLeaderboard == null ? false : hasOverallLeaderboard);
return result;
}
}
@@ -16,32 +16,27 @@ import com.sap.sailing.server.gateway.serialization.impl.TeamJsonSerializer;
public class TeamJsonDeserializer implements JsonDeserializer<DynamicTeam> {
private final JsonDeserializer<DynamicPerson> personDeserializer;
private final JsonDeserializer<DynamicPerson> personDeserializer;
public static TeamJsonDeserializer create(SharedDomainFactory baseDomainFactory) {
return new TeamJsonDeserializer(new PersonJsonDeserializer(
new NationalityJsonDeserializer(baseDomainFactory)));
}
public static TeamJsonDeserializer create(SharedDomainFactory baseDomainFactory) {
return new TeamJsonDeserializer(new PersonJsonDeserializer(new NationalityJsonDeserializer(baseDomainFactory)));
}
public TeamJsonDeserializer(JsonDeserializer<DynamicPerson> personDeserializer) {
this.personDeserializer = personDeserializer;
}
public TeamJsonDeserializer(JsonDeserializer<DynamicPerson> personDeserializer) {
this.personDeserializer = personDeserializer;
}
@Override
public DynamicTeam deserialize(JSONObject object)
throws JsonDeserializationException {
String name = (String) object.get(TeamJsonSerializer.FIELD_NAME);
DynamicPerson coach = personDeserializer.deserialize((JSONObject) object
.get(TeamJsonSerializer.FIELD_COACH));
Set<DynamicPerson> sailors = new HashSet<DynamicPerson>();
@Override
public DynamicTeam deserialize(JSONObject object) throws JsonDeserializationException {
String name = (String) object.get(TeamJsonSerializer.FIELD_NAME);
DynamicPerson coach = personDeserializer.deserialize((JSONObject) object.get(TeamJsonSerializer.FIELD_COACH));
Set<DynamicPerson> sailors = new HashSet<DynamicPerson>();
JSONArray sailorsJson = (JSONArray) object
.get(TeamJsonSerializer.FIELD_SAILORS);
for (Object sailorObject : sailorsJson) {
sailors.add(personDeserializer
.deserialize((JSONObject) sailorObject));
}
return new TeamImpl(name, sailors, coach);
}
JSONArray sailorsJson = (JSONArray) object.get(TeamJsonSerializer.FIELD_SAILORS);
for (Object sailorObject : sailorsJson) {
sailors.add(personDeserializer.deserialize((JSONObject) sailorObject));
}
return new TeamImpl(name, sailors, coach);
}
}
@@ -17,21 +17,15 @@ public class VenueJsonDeserializer implements JsonDeserializer<Venue> {
this.courseAreaDeserializer = courseAreaDeserializer;
}
public Venue deserialize(JSONObject object)
throws JsonDeserializationException {
String name = object.get(VenueJsonSerializer.FIELD_NAME).toString();
public Venue deserialize(JSONObject object) throws JsonDeserializationException {
String name = (String) object.get(VenueJsonSerializer.FIELD_NAME);
Venue venue = new VenueImpl(name);
JSONArray courseAreaArray = Helpers.getNestedArraySafe(
object,
VenueJsonSerializer.FIELD_COURSE_AREAS);
JSONArray courseAreaArray = Helpers.getNestedArraySafe(object, VenueJsonSerializer.FIELD_COURSE_AREAS);
for (Object element : courseAreaArray) {
JSONObject courseAreaObject = Helpers.toJSONObjectSafe(element);
venue.addCourseArea(courseAreaDeserializer.deserialize(courseAreaObject));
}
return venue;
}
}
@@ -9,6 +9,7 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
public static final String FIELD_ID = "id";
public static final String FIELD_NAME = "name";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_DISPLAY_NAME = "displayName";
public static final String FIELD_HAS_OVERALL_LEADERBOARD = "hasOverallLeaderboard";
public LeaderboardGroupBaseJsonSerializer() {
@@ -19,6 +20,7 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
result.put(FIELD_ID, leaderboardGroup.getId().toString());
result.put(FIELD_NAME, leaderboardGroup.getName());
result.put(FIELD_DESCRIPTION, leaderboardGroup.getDescription());
result.put(FIELD_DISPLAY_NAME, leaderboardGroup.getDisplayName());
result.put(FIELD_HAS_OVERALL_LEADERBOARD, leaderboardGroup.hasOverallLeaderboard());
return result;
}
@@ -67,20 +67,17 @@ public class LeaderboardGroupJsonExportTest extends AbstractJsonExportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(regatta.getName());
leaderboardGroup = racingEventService.addLeaderboardGroup(UUID.randomUUID(), leaderboardGroupName, "description",
/* displayGroupsInReverseOrder */ false, leaderboardNames, /* overallLeaderboardDiscardThresholds */ null, /* overallLeaderboardScoringSchemeType */ null);
"The LG displayName", /* displayGroupsInReverseOrder */ false,
leaderboardNames, /* overallLeaderboardDiscardThresholds */ null, /* overallLeaderboardScoringSchemeType */ null);
}
@Test
public void testExportLeaderboardGroupsAsJson() throws Exception {
String jsonString = callJsonHttpServlet(new LeaderboardGroupsJsonGetServlet(), "GET", null);
Object obj= JSONValue.parse(jsonString);
JSONArray array= (JSONArray) obj;
Object obj = JSONValue.parse(jsonString);
JSONArray array = (JSONArray) obj;
assertTrue(array.size() == 1);
String jsonFirstLeaderboardGroup = (String) array.get(0);
assertTrue(leaderboardGroup.getName().equals(jsonFirstLeaderboardGroup));
}
}
@@ -42,6 +42,7 @@ public class LeaderboardGroupJsonGetServlet extends AbstractJsonHttpServlet {
JSONObject jsonLeaderboardGroup = new JSONObject();
jsonLeaderboardGroup.put("name", leaderboardGroup.getName());
jsonLeaderboardGroup.put("description", leaderboardGroup.getDescription());
jsonLeaderboardGroup.put("displayName", leaderboardGroup.getDisplayName());
jsonLeaderboardGroup.put("timepoint", timePoint.toString());
JSONArray jsonLeaderboardEntries = new JSONArray();
jsonLeaderboardGroup.put("leaderboards", jsonLeaderboardEntries);
@@ -57,9 +57,9 @@ public class EventReplicationTest extends AbstractServerReplicationTest {
final Event masterEvent = master.addEvent(eventName, null, null, venueName, isPublic, UUID.randomUUID());
final String leaderboardGroupName = "LGName";
LeaderboardGroup lg = master.apply(new CreateLeaderboardGroup(leaderboardGroupName, "LGDescription", /* displayGroupsInReverseOrder */
false, /* leaderboardNames */
Collections.<String> emptyList(), /* overallLeaderboardDiscardThresholds */null, /* overallLeaderboardScoringSchemeType */
null));
"displayName", /* leaderboardNames */
false, Collections.<String> emptyList(), /* overallLeaderboardScoringSchemeType */
/* overallLeaderboardDiscardThresholds */null, null));
master.apply(new AddLeaderboardGroupToEvent(masterEvent.getId(), lg.getId()));
Thread.sleep(1000);
Event replicatedEvent = replica.getEvent(masterEvent.getId());
@@ -115,7 +115,8 @@ public class InitialLoadReplicationObjectIdentityTest extends AbstractServerRepl
leaderboardNames.add(leaderboardName);
int[] overallLeaderboardDiscardThresholds = new int[] {};
ScoringSchemeType overallLeaderboardScoringSchemeType = ScoringSchemeType.HIGH_POINT;
LeaderboardGroup leaderboardGroup = master.addLeaderboardGroup(UUID.randomUUID(), leaderBoardGroupName, "Some descriptive Description", false, leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
LeaderboardGroup leaderboardGroup = master.addLeaderboardGroup(UUID.randomUUID(), leaderBoardGroupName, "Some descriptive Description",
"displayName", false, leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
assertNotNull(master.getLeaderboardGroupByName(leaderBoardGroupName));
assertNull(replica.getLeaderboardGroupByName(leaderBoardGroupName));
@@ -25,8 +25,9 @@ public class ReplicationInstancesManagerLoggingPerformanceTest {
replicationInstanceManager = new ReplicationInstancesManager();
replica = new ReplicaDescriptor(InetAddress.getLocalHost(), UUID.randomUUID(), "");
replicationInstanceManager.registerReplica(replica);
operation = new CreateLeaderboardGroup("Test Leaderboard Group", "Description of Test Leaderboard Group", /* displayGroupsInReverseOrder */ false, Arrays.asList(new String[] { "Default Leaderboard" }),
/* overallLeaderboardDiscardThresholds */ null, /* overallLeaderboardScoringSchemeType */ null);
operation = new CreateLeaderboardGroup("Test Leaderboard Group", "Description of Test Leaderboard Group", /* displayName */ null,
/* displayGroupsInReverseOrder */ false,
Arrays.asList(new String[] { "Default Leaderboard" }), /* overallLeaderboardDiscardThresholds */ null, /* overallLeaderboardScoringSchemeType */ null);
}
@Test
@@ -188,7 +188,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
event.addLeaderboardGroup(group);
// Set tracked Race with competitors
@@ -401,7 +401,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -555,7 +555,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -676,7 +676,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -831,7 +831,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -944,7 +944,7 @@ public class MasterDataImportTest {
List<String> leaderboardNamesNotToOverride = new ArrayList<String>();
leaderboardNamesNotToOverride.add(leaderboardNotToOverride.getName());
groupNotToOverride = destService.addLeaderboardGroup(UUID.randomUUID(),
TEST_GROUP_NAME, "testGroupDescNotToOverride", false, leaderboardNamesNotToOverride, null, null);
TEST_GROUP_NAME, "testGroupDescNotToOverride", /* displayName */ null, false, leaderboardNamesNotToOverride, null, null);
inputStream = new ByteArrayInputStream(os.toByteArray());
MasterDataImporter importer = new MasterDataImporter(domainFactory, destService);
@@ -1029,7 +1029,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -1155,8 +1155,8 @@ public class MasterDataImportTest {
identifierOfRegattaTrackedRace = regattaToOverride
.getRaceIdentifier(columnToOverride.getRaceDefinition(testFleet1ToOverride));
destService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDescToOverride", false,
new ArrayList<String>(), null, null);
destService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDescToOverride", /* displayName */ null,
false, new ArrayList<String>(), null, null);
destService.getLeaderboardGroupByName(TEST_GROUP_NAME).addLeaderboard(leaderboardToOverride);
destService.addLeaderboard(leaderboardToOverride);
inputStream = new ByteArrayInputStream(os.toByteArray());
@@ -1241,7 +1241,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Serialize
List<String> groupNamesToExport = new ArrayList<String>();
@@ -1318,7 +1318,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -1451,7 +1451,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -1656,9 +1656,9 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group1 = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
LeaderboardGroup group2 = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME2, "testGroupDesc2",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
Set<Competitor> competitors = new HashSet<Competitor>();
@@ -1752,7 +1752,7 @@ public class MasterDataImportTest {
ScoringScheme scheme = new LowPoint();
List<String> leaderboardNames = new ArrayList<String>();
LeaderboardGroup sourceGroup = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, discardRule, scheme.getType());
/* displayName */ null, false, leaderboardNames, discardRule, scheme.getType());
FlexibleLeaderboard sourceLeaderboard1 = new FlexibleLeaderboardImpl("Leaderboard1", null, scheme, null);
sourceService.addLeaderboard(sourceLeaderboard1);
sourceGroup.addLeaderboard(sourceLeaderboard1);
@@ -1884,7 +1884,7 @@ public class MasterDataImportTest {
List<String> leaderboardNames = new ArrayList<String>();
leaderboardNames.add(leaderboard.getName());
LeaderboardGroup group = sourceService.addLeaderboardGroup(UUID.randomUUID(), TEST_GROUP_NAME, "testGroupDesc",
false, leaderboardNames, null, null);
/* displayName */ null, false, leaderboardNames, null, null);
// Set tracked Race with competitors
@@ -236,15 +236,15 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
* The name of the new group
* @param description
* The description of the new group
* @param displayName TODO
* @param displayGroupsInReverseOrder TODO
* @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(UUID id, String groupName, String description,
boolean displayGroupsInReverseOrder, List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
String displayName, boolean displayGroupsInReverseOrder, List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
/**
* Removes the group with the name <code>groupName</code> from the service and the database.
@@ -289,8 +289,8 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
*/
void addRace(RegattaIdentifier addToRegatta, RaceDefinition raceDefinition);
void updateLeaderboardGroup(String oldName, String newName, String description, List<String> leaderboardNames,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
void updateLeaderboardGroup(String oldName, String newName, String description, String displayName,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType);
/**
* Executes an operation whose effects need to be replicated to any replica of this service known and
@@ -1892,8 +1892,8 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
@Override
public LeaderboardGroup addLeaderboardGroup(UUID id, String groupName,
String description, boolean displayGroupsInReverseOrder,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
String description, String displayName,
boolean displayGroupsInReverseOrder, List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
ArrayList<Leaderboard> leaderboards = new ArrayList<>();
for (String leaderboardName : leaderboardNames) {
Leaderboard leaderboard = leaderboardsByName.get(leaderboardName);
@@ -1903,8 +1903,8 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
leaderboards.add(leaderboard);
}
}
LeaderboardGroup result = new LeaderboardGroupImpl(id, groupName, description, displayGroupsInReverseOrder,
leaderboards);
LeaderboardGroup result = new LeaderboardGroupImpl(id, groupName, description, displayName,
displayGroupsInReverseOrder, leaderboards);
if (overallLeaderboardScoringSchemeType != null) {
// create overall leaderboard and its discards settings
addOverallLeaderboardToLeaderboardGroup(result,
@@ -1984,8 +1984,8 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
@Override
public void updateLeaderboardGroup(String oldName, String newName, String description,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds,
ScoringSchemeType overallLeaderboardScoringSchemeType) {
String displayName, List<String> leaderboardNames,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
if (!oldName.equals(newName)) {
renameLeaderboardGroup(oldName, newName);
}
@@ -1993,6 +1993,9 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
if (!description.equals(group.getDescription())) {
group.setDescriptiom(description);
}
if (!Util.equalsWithNull(displayName, group.getDisplayName())) {
group.setDisplayName(displayName);
}
group.clearLeaderboards();
for (String leaderboardName : leaderboardNames) {
Leaderboard leaderboard = getLeaderboardByName(leaderboardName);
@@ -12,16 +12,18 @@ public class CreateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Le
private static final long serialVersionUID = -5028997286564650805L;
private final UUID id;
private final String description;
private final String displayName;
private final boolean displayGroupsInReverseOrder;
private final List<String> leaderboardNames;
private final int[] overallLeaderboardDiscardThresholds;
private final ScoringSchemeType overallLeaderboardScoringSchemeType;
public CreateLeaderboardGroup(String leaderboardGroupName, String description, boolean displayGroupsInReverseOrder, List<String> leaderboardNames,
int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
public CreateLeaderboardGroup(String leaderboardGroupName, String description, String displayName, boolean displayGroupsInReverseOrder,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
super(leaderboardGroupName);
this.id = UUID.randomUUID();
this.description = description;
this.displayName = displayName;
this.displayGroupsInReverseOrder = displayGroupsInReverseOrder;
this.leaderboardNames = leaderboardNames;
this.overallLeaderboardDiscardThresholds = overallLeaderboardDiscardThresholds;
@@ -43,8 +45,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(id, getLeaderboardGroupName(), description, displayGroupsInReverseOrder,
leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
return toState.addLeaderboardGroup(id, getLeaderboardGroupName(), description, displayName,
displayGroupsInReverseOrder, leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
}
}
@@ -10,15 +10,17 @@ public class UpdateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Vo
private static final long serialVersionUID = -1822477339916802467L;
private final String newName;
private final String newDescription;
private final String newDisplayName;
private final List<String> leaderboardNames;
private final int[] overallLeaderboardDiscardThresholds;
private final ScoringSchemeType overallLeaderboardScoringSchemeType;
public UpdateLeaderboardGroup(String leaderboardGroupName, String newName, String newDescription,
List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
String newDisplayName, List<String> leaderboardNames, int[] overallLeaderboardDiscardThresholds, ScoringSchemeType overallLeaderboardScoringSchemeType) {
super(leaderboardGroupName);
this.newName = newName;
this.newDescription = newDescription;
this.newDisplayName = newDisplayName;
this.leaderboardNames = leaderboardNames;
this.overallLeaderboardDiscardThresholds = overallLeaderboardDiscardThresholds;
this.overallLeaderboardScoringSchemeType = overallLeaderboardScoringSchemeType;
@@ -38,8 +40,8 @@ public class UpdateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Vo
@Override
public Void internalApplyTo(RacingEventService toState) {
toState.updateLeaderboardGroup(getLeaderboardGroupName(), newName, newDescription, leaderboardNames,
overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
toState.updateLeaderboardGroup(getLeaderboardGroupName(), newName, newDescription, newDisplayName,
leaderboardNames, overallLeaderboardDiscardThresholds, overallLeaderboardScoringSchemeType);
return null;
}