Search in sources :

Example 1 with GymRepository

use of pokeraidbot.domain.gym.GymRepository in project pokeraidbot by magnusmickelsson.

the class TestServerMain method getGymRepositoryForConfig.

public static GymRepository getGymRepositoryForConfig(LocaleService localeService, ServerConfigRepository serverConfigRepository) {
    Map<String, Set<Gym>> gymsPerRegion = new HashMap<>();
    final Map<String, Config> configMap = serverConfigRepository.getAllConfig();
    System.out.println("Config has following servers: " + configMap.keySet());
    for (String server : configMap.keySet()) {
        final Config config = serverConfigRepository.getConfigForServer(server);
        final String region = config.getRegion();
        if (!gymsPerRegion.containsKey(region)) {
            final Set<Gym> gymsInRegion = new CSVGymDataReader("/gyms_" + region + ".csv").readAll();
            gymsPerRegion.put(region, gymsInRegion);
            System.out.println("Loaded " + gymsInRegion.size() + " gyms for server " + server + ".");
        }
    }
    return new GymRepository(gymsPerRegion, localeService);
}
Also used : Set(java.util.Set) GymRepository(pokeraidbot.domain.gym.GymRepository) HashMap(java.util.HashMap) Config(pokeraidbot.infrastructure.jpa.config.Config) Gym(pokeraidbot.domain.gym.Gym) CSVGymDataReader(pokeraidbot.infrastructure.CSVGymDataReader)

Aggregations

HashMap (java.util.HashMap)1 Set (java.util.Set)1 Gym (pokeraidbot.domain.gym.Gym)1 GymRepository (pokeraidbot.domain.gym.GymRepository)1 CSVGymDataReader (pokeraidbot.infrastructure.CSVGymDataReader)1 Config (pokeraidbot.infrastructure.jpa.config.Config)1