mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
new isTrackedByTracTrac method for events
This commit is contained in:
1 parent
53b01cd2bc
commit
2bc9db7785
6 files changed
+38
-6
No files matched your search
+7
@@ -105,4 +105,11 @@ public interface EventBase extends NamedWithID, WithDescription, Renamable, With
|
||||
* Sets and converts all event images and videos from the old URL based format to the new richer format
|
||||
* */
|
||||
boolean setMediaURLs(Iterable<URL> imageURLs, Iterable<URL> sponsorImageURLs, Iterable<URL> videoURLs, URL logoImageURL, Map<URL, ImageSize> imageSizes);
|
||||
|
||||
/**
|
||||
* Determines whether the race is tracked by TracTrac or not
|
||||
* @return a boolean flag, whether any @TrackedRace in the event is tracked by TracTrac or not
|
||||
*/
|
||||
boolean isTrackedByTracTrac();
|
||||
|
||||
}
|
||||
+11
-4
@@ -16,22 +16,29 @@ import com.sap.sse.common.TimePoint;
|
||||
*
|
||||
*/
|
||||
public class StrippedEventImpl extends EventBaseImpl {
|
||||
private static final long serialVersionUID = 5608501747499933988L;
|
||||
private static final long serialVersionUID = -8158306909959745156L;
|
||||
private final boolean isTrackedByTracTrac;
|
||||
private final Iterable<LeaderboardGroupBase> leaderboardGroups;
|
||||
|
||||
public StrippedEventImpl(String name, TimePoint startDate, TimePoint endDate, String venueName,
|
||||
boolean isPublic, UUID id, Iterable<LeaderboardGroupBase> leaderboardGroups) {
|
||||
this(name, startDate, endDate, new VenueImpl(venueName), isPublic, id, leaderboardGroups);
|
||||
boolean isPublic, UUID id, Iterable<LeaderboardGroupBase> leaderboardGroups, boolean isTrackedByTracTrac) {
|
||||
this(name, startDate, endDate, new VenueImpl(venueName), isPublic, id, leaderboardGroups, isTrackedByTracTrac);
|
||||
}
|
||||
|
||||
public StrippedEventImpl(String name, TimePoint startDate, TimePoint endDate, Venue venue,
|
||||
boolean isPublic, UUID id, Iterable<LeaderboardGroupBase> leaderboardGroups) {
|
||||
boolean isPublic, UUID id, Iterable<LeaderboardGroupBase> leaderboardGroups, boolean isTrackedByTracTrac) {
|
||||
super(name, startDate, endDate, venue, isPublic, id);
|
||||
this.leaderboardGroups = leaderboardGroups;
|
||||
this.isTrackedByTracTrac = isTrackedByTracTrac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<LeaderboardGroupBase> getLeaderboardGroups() {
|
||||
return leaderboardGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrackedByTracTrac() {
|
||||
return isTrackedByTracTrac;
|
||||
}
|
||||
}
|
||||
@@ -102,4 +102,19 @@ public class EventImpl extends EventBaseImpl implements Event {
|
||||
windFinderReviewedSpotsCollectionIds.putIfAbsent(reviewedSpotsCollectionId, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrackedByTracTrac() {
|
||||
for (LeaderboardGroup lbg : this.getLeaderboardGroups()) {
|
||||
for (Leaderboard lb : lbg.getLeaderboards()) {
|
||||
//Leaderboard.getTrackedRaces() could lead to performance issues due to duplicative collection of TrackedRaces
|
||||
for (TrackedRace tr : lb.getTrackedRaces()) {
|
||||
if("TRAC_TRAC".equals(tr.getTrackingConnector())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -56,8 +56,9 @@ public class EventBaseJsonDeserializer implements JsonDeserializer<EventBase> {
|
||||
leaderboardGroups.add(leaderboardGroupDeserializer.deserialize((JSONObject) lgJson));
|
||||
}
|
||||
}
|
||||
boolean isTrackedByTracTrac = Boolean.TRUE.equals(eventJson.get(EventBaseJsonSerializer.Field_TRACKED_BY_TRACTRAC));
|
||||
StrippedEventImpl result = new StrippedEventImpl(name, startDate == null ? null : new MillisecondsTimePoint(startDate.longValue()),
|
||||
endDate == null ? null : new MillisecondsTimePoint(endDate.longValue()), venue, /* is public */ true, id, leaderboardGroups);
|
||||
endDate == null ? null : new MillisecondsTimePoint(endDate.longValue()), venue, /* is public */ true, id, leaderboardGroups, isTrackedByTracTrac);
|
||||
result.setDescription(description);
|
||||
if (officialWebsiteURLAsString != null) {
|
||||
try {
|
||||
|
||||
+2
@@ -39,6 +39,7 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
public static final String FIELD_CREATEDATDATE = "createdAtDate";
|
||||
public static final String FIELD_LOCALE = "locale";
|
||||
public static final String FIELD_TAGS = "tags";
|
||||
public static final String Field_TRACKED_BY_TRACTRAC = "trackedByTracTrac";
|
||||
// specific image fields
|
||||
public static final String FIELD_IMAGES = "images";
|
||||
public static final String FIELD_IMAGE_WIDTH_IN_PX = "widthInPixel";
|
||||
@@ -73,6 +74,7 @@ public class EventBaseJsonSerializer implements JsonSerializer<EventBase> {
|
||||
for (LeaderboardGroupBase lg : event.getLeaderboardGroups()) {
|
||||
leaderboardGroups.add(leaderboardGroupBaseSerializer.serialize(lg));
|
||||
}
|
||||
result.put(Field_TRACKED_BY_TRACTRAC, event.isTrackedByTracTrac());
|
||||
JSONArray imageSizes = new JSONArray();
|
||||
result.put(FIELD_IMAGE_SIZES, imageSizes);
|
||||
for (ImageDescriptor image : event.getImages()) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EventUtilTest {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(year, month - 1, date);
|
||||
MillisecondsTimePoint startEnd = new MillisecondsTimePoint(calendar.getTime());
|
||||
return new StrippedEventImpl("Test", startEnd, startEnd, "Anywhere", true, UUID.randomUUID(), null);
|
||||
return new StrippedEventImpl("Test", startEnd, startEnd, "Anywhere", true, UUID.randomUUID(), null, false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user