From 054d72bfa0e40c447832679b13a0deb8d2c06dc0 Mon Sep 17 00:00:00 2001 From: Benjamin Barth Date: Tue, 15 Sep 2015 15:23:45 +0200 Subject: [PATCH] Adjusted logic for loading event stage content --- .../sailing/gwt/server/HomeServiceUtil.java | 9 +++++ .../event/GetEventOverviewStageAction.java | 37 ++++++++++--------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/server/HomeServiceUtil.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/server/HomeServiceUtil.java index 41ff5524c95..4333c58e712 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/server/HomeServiceUtil.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/server/HomeServiceUtil.java @@ -133,6 +133,15 @@ public final class HomeServiceUtil { return event.findImageWithTag(MediaTagConstants.TEASER); } + public static ImageDescriptor getFeaturedImage(EventBase event) { + return event.findImageWithTag(MediaTagConstants.FEATURED); + } + + public static String getFeaturedImageUrlAsString(EventBase event) { + ImageDescriptor image = getFeaturedImage(event); + return image == null ? null : image.getURL().toString(); + } + public static String getStageImageURLAsString(final EventBase event) { ImageDescriptor image = getStageImage(event); return image == null ? null : image.getURL().toString(); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/GetEventOverviewStageAction.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/GetEventOverviewStageAction.java index 78e28f34706..3caa25a42e0 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/GetEventOverviewStageAction.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/GetEventOverviewStageAction.java @@ -3,8 +3,8 @@ package com.sap.sailing.gwt.ui.shared.dispatch.event; import static com.sap.sailing.gwt.server.HomeServiceUtil.findEventThumbnailImageUrlAsString; import static com.sap.sailing.gwt.server.HomeServiceUtil.getStageImageURLAsString; -import java.util.Arrays; -import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.UUID; import com.google.gwt.core.shared.GwtIncompatible; @@ -13,6 +13,7 @@ import com.sap.sailing.gwt.server.HomeServiceUtil; import com.sap.sailing.gwt.ui.shared.dispatch.Action; import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext; import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL; +import com.sap.sailing.gwt.ui.shared.dispatch.event.EventOverviewVideoStageDTO.Type; import com.sap.sailing.gwt.ui.shared.general.EventState; import com.sap.sse.common.Duration; import com.sap.sse.common.TimePoint; @@ -22,8 +23,6 @@ import com.sap.sse.common.media.MediaTagConstants; import com.sap.sse.common.media.VideoDescriptor; public class GetEventOverviewStageAction implements Action> { - private static final Collection rankedTags = Arrays.asList(MediaTagConstants.STAGE, MediaTagConstants.LIVESTREAM, MediaTagConstants.FEATURED, MediaTagConstants.HIGHLIGHT); - private static final Collection rankedTagsFinished = Arrays.asList(MediaTagConstants.STAGE, MediaTagConstants.FEATURED, MediaTagConstants.HIGHLIGHT); private UUID eventId; private boolean useTeaserImage; @@ -58,23 +57,25 @@ public class GetEventOverviewStageAction implements Action tags = state == EventState.FINISHED ? rankedTagsFinished : rankedTags; - VideoDescriptor stageVideo = HomeServiceUtil.getStageVideo(event, context.getClientLocale(), tags, true); - if(stageVideo != null) { - return new EventOverviewVideoStageDTO(EventOverviewVideoStageDTO.Type.MEDIA, HomeServiceUtil.toVideoDTO(stageVideo)); + // P1: Featured video if available + List videoTags = Collections.singletonList(MediaTagConstants.FEATURED); + VideoDescriptor featuredVideo = HomeServiceUtil.getStageVideo(event, context.getClientLocale(), videoTags , false); + if (featuredVideo != null) { + return new EventOverviewVideoStageDTO(Type.MEDIA, HomeServiceUtil.toVideoDTO(featuredVideo)); } - String stageImageUrl = useTeaserImage ? findEventThumbnailImageUrlAsString(event) : getStageImageURLAsString(event); + + // P2: Featured image if available + String imageUrl = HomeServiceUtil.getFeaturedImageUrlAsString(event); + if (imageUrl == null) { + // P3: Show Teaser/Stage image + imageUrl = useTeaserImage ? findEventThumbnailImageUrlAsString(event) : getStageImageURLAsString(event); + } + + // Show countdown for planned or upcoming events if(state == EventState.UPCOMING || state == EventState.PLANNED) { - return new EventOverviewTickerStageDTO(event.getStartDate().asDate(), event.getName(), stageImageUrl); + return new EventOverviewTickerStageDTO(event.getStartDate().asDate(), event.getName(), imageUrl); } - return new EventOverviewTickerStageDTO(null, null, stageImageUrl); - - + return new EventOverviewTickerStageDTO(null, null, imageUrl); // TODO do the full implementation