* @throws ValidationException if the import data is not valid
*/
private void validateImportData() throws ValidationException {
// does the file contain player and player history records?
if (importService.getPlayers().isEmpty() || importService.getHistory().isEmpty()) {
throw new ValidationException(ResourceLoader.getMessage(MessageId.V003.getMessageKey()));
}
// was the data already imported?
final List<Date> allImportDatesInDb = playerHistoryService.findAllImportDates();
final Date importDateOfFile = importService.getImportDate();
if (allImportDatesInDb.contains(importDateOfFile)) {
final String message = ResourceLoader.getMessage(MessageId.V001.getMessageKey(), importFile.getName());
throw new ValidationException(message);
}
// does every player have his own history data record?
final List<Player> players = importService.getPlayers();
for (final Player player : players) {
if (!importService.getHistory().containsKey(player.getId())) {
final String message = ResourceLoader.getMessage(MessageId.V002.getMessageKey(), player.getLastName());
throw new ValidationException(message);
}
}
}