mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 20:13:52 +00:00
Prepared NotificationSets for BoatClass and Competitor Notifications
This commit is contained in:
1 parent
59a3c3bb8a
commit
3212ed03db
5 files changed
+115
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
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.sse.security.PreferenceObjectBasedNotificationSet;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public abstract class AbstractBoatClassNotificationSet
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, BoatClassMasterdata> {
|
||||
|
||||
public AbstractBoatClassNotificationSet(UserStore store) {
|
||||
super(NotificationPreferences.PREF_NAME, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<BoatClassMasterdata> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<BoatClassMasterdata> result = new HashSet<>();
|
||||
for (BoatClassNotificationPreference pref : preference.getBoatClassPreferences().getBoatClasses()) {
|
||||
if (shouldNotifyFor(pref)) {
|
||||
result.add(pref.getBoatClass());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract boolean shouldNotifyFor(BoatClassNotificationPreference pref);
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
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.sse.security.PreferenceObjectBasedNotificationSet;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public abstract class AbstractCompetitorNotificationSet
|
||||
extends PreferenceObjectBasedNotificationSet<NotificationPreferences, Serializable> {
|
||||
|
||||
public AbstractCompetitorNotificationSet(UserStore store) {
|
||||
super(NotificationPreferences.PREF_NAME, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Serializable> calculateObjectsToNotify(NotificationPreferences preference) {
|
||||
Set<Serializable> result = new HashSet<>();
|
||||
for (CompetitorNotificationPreference pref : preference.getCompetitorPreferences().getCompetitors()) {
|
||||
if (shouldNotifyFor(pref)) {
|
||||
result.add(pref.getCompetitorId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected abstract boolean shouldNotifyFor(CompetitorNotificationPreference pref);
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.BoatClassNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class BoatClassResultsNotificationSet extends AbstractBoatClassNotificationSet {
|
||||
|
||||
public BoatClassResultsNotificationSet(UserStore store) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotifyFor(BoatClassNotificationPreference pref) {
|
||||
return pref.isNotifyAboutResults();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.BoatClassNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class BoatClassUpcomingRaceNotificationSet extends AbstractBoatClassNotificationSet {
|
||||
|
||||
public BoatClassUpcomingRaceNotificationSet(UserStore store) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotifyFor(BoatClassNotificationPreference pref) {
|
||||
return pref.isNotifyAboutUpcomingRaces();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.server.impl.preferences;
|
||||
|
||||
import com.sap.sailing.domain.common.preferences.CompetitorNotificationPreference;
|
||||
import com.sap.sse.security.UserStore;
|
||||
|
||||
public class CompetitorResultsNotificationSet extends AbstractCompetitorNotificationSet {
|
||||
|
||||
public CompetitorResultsNotificationSet(UserStore store) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotifyFor(CompetitorNotificationPreference pref) {
|
||||
return pref.isNotifyAboutResults();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user