Merge remote-tracking branch 'server_ext/permission-vertical' into permission-vertical

Change-Id: I67b612821ca97852013c5825d55f52b244d37469
This commit is contained in:
Axel Uhl committed 2018-09-26 18:01:14 +02:00
commit 154e782bb3
35 files changed
+510 -379

No files matched your search

@@ -14,11 +14,9 @@ import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sailing.domain.common.ScoringSchemeType;
import com.sap.sse.common.Util;
public abstract class AbstractLeaderboardDTO implements Serializable {
public abstract class AbstractLeaderboardDTO extends NamedSecuredObjectDTO implements Serializable {
private static final long serialVersionUID = -205106531931903527L;
public String name;
private List<RaceColumnDTO> races;
public Map<CompetitorDTO, String> competitorDisplayNames;
public Map<CompetitorDTO, LeaderboardRowDTO> rows;
@@ -350,7 +348,7 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
result = prime * result + Arrays.hashCode(discardThresholds);
result = prime * result + (hasCarriedPoints ? 1231 : 1237);
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
result = prime * result + ((scoringScheme == null) ? 0 : scoringScheme.hashCode());
if (races == null) {
result = prime * result;
@@ -387,10 +385,10 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
return false;
if (scoringScheme != other.scoringScheme)
return false;
if (name == null) {
if (other.name != null)
if (getName() == null) {
if (other.getName() != null)
return false;
} else if (!name.equals(other.name))
} else if (!getName().equals(other.getName()))
return false;
if (races == null) {
if (other.races != null)
@@ -440,9 +438,4 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
}
return result;
}
public String getName() {
return name;
}
}
@@ -37,12 +37,12 @@ public class LeaderboardDTOCacheInvalidationTest {
LeaderboardDTO dto = l.getLeaderboardDTO(now, Collections.<String> emptySet(),
/* addOverallDetails */ false, /* trackedRegattaRegistry */ null, DomainFactory.INSTANCE,
/* fillTotalPointsUncorrected */ false);
assertEquals(oldName, dto.name);
assertEquals(oldName, dto.getName());
l.setName(newName);
LeaderboardDTO dtoNew = l.getLeaderboardDTO(now, Collections.<String> emptySet(),
/* addOverallDetails */ false, /* trackedRegattaRegistry */ null, DomainFactory.INSTANCE,
/* fillTotalPointsUncorrected */ false);
assertEquals(newName, dtoNew.name);
assertEquals(newName, dtoNew.getName());
}
@Test
@@ -157,13 +157,6 @@ public abstract class AbstractLeaderboardWithCache implements Leaderboard {
}
}
private static class UUIDGenerator implements LeaderboardDTO.UUIDGenerator {
@Override
public String generateRandomUUID() {
return UUID.randomUUID().toString();
}
}
/**
* Handles the invalidation of the {@link SailingServiceImpl#raceDetailsAtEndOfTrackingCache} entries if the tracked
* race changes in any way. In particular, for {@link #statusChanged}, when the status changes away from LOADING,
@@ -365,11 +358,11 @@ public abstract class AbstractLeaderboardWithCache implements Leaderboard {
: this.getScoreCorrection().getTimePointOfLastCorrectionsValidity().asDate(),
this.getScoreCorrection() == null ? null : this.getScoreCorrection().getComment(),
this.getScoringScheme() == null ? null : this.getScoringScheme().getType(), this
.getScoringScheme().isHigherBetter(), new UUIDGenerator(), addOverallDetails,
.getScoringScheme().isHigherBetter(), () -> UUID.randomUUID().toString(), addOverallDetails,
boatClass==null?null:new BoatClassDTO(boatClass.getName(), boatClass.getDisplayName(), boatClass.getHullLength(), boatClass.getHullBeam()));
result.type = getLeaderboardType();
result.competitors = new ArrayList<>();
result.name = this.getName();
result.setName(this.getName());
result.displayName = this.getDisplayName();
result.competitorDisplayNames = new HashMap<>();
boolean isLeaderboardThatHasRegattaLike = this instanceof LeaderboardThatHasRegattaLike;
@@ -124,7 +124,7 @@ public class GwtTestCaseColumnToggling extends GWTTestCase {
new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onSuccess(StrippedLeaderboardDTO result) {
System.out.println("Created Leaderboard "+result.name);
System.out.println("Created Leaderboard "+result.getName());
addColumnToLeaderboard();
}
@@ -130,7 +130,7 @@ public class AutoPlayStartViewImpl extends Composite implements AutoPlayStartVie
leaderboardSelectionBox.addItem(StringMessages.INSTANCE.selectALeaderboard());
for (LeaderboardGroupDTO leaderboardGroup : selectedEvent.getLeaderboardGroups()) {
for (StrippedLeaderboardDTO leaderboard : leaderboardGroup.getLeaderboards()) {
leaderboardSelectionBox.addItem(leaderboard.name);
leaderboardSelectionBox.addItem(leaderboard.getName());
}
}
}
@@ -255,7 +255,7 @@ public class AutoPlayStartViewImpl extends Composite implements AutoPlayStartVie
String selectedLeaderboardName = getSelectedLeaderboardName();
for (LeaderboardGroupDTO leaderboardGroup : selectedEvent.getLeaderboardGroups()) {
for (StrippedLeaderboardDTO leaderboard : leaderboardGroup.getLeaderboards()) {
if (leaderboard.name.equals(selectedLeaderboardName)) {
if (leaderboard.getName().equals(selectedLeaderboardName)) {
return leaderboard;
}
}
@@ -24,7 +24,7 @@ public class LeaderboardWithZoomingPerspectiveLifecycle extends AbstractPerspect
this.stringMessages = stringMessages;
this.leaderboardPanelLifecycle = new MultiRaceLeaderboardPanelLifecycle(leaderboard, stringMessages, availableDetailTypes);
this.sapHeaderLifecycle = new SAPHeaderComponentLifecycle(stringMessages.leaderboard() + ": " +
(leaderboard.getDisplayName() == null ? leaderboard.name : leaderboard.getDisplayName()),
(leaderboard.getDisplayName() == null ? leaderboard.getName() : leaderboard.getDisplayName()),
stringMessages);
addLifeCycle(leaderboardPanelLifecycle);
@@ -115,7 +115,7 @@ public class AutoplayHelper {
public static StrippedLeaderboardDTO getSelectedLeaderboard(EventDTO event, String leaderBoardName) {
for (LeaderboardGroupDTO leaderboardGroup : event.getLeaderboardGroups()) {
for (StrippedLeaderboardDTO leaderboard : leaderboardGroup.getLeaderboards()) {
if (leaderboard.name.equals(leaderBoardName)) {
if (leaderboard.getName().equals(leaderBoardName)) {
return leaderboard;
}
}
@@ -172,7 +172,7 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
@Override
public List<String> getSearchableStrings(StrippedLeaderboardDTO t) {
List<String> strings = new ArrayList<String>();
strings.add(t.name);
strings.add(t.getName());
strings.add(t.displayName);
return strings;
}
@@ -334,11 +334,11 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
tableResources.cellTableStyle().cellTableCheckboxColumnCell(), new EntityIdentityComparator<StrippedLeaderboardDTO>() {
@Override
public boolean representSameEntity(StrippedLeaderboardDTO dto1, StrippedLeaderboardDTO dto2) {
return dto1.name.equals(dto2.name);
return dto1.getName().equals(dto2.getName());
}
@Override
public int hashCode(StrippedLeaderboardDTO t) {
return t.name.hashCode();
return t.getName().hashCode();
}
}, listDataProvider, leaderboardTable);
selectionCheckboxColumn.setSortable(true);
@@ -368,7 +368,7 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
@Override
public void onSuccess(StrippedLeaderboardDTO leaderboard) {
for (StrippedLeaderboardDTO leaderboardDTO : leaderboardSelectionModel.getSelectedSet()) {
if (leaderboardDTO.name.equals(leaderboardName)) {
if (leaderboardDTO.getName().equals(leaderboardName)) {
leaderboardSelectionModel.setSelected(leaderboardDTO, false);
break;
}
@@ -392,7 +392,7 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
int index = -1;
for (StrippedLeaderboardDTO existingLeaderboard : leaderboardList) {
index++;
if (existingLeaderboard.name.equals(leaderboardToReplace)) {
if (existingLeaderboard.getName().equals(leaderboardToReplace)) {
break;
}
}
@@ -500,7 +500,7 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
}
protected String getSelectedLeaderboardName() {
return getSelectedLeaderboard() != null ? getSelectedLeaderboard().name : null;
return getSelectedLeaderboard() != null ? getSelectedLeaderboard().getName() : null;
}
protected boolean canBoatsOfCompetitorsChangePerRace() {
@@ -1,28 +1,91 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import com.sap.sailing.domain.common.dto.NamedSecuredObjectDTO;
import com.sap.sse.gwt.client.celltable.ImagesBarCell;
import com.sap.sse.gwt.client.celltable.ImagesBarColumn;
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
import com.sap.sse.security.shared.AccessControlList;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.shared.HasPermissions.Action;
import com.sap.sse.security.shared.Ownership;
import com.sap.sse.security.shared.WildcardPermission;
import com.sap.sse.security.ui.client.UserService;
import com.sap.sse.security.ui.shared.UserDTO;
public abstract class AccessControlledActionsColumn<T, S extends ImagesBarCell> extends ImagesBarColumn<T, S> {
public class AccessControlledActionsColumn<T extends NamedSecuredObjectDTO, S extends ImagesBarCell>
extends ImagesBarColumn<T, S> {
public AccessControlledActionsColumn(S imagesBarCell) {
private final Map<String, Consumer<T>> nameToCallbackMap = new HashMap<>();
private final Map<String, Action> nameToActionMap = new HashMap<>();
private final UserService userService;
private final BiFunction<Action, T, WildcardPermission> permissionFactory;
public AccessControlledActionsColumn(final S imagesBarCell, final UserService userService,
final HasPermissions type, final Function<T, String> idFactory) {
super(imagesBarCell);
this.userService = userService;
this.permissionFactory = (action, object) -> type.getPermissionForObjects(action, idFactory.apply(object));
this.setFieldUpdater((index, object, value) -> nameToCallbackMap.get(value).accept(object));
}
/**
* Adds an action identified by the provided name which will always be accessible.
*
* @param name
* {@link String} to identify the action
* @param callback
* {@link Consumer} to execute when the action is triggered
*/
public void addAction(final String name, final Consumer<T> callback) {
this.nameToCallbackMap.put(name, callback);
}
/**
* Adds an action identified by the provided name which will only be accessible, if the current user has the
* required permission specified by the provided {@link Action action}.
*
* @param name
* {@link String} to identify the action
* @param action
* {@link Action} specified the permission which is required to access the action
* @param callback
* {@link Consumer} to execute when the action is triggered
*/
public void addAction(final String name, final Action action, final Consumer<T> callback) {
this.nameToActionMap.put(name, action);
this.addAction(name, callback);
}
protected abstract Iterable<DefaultActions> getAllowedActions(T object);
@Override
public String getValue(T object) {
public final String getValue(final T object) {
final ArrayList<String> allowedActions = new ArrayList<>();
for (final DefaultActions action : getAllowedActions(object)) {
final String actionName = action.name();
actionName.replace("\\", "\\\\");
actionName.replace(",", "\\,");
allowedActions.add(actionName);
final UserDTO user = userService.getCurrentUser();
for (final String name : nameToCallbackMap.keySet()) {
final Action action = nameToActionMap.get(name);
if (isNotRestrictedOrHasPermission(user, action, object)) {
final String escapedName = name.replace("\\", "\\\\").replace(",", "\\,");
allowedActions.add(escapedName);
}
}
return String.join(",", allowedActions);
}
private boolean isNotRestrictedOrHasPermission(final UserDTO user, final Action action, final T object) {
final boolean result;
if (action == null) {
result = true;
} else {
final Ownership ownership = object.getOwnership();
final AccessControlList accessControlList = object.getAccessControlList();
result = user.hasPermission(permissionFactory.apply(action, object), ownership, accessControlList);
}
return result;
}
}
@@ -176,15 +176,15 @@ public class CreateRegattaCallback implements DialogCallback<RegattaDTO>{
public void ok(final LeaderboardGroupDTO selectedLeaderboardGroup) {
final List<String> leaderboardNames = new ArrayList<>();
for (StrippedLeaderboardDTO leaderboard : selectedLeaderboardGroup.getLeaderboards()) {
leaderboardNames.add(leaderboard.name);
leaderboardNames.add(leaderboard.getName());
}
leaderboardNames.add(newRegattaLeaderboard.name);
leaderboardNames.add(newRegattaLeaderboard.getName());
sailingService.updateLeaderboardGroup(selectedLeaderboardGroup.getName(), selectedLeaderboardGroup.getName(), selectedLeaderboardGroup.description,
selectedLeaderboardGroup.getDisplayName(), leaderboardNames, selectedLeaderboardGroup.getOverallLeaderboardDiscardThresholds(),
selectedLeaderboardGroup.getOverallLeaderboardScoringSchemeType(), new MarkedAsyncCallback<Void>(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
errorReporter.reportError(stringMessages.failedToLinkLeaderboardToLeaderboardGroup(newRegattaLeaderboard.name, selectedLeaderboardGroup.getName()));
errorReporter.reportError(stringMessages.failedToLinkLeaderboardToLeaderboardGroup(newRegattaLeaderboard.getName(), selectedLeaderboardGroup.getName()));
}
@Override
@@ -1,15 +1,22 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.function.Consumer;
import java.util.function.Function;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.domain.common.dto.NamedSecuredObjectDTO;
import com.sap.sailing.domain.common.security.SecuredDomainType;
import com.sap.sailing.gwt.ui.adminconsole.EditOwnershipDialog.OwnershipDialogResult;
import com.sap.sse.gwt.client.Notification;
import com.sap.sse.gwt.client.Notification.NotificationType;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.shared.Ownership;
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
import com.sap.sse.security.shared.SecurityUser;
import com.sap.sse.security.shared.UserGroup;
import com.sap.sse.security.shared.impl.OwnershipImpl;
@@ -18,6 +25,7 @@ import com.sap.sse.security.ui.client.i18n.StringMessages;
import com.sap.sse.security.ui.shared.UserDTO;
public class EditOwnershipDialog extends DataEntryDialog<OwnershipDialogResult> {
private final StringMessages stringMessages;
private final UserManagementServiceAsync userManagementService;
private final TextBox usernameBox;
@@ -112,7 +120,7 @@ public class EditOwnershipDialog extends DataEntryDialog<OwnershipDialogResult>
private void resolveUserGroup() {
resolvedUserGroup = null;
resolvingUserGroupName = true;
getUserManagementService().getUserGroupByName(groupnameBox.getText(), new AsyncCallback<UserGroup>() {
userManagementService.getUserGroupByName(groupnameBox.getText(), new AsyncCallback<UserGroup>() {
@Override
public void onSuccess(UserGroup result) {
resolvedUserGroup = result;
@@ -130,7 +138,7 @@ public class EditOwnershipDialog extends DataEntryDialog<OwnershipDialogResult>
private void resolveUser() {
resolvedUser = null;
resolvingUsername = true;
getUserManagementService().getUserByName(usernameBox.getText(), new AsyncCallback<UserDTO>() {
userManagementService.getUserByName(usernameBox.getText(), new AsyncCallback<UserDTO>() {
@Override
public void onSuccess(UserDTO result) {
resolvedUser = result;
@@ -145,13 +153,98 @@ public class EditOwnershipDialog extends DataEntryDialog<OwnershipDialogResult>
});
}
public UserManagementServiceAsync getUserManagementService() {
return userManagementService;
}
@Override
protected OwnershipDialogResult getResult() {
return new OwnershipDialogResult(new OwnershipImpl(resolvedUser, resolvedUserGroup), usernameBox.getText(), groupnameBox.getText(), resolvingUsername, resolvingUserGroupName);
}
/**
* Creates a new {@link DialogConfig dialog configuration} instance which be (re-)used to
* {@link DialogConfig#openDialog(NamedSecuredObjectDTO) open} a {@link EditOwnershipDialog dialog}.
*
* @param userManagementService
* {@link UserManagementServiceAsync} to use to the secured object's ownership
* @param type
* {@link SecuredDomainType} specifying the type of required permissions to modify the secured object
* @param typeRelativeIdFactory
* {@link Function factory} to get a {@link String type relative identifier} for the secured object
* @param updateCallback
* {@link Consumer callback} to execute when the dialog is confirmed and ownership update succeeded
* @param errorCallback
* {@link Consumer callback} to execute when the dialog is confirmed and ownership update fails
*/
public static <T extends NamedSecuredObjectDTO> DialogConfig<T> create(
final UserManagementServiceAsync userManagementService, final HasPermissions type,
final Function<T, String> typeRelativeIdFactory, final Consumer<T> updateCallback,
final Consumer<T> errorCallback) {
return new DialogConfig<>(userManagementService, type, typeRelativeIdFactory, updateCallback, errorCallback);
}
public static class DialogConfig<T extends NamedSecuredObjectDTO> {
private final UserManagementServiceAsync userManagementService;
private final Consumer<T> updateCallback, errorCallback;
private final Function<T, QualifiedObjectIdentifier> identifierFactory;
private DialogConfig(final UserManagementServiceAsync userManagementService, final HasPermissions type,
final Function<T, String> idFactory, final Consumer<T> updateCallback,
final Consumer<T> errorCallback) {
this.userManagementService = userManagementService;
this.identifierFactory = idFactory.andThen(type::getQualifiedObjectIdentifier);
this.updateCallback = updateCallback;
this.errorCallback = errorCallback;
}
/**
* Opens a {@link EditOwnershipDialog dialog} to edit ownerships for the provided secured object instance.
*
* @param securedObject
* {@link NamedSecuredObjectDTO secured object} instance to edit ownerships for
*/
public void openDialog(final T securedObject) {
new EditOwnershipDialog(userManagementService, securedObject.getOwnership(),
SecuredObjectUtils.SECURITY_MESSAGES, new EditOwnershipDialogCallback(securedObject)).show();
}
private class EditOwnershipDialogCallback implements DialogCallback<OwnershipDialogResult> {
private final T securedObject;
private EditOwnershipDialogCallback(T securedObject) {
this.securedObject = securedObject;
}
@Override
public void ok(OwnershipDialogResult editedObject) {
final QualifiedObjectIdentifier objectIdentifier = identifierFactory.apply(securedObject);
userManagementService.setOwnership(editedObject.getOwnership(), objectIdentifier,
securedObject.getName(), new UpdateOwnershipAsyncCallback(editedObject));
}
@Override
public final void cancel() {
}
private class UpdateOwnershipAsyncCallback implements AsyncCallback<QualifiedObjectIdentifier> {
private final OwnershipDialogResult editResult;
private UpdateOwnershipAsyncCallback(final OwnershipDialogResult result) {
this.editResult = result;
}
@Override
public final void onSuccess(QualifiedObjectIdentifier result) {
securedObject.setOwnership(editResult.getOwnership());
updateCallback.accept(securedObject);
}
@Override
public final void onFailure(Throwable caught) {
errorCallback.accept(securedObject);
}
}
}
}
}
@@ -1,5 +1,9 @@
package com.sap.sailing.gwt.ui.adminconsole;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.CHANGE_OWNERSHIP;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.DELETE;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.UPDATE;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -9,6 +13,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.google.gwt.cell.client.AbstractCell;
@@ -37,6 +42,7 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.sap.sailing.domain.common.security.SecuredDomainType;
import com.sap.sailing.gwt.ui.adminconsole.EditOwnershipDialog.DialogConfig;
import com.sap.sailing.gwt.ui.adminconsole.LeaderboardGroupDialog.LeaderboardGroupDescriptor;
import com.sap.sailing.gwt.ui.client.EntryPointLinkFactory;
import com.sap.sailing.gwt.ui.client.EventsRefresher;
@@ -65,6 +71,7 @@ import com.sap.sse.gwt.client.celltable.SelectionCheckboxColumn;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
import com.sap.sse.security.ui.client.UserService;
import com.sap.sse.security.ui.shared.UserDTO;
@@ -342,16 +349,23 @@ public class EventListComposite extends Composite implements EventsRefresher, Le
}
};
final SecuredObjectCompositeConfig<EventDTO> securedObjectConfig = new SecuredObjectCompositeConfig<>(
userService, errorReporter, stringMessages, SecuredDomainType.EVENT, event -> event.id.toString());
securedObjectConfig.addAction(DefaultActions.UPDATE, this::openEditEventDialog);
securedObjectConfig.addAction(DefaultActions.DELETE, event -> {
final SecuredObjectOwnerColumn<EventDTO> groupColumn = SecuredObjectOwnerColumn.getGroupOwnerColumn();
final SecuredObjectOwnerColumn<EventDTO> userColumn = SecuredObjectOwnerColumn.getUserOwnerColumn();
final HasPermissions type = SecuredDomainType.EVENT;
final Function<EventDTO, String> idFactory = SecuredObjectUtils::getTypeRelativeObjectIdentifier;
final AccessControlledActionsColumn<EventDTO, EventConfigImagesBarCell> actionsColumn = new AccessControlledActionsColumn<>(
new EventConfigImagesBarCell(stringMessages), userService, type, idFactory);
actionsColumn.addAction(UPDATE.name(), UPDATE, this::openEditEventDialog);
actionsColumn.addAction(DELETE.name(), DELETE, event -> {
if (Window.confirm(stringMessages.doYouReallyWantToRemoveEvent(event.getName()))) {
removeEvent(event);
}
});
securedObjectConfig.addAction(DefaultActions.CHANGE_OWNERSHIP,
oldEvent -> securedObjectConfig.openOwnershipDialog(oldEvent, event -> updateEvent(event, event)));
final DialogConfig<EventDTO> config = EditOwnershipDialog.create(userService.getUserManagementService(), type,
idFactory, event -> updateEvent(event, event),
event -> errorReporter.reportError(stringMessages.errorUpdatingOwnership(event.getName())));
actionsColumn.addAction(CHANGE_OWNERSHIP.name(), CHANGE_OWNERSHIP, config::openDialog);
eventNameColumn.setSortable(true);
venueNameColumn.setSortable(true);
@@ -359,10 +373,12 @@ public class EventListComposite extends Composite implements EventsRefresher, Le
startEndDateColumn.setSortable(true);
courseAreasColumn.setSortable(true);
leaderboardGroupsColumn.setSortable(true);
groupColumn.setSortable(true);
userColumn.setSortable(true);
final ListHandler<EventDTO> columnSortHandler = getEventTableColumnSortHandler(eventListDataProvider.getList(),
eventSelectionCheckboxColumn, eventNameColumn, venueNameColumn, startEndDateColumn, isPublicColumn,
courseAreasColumn, leaderboardGroupsColumn);
courseAreasColumn, leaderboardGroupsColumn, groupColumn, userColumn);
table.addColumn(eventSelectionCheckboxColumn, eventSelectionCheckboxColumn.getHeader());
table.addColumn(eventNameColumn, stringMessages.event());
@@ -373,8 +389,9 @@ public class EventListComposite extends Composite implements EventsRefresher, Le
table.addColumn(leaderboardGroupsColumn, stringMessages.leaderboardGroups());
table.addColumn(imagesColumn, stringMessages.images());
table.addColumn(videosColumn, stringMessages.videos());
securedObjectConfig.addOwnerColumns(table, columnSortHandler);
securedObjectConfig.addActionColumn(table, new EventConfigImagesBarCell(stringMessages));
table.addColumn(groupColumn, SecuredObjectUtils.SECURITY_MESSAGES.group());
table.addColumn(userColumn, SecuredObjectUtils.SECURITY_MESSAGES.user());
table.addColumn(actionsColumn, stringMessages.actions());
table.setSelectionModel(eventSelectionCheckboxColumn.getSelectionModel(), eventSelectionCheckboxColumn.getSelectionManager());
table.addColumnSortHandler(columnSortHandler);
@@ -387,7 +404,8 @@ public class EventListComposite extends Composite implements EventsRefresher, Le
SelectionCheckboxColumn<EventDTO> eventSelectionCheckboxColumn, Column<EventDTO, SafeHtml> eventNameColumn,
TextColumn<EventDTO> venueNameColumn, TextColumn<EventDTO> startEndDateColumn,
TextColumn<EventDTO> isPublicColumn, Column<EventDTO, SafeHtml> courseAreasColumn,
Column<EventDTO, List<MultipleLinkCell.CellLink>> leaderboardGroupsColumn) {
Column<EventDTO, List<MultipleLinkCell.CellLink>> leaderboardGroupsColumn,
SecuredObjectOwnerColumn<EventDTO> groupColumn, SecuredObjectOwnerColumn<EventDTO> userColumn) {
ListHandler<EventDTO> result = new ListHandler<EventDTO>(eventRecords);
result.setComparator(eventSelectionCheckboxColumn, eventSelectionCheckboxColumn.getComparator());
result.setComparator(eventNameColumn, new Comparator<EventDTO>() {
@@ -436,6 +454,8 @@ public class EventListComposite extends Composite implements EventsRefresher, Le
return e1.getLeaderboardGroups().toString().compareTo(e2.getLeaderboardGroups().toString());
}
});
result.setComparator(groupColumn, groupColumn.getComparator());
result.setComparator(userColumn, userColumn.getComparator());
return result;
}
@@ -239,7 +239,7 @@ public class ExpeditionAllInOneAfterImportHandler {
String raceColumnName = race.getB();
String fleetName= race.getC();
racesToStopAndStartTrackingFor.add(new RegattaNameAndRaceName(regattaName, raceName));
leaderboardRaceColumnFleetNames.add(new Triple<>(leaderboard.name, raceColumnName, fleetName));
leaderboardRaceColumnFleetNames.add(new Triple<>(leaderboard.getName(), raceColumnName, fleetName));
raceNames.add(new Pair<String, String>(raceName, raceColumnName));
}
@@ -38,7 +38,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
boolean nonEmpty = leaderboardToValidate.getName() != null && leaderboardToValidate.getName().length() > 0;
boolean unique = true;
for (StrippedLeaderboardDTO dao : existingLeaderboards) {
if(dao.name.equals(leaderboardToValidate.getName())){
if(dao.getName().equals(leaderboardToValidate.getName())){
unique = false;
}
}
@@ -181,9 +181,9 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
@Override
public SafeHtml getValue(StrippedLeaderboardDTO object) {
final String link = EntryPointWithSettingsLinkFactory.createLeaderboardLink(
new LeaderboardContextDefinition(object.name, object.displayName),
new LeaderboardContextDefinition(object.getName(), object.displayName),
new LeaderboardPerspectiveOwnSettings(showRaceDetails));
return ANCHORTEMPLATE.cell(UriUtils.fromString(link), object.name);
return ANCHORTEMPLATE.cell(UriUtils.fromString(link), object.getName());
}
};
@@ -192,12 +192,12 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
@Override
public int compare(StrippedLeaderboardDTO o1, StrippedLeaderboardDTO o2) {
boolean ascending = isSortedAscending();
if (o1.name.equals(o2.name)) {
if (o1.getName().equals(o2.getName())) {
return 0;
}
int val = -1;
val = (o1 != null && o2 != null && ascending) ? (o1.name.compareTo(o2.name)) : -(o2.name
.compareTo(o1.name));
val = (o1 != null && o2 != null && ascending) ? (o1.getName().compareTo(o2.getName())) : -(o2.getName()
.compareTo(o1.getName()));
return val;
}
@@ -317,16 +317,16 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
@Override
public void update(int index, StrippedLeaderboardDTO leaderboardDTO, String value) {
if (LeaderboardConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
if (Window.confirm(stringMessages.doYouReallyWantToRemoveLeaderboard(leaderboardDTO.name))) {
if (Window.confirm(stringMessages.doYouReallyWantToRemoveLeaderboard(leaderboardDTO.getName()))) {
removeLeaderboard(leaderboardDTO);
}
} else if (LeaderboardConfigImagesBarCell.ACTION_EDIT.equals(value)) {
editLeaderboard(leaderboardDTO);
} else if (LeaderboardConfigImagesBarCell.ACTION_EDIT_SCORES.equals(value)) {
String leaderboardEditingUrl = EntryPointWithSettingsLinkFactory.createLeaderboardEditingLink(leaderboardDTO.name);
String leaderboardEditingUrl = EntryPointWithSettingsLinkFactory.createLeaderboardEditingLink(leaderboardDTO.getName());
Window.open(leaderboardEditingUrl, "_blank", null);
} else if (LeaderboardConfigImagesBarCell.ACTION_EDIT_COMPETITORS.equals(value)) {
EditCompetitorsDialog editCompetitorsDialog = new EditCompetitorsDialog(sailingService, leaderboardDTO.name, stringMessages,
EditCompetitorsDialog editCompetitorsDialog = new EditCompetitorsDialog(sailingService, leaderboardDTO.getName(), stringMessages,
errorReporter, new DialogCallback<List<CompetitorWithBoatDTO>>() {
@Override
public void cancel() {
@@ -338,7 +338,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
});
editCompetitorsDialog.show();
} else if (LeaderboardConfigImagesBarCell.ACTION_CONFIGURE_URL.equals(value)) {
sailingService.getAvailableDetailTypesForLeaderboard(leaderboardDTO.name, null, new AsyncCallback<Iterable<DetailType>>() {
sailingService.getAvailableDetailTypesForLeaderboard(leaderboardDTO.getName(), null, new AsyncCallback<Iterable<DetailType>>() {
@Override
public void onFailure(Throwable caught) {
@@ -351,10 +351,10 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
}
});
} else if (LeaderboardConfigImagesBarCell.ACTION_EXPORT_XML.equals(value)) {
Window.open(UriUtils.fromString("/export/xml?domain=leaderboard&name=" + leaderboardDTO.name).asString(), "", null);
Window.open(UriUtils.fromString("/export/xml?domain=leaderboard&name=" + leaderboardDTO.getName()).asString(), "", null);
} else if (LeaderboardConfigImagesBarCell.ACTION_OPEN_COACH_DASHBOARD.equals(value)) {
Map<String, String> dashboardURLParameters = new HashMap<String, String>();
dashboardURLParameters.put("leaderboardName", leaderboardDTO.name);
dashboardURLParameters.put("leaderboardName", leaderboardDTO.getName());
Window.open(EntryPointLinkFactory.createDashboardLink(dashboardURLParameters), "", null);
} else if (LeaderboardConfigImagesBarCell.ACTION_SHOW_REGATTA_LOG.equals(value)) {
showRegattaLog();
@@ -379,7 +379,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
}
private void editLeaderboard(StrippedLeaderboardDTO leaderboardDTO) {
final String oldLeaderboardName = leaderboardDTO.name;
final String oldLeaderboardName = leaderboardDTO.getName();
List<StrippedLeaderboardDTO> otherExistingLeaderboard = new ArrayList<StrippedLeaderboardDTO>();
otherExistingLeaderboard.addAll(availableLeaderboardList);
otherExistingLeaderboard.remove(leaderboardDTO);
@@ -437,7 +437,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
dialog.show();
break;
case FlexibleLeaderboard:
openUpdateFlexibleLeaderboardDialog(leaderboardDTO, otherExistingLeaderboard, leaderboardDTO.name, createLeaderboardDescriptor(leaderboardDTO,
openUpdateFlexibleLeaderboardDialog(leaderboardDTO, otherExistingLeaderboard, leaderboardDTO.getName(), createLeaderboardDescriptor(leaderboardDTO,
leaderboardDTO.scoringScheme));
break;
default:
@@ -447,7 +447,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
}
private LeaderboardDescriptor createLeaderboardDescriptor(StrippedLeaderboardDTO leaderboardDTO, ScoringSchemeType scoringScheme) {
return new LeaderboardDescriptor(leaderboardDTO.name,
return new LeaderboardDescriptor(leaderboardDTO.getName(),
leaderboardDTO.displayName, scoringScheme,
leaderboardDTO.discardThresholds, leaderboardDTO.regattaName,
leaderboardDTO.defaultCourseAreaId);
@@ -477,7 +477,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
isMedalRaceCheckboxColumn.setFieldUpdater(new FieldUpdater<RaceColumnDTOAndFleetDTOWithNameBasedEquality, Boolean>() {
@Override
public void update(int index, RaceColumnDTOAndFleetDTOWithNameBasedEquality object, Boolean value) {
setIsMedalRace(getSelectedLeaderboard().name, object.getA(), value);
setIsMedalRace(getSelectedLeaderboard().getName(), object.getA(), value);
}
});
isMedalRaceCheckboxColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
@@ -623,7 +623,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
} else {
lifeCycle = new LeaderboardPerspectiveLifecycle(stringMessages, leaderboard, availableDetailType);
}
final LeaderboardContextDefinition leaderboardContextSettings = new LeaderboardContextDefinition(leaderboard.name,
final LeaderboardContextDefinition leaderboardContextSettings = new LeaderboardContextDefinition(leaderboard.getName(),
leaderboard.getDisplayName());
final LinkWithSettingsGenerator<PerspectiveCompositeSettings<LeaderboardPerspectiveOwnSettings>> linkWithSettingsGenerator = new LinkWithSettingsGenerator<>(
EntryPointLinkFactory.LEADERBOARD_PATH, lifeCycle::createDefaultSettings, leaderboardContextSettings);
@@ -853,7 +853,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
}
}
selectedLeaderBoardPanel.setVisible(true);
selectedLeaderBoardPanel.setCaptionText("Details of leaderboard '" + selectedLeaderboard.name + "'");
selectedLeaderBoardPanel.setCaptionText("Details of leaderboard '" + selectedLeaderboard.getName() + "'");
if (!selectedLeaderboard.type.isMetaLeaderboard()) {
trackedRacesListComposite.setRegattaFilterValue(selectedLeaderboard.regattaName);
trackedRacesCaptionPanel.setVisible(true);
@@ -1005,7 +1005,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
int indexOfLeaderboard = 0;
for (int i = 0; i < filteredLeaderboardList.getList().size(); i++) {
StrippedLeaderboardDTO dao = filteredLeaderboardList.getList().get(i);
if (dao.name.equals(oldLeaderboardName)) {
if (dao.getName().equals(oldLeaderboardName)) {
indexOfLeaderboard = i;
break;
}
@@ -1020,7 +1020,7 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
if (!leaderboards.isEmpty()) {
Set<String> leaderboardNames = new HashSet<String>();
for (StrippedLeaderboardDTO leaderboard : leaderboards) {
leaderboardNames.add(leaderboard.name);
leaderboardNames.add(leaderboard.getName());
}
sailingService.removeLeaderboards(leaderboardNames, new AsyncCallback<Void>() {
@Override
@@ -1040,11 +1040,11 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
}
private void removeLeaderboard(final StrippedLeaderboardDTO leaderBoard) {
sailingService.removeLeaderboard(leaderBoard.name, new MarkedAsyncCallback<Void>(
sailingService.removeLeaderboard(leaderBoard.getName(), new MarkedAsyncCallback<Void>(
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
errorReporter.reportError("Error trying to remove leaderboard " + leaderBoard.name + ": "
errorReporter.reportError("Error trying to remove leaderboard " + leaderBoard.getName() + ": "
+ caught.getMessage());
}
@@ -1,5 +1,9 @@
package com.sap.sailing.gwt.ui.adminconsole;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.CHANGE_OWNERSHIP;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.DELETE;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.UPDATE;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -8,6 +12,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.google.gwt.core.client.GWT;
@@ -35,6 +40,7 @@ import com.google.gwt.view.client.SelectionChangeEvent;
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
import com.sap.sailing.domain.common.security.SecuredDomainType;
import com.sap.sailing.gwt.settings.client.raceboard.RaceBoardPerspectiveOwnSettings;
import com.sap.sailing.gwt.ui.adminconsole.EditOwnershipDialog.DialogConfig;
import com.sap.sailing.gwt.ui.adminconsole.LeaderboardConfigPanel.AnchorCell;
import com.sap.sailing.gwt.ui.adminconsole.LeaderboardGroupDialog.LeaderboardGroupDescriptor;
import com.sap.sailing.gwt.ui.client.AbstractRegattaPanel;
@@ -63,7 +69,7 @@ import com.sap.sse.gwt.client.celltable.RefreshableMultiSelectionModel;
import com.sap.sse.gwt.client.celltable.SelectionCheckboxColumn;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel;
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.ui.client.UserService;
public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements LeaderboardGroupsDisplayer, LeaderboardsDisplayer {
@@ -203,7 +209,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
@Override
public Iterable<String> getSearchableStrings(StrippedLeaderboardDTO t) {
List<String> strings = new ArrayList<String>();
strings.add(t.name);
strings.add(t.getName());
strings.add(t.displayName);
return strings;
}
@@ -216,11 +222,11 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
new EntityIdentityComparator<StrippedLeaderboardDTO>() {
@Override
public boolean representSameEntity(StrippedLeaderboardDTO dto1, StrippedLeaderboardDTO dto2) {
return dto1.name.equals(dto2.name);
return dto1.getName().equals(dto2.getName());
}
@Override
public int hashCode(StrippedLeaderboardDTO t) {
return t.name.hashCode();
return t.getName().hashCode();
}
}, leaderboardsFilterablePanel.getAllListDataProvider(), leaderboardsTable);
refreshableLeaderboardsSelectionModel = leaderboardTableSelectionColumn.getSelectionModel();
@@ -241,14 +247,14 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
TextColumn<StrippedLeaderboardDTO> leaderboardsNameColumn = new TextColumn<StrippedLeaderboardDTO>() {
@Override
public String getValue(StrippedLeaderboardDTO leaderboard) {
return leaderboard.name;
return leaderboard.getName();
}
};
leaderboardsNameColumn.setSortable(true);
leaderboardsListHandler.setComparator(leaderboardsNameColumn, new Comparator<StrippedLeaderboardDTO>() {
@Override
public int compare(StrippedLeaderboardDTO l1, StrippedLeaderboardDTO l2) {
return new NaturalComparator(false).compare(l1.name, l2.name);
return new NaturalComparator(false).compare(l1.getName(), l2.getName());
}
});
@@ -355,7 +361,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
TextColumn<StrippedLeaderboardDTO> groupDetailsNameColumn = new TextColumn<StrippedLeaderboardDTO>() {
@Override
public String getValue(StrippedLeaderboardDTO leaderboard) {
return leaderboard.name;
return leaderboard.getName();
}
};
@@ -386,11 +392,11 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
@Override
public boolean representSameEntity(StrippedLeaderboardDTO dto1,
StrippedLeaderboardDTO dto2) {
return dto1.name.equals(dto2.name);
return dto1.getName().equals(dto2.getName());
}
@Override
public int hashCode(StrippedLeaderboardDTO t) {
return t.name.hashCode();
return t.getName().hashCode();
}
}, groupDetailsProvider, groupDetailsTable);
@@ -582,22 +588,34 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
}
});
final SecuredObjectCompositeConfig<LeaderboardGroupDTO> securedObjectConfig = new SecuredObjectCompositeConfig<>(
userService, errorReporter, stringMessages, SecuredDomainType.LEADERBOARD_GROUP,
lbg -> lbg.getId().toString());
securedObjectConfig.addAction(DefaultActions.UPDATE, this::openEditLeaderboardGroupDialog);
securedObjectConfig.addAction(DefaultActions.DELETE, group -> {
final SecuredObjectOwnerColumn<LeaderboardGroupDTO> groupColumn = SecuredObjectOwnerColumn
.getGroupOwnerColumn();
groupColumn.setSortable(true);
leaderboardGroupsListHandler.setComparator(groupColumn, groupColumn.getComparator());
final SecuredObjectOwnerColumn<LeaderboardGroupDTO> userColumn = SecuredObjectOwnerColumn.getUserOwnerColumn();
userColumn.setSortable(true);
leaderboardGroupsListHandler.setComparator(userColumn, userColumn.getComparator());
final HasPermissions type = SecuredDomainType.LEADERBOARD_GROUP;
final Function<LeaderboardGroupDTO, String> idFactory = SecuredObjectUtils::getTypeRelativeObjectIdentifier;
final AccessControlledActionsColumn<LeaderboardGroupDTO, LeaderboardGroupConfigImagesBarCell> actionsColumn = new AccessControlledActionsColumn<>(
new LeaderboardGroupConfigImagesBarCell(stringMessages), userService, type, idFactory);
actionsColumn.addAction(UPDATE.name(), UPDATE, this::openEditLeaderboardGroupDialog);
actionsColumn.addAction(DELETE.name(), DELETE, group -> {
if (Window.confirm(stringMessages.doYouReallyWantToRemoveLeaderboardGroup(group.getName()))) {
removeLeaderboardGroup(group);
}
});
securedObjectConfig.addAction(DefaultActions.CHANGE_OWNERSHIP, group -> {
final LeaderboardGroupDescriptor descriptor = new LeaderboardGroupDescriptor(group.getName(),
group.description, group.getDisplayName(), group.displayLeaderboardsInReverseOrder,
group.isHasOverallLeaderboard(), group.getOverallLeaderboardDiscardThresholds(),
group.getOverallLeaderboardScoringSchemeType());
securedObjectConfig.openOwnershipDialog(group, g -> updateGroup(group.getName(), g, descriptor));
});
final DialogConfig<LeaderboardGroupDTO> config = EditOwnershipDialog
.create(userService.getUserManagementService(), type, idFactory, group -> {
final LeaderboardGroupDescriptor descriptor = new LeaderboardGroupDescriptor(group.getName(),
group.description, group.getDisplayName(), group.displayLeaderboardsInReverseOrder,
group.isHasOverallLeaderboard(), group.getOverallLeaderboardDiscardThresholds(),
group.getOverallLeaderboardScoringSchemeType());
updateGroup(group.getName(), group, descriptor);
}, group -> errorReporter.reportError(stringMessages.errorUpdatingOwnership(group.getName())));
actionsColumn.addAction(CHANGE_OWNERSHIP.name(), CHANGE_OWNERSHIP, config::openDialog);
SelectionCheckboxColumn<LeaderboardGroupDTO> leaderboardTableSelectionColumn =
new SelectionCheckboxColumn<LeaderboardGroupDTO>(
@@ -621,8 +639,9 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
groupsTable.addColumn(groupDescriptionColumn, stringMessages.description());
groupsTable.addColumn(groupDisplayNameColumn, stringMessages.displayName());
groupsTable.addColumn(hasOverallLeaderboardColumn, stringMessages.useOverallLeaderboard());
securedObjectConfig.addOwnerColumns(groupsTable, leaderboardGroupsListHandler);
securedObjectConfig.addActionColumn(groupsTable, new LeaderboardGroupConfigImagesBarCell(stringMessages));
groupsTable.addColumn(groupColumn, SecuredObjectUtils.SECURITY_MESSAGES.group());
groupsTable.addColumn(userColumn, SecuredObjectUtils.SECURITY_MESSAGES.user());
groupsTable.addColumn(actionsColumn, stringMessages.actions());
groupsTable.addColumnSortHandler(leaderboardGroupsListHandler);
refreshableGroupsSelectionModel = leaderboardTableSelectionColumn.getSelectionModel();
@@ -749,7 +768,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
private void updateGroup(final String oldGroupName, final LeaderboardGroupDTO groupToUpdate, final LeaderboardGroupDescriptor updateDescriptor) {
List<String> leaderboardNames = new ArrayList<String>();
for (StrippedLeaderboardDTO leaderboardDTO : groupToUpdate.leaderboards) {
leaderboardNames.add(leaderboardDTO.name);
leaderboardNames.add(leaderboardDTO.getName());
}
sailingService.updateLeaderboardGroup(oldGroupName, updateDescriptor.getName(), updateDescriptor.getDescription(),
updateDescriptor.getDisplayName(),
@@ -801,7 +820,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel implements
private void updateGroup(final LeaderboardGroupDTO group) {
List<String> leaderboardNames = new ArrayList<String>();
for (StrippedLeaderboardDTO leaderboardDTO : group.leaderboards) {
leaderboardNames.add(leaderboardDTO.name);
leaderboardNames.add(leaderboardDTO.getName());
}
sailingService.updateLeaderboardGroup(group.getName(), group.getName(), group.description,
group.getDisplayName(),
@@ -116,7 +116,7 @@ public class LeaderboardGroupSelectorComposite extends Composite implements HasV
} else {
builder.appendHtmlConstant("<br>");
}
builder.appendEscaped(leaderboard.name);
builder.appendEscaped(leaderboard.getName());
}
return builder.toSafeHtml();
}
@@ -195,7 +195,7 @@ public class LeaderboardGroupSelectorComposite extends Composite implements HasV
} else {
builder.appendHtmlConstant("<br>");
}
builder.appendEscaped(leaderboard.name);
builder.appendEscaped(leaderboard.getName());
}
return builder.toSafeHtml();
}
@@ -20,7 +20,7 @@ public class LinkRegattaLeaderboardToLeaderboardGroupOfEventDialog extends DataE
public LinkRegattaLeaderboardToLeaderboardGroupOfEventDialog(SailingServiceAsync sailingService, final StringMessages stringMessages,
ErrorReporter errorReporter, StrippedLeaderboardDTO leaderboard, EventDTO event, DialogCallback<LeaderboardGroupDTO> callback) {
super(stringMessages.linkLeaderboardToLeaderboardGroupOfEvent(),
/*message*/ stringMessages.doYouWantToLinkLeaderboardToLeaderboardGroupOfEvent(leaderboard.name, event.getName()),
/*message*/ stringMessages.doYouWantToLinkLeaderboardToLeaderboardGroupOfEvent(leaderboard.getName(), event.getName()),
stringMessages.yes(), stringMessages.no(),
/*validator*/ new Validator<LeaderboardGroupDTO>() {
@Override
@@ -36,14 +36,14 @@ extends TableWrapper<RaceColumnDTOAndFleetDTOWithNameBasedEquality, S> {
@Override
public boolean representSameEntity(RaceColumnDTOAndFleetDTOWithNameBasedEquality dto1,
RaceColumnDTOAndFleetDTOWithNameBasedEquality dto2) {
return dto1.getC().name.equals(dto2.getC().name) &&
return dto1.getC().getName().equals(dto2.getC().getName()) &&
dto1.getA().getName().equals(dto2.getA().getName()) &&
dto1.getB().getName().equals(dto2.getB().getName());
}
@Override
public int hashCode(RaceColumnDTOAndFleetDTOWithNameBasedEquality t) {
return t.getA().getName().concat(t.getB().getName()).concat(t.getC().name).hashCode();
return t.getA().getName().concat(t.getB().getName()).concat(t.getC().getName()).hashCode();
}
});
Column<RaceColumnDTOAndFleetDTOWithNameBasedEquality, SafeHtml> raceNameColumn =
@@ -36,7 +36,7 @@ public abstract class RegattaLeaderboardDialog extends AbstractLeaderboardDialog
String errorMessage;
boolean unique = true;
for (StrippedLeaderboardDTO dao : existingLeaderboards) {
if (dao.name.equals(leaderboardToValidate.getName())) {
if (dao.getName().equals(leaderboardToValidate.getName())) {
unique = false;
}
}
@@ -56,7 +56,7 @@ public abstract class RegattaLeaderboardWithEliminationsDialog extends AbstractL
String errorMessage;
boolean unique = true;
for (StrippedLeaderboardDTO dao : existingLeaderboards) {
if (dao.name.equals(leaderboardToValidate.getName())) {
if (dao.getName().equals(leaderboardToValidate.getName())) {
unique = false;
}
}
@@ -148,7 +148,7 @@ public abstract class RegattaLeaderboardWithEliminationsDialog extends AbstractL
protected StrippedLeaderboardDTO getSelectedLeaderboard() {
final String selectedRegattaLeaderboardName = regattaLeaderboardsListBox.getSelectedValue();
for (final StrippedLeaderboardDTO l : existingLeaderboards) {
if (l.name.equals(selectedRegattaLeaderboardName)) {
if (l.getName().equals(selectedRegattaLeaderboardName)) {
return l;
}
}
@@ -162,13 +162,13 @@ public abstract class RegattaLeaderboardWithEliminationsDialog extends AbstractL
for (StrippedLeaderboardDTO leaderboard : existingLeaderboards) {
sortedRegattaLeaderboards.add(leaderboard);
}
Collections.sort(sortedRegattaLeaderboards, (rl1, rl2) -> rl1.name.compareTo(rl2.name));
Collections.sort(sortedRegattaLeaderboards, (rl1, rl2) -> rl1.getName().compareTo(rl2.getName()));
result.addItem(stringMessages.pleaseSelectARegatta());
int i=1;
for (StrippedLeaderboardDTO leaderboard : sortedRegattaLeaderboards) {
if (leaderboard.type.isRegattaLeaderboard()) {
result.addItem(leaderboard.name, leaderboard.name);
if (preSelectedRegattaName != null && leaderboard.name.equals(preSelectedRegattaName)) {
result.addItem(leaderboard.getName(), leaderboard.getName());
if (preSelectedRegattaName != null && leaderboard.getName().equals(preSelectedRegattaName)) {
result.setSelectedIndex(i);
}
i++;
@@ -1,11 +1,16 @@
package com.sap.sailing.gwt.ui.adminconsole;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.CHANGE_OWNERSHIP;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.DELETE;
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.UPDATE;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.GWT;
@@ -26,6 +31,7 @@ import com.google.gwt.view.client.SelectionChangeEvent;
import com.sap.sailing.domain.common.RegattaIdentifier;
import com.sap.sailing.domain.common.RegattaName;
import com.sap.sailing.domain.common.security.SecuredDomainType;
import com.sap.sailing.gwt.ui.adminconsole.EditOwnershipDialog.DialogConfig;
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
import com.sap.sailing.gwt.ui.client.RegattasDisplayer;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
@@ -46,7 +52,7 @@ import com.sap.sse.gwt.client.celltable.RefreshableMultiSelectionModel;
import com.sap.sse.gwt.client.celltable.SelectionCheckboxColumn;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel;
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.ui.client.UserService;
/**
@@ -228,16 +234,27 @@ public class RegattaListComposite extends Composite implements RegattasDisplayer
}
});
final SecuredObjectCompositeConfig<RegattaDTO> securedObjectConfig = new SecuredObjectCompositeConfig<>(
userService, errorReporter, stringMessages, SecuredDomainType.REGATTA, RegattaDTO::getName);
securedObjectConfig.addAction(DefaultActions.UPDATE, this::editRegatta);
securedObjectConfig.addAction(DefaultActions.DELETE, regatta -> {
final SecuredObjectOwnerColumn<RegattaDTO> groupColumn = SecuredObjectOwnerColumn.getGroupOwnerColumn();
groupColumn.setSortable(true);
columnSortHandler.setComparator(groupColumn, groupColumn.getComparator());
final SecuredObjectOwnerColumn<RegattaDTO> userColumn = SecuredObjectOwnerColumn.getUserOwnerColumn();
userColumn.setSortable(true);
columnSortHandler.setComparator(userColumn, userColumn.getComparator());
final HasPermissions type = SecuredDomainType.REGATTA;
final Function<RegattaDTO, String> idFactory = SecuredObjectUtils::getTypeRelativeObjectIdentifier;
final AccessControlledActionsColumn<RegattaDTO, RegattaConfigImagesBarCell> actionsColumn = new AccessControlledActionsColumn<>(
new RegattaConfigImagesBarCell(stringMessages), userService, type, idFactory);
actionsColumn.addAction(UPDATE.name(), UPDATE, this::editRegatta);
actionsColumn.addAction(DELETE.name(), DELETE, regatta -> {
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(regatta.getName()))) {
removeRegatta(regatta);
}
});
securedObjectConfig.addAction(DefaultActions.CHANGE_OWNERSHIP,
regatta -> securedObjectConfig.openOwnershipDialog(regatta, this::commitEditedRegatta));
final DialogConfig<RegattaDTO> config = EditOwnershipDialog.create(userService.getUserManagementService(), type,
idFactory, this::commitEditedRegatta,
regatta -> errorReporter.reportError(stringMessages.errorUpdatingOwnership(regatta.getName())));
actionsColumn.addAction(CHANGE_OWNERSHIP.name(), CHANGE_OWNERSHIP, config::openDialog);
table.addColumn(regattaSelectionCheckboxColumn, regattaSelectionCheckboxColumn.getHeader());
table.addColumn(regattaNameColumn, stringMessages.regattaName());
@@ -245,8 +262,9 @@ public class RegattaListComposite extends Composite implements RegattasDisplayer
table.addColumn(startEndDateColumn, stringMessages.from() + "/" + stringMessages.to());
table.addColumn(regattaBoatClassColumn, stringMessages.boatClass());
table.addColumn(rankingMetricColumn, stringMessages.rankingMetric());
securedObjectConfig.addOwnerColumns(table, columnSortHandler);
securedObjectConfig.addActionColumn(table, new RegattaConfigImagesBarCell(stringMessages));
table.addColumn(groupColumn, SecuredObjectUtils.SECURITY_MESSAGES.group());
table.addColumn(userColumn, SecuredObjectUtils.SECURITY_MESSAGES.user());
table.addColumn(actionsColumn, stringMessages.actions());
table.setSelectionModel(regattaSelectionCheckboxColumn.getSelectionModel(), regattaSelectionCheckboxColumn.getSelectionManager());
return table;
}
@@ -1,212 +0,0 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.cellview.client.AbstractCellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.sap.sailing.domain.common.dto.NamedSecuredObjectDTO;
import com.sap.sailing.domain.common.security.SecuredDomainType;
import com.sap.sailing.gwt.ui.adminconsole.EditOwnershipDialog.OwnershipDialogResult;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sse.common.Named;
import com.sap.sse.gwt.client.ErrorReporter;
import com.sap.sse.gwt.client.celltable.ImagesBarCell;
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
import com.sap.sse.security.shared.HasPermissions;
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
import com.sap.sse.security.shared.Ownership;
import com.sap.sse.security.shared.QualifiedObjectIdentifier;
import com.sap.sse.security.shared.WildcardPermission;
import com.sap.sse.security.ui.client.UserManagementServiceAsync;
import com.sap.sse.security.ui.client.UserService;
import com.sap.sse.security.ui.shared.UserDTO;
/**
* Helper class to setup the configuration of a composite for {@link NamedSecuredObjectDTO secured object}s.
*
* @param <T>
* the actual type of the secured object
*/
public class SecuredObjectCompositeConfig<T extends NamedSecuredObjectDTO> {
private final com.sap.sse.security.ui.client.i18n.StringMessages securityStringMessages = GWT
.create(com.sap.sse.security.ui.client.i18n.StringMessages.class);
private final Map<DefaultActions, Consumer<T>> actionCallbacks = new HashMap<>();
private final UserService userService;
private final ErrorReporter errorReporter;
private final StringMessages stringMessages;
private final Function<T, QualifiedObjectIdentifier> identifierFactory;
private final BiFunction<DefaultActions, T, WildcardPermission> permissionFactory;
/**
* Creates a new {@link SecuredObjectCompositeConfig} instance with the given parameters.
*
* @param userService
* {@link UserService} to determine current user and {@link UserManagementServiceAsync} interface
* @param errorReporter
* {@link ErrorReporter} to report failures, e.g. during ownership updates
* @param stringMessages
* {@link StringMessages} instance to use
* @param type
* {@link SecuredDomainType} specifying the type of required permissions to modify the secured object
* @param idFactory
* {@link Function factory} to get a {@link String type relative identifier} for the secured object
*/
public SecuredObjectCompositeConfig(final UserService userService, final ErrorReporter errorReporter,
final StringMessages stringMessages, final HasPermissions type, final Function<T, String> idFactory) {
this.userService = userService;
this.errorReporter = errorReporter;
this.stringMessages = stringMessages;
this.identifierFactory = idFactory.andThen(type::getQualifiedObjectIdentifier);
this.permissionFactory = (action, object) -> type.getPermissionForObjects(action, idFactory.apply(object));
}
/**
* Adds an {@link DefaultActions action} for the secured object which will be contained in the
* {@link #addActionColumn(AbstractCellTable, ImagesBarCell) action column} if the current user has the respectively
* required permissions.
*
* @param action
* {@link DefaultActions action} to add to the {@link AccessControlledActionsColumn action column}
* @param actionCallback
* {@link Consumer callback} to execute when the action is triggered
*/
public void addAction(final DefaultActions action, final Consumer<T> actionCallback) {
this.actionCallbacks.put(action, actionCallback);
}
/**
* Adds the an {@link AccessControlledActionsColumn action column} using the given {@link ImagesBarCell image bar
* cell} to the provided {@link AbstractCellTable cell table} which contains previously
* {@link #addAction(DefaultActions, Consumer) added actions} where the current user has permissions for.
*
* @param table
* {@link AbstractCellTable table} to add the action column to
* @param imageBarCell
* {@link ImagesBarCell cell} to use to render the action column
*/
public <C extends ImagesBarCell> void addActionColumn(final AbstractCellTable<T> table, final C imageBarCell) {
final AccessControlledActionsColumn<T, C> actionColumn = new AccessControlledActionsColumn<T, C>(imageBarCell) {
@Override
public Iterable<DefaultActions> getAllowedActions(T object) {
final UserDTO user = userService.getCurrentUser();
return actionCallbacks.keySet().stream()
.filter(action -> user.hasPermission(permissionFactory.apply(action, object),
object.getOwnership(), object.getAccessControlList()))
.collect(Collectors.toSet());
}
};
actionColumn.setFieldUpdater((index, securedObject, value) -> {
final DefaultActions action = DefaultActions.valueOf(value);
actionCallbacks.get(action).accept(securedObject);
});
table.addColumn(actionColumn, stringMessages.actions());
}
/**
* Adds sortable {@link Column column}s to the provided {@link AbstractCellTable cell table} showing group owner and
* user owner information of secured object table entries, if any.
*
* @param table
* {@link AbstractCellTable table} to add the column to
* @param columnSortHandler
* {@link ListHandler handler} to register the column's sort {@link Comparator comparator}
*/
public void addOwnerColumns(final AbstractCellTable<T> table, final ListHandler<T> columnSortHandler) {
final OwnerColumn groupColumn = new OwnerColumn(Ownership::getTenantOwner);
table.addColumn(groupColumn, securityStringMessages.group());
columnSortHandler.setComparator(groupColumn, groupColumn.getComparator());
final OwnerColumn userColumn = new OwnerColumn(Ownership::getUserOwner);
table.addColumn(userColumn, securityStringMessages.user());
columnSortHandler.setComparator(userColumn, userColumn.getComparator());
}
/**
* Opens a {@link EditOwnershipDialog dialog} to edit ownerships for the provided secured object instance.
*
* @param securedObject
* {@link NamedSecuredObjectDTO secured object} instance to edit ownerships for
* @param updateCallback
* {@link Consumer callback} to execute when the dialog is confirmed
*/
public void openOwnershipDialog(final T securedObject, final Consumer<T> updateCallback) {
new EditOwnershipDialog(userService.getUserManagementService(), securedObject.getOwnership(),
securityStringMessages, new EditOwnershipDialogCallback(securedObject, updateCallback)).show();
}
private class EditOwnershipDialogCallback implements DialogCallback<OwnershipDialogResult> {
private final T securedObject;
private final Consumer<T> updateCallback;
private EditOwnershipDialogCallback(T securedObject, Consumer<T> updateCallback) {
this.securedObject = securedObject;
this.updateCallback = updateCallback;
}
@Override
public void ok(OwnershipDialogResult editedObject) {
final QualifiedObjectIdentifier objectIdentifier = identifierFactory.apply(securedObject);
userService.getUserManagementService().setOwnership(editedObject.getOwnership(), objectIdentifier,
securedObject.getName(), new UpdateOwnershipAsyncCallback(editedObject));
}
@Override
public final void cancel() {
}
private class UpdateOwnershipAsyncCallback implements AsyncCallback<QualifiedObjectIdentifier> {
private final OwnershipDialogResult editResult;
private UpdateOwnershipAsyncCallback(final OwnershipDialogResult result) {
this.editResult = result;
}
@Override
public final void onSuccess(QualifiedObjectIdentifier result) {
securedObject.setOwnership(editResult.getOwnership());
updateCallback.accept(securedObject);
}
@Override
public final void onFailure(Throwable caught) {
errorReporter.reportError(stringMessages.errorUpdatingOwnership(securedObject.getName()));
}
}
}
private class OwnerColumn extends TextColumn<T> {
private final Function<T, Named> ownerResolver;
private OwnerColumn(Function<Ownership, Named> ownerResolver) {
final Function<T, Ownership> ownershipResolver = NamedSecuredObjectDTO::getOwnership;
this.ownerResolver = ownershipResolver.andThen(ownerResolver);
this.setSortable(true);
}
@Override
public final String getValue(T object) {
return Optional.ofNullable(ownerResolver.apply(object)).map(Named::getName).orElse("");
}
private Comparator<T> getComparator() {
return Comparator.comparing(this::getValue);
}
}
}
@@ -0,0 +1,69 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.Comparator;
import java.util.Optional;
import java.util.function.Function;
import com.google.gwt.user.cellview.client.TextColumn;
import com.sap.sailing.domain.common.dto.NamedSecuredObjectDTO;
import com.sap.sse.common.Named;
import com.sap.sse.security.shared.Ownership;
/**
* {@link TextColumn Text column} extension which can be used to show {@link Ownership ownership} information of
* {@link NamedSecuredObjectDTO secured object} table entries, if any. This column also {@link #getComparator()
* provides} a suitable {@link Comparator comparator} which can be used for sorting purposes, if required.
*
* @param table
* {@link AbstractCellTable table} to add the column to
* @param columnSortHandler
* {@link ListHandler handler} to register the column's sort {@link Comparator comparator}
*/
/**
* @author bbarth
*
* @param <T>
*/
public class SecuredObjectOwnerColumn<T extends NamedSecuredObjectDTO> extends TextColumn<T> {
private final Function<T, Named> ownerResolver;
/**
* Creates a new {@link SecuredObjectOwnerColumn} instance used the provided {@link Function resolver} to determine
* the {@link Named owner reference} who's name will be shown in this column.
*
* @param ownerResolver
* {@link Function} to resolve the owner reference
*/
public SecuredObjectOwnerColumn(final Function<Ownership, Named> ownerResolver) {
final Function<T, Ownership> ownershipResolver = NamedSecuredObjectDTO::getOwnership;
this.ownerResolver = ownershipResolver.andThen(ownerResolver);
}
@Override
public final String getValue(final T object) {
return Optional.ofNullable(ownerResolver.apply(object)).map(Named::getName).orElse("");
}
/**
* @return a suitable {@link Comparator comparator} for this column
*/
public Comparator<T> getComparator() {
return Comparator.comparing(this::getValue);
}
/**
* @return {@link SecuredObjectOwnerColumn} instance showing the {@link Ownership#getTenantOwner() tenant owner}
*/
public static <T extends NamedSecuredObjectDTO> SecuredObjectOwnerColumn<T> getGroupOwnerColumn() {
return new SecuredObjectOwnerColumn<>(Ownership::getTenantOwner);
}
/**
* @return {@link SecuredObjectOwnerColumn} instance showing the {@link Ownership#getUserOwner() user owner}
*/
public static <T extends NamedSecuredObjectDTO> SecuredObjectOwnerColumn<T> getUserOwnerColumn() {
return new SecuredObjectOwnerColumn<>(Ownership::getUserOwner);
}
}
@@ -0,0 +1,75 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.Comparator;
import java.util.Optional;
import java.util.function.Function;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.cellview.client.AbstractCellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import com.sap.sailing.domain.common.dto.NamedSecuredObjectDTO;
import com.sap.sailing.gwt.ui.shared.EventDTO;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sse.common.Named;
import com.sap.sse.security.shared.Ownership;
import com.sap.sse.security.ui.client.i18n.StringMessages;
public class SecuredObjectUtils {
public static final StringMessages SECURITY_MESSAGES = GWT.create(StringMessages.class);
public static String getTypeRelativeObjectIdentifier(final EventDTO securedObject) {
return securedObject.id.toString();
}
public static String getTypeRelativeObjectIdentifier(final RegattaDTO securedObject) {
return securedObject.getName();
}
public static String getTypeRelativeObjectIdentifier(final LeaderboardGroupDTO securedObject) {
return securedObject.getId().toString();
}
/**
* Adds sort-able {@link Column column}s to the provided {@link AbstractCellTable cell table} showing group owner
* and user owner information of secured object table entries, if any. The {@link Comparator comparator}s used for
* sorting will be set on the provided {@link ListHandler list handler}.
*
* @param table
* {@link AbstractCellTable table} to add the column to
* @param columnSortHandler
* {@link ListHandler handler} to register the column's sort {@link Comparator comparator}
*/
public static <T extends NamedSecuredObjectDTO> void configureOwnerColumns(final AbstractCellTable<T> table,
final ListHandler<T> columnSortHandler) {
final OwnerColumn<T> groupColumn = new OwnerColumn<>(Ownership::getTenantOwner);
table.addColumn(groupColumn, SECURITY_MESSAGES.group());
columnSortHandler.setComparator(groupColumn, groupColumn.getComparator());
final OwnerColumn<T> userColumn = new OwnerColumn<>(Ownership::getUserOwner);
table.addColumn(userColumn, SECURITY_MESSAGES.user());
columnSortHandler.setComparator(userColumn, userColumn.getComparator());
}
private static class OwnerColumn<T extends NamedSecuredObjectDTO> extends TextColumn<T> {
private final Function<T, String> ownerNameResolver;
private OwnerColumn(Function<Ownership, Named> ownerResolver) {
final Function<T, Ownership> ownershipResolver = NamedSecuredObjectDTO::getOwnership;
this.ownerNameResolver = ownershipResolver.andThen(ownerResolver).andThen(Named::getName);
}
@Override
public final String getValue(T object) {
return Optional.ofNullable(ownerNameResolver.apply(object)).orElse("");
}
private Comparator<T> getComparator() {
return Comparator.comparing(this::getValue);
}
}
}
@@ -106,12 +106,12 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
@Override
public void racesStoppedTracking(Iterable<? extends RegattaAndRaceIdentifier> regattaAndRaceIdentifiers) {
loadAndRefreshLeaderboard(getSelectedLeaderboard().name);
loadAndRefreshLeaderboard(getSelectedLeaderboard().getName());
}
@Override
public void racesRemoved(Iterable<? extends RegattaAndRaceIdentifier> regattaAndRaceIdentifiers) {
loadAndRefreshLeaderboard(getSelectedLeaderboard().name);
loadAndRefreshLeaderboard(getSelectedLeaderboard().getName());
}
});
}
@@ -133,14 +133,14 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
TextColumn<StrippedLeaderboardDTO> leaderboardNameColumn = new TextColumn<StrippedLeaderboardDTO>() {
@Override
public String getValue(StrippedLeaderboardDTO leaderboard) {
return leaderboard.name;
return leaderboard.getName();
}
};
leaderboardNameColumn.setSortable(true);
leaderboardColumnListHandler.setComparator(leaderboardNameColumn, new Comparator<StrippedLeaderboardDTO>() {
@Override
public int compare(StrippedLeaderboardDTO o1, StrippedLeaderboardDTO o2) {
return new NaturalComparator(false).compare(o1.name, o2.name);
return new NaturalComparator(false).compare(o1.getName(), o2.getName());
}
});
@@ -175,7 +175,7 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
leaderboardActionColumn.setFieldUpdater(new FieldUpdater<StrippedLeaderboardDTO, String>() {
@Override
public void update(int index, StrippedLeaderboardDTO leaderboardDTO, String value) {
final String leaderboardName = leaderboardDTO.name;
final String leaderboardName = leaderboardDTO.getName();
final boolean canBoatsOfCompetitorsChangePerRace = leaderboardDTO.canBoatsOfCompetitorsChangePerRace;
if (RaceLogTrackingEventManagementImagesBarCell.ACTION_DENOTE_FOR_RACELOG_TRACKING.equals(value)) {
denoteForRaceLogTracking(leaderboardDTO);
@@ -547,7 +547,7 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
for (TrackedRaceChangedListener listener : trackedRacesListComposite.raceIsTrackedRaceChangeListener) {
listener.racesStoppedTracking(racesToStopTracking);
}
loadAndRefreshLeaderboard(getSelectedLeaderboard().name);
loadAndRefreshLeaderboard(getSelectedLeaderboard().getName());
}
}));
}
@@ -609,7 +609,7 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
List<Triple<String, String, String>> raceColumnsAndFleets = new ArrayList<Triple<String, String, String>>();
for (RaceColumnDTO raceColumn : selectedLeaderboard.getRaceList()) {
for (FleetDTO fleet : raceColumn.getFleets()) {
raceColumnsAndFleets.add(new Triple<String, String, String>(selectedLeaderboard.name, raceColumn.getName(), fleet.getName()));
raceColumnsAndFleets.add(new Triple<String, String, String>(selectedLeaderboard.getName(), raceColumn.getName(), fleet.getName()));
}
}
sailingService.getTrackingTimes(raceColumnsAndFleets,
@@ -632,12 +632,12 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
}
});
selectedLeaderBoardPanel.setVisible(true);
selectedLeaderBoardPanel.setCaptionText("Details of leaderboard '" + selectedLeaderboard.name + "'");
selectedLeaderBoardPanel.setCaptionText("Details of leaderboard '" + selectedLeaderboard.getName() + "'");
if (!selectedLeaderboard.type.isMetaLeaderboard()) {
trackedRacesListComposite.setRegattaFilterValue(selectedLeaderboard.regattaName);
trackedRacesCaptionPanel.setVisible(true);
}
sailingService.doesRegattaLogContainCompetitors(((StrippedLeaderboardDTO) leaderboardSelectionModel.getSelectedSet().toArray()[0]).name, new RegattaLogCallBack());
sailingService.doesRegattaLogContainCompetitors(((StrippedLeaderboardDTO) leaderboardSelectionModel.getSelectedSet().toArray()[0]).getName(), new RegattaLogCallBack());
} else {
selectedLeaderBoardPanel.setVisible(false);
trackedRacesCaptionPanel.setVisible(false);
@@ -645,7 +645,7 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
}
public Pair<TimePointSpecificationFoundInLog, TimePointSpecificationFoundInLog> getTrackingTimesFor(RaceColumnDTOAndFleetDTOWithNameBasedEquality raceColumnDTOAndFleet){
return raceWithStartAndEndOfTrackingTime.get(new Triple<String, String, String>(getSelectedLeaderboard().name, raceColumnDTOAndFleet.getA().getName(), raceColumnDTOAndFleet.getB().getName()));
return raceWithStartAndEndOfTrackingTime.get(new Triple<String, String, String>(getSelectedLeaderboard().getName(), raceColumnDTOAndFleet.getA().getName(), raceColumnDTOAndFleet.getB().getName()));
}
@@ -667,10 +667,10 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
@Override
public void ok(String prefix) {
sailingService.denoteForRaceLogTracking(leaderboard.name, prefix, new AsyncCallback<Void>() {
sailingService.denoteForRaceLogTracking(leaderboard.getName(), prefix, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
loadAndRefreshLeaderboard(leaderboard.name);
loadAndRefreshLeaderboard(leaderboard.getName());
updateRegattaConfigDesignerModeToByMarks(leaderboard.regattaName);
raceColumnTableSelectionModel.clear();
}
@@ -766,11 +766,11 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
private void denoteForRaceLogTracking(final RaceColumnDTO raceColumn, final FleetDTO fleet) {
final StrippedLeaderboardDTO leaderboard = getSelectedLeaderboard();
sailingService.denoteForRaceLogTracking(leaderboard.name, raceColumn.getName(), fleet.getName(), new AsyncCallback<Boolean>() {
sailingService.denoteForRaceLogTracking(leaderboard.getName(), raceColumn.getName(), fleet.getName(), new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result == true) {
loadAndRefreshLeaderboard(leaderboard.name);
loadAndRefreshLeaderboard(leaderboard.getName());
}
}
@@ -783,10 +783,10 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
private void removeDenotation(final RaceColumnDTO raceColumn, final FleetDTO fleet) {
final StrippedLeaderboardDTO leaderboard = getSelectedLeaderboard();
sailingService.removeDenotationForRaceLogTracking(leaderboard.name, raceColumn.getName(), fleet.getName(), new AsyncCallback<Void>() {
sailingService.removeDenotationForRaceLogTracking(leaderboard.getName(), raceColumn.getName(), fleet.getName(), new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
loadAndRefreshLeaderboard(leaderboard.name);
loadAndRefreshLeaderboard(leaderboard.getName());
}
@Override
@@ -818,13 +818,13 @@ public class SmartphoneTrackingEventManagementPanel extends AbstractLeaderboardC
for (RaceColumnDTOAndFleetDTOWithNameBasedEquality race : races) {
final RaceColumnDTO raceColumn = race.getA();
final FleetDTO fleet = race.getB();
leaderboardRaceColumnFleetNames.add(new Triple<>(leaderboard.name, raceColumn.getName(), fleet.getName()));
leaderboardRaceColumnFleetNames.add(new Triple<>(leaderboard.getName(), raceColumn.getName(), fleet.getName()));
}
sailingService.startRaceLogTracking(leaderboardRaceColumnFleetNames, trackWind, correctWindByDeclination,
new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
loadAndRefreshLeaderboard(leaderboard.name);
loadAndRefreshLeaderboard(leaderboard.getName());
trackedRacesListComposite.regattaRefresher.fillRegattas();
}
@@ -71,7 +71,7 @@ public class RaceIdentifierToLeaderboardRaceColumnAndFleetMapper {
if (fleet == null) {
result = null;
} else {
result = new LeaderboardNameRaceColumnNameAndFleetName(leaderboard.name, raceColumn.getName(), fleet.getName());
result = new LeaderboardNameRaceColumnNameAndFleetName(leaderboard.getName(), raceColumn.getName(), fleet.getName());
}
}
return result;
@@ -254,7 +254,7 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<BulkSco
@Override
protected BulkScoreCorrectionDTO getResult() {
BulkScoreCorrectionDTO result = new BulkScoreCorrectionDTO(leaderboard.name);
BulkScoreCorrectionDTO result = new BulkScoreCorrectionDTO(leaderboard.getName());
for (CompetitorDTO competitor : leaderboard.competitors) {
for (RaceColumnDTO raceColumn : leaderboard.getRaceList()) {
Util.Pair<CompetitorDTO, RaceColumnDTO> key = new Util.Pair<>(competitor, raceColumn);
@@ -176,7 +176,7 @@ public abstract class AbstractRaceBoardMode implements RaceBoardMode, RaceTimesI
raceColumnNameAsList.add(getRaceColumn().getName());
}
final GetLeaderboardByNameAction getLeaderboardByNameAction = new GetLeaderboardByNameAction(
getLeaderboardPanel().getSailingService(), getLeaderboardPanel().getLeaderboard().name,
getLeaderboardPanel().getSailingService(), getLeaderboardPanel().getLeaderboard().getName(),
getTimer().getTime(), raceColumnNameAsList, /* addOverallDetails */ false,
getLeaderboard(), /* fillTotalPointsUncorrected */ false,
/* timerToAdjustOffsetIn */ getTimer(), /* errorReporter */ null, StringMessages.INSTANCE);
@@ -166,7 +166,7 @@ public class StartAnalysisMode extends RaceBoardModeWithPerRaceCompetitors {
if (getLeaderboardForSpecificTimePoint() == null &&
getRaceColumn() != null && getLeaderboard() != null
&& timerAdjusted) {
loadLeaderboardForSpecificTimePoint(getLeaderboard().name, getRaceColumn().getName(), getTimer().getTime());
loadLeaderboardForSpecificTimePoint(getLeaderboard().getName(), getRaceColumn().getName(), getTimer().getTime());
}
if (!competitorSelectionUpdated && getLeaderboardForSpecificTimePoint() != null && getCompetitorsInRace() != null) {
competitorSelectionUpdated = true;
@@ -125,7 +125,7 @@ public class WinningLanesMode extends RaceBoardModeWithPerRaceCompetitors {
adjustLeaderboardSettings();
}
if (getLeaderboardForSpecificTimePoint() == null && tailLength != null && getLeaderboard() != null && getRaceColumn() != null) {
loadLeaderboardForSpecificTimePoint(getLeaderboard().name, getRaceColumn().getName(), getTimer().getTime());
loadLeaderboardForSpecificTimePoint(getLeaderboard().getName(), getRaceColumn().getName(), getTimer().getTime());
}
if (!adjustedCompetitorSelection && getLeaderboardForSpecificTimePoint() != null && getCompetitorsInRace() != null) {
stopReceivingCompetitorsInRace();
@@ -2588,7 +2588,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
StrippedLeaderboardDTO leaderboardDTO = new StrippedLeaderboardDTO(convertToBoatClassDTO(leaderboard.getBoatClass()));
TimePoint startOfLatestRace = null;
Long delayToLiveInMillisForLatestRace = null;
leaderboardDTO.name = leaderboard.getName();
leaderboardDTO.setName(leaderboard.getName());
leaderboardDTO.displayName = leaderboard.getDisplayName();
leaderboardDTO.competitorDisplayNames = new HashMap<>();
leaderboardDTO.competitorsCount = Util.size(leaderboard.getCompetitors());
@@ -81,7 +81,7 @@ public class EventDTO extends EventBaseDTO {
public AbstractLeaderboardDTO getLeaderboardByName(String leaderboardName) {
for (LeaderboardGroupDTO leaderboardGroup : this.getLeaderboardGroups()) {
for (StrippedLeaderboardDTO leaderboardDTO : leaderboardGroup.getLeaderboards()) {
if(leaderboardName.equals(leaderboardDTO.name)) {
if(leaderboardName.equals(leaderboardDTO.getName())) {
return leaderboardDTO;
}
}
@@ -249,7 +249,7 @@ public class LeaderboardGroupOverviewPanel extends FormPanel {
if (!first) {
sb.append(", ");
}
sb.append(leaderboard.name);
sb.append(leaderboard.getName());
first = false;
}
return sb.toString();
@@ -360,11 +360,11 @@ public class LeaderboardGroupOverviewPanel extends FormPanel {
public SafeHtml getValue(StrippedLeaderboardDTO leaderboard) {
LeaderboardGroupDTO selectedGroup = groupsSelectionModel.getSelectedObject();
String debugParam = Window.Location.getParameter("gwt.codesvr");
String link = URLEncoder.encode("/gwt/Leaderboard.html?name=" + leaderboard.name
String link = URLEncoder.encode("/gwt/Leaderboard.html?name=" + leaderboard.getName()
+ (showRaceDetails ? "&showRaceDetails=true" : "")
+ "&leaderboardGroupName=" + selectedGroup.getName() + "&root=overview"
+ (debugParam != null && !debugParam.isEmpty() ? "&gwt.codesvr=" + debugParam : ""));
return ANCHORTEMPLATE.anchor(UriUtils.fromString(link), leaderboard.name);
return ANCHORTEMPLATE.anchor(UriUtils.fromString(link), leaderboard.getName());
}
};
@@ -454,7 +454,7 @@ public class LeaderboardGroupOverviewPanel extends FormPanel {
RegattaNameAndRaceName raceId = (RegattaNameAndRaceName) race.getRaceIdentifier(fleet);
String debugParam = Window.Location.getParameter("gwt.codesvr");
String link = URLEncoder.encode("/gwt/RaceBoard.html?leaderboardName="
+ selectedLeaderboard.name + "&raceName=" + raceId.getRaceName() + "&regattaName="
+ selectedLeaderboard.getName() + "&raceName=" + raceId.getRaceName() + "&regattaName="
+ raceId.getRegattaName() + "&leaderboardGroupName=" + selectedGroup.getName()
+ "&root=overview"
+ (debugParam != null && !debugParam.isEmpty() ? "&gwt.codesvr=" + debugParam : ""));
@@ -229,7 +229,7 @@ public class LeaderboardGroupPanel extends SimplePanel implements HasWelcomeWidg
leaderboardNameCell) {
@Override
public SafeHtml getValue(StrippedLeaderboardDTO strippedLeaderboardDTO) {
String text = strippedLeaderboardDTO.displayName != null ? strippedLeaderboardDTO.displayName : strippedLeaderboardDTO.name;
String text = strippedLeaderboardDTO.displayName != null ? strippedLeaderboardDTO.displayName : strippedLeaderboardDTO.getName();
SafeHtmlBuilder b = new SafeHtmlBuilder();
b.append(TEXTTEMPLATE.textWithClass(text, STYLE_BOATCLASS));
return b.toSafeHtml();
@@ -242,7 +242,7 @@ public class LeaderboardGroupPanel extends SimplePanel implements HasWelcomeWidg
@Override
public SafeHtml getValue(StrippedLeaderboardDTO leaderboard) {
final String link = EntryPointWithSettingsLinkFactory.createLeaderboardLink(
new LeaderboardContextDefinition(leaderboard.name, leaderboard.displayName,
new LeaderboardContextDefinition(leaderboard.getName(), leaderboard.displayName,
leaderboardGroup.getName()),
new LeaderboardPerspectiveOwnSettings(showRaceDetails, isEmbedded));
return getAnchor(link, stringMessages.leaderboard(),
@@ -334,7 +334,7 @@ public class LeaderboardGroupPanel extends SimplePanel implements HasWelcomeWidg
STYLE_TABLE_TEXT));
fleetGridsFormatter.setVerticalAlignment(fleetRow, 1, HasVerticalAlignment.ALIGN_MIDDLE);
List<RaceColumnDTO> raceColumnsOfSeries = getRacesOfFleet(leaderboard, series, fleet);
fleetsGrid.setHTML(fleetRow, 2, renderRacesToHTml(leaderboard.name, raceColumnsOfSeries, fleet));
fleetsGrid.setHTML(fleetRow, 2, renderRacesToHTml(leaderboard.getName(), raceColumnsOfSeries, fleet));
fleetRow++;
}
seriesGrid.setWidget(seriesRow, 1, fleetsGrid);
@@ -349,10 +349,10 @@ public class LeaderboardGroupPanel extends SimplePanel implements HasWelcomeWidg
fleetsGrid.setHTML(0, 0, TEXTTEMPLATE.textWithClass(displayName, 50,
STYLE_TABLE_TEXT));
fleetGridsFormatter.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
fleetsGrid.setHTML(0, 1, renderRacesToHTml(leaderboard.name, raceColumnsOfSeries, fleet));
fleetsGrid.setHTML(0, 1, renderRacesToHTml(leaderboard.getName(), raceColumnsOfSeries, fleet));
seriesGrid.setWidget(seriesRow, 1, fleetsGrid);
} else {
seriesGrid.setHTML(seriesRow, 1, renderRacesToHTml(leaderboard.name, raceColumnsOfSeries, fleet));
seriesGrid.setHTML(seriesRow, 1, renderRacesToHTml(leaderboard.getName(), raceColumnsOfSeries, fleet));
}
}
seriesRow++;
@@ -361,7 +361,7 @@ public class LeaderboardGroupPanel extends SimplePanel implements HasWelcomeWidg
}
} else {
List<RaceColumnDTO> raceColumns = leaderboard.getRaceList();
b.append(renderRacesToHTml(leaderboard.name, raceColumns, new FleetDTO(LeaderboardNameConstants.DEFAULT_FLEET_NAME, 0, null)));
b.append(renderRacesToHTml(leaderboard.getName(), raceColumns, new FleetDTO(LeaderboardNameConstants.DEFAULT_FLEET_NAME, 0, null)));
}
return b.toSafeHtml();
}