EntsoeCaseRepository implements CaseRepository { @Override public Set<DateTime> dataAvailable(CaseType type, Set<Country> countries, Interval interval) { Set<EntsoeGeographicalCode> geographicalCodes = new HashSet<>(); if (countries == null) { geographicalCodes.add(EntsoeGeographicalCode.UX); } else { for (Country country : countries) { geographicalCodes.addAll(forCountryHacked(country)); } } Multimap<DateTime, EntsoeGeographicalCode> dates = HashMultimap.create(); for (EntsoeFormat format : formats) { Path formatDir = config.getRootDir().resolve(format.getDirName()); if (Files.exists(formatDir)) { Path typeDir = formatDir.resolve(type.name()); if (Files.exists(typeDir)) { browse(typeDir, path -> { EntsoeFileName entsoeFileName = EntsoeFileName.parse(path.getFileName().toString()); EntsoeGeographicalCode geographicalCode = entsoeFileName.getGeographicalCode(); if (geographicalCode != null && !config.getForbiddenFormatsByGeographicalCode().get(geographicalCode).contains(format.getImporter().getFormat()) && interval.contains(entsoeFileName.getDate())) { dates.put(entsoeFileName.getDate(), geographicalCode); } }); } } } return dates.asMap().entrySet().stream() .filter(e -> new HashSet<>(e.getValue()).containsAll(geographicalCodes)) .map(Map.Entry::getKey) .collect(Collectors.toCollection(TreeSet::new)); } EntsoeCaseRepository(EntsoeCaseRepositoryConfig config, List<EntsoeFormat> formats, ReadOnlyDataSourceFactory dataSourceFactory);   EntsoeCaseRepository(EntsoeCaseRepositoryConfig config, ComputationManager computationManager); static CaseRepository create(ComputationManager computationManager); EntsoeCaseRepositoryConfig getConfig(); @Override List<Network> load(DateTime date, CaseType type, Country country); @Override boolean isDataAvailable(DateTime date, CaseType type, Country country); @Override Set<DateTime> dataAvailable(CaseType type, Set<Country> countries, Interval interval);  }
@Test public void testDataAvailable() throws Exception { assertTrue(caseRepository.dataAvailable(CaseType.SN, EnumSet.of(Country.FR), Interval.parse("2013-01-13T00:00:00+01:00/2013-01-13T00:30:00+01:00")) .equals(Sets.newHashSet(DateTime.parse("2013-01-13T00:15:00+01:00")))); assertTrue(caseRepository.dataAvailable(CaseType.SN, EnumSet.of(Country.FR), Interval.parse("2013-01-13T00:00:00+01:00/2013-01-13T01:00:00+01:00")) .equals(Sets.newHashSet(DateTime.parse("2013-01-13T00:15:00+01:00"), DateTime.parse("2013-01-13T00:45:00+01:00")))); assertTrue(caseRepository.dataAvailable(CaseType.SN, EnumSet.of(Country.BE, Country.DE), Interval.parse("2013-01-13T00:00:00+01:00/2013-01-13T01:00:00+01:00")) .isEmpty()); assertTrue(caseRepository.dataAvailable(CaseType.SN, EnumSet.of(Country.FR), Interval.parse("2013-01-14T00:00:00+01:00/2013-01-14T01:00:00+01:00")) .equals(Sets.newHashSet(DateTime.parse("2013-01-14T00:15:00+01:00"), DateTime.parse("2013-01-14T00:30:00+01:00")))); }