private Content updateEventPublisher(Content content) { List<EventRef> eventRefs = content.events(); for (EventRef eventRef : eventRefs) { Event event = eventResolver.fetch(eventRef.id()).orNull(); checkNotNull(event); checkNotNull(event.publisher()); eventRef.setPublisher(event.publisher()); } content.setEventRefs(ImmutableList.copyOf(eventRefs)); return content; }
@Override public Optional<Event> parseEvent(SportsMatchData match, OptaSportType sport) { Optional<String> title = createTitle(match, sport); if (!title.isPresent()) { return Optional.absent(); } Optional<DateTime> startTime = parseStartTime(match, sport); if (!startTime.isPresent()) { log.error("Unable to identify start time for {}", title.get()); return Optional.absent(); } Optional<Topic> venue = createOrResolveVenue(match); if (!venue.isPresent()) { log.error("Unable to identify venue for {} on {}", title.get(), startTime.get().toString()); return Optional.absent(); } Optional<DateTime> endTime = utility.createEndTime(sport, startTime.get()); if (!endTime.isPresent()) { log.error("No duration mapping exists for sport {}", sport.name()); return Optional.absent(); } Event event = Event.builder() .withTitle(title.get()) .withPublisher(Publisher.OPTA) .withVenue(venue.get()) .withStartTime(startTime.get()) .withEndTime(endTime.get()) .withOrganisations(parseOrganisations(match, sport)) .withEventGroups(parseEventGroups(sport)) .build(); event.setCanonicalUri(utility.createEventUri(match.attributes().uId())); return Optional.of(event); }