mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
Bug 4211: added findSailorProfileById to SailorProfileDataProvider +
adjusted several synchronization issues
This commit is contained in:
1 parent
0e8d417336
commit
3e0aac8628
9 files changed
+109
-65
No files matched your search
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.user.profile.sailorprofiletab;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.SailorProfileEntry;
|
||||
|
||||
public interface SailorProfileOverview extends SailorProfileView {
|
||||
|
||||
void setProfileList(List<SailorProfileEntry> entries);
|
||||
void setProfileList(Collection<SailorProfileEntry> entries);
|
||||
|
||||
}
|
||||
+5
-20
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.user.profile.sailorprofiletab;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.common.theme.component.celltable.DesignedCellTableResources;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.SailorProfilePlace;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.BadgeDTO;
|
||||
@@ -45,7 +44,7 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfileList(List<SailorProfileEntry> entries) {
|
||||
public void setProfileList(Collection<SailorProfileEntry> entries) {
|
||||
sailorProfilesTable.setPageSize(entries.size());
|
||||
sailorProfilesTable.setList(entries);
|
||||
}
|
||||
@@ -67,17 +66,6 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
|
||||
});
|
||||
}
|
||||
|
||||
private String createCommaSeparatedString(List<String> strings) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < strings.size(); i++) {
|
||||
sb.append(strings.get(i));
|
||||
if (i < strings.size() - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private final Column<SailorProfileEntry, String> profileNameColumn = new Column<SailorProfileEntry, String>(
|
||||
new TextCell()) {
|
||||
@Override
|
||||
@@ -90,8 +78,7 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
|
||||
@Override
|
||||
public String getValue(SailorProfileEntry entry) {
|
||||
if (entry != null && entry.getBadges() != null) {
|
||||
return createCommaSeparatedString(
|
||||
entry.getBadges().stream().map(BadgeDTO::getName).collect(Collectors.toList()));
|
||||
return entry.getBadges().stream().map(BadgeDTO::getName).collect(Collectors.joining(", "));
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
@@ -101,8 +88,7 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
|
||||
@Override
|
||||
public String getValue(SailorProfileEntry entry) {
|
||||
if (entry != null && entry.getBoatclasses() != null) {
|
||||
return createCommaSeparatedString(
|
||||
entry.getBoatclasses().stream().map(BoatClassDTO::getName).collect(Collectors.toList()));
|
||||
return entry.getBoatclasses().stream().map(BoatClassDTO::getName).collect(Collectors.joining(", "));
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
@@ -112,8 +98,7 @@ public class SailorProfileOverviewImpl extends Composite implements SailorProfil
|
||||
@Override
|
||||
public String getValue(SailorProfileEntry entry) {
|
||||
if (entry != null && entry.getCompetitors() != null) {
|
||||
return createCommaSeparatedString(
|
||||
entry.getCompetitors().stream().map(CompetitorDTO::getName).collect(Collectors.toList()));
|
||||
return entry.getCompetitors().stream().map(c -> c.getName()).collect(Collectors.joining(", "));
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
+21
-7
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.home.desktop.places.user.profile.sailorprofiletab;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.sap.sailing.gwt.common.client.controls.tabbar.TabView;
|
||||
@@ -10,6 +11,7 @@ import com.sap.sailing.gwt.home.desktop.places.user.profile.UserProfileTabView;
|
||||
import com.sap.sailing.gwt.home.desktop.places.user.profile.UserProfileView;
|
||||
import com.sap.sailing.gwt.home.desktop.places.user.profile.sailorprofiletab.details.SailorProfileDetails;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.SailorProfilePlace;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.SailorProfileEntry;
|
||||
import com.sap.sailing.gwt.ui.client.FlagImageResolver;
|
||||
import com.sap.sse.security.ui.authentication.app.AuthenticationContext;
|
||||
|
||||
@@ -37,18 +39,30 @@ public class SailorProfileTabView extends Composite implements UserProfileTabVie
|
||||
|
||||
@Override
|
||||
public void start(SailorProfilePlace myPlace, AcceptsOneWidget contentArea) {
|
||||
try {
|
||||
UUID uuid = myPlace.getSailorProfileUuid();
|
||||
view = new SailorProfileDetails(uuid);
|
||||
this.currentPresenter = new SailorProfileOverviewImplPresenter(view, ownPresenter);
|
||||
UUID uuid = myPlace.getSailorProfileUuid();
|
||||
if (uuid != null) {
|
||||
final SailorProfileDetails sailorView = new SailorProfileDetails();
|
||||
view = sailorView;
|
||||
currentPresenter = new SailorProfileOverviewImplPresenter(view, ownPresenter);
|
||||
contentArea.setWidget(view);
|
||||
} catch (Exception e) {
|
||||
currentPresenter.getSharedSailorProfilePresenter().getDataProvider().findSailorProfileById(uuid,
|
||||
new AsyncCallback<SailorProfileEntry>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log(caught.getMessage(), caught);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SailorProfileEntry result) {
|
||||
sailorView.setEntry(result);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
view = new SailorProfileOverviewImpl(flagImageResolver);
|
||||
this.currentPresenter = new SailorProfileOverviewImplPresenter(view, ownPresenter);
|
||||
contentArea.setWidget(view);
|
||||
|
||||
}
|
||||
GWT.log("place: " + myPlace.getSailorProfileUuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-8
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.gwt.home.desktop.places.user.profile.sailorprofiletab.details;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
@@ -24,19 +22,29 @@ public class SailorProfileDetails extends Composite implements SailorProfileDeta
|
||||
AuthorizedContentDecoratorDesktop decoratorUi;
|
||||
@UiField(provided = true)
|
||||
EditSailorProfile editSailorProfileUi;
|
||||
|
||||
private final SailorProfileEntry entry;
|
||||
|
||||
public SailorProfileDetails(UUID uuid) {
|
||||
// TODO: lookup entry
|
||||
this.entry = null;
|
||||
private SailorProfileEntry entry;
|
||||
|
||||
public SailorProfileDetails() {
|
||||
}
|
||||
|
||||
public void setEntry(SailorProfileEntry entry) {
|
||||
this.entry = entry;
|
||||
propagateEntryIfNecessary();
|
||||
}
|
||||
|
||||
private void propagateEntryIfNecessary() {
|
||||
if (this.entry != null && editSailorProfileUi != null) {
|
||||
editSailorProfileUi.setEntry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPresenter(SailingProfileOverviewPresenter presenter) {
|
||||
decoratorUi = new AuthorizedContentDecoratorDesktop(presenter);
|
||||
editSailorProfileUi = new EditSailorProfile(presenter.getSharedSailorProfilePresenter(), entry);
|
||||
editSailorProfileUi = new EditSailorProfile(presenter.getSharedSailorProfilePresenter());
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
propagateEntryIfNecessary();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
-1
@@ -44,7 +44,9 @@ public class EditSailorProfile extends Composite implements SharedSailorProfileV
|
||||
@UiField
|
||||
DivElement notificationsTextUi;
|
||||
|
||||
public EditSailorProfile(SharedSailorProfileView.Presenter presenter, SailorProfileEntry entry) {
|
||||
private SailorProfileEntry entry;
|
||||
|
||||
public EditSailorProfile(SharedSailorProfileView.Presenter presenter) {
|
||||
FlagImageResolver.get(new AsyncCallback<FlagImageResolver>() {
|
||||
|
||||
@Override
|
||||
@@ -52,6 +54,7 @@ public class EditSailorProfile extends Composite implements SharedSailorProfileV
|
||||
competitorSelectionUi = new CompetitorDisplayImpl(presenter.getFavoriteCompetitorsDataProvider(),
|
||||
flagImageResolver).selectionUi;
|
||||
initWidget(uiBinder.createAndBindUi(EditSailorProfile.this));
|
||||
setEntryWhenReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,6 +64,12 @@ public class EditSailorProfile extends Composite implements SharedSailorProfileV
|
||||
// TODO hide notificationsTextUi if the user's mail address is already verified
|
||||
}
|
||||
|
||||
private void setEntryWhenReady() {
|
||||
if (competitorSelectionUi != null && entry != null) {
|
||||
competitorSelectionUi.setSelectedItems(entry.getCompetitors());
|
||||
}
|
||||
}
|
||||
|
||||
public void setEdgeToEdge(boolean edgeToEdge) {
|
||||
competitorSelectionUi.setStyleName(style.edgeToEdge(), edgeToEdge);
|
||||
competitorSelectionUi.getElement().getParentElement().removeClassName(res.mediaCss().column());
|
||||
@@ -93,4 +102,9 @@ public class EditSailorProfile extends Composite implements SharedSailorProfileV
|
||||
notifyAboutResultsUi.setEnabled(notifyAboutResults);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntry(SailorProfileEntry entry) {
|
||||
this.entry = entry;
|
||||
setEntryWhenReady();
|
||||
}
|
||||
}
|
||||
+8
-4
@@ -29,11 +29,15 @@ public class SailorProfilePlace extends AbstractUserProfilePlace implements HasM
|
||||
public static class Tokenizer implements PlaceTokenizer<SailorProfilePlace> {
|
||||
@Override
|
||||
public SailorProfilePlace getPlace(String token) {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(token);
|
||||
return new SailorProfilePlace(uuid);
|
||||
} catch (Exception e) {
|
||||
if (token == null || "".equals(token)) {
|
||||
return new SailorProfilePlace(null);
|
||||
} else {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(token);
|
||||
return new SailorProfilePlace(uuid);
|
||||
} catch (Exception e) {
|
||||
return new SailorProfilePlace(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -1,11 +1,15 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.dataprovider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.SailorProfileEntry;
|
||||
|
||||
public interface SailorProfileDataProvider {
|
||||
|
||||
List<SailorProfileEntry> loadSailorProfiles();
|
||||
Collection<SailorProfileEntry> loadSailorProfiles();
|
||||
|
||||
void findSailorProfileById(UUID uuid, AsyncCallback<SailorProfileEntry> asyncCallback);
|
||||
|
||||
}
|
||||
+31
-17
@@ -1,31 +1,35 @@
|
||||
package com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.dataprovider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTOImpl;
|
||||
import com.sap.sailing.gwt.home.communication.event.SimpleCompetitorWithIdDTO;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.BadgeDTO;
|
||||
import com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain.SailorProfileEntry;
|
||||
|
||||
public class SailorProfileDataProviderImpl implements SailorProfileDataProvider {
|
||||
|
||||
@Override
|
||||
public List<SailorProfileEntry> loadSailorProfiles() {
|
||||
private Map<UUID, SailorProfileEntry> entries;
|
||||
|
||||
public SailorProfileDataProviderImpl() {
|
||||
List<BadgeDTO> badges = new ArrayList<>();
|
||||
BadgeDTO b1 = new BadgeDTO(UUID.randomUUID().toString(), "Best Sailor Ever");
|
||||
BadgeDTO b2 = new BadgeDTO(UUID.randomUUID().toString(), "100 Miles Sailed");
|
||||
|
||||
UUID uid1 = UUID.randomUUID();
|
||||
UUID uid2 = UUID.randomUUID();
|
||||
BadgeDTO b1 = new BadgeDTO(uid1.toString(), "Best Sailor Ever");
|
||||
BadgeDTO b2 = new BadgeDTO(uid2.toString(), "100 Miles Sailed");
|
||||
badges.add(b1);
|
||||
badges.add(b2);
|
||||
|
||||
List<CompetitorDTO> competitors = new ArrayList<>();
|
||||
CompetitorDTOImpl c1 = new CompetitorDTOImpl();
|
||||
c1.setName("Hard Competition");
|
||||
CompetitorDTOImpl c2 = new CompetitorDTOImpl();
|
||||
c2.setName("Easy Competition");
|
||||
List<SimpleCompetitorWithIdDTO> competitors = new ArrayList<>();
|
||||
SimpleCompetitorWithIdDTO c1 = new SimpleCompetitorWithIdDTO("0000", "EZ Competition", "", "", "");
|
||||
SimpleCompetitorWithIdDTO c2 = new SimpleCompetitorWithIdDTO("0001", "Hard Competition", "", "", "");
|
||||
competitors.add(c1);
|
||||
competitors.add(c2);
|
||||
|
||||
@@ -35,15 +39,25 @@ public class SailorProfileDataProviderImpl implements SailorProfileDataProvider
|
||||
boatclasses.add(bc1);
|
||||
boatclasses.add(bc2);
|
||||
|
||||
SailorProfileEntry e1 = new SailorProfileEntry(UUID.randomUUID().toString(), "My Favourite Guy", competitors,
|
||||
SailorProfileEntry e1 = new SailorProfileEntry(uid1.toString(), "My Favourite Guy", competitors,
|
||||
badges, boatclasses);
|
||||
SailorProfileEntry e2 = new SailorProfileEntry(UUID.randomUUID().toString(), "This Other Guy", competitors,
|
||||
SailorProfileEntry e2 = new SailorProfileEntry(uid2.toString(), "This Other Guy", competitors,
|
||||
badges, boatclasses);
|
||||
|
||||
List<SailorProfileEntry> entries = new ArrayList<>();
|
||||
entries.add(e1);
|
||||
entries.add(e2);
|
||||
return entries;
|
||||
entries = new HashMap<>();
|
||||
entries.put(uid1, e1);
|
||||
entries.put(uid2, e2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SailorProfileEntry> loadSailorProfiles() {
|
||||
return entries.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findSailorProfileById(UUID uuid, AsyncCallback<SailorProfileEntry> asyncCallback) {
|
||||
SailorProfileEntry entr = entries.get(uuid);
|
||||
asyncCallback.onSuccess(entr);
|
||||
}
|
||||
|
||||
}
|
||||
+5
-4
@@ -3,17 +3,18 @@ package com.sap.sailing.gwt.home.shared.places.user.profile.sailorprofile.domain
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.home.communication.event.SimpleCompetitorWithIdDTO;
|
||||
|
||||
public class SailorProfileEntry {
|
||||
|
||||
private final String key;
|
||||
private final String name;
|
||||
private final List<CompetitorDTO> competitors;
|
||||
private final List<SimpleCompetitorWithIdDTO> competitors;
|
||||
private final List<BadgeDTO> badges;
|
||||
private final List<BoatClassDTO> boatclasses;
|
||||
|
||||
public SailorProfileEntry(String key, String name, List<CompetitorDTO> competitors, List<BadgeDTO> badges,
|
||||
public SailorProfileEntry(String key, String name, List<SimpleCompetitorWithIdDTO> competitors,
|
||||
List<BadgeDTO> badges,
|
||||
List<BoatClassDTO> boatclasses) {
|
||||
super();
|
||||
this.key = key;
|
||||
@@ -27,7 +28,7 @@ public class SailorProfileEntry {
|
||||
return key;
|
||||
}
|
||||
|
||||
public List<CompetitorDTO> getCompetitors() {
|
||||
public List<SimpleCompetitorWithIdDTO> getCompetitors() {
|
||||
return competitors;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user