mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 20:13:52 +00:00
The NotificationPreferences are now backend specific by using lookup
mechanisms for BoatClasses and Competitors. With this the NotificationPreferences can't be used in the GWT UI anymore. Currently the UI doesn't compile -> this needs to be fixed in a subsequent commit
This commit is contained in:
1 parent
b5524aefde
commit
d85ab8b470
18 files changed
+283
-202
No files matched your search
@@ -21,7 +21,6 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
|
||||
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.preferences.NotificationPreferences;
|
||||
import com.sap.sailing.domain.common.tracking.impl.GPSFixImpl;
|
||||
import com.sap.sailing.domain.common.tracking.impl.GPSFixMovingImpl;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.GPSFixMongoHandler;
|
||||
@@ -31,6 +30,7 @@ import com.sap.sailing.domain.polars.PolarDataService;
|
||||
import com.sap.sailing.server.MasterDataImportClassLoaderService;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceMXBean;
|
||||
import com.sap.sailing.server.impl.preferences.model.NotificationPreferences;
|
||||
import com.sap.sse.common.TypeBasedServiceFinder;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.osgi.CachedOsgiTypeBasedServiceFinderFactory;
|
||||
@@ -143,7 +143,8 @@ public class Activator implements BundleActivator {
|
||||
|
||||
protected void registerPreferenceConvertersForUserStore(UserStore userStore) {
|
||||
userStore.registerPreferenceConverter(NotificationPreferences.PREF_NAME,
|
||||
new GenericJSONPreferenceConverter<NotificationPreferences>(NotificationPreferences::new));
|
||||
new GenericJSONPreferenceConverter<NotificationPreferences>(
|
||||
() -> new NotificationPreferences(racingEventService)));
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
|
||||
+6
-6
@@ -4,22 +4,22 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.common.BoatClassMasterdata;
|
||||
import com.sap.sailing.domain.common.preferences.BoatClassNotificationPreference;
|
||||
import com.sap.sailing.domain.common.preferences.NotificationPreferences;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.server.impl.preferences.model.BoatClassNotificationPreference;
|
||||
import com.sap.sailing.server.impl.preferences.model.NotificationPreferences;
|
||||
import com.sap.sse.security.PreferenceObjectBasedNotificationSet;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public abstract class AbstractBoatClassNotificationSet
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, BoatClassMasterdata> {
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, BoatClass> {
|
||||
|
||||
public AbstractBoatClassNotificationSet(UserStore store) {
|
||||
super(NotificationPreferences.PREF_NAME, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<BoatClassMasterdata> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<BoatClassMasterdata> result = new HashSet<>();
|
||||
protected Collection<BoatClass> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<BoatClass> result = new HashSet<>();
|
||||
for (BoatClassNotificationPreference pref : preference.getBoatClassPreferences().getBoatClasses()) {
|
||||
if (shouldNotifyFor(pref)) {
|
||||
result.add(pref.getBoatClass());
|
||||
|
||||
+7
-7
@@ -1,28 +1,28 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.CompetitorNotificationPreference;
|
||||
import com.sap.sailing.domain.common.preferences.NotificationPreferences;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.server.impl.preferences.model.CompetitorNotificationPreference;
|
||||
import com.sap.sailing.server.impl.preferences.model.NotificationPreferences;
|
||||
import com.sap.sse.security.PreferenceObjectBasedNotificationSet;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public abstract class AbstractCompetitorNotificationSet
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, Serializable> {
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, Competitor> {
|
||||
|
||||
public AbstractCompetitorNotificationSet(UserStore store) {
|
||||
super(NotificationPreferences.PREF_NAME, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Serializable> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<Serializable> result = new HashSet<>();
|
||||
protected Collection<Competitor> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<Competitor> result = new HashSet<>();
|
||||
for (CompetitorNotificationPreference pref : preference.getCompetitorPreferences().getCompetitors()) {
|
||||
if (shouldNotifyFor(pref)) {
|
||||
result.add(pref.getCompetitorId());
|
||||
result.add(pref.getCompetitor());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.BoatClassNotificationPreference;
|
||||
import com.sap.sailing.server.impl.preferences.model.BoatClassNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class BoatClassResultsNotificationSet extends AbstractBoatClassNotificationSet {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.BoatClassNotificationPreference;
|
||||
import com.sap.sailing.server.impl.preferences.model.BoatClassNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class BoatClassUpcomingRaceNotificationSet extends AbstractBoatClassNotificationSet {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.CompetitorNotificationPreference;
|
||||
import com.sap.sailing.server.impl.preferences.model.CompetitorNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class CompetitorResultsNotificationSet extends AbstractCompetitorNotificationSet {
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.BooleanSetting;
|
||||
|
||||
public class BoatClassNotificationPreference extends AbstractGenericSerializableSettings {
|
||||
private static final long serialVersionUID = -6510535362114348707L;
|
||||
|
||||
private transient BoatClassSetting boatClass;
|
||||
private transient BooleanSetting notifyAboutUpcomingRaces;
|
||||
private transient BooleanSetting notifyAboutResults;
|
||||
|
||||
public BoatClassNotificationPreference(DomainFactory domainFactory) {
|
||||
boatClass = new BoatClassSetting("boatClass", this, domainFactory);
|
||||
notifyAboutUpcomingRaces = new BooleanSetting("notifyAboutUpcomingRaces", this, false);
|
||||
notifyAboutResults = new BooleanSetting("notifyAboutResults", this, false);
|
||||
}
|
||||
|
||||
public BoatClassNotificationPreference(DomainFactory domainFactory, BoatClass boatClass, boolean notifyAboutRaces,
|
||||
boolean notifyAboutResults) {
|
||||
this(domainFactory);
|
||||
this.boatClass.setValue(boatClass);
|
||||
this.notifyAboutUpcomingRaces.setValue(notifyAboutRaces);
|
||||
this.notifyAboutResults.setValue(notifyAboutResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildSettings() {
|
||||
// We do not create the Setting instances here, because access to the RacingEventService would not be given.
|
||||
// Doing this, Java/GWT Serialization isn't working anymore. Because the preferences are only serialized as JSON
|
||||
// in the backend an transferred as DTO to the frontend, this isn't a problem. Due to usage of BoatClass and
|
||||
// Competitor domain objects, it wouldn't be GWT compatible anyway.
|
||||
// The usage of Java Serialization isn't planned by now too.
|
||||
}
|
||||
|
||||
public BoatClass getBoatClass() {
|
||||
return boatClass.getValue();
|
||||
}
|
||||
|
||||
public boolean isNotifyAboutUpcomingRaces() {
|
||||
return Boolean.TRUE.equals(notifyAboutUpcomingRaces.getValue());
|
||||
}
|
||||
|
||||
public boolean isNotifyAboutResults() {
|
||||
return Boolean.TRUE.equals(notifyAboutResults.getValue());
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.SettingsList;
|
||||
|
||||
public class BoatClassNotificationPreferences extends AbstractGenericSerializableSettings {
|
||||
private static final long serialVersionUID = -3682996540081614053L;
|
||||
|
||||
private transient SettingsList<BoatClassNotificationPreference> boatClasses;
|
||||
|
||||
public BoatClassNotificationPreferences(String name, AbstractGenericSerializableSettings settings,
|
||||
RacingEventService racingEventService) {
|
||||
super(name, settings);
|
||||
boatClasses = new SettingsList<>("boatClasses", this,
|
||||
() -> new BoatClassNotificationPreference(racingEventService.getBaseDomainFactory()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildSettings() {
|
||||
// We do not create the Setting instances here, because access to the RacingEventService would not be given.
|
||||
// Doing this, Java/GWT Serialization isn't working anymore. Because the preferences are only serialized as JSON
|
||||
// in the backend an transferred as DTO to the frontend, this isn't a problem. Due to usage of BoatClass and
|
||||
// Competitor domain objects, it wouldn't be GWT compatible anyway.
|
||||
// The usage of Java Serialization isn't planned by now too.
|
||||
}
|
||||
|
||||
public Iterable<BoatClassNotificationPreference> getBoatClasses() {
|
||||
return boatClasses.getValues();
|
||||
}
|
||||
|
||||
public void setBoatClasses(Iterable<BoatClassNotificationPreference> boatClasses) {
|
||||
this.boatClasses.setValues(boatClasses);
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.ValueConverter;
|
||||
import com.sap.sse.common.settings.generic.base.AbstractValueSetting;
|
||||
import com.sap.sse.common.settings.value.StringValue;
|
||||
import com.sap.sse.common.settings.value.Value;
|
||||
|
||||
/**
|
||||
* Specific setting to hold a {@link BoatClass} instance. The competitor is being serialized using the boat classes'
|
||||
* name and deserialized using the given {@link DomainFactory}.
|
||||
*/
|
||||
public class BoatClassSetting extends AbstractValueSetting<BoatClass> {
|
||||
|
||||
protected BoatClassSetting(String name, AbstractGenericSerializableSettings settings, DomainFactory domainFactory) {
|
||||
super(name, settings, null, new Converter(domainFactory));
|
||||
}
|
||||
|
||||
public static class Converter implements ValueConverter<BoatClass> {
|
||||
|
||||
private final DomainFactory domainFactory;
|
||||
|
||||
public Converter(DomainFactory domainFactory) {
|
||||
this.domainFactory = domainFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toJSONValue(BoatClass value) {
|
||||
return toStringValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClass fromJSONValue(Object jsonValue) {
|
||||
return fromStringValue((String) jsonValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringValue(BoatClass value) {
|
||||
return value == null ? null : value.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClass fromStringValue(String stringValue) {
|
||||
return stringValue == null ? null : domainFactory.getOrCreateBoatClass(stringValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClass fromValue(Value value) {
|
||||
return fromStringValue(((StringValue) value).getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value toValue(BoatClass value) {
|
||||
return new StringValue(toStringValue(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CompetitorStore;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.BooleanSetting;
|
||||
|
||||
public class CompetitorNotificationPreference extends AbstractGenericSerializableSettings {
|
||||
private static final long serialVersionUID = -6510535362114348707L;
|
||||
|
||||
private transient CompetitorSetting competitor;
|
||||
private transient BooleanSetting notifyAboutResults;
|
||||
|
||||
public CompetitorNotificationPreference(CompetitorStore competitorStore) {
|
||||
competitor = new CompetitorSetting("competitor", this, competitorStore);
|
||||
notifyAboutResults = new BooleanSetting("notifyAboutResults", this, false);
|
||||
}
|
||||
|
||||
public CompetitorNotificationPreference(CompetitorStore competitorStore, Competitor competitor,
|
||||
boolean notifyAboutResults) {
|
||||
this(competitorStore);
|
||||
this.competitor.setValue(competitor);
|
||||
this.notifyAboutResults.setValue(notifyAboutResults);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildSettings() {
|
||||
// We do not create the Setting instances here, because access to the RacingEventService would not be given.
|
||||
// Doing this, Java/GWT Serialization isn't working anymore. Because the preferences are only serialized as JSON
|
||||
// in the backend an transferred as DTO to the frontend, this isn't a problem. Due to usage of BoatClass and
|
||||
// Competitor domain objects, it wouldn't be GWT compatible anyway.
|
||||
// The usage of Java Serialization isn't planned by now too.
|
||||
}
|
||||
|
||||
public Competitor getCompetitor() {
|
||||
return competitor.getValue();
|
||||
}
|
||||
|
||||
public boolean isNotifyAboutResults() {
|
||||
return Boolean.TRUE.equals(notifyAboutResults.getValue());
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.SettingsList;
|
||||
|
||||
public class CompetitorNotificationPreferences extends AbstractGenericSerializableSettings {
|
||||
private static final long serialVersionUID = -3682996540081614053L;
|
||||
|
||||
private transient SettingsList<CompetitorNotificationPreference> competitors;
|
||||
|
||||
public CompetitorNotificationPreferences(String name, AbstractGenericSerializableSettings settings,
|
||||
RacingEventService racingEventService) {
|
||||
super(name, settings);
|
||||
competitors = new SettingsList<>("competitors", this,
|
||||
() -> new CompetitorNotificationPreference(racingEventService.getCompetitorStore()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildSettings() {
|
||||
// We do not create the Setting instances here, because access to the RacingEventService would not be given.
|
||||
// Doing this, Java/GWT Serialization isn't working anymore. Because the preferences are only serialized as JSON
|
||||
// in the backend an transferred as DTO to the frontend, this isn't a problem. Due to usage of BoatClass and
|
||||
// Competitor domain objects, it wouldn't be GWT compatible anyway.
|
||||
// The usage of Java Serialization isn't planned by now too.
|
||||
}
|
||||
|
||||
public Iterable<CompetitorNotificationPreference> getCompetitors() {
|
||||
return competitors.getValues();
|
||||
}
|
||||
|
||||
public void setCompetitors(Iterable<CompetitorNotificationPreference> boatClasses) {
|
||||
this.competitors.setValues(boatClasses);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CompetitorStore;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
import com.sap.sse.common.settings.generic.ValueConverter;
|
||||
import com.sap.sse.common.settings.generic.base.AbstractValueSetting;
|
||||
import com.sap.sse.common.settings.value.StringValue;
|
||||
import com.sap.sse.common.settings.value.Value;
|
||||
|
||||
/**
|
||||
* Specific setting to hold a {@link Competitor} instance. The competitor is being serialized as ID and deserialized
|
||||
* doing as lookup in the given {@link CompetitorStore}.
|
||||
*/
|
||||
public class CompetitorSetting extends AbstractValueSetting<Competitor> {
|
||||
|
||||
protected CompetitorSetting(String name, AbstractGenericSerializableSettings settings,
|
||||
CompetitorStore competitorStore) {
|
||||
super(name, settings, null, new Converter(competitorStore));
|
||||
}
|
||||
|
||||
public static class Converter implements ValueConverter<Competitor> {
|
||||
|
||||
private final CompetitorStore competitorStore;
|
||||
|
||||
public Converter(CompetitorStore competitorStore) {
|
||||
this.competitorStore = competitorStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object toJSONValue(Competitor value) {
|
||||
return toStringValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor fromJSONValue(Object jsonValue) {
|
||||
return fromStringValue((String) jsonValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringValue(Competitor value) {
|
||||
return value == null ? null : value.getId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor fromStringValue(String stringValue) {
|
||||
return stringValue == null ? null : competitorStore.getExistingCompetitorByIdAsString(stringValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor fromValue(Value value) {
|
||||
return fromStringValue(((StringValue) value).getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value toValue(Competitor value) {
|
||||
return new StringValue(toStringValue(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.sap.sailing.server.impl.preferences.model;
|
||||
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sse.common.settings.generic.AbstractGenericSerializableSettings;
|
||||
|
||||
/**
|
||||
* Preferences for Sailing users that define for which Objects a user wants to receive specific notifications.
|
||||
* This currently includes:
|
||||
* <ul>
|
||||
* <li>Results for a favorite Competitor</li>
|
||||
* <li>Results for a favorite BoatClass</li>
|
||||
* <li>Upcoming races for a favorite BoatClass</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class NotificationPreferences extends AbstractGenericSerializableSettings {
|
||||
private static final long serialVersionUID = 8865010526321472376L;
|
||||
|
||||
public static final String PREF_NAME = "sailing.notifications";
|
||||
|
||||
private transient BoatClassNotificationPreferences boatClassPreferences;
|
||||
private transient CompetitorNotificationPreferences competitorPreferences;
|
||||
|
||||
public NotificationPreferences(RacingEventService racingEventService) {
|
||||
boatClassPreferences = new BoatClassNotificationPreferences("boatClassPreferences", this, racingEventService);
|
||||
competitorPreferences = new CompetitorNotificationPreferences("competitorPreferences", this, racingEventService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildSettings() {
|
||||
// We do not create the Setting instances here, because access to the RacingEventService would not be given.
|
||||
// Doing this, Java/GWT Serialization isn't working anymore. Because the preferences are only serialized as JSON
|
||||
// in the backend an transferred as DTO to the frontend, this isn't a problem. Due to usage of BoatClass and
|
||||
// Competitor domain objects, it wouldn't be GWT compatible anyway.
|
||||
// The usage of Java Serialization isn't planned by now too.
|
||||
}
|
||||
|
||||
public BoatClassNotificationPreferences getBoatClassPreferences() {
|
||||
return boatClassPreferences;
|
||||
}
|
||||
|
||||
public CompetitorNotificationPreferences getCompetitorPreferences() {
|
||||
return competitorPreferences;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user