@Override public String createTeamUri(OptaSportType sportType, String id) { OptaSportConfiguration sportConfig = config.get(sportType); if (sportConfig == null) { throw new IllegalArgumentException("Sport type " + sportType.name() + " not configured"); } return TEAM_URI_BASE + normalizeTeamId(id, sportConfig.prefixToStripFromId()); }
private Iterable<Topic> parseEventGroups(OptaSportType sport) { Optional<Set<Topic>> eventGroups = utility.parseEventGroups(sport); if (!eventGroups.isPresent()) { log.warn("No event groups mapped to sport {}", sport.name()); return ImmutableList.of(); } else { return eventGroups.get(); } }
@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); }