// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/StopStore.java
// public class StopStore {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(StopStore.class);
// 
//     private static Map<String, String> store = new HashMap<>();
//     private static Set<String> missing = new HashSet<>();
// 
//     public static Optional<String> getQuayFromCode(String dataOwner, String stopCode) {
//         String key = dataOwner+"|"+stopCode;
//         if (store.containsKey(key)) {
//             return Optional.of(store.get(key));
//         }
//         missing.add(key);
//         return Optional.empty();
//     }
// 
//     public static boolean stopExists(String quayOrStopCode) {
//         return store.values().contains(quayOrStopCode);
//     }
// 
//     public static Map<String, String> getStore() {
//         return store;
//     }
// 
//     public static Set<String> getMissing() {
//         return missing;
//     }
// 
//     public static void setStore(Map<String, String> storeData) {
//         store = storeData;
//     }
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/util/DateTimeUtil.java
// public class DateTimeUtil {
// 
//     public static ZonedDateTime getTime(LocalDate date, String time) {
//         String[] split = time.split(":");
//         int hour = Integer.valueOf(split[0]);
//         boolean addDay = false;
//         if (hour > 23) {
//             hour = hour - 24;
//             addDay = true;
//         }
//         ZonedDateTime dateTime = ZonedDateTime.of(date, LocalTime.of(hour, Integer.valueOf(split[1]), Integer.valueOf(split[2])), Configuration.getZoneId());
//         if (addDay) {
//             dateTime = dateTime.plusDays(1);
//         }
//         return dateTime;
//     }
// 
//     public static long getMinutesTill(String time) {
//         String[] split = time.split(":");
//         return getMinutesTill(Integer.valueOf(split[0]), Integer.valueOf(split[1]));
//     }
// 
//     public static long getMinutesTill(int hour) {
//         return getMinutesTill(hour, 0);
//     }
// 
//     public static long getMinutesTill(int hour, int min) {
//         ZonedDateTime tomorrow = ZonedDateTime.now(Configuration.getZoneId()).plusDays(1).withHour(hour).withMinute(min);
//         return ChronoUnit.MINUTES.between(ZonedDateTime.now(Configuration.getZoneId()), tomorrow);
//     }
// }


import nl.crowndov.displaydirect.distribution.chb.StopStore;
import nl.crowndov.displaydirect.distribution.domain.travelinfo.*;
import nl.crowndov.displaydirect.distribution.util.DateTimeUtil;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;
package nl.crowndov.displaydirect.distribution.kv78;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class PlanningMapper {

    public static PassTime passTime(LocalDate date, Map<String, String> r, ZonedDateTime generated) {
        PassTime pt = new PassTime(r.get("DataOwnerCode"), date,
                r.get("LinePlanningNumber"), Integer.valueOf(r.get("JourneyNumber")), r.get("UserStopCode"));
        pt.setTargetArrivalTime((int) DateTimeUtil.getTime(date, r.get("TargetArrivalTime")).toEpochSecond());
        pt.setTargetDepartureTime((int) DateTimeUtil.getTime(date, r.get("TargetDepartureTime")).toEpochSecond());

        if ("ACCESSIBLE".contentEquals(r.get("WheelChairAccessible"))) {
            pt.setWheelchairAccessible(true);
        } else if ("NOTACCESSIBLE".contentEquals(r.get("WheelChairAccessible"))) {
            pt.setWheelchairAccessible(false);
        } // Else null = unknown

        if (r.get("NumberOfCoaches") != null) {
            pt.setNumberOfCoaches(Integer.valueOf(r.get("NumberOfCoaches")));
        }

// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/StopStore.java
// public class StopStore {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(StopStore.class);
// 
//     private static Map<String, String> store = new HashMap<>();
//     private static Set<String> missing = new HashSet<>();
// 
//     public static Optional<String> getQuayFromCode(String dataOwner, String stopCode) {
//         String key = dataOwner+"|"+stopCode;
//         if (store.containsKey(key)) {
//             return Optional.of(store.get(key));
//         }
//         missing.add(key);
//         return Optional.empty();
//     }
// 
//     public static boolean stopExists(String quayOrStopCode) {
//         return store.values().contains(quayOrStopCode);
//     }
// 
//     public static Map<String, String> getStore() {
//         return store;
//     }
// 
//     public static Set<String> getMissing() {
//         return missing;
//     }
// 
//     public static void setStore(Map<String, String> storeData) {
//         store = storeData;
//     }
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/util/DateTimeUtil.java
// public class DateTimeUtil {
// 
//     public static ZonedDateTime getTime(LocalDate date, String time) {
//         String[] split = time.split(":");
//         int hour = Integer.valueOf(split[0]);
//         boolean addDay = false;
//         if (hour > 23) {
//             hour = hour - 24;
//             addDay = true;
//         }
//         ZonedDateTime dateTime = ZonedDateTime.of(date, LocalTime.of(hour, Integer.valueOf(split[1]), Integer.valueOf(split[2])), Configuration.getZoneId());
//         if (addDay) {
//             dateTime = dateTime.plusDays(1);
//         }
//         return dateTime;
//     }
// 
//     public static long getMinutesTill(String time) {
//         String[] split = time.split(":");
//         return getMinutesTill(Integer.valueOf(split[0]), Integer.valueOf(split[1]));
//     }
// 
//     public static long getMinutesTill(int hour) {
//         return getMinutesTill(hour, 0);
//     }
// 
//     public static long getMinutesTill(int hour, int min) {
//         ZonedDateTime tomorrow = ZonedDateTime.now(Configuration.getZoneId()).plusDays(1).withHour(hour).withMinute(min);
//         return ChronoUnit.MINUTES.between(ZonedDateTime.now(Configuration.getZoneId()), tomorrow);
//     }
// }


// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/kv78/PlanningMapper.java
import nl.crowndov.displaydirect.distribution.chb.StopStore;
import nl.crowndov.displaydirect.distribution.domain.travelinfo.*;
import nl.crowndov.displaydirect.distribution.util.DateTimeUtil;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.Optional;

package nl.crowndov.displaydirect.distribution.kv78;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class PlanningMapper {

    public static PassTime passTime(LocalDate date, Map<String, String> r, ZonedDateTime generated) {
        PassTime pt = new PassTime(r.get("DataOwnerCode"), date,
                r.get("LinePlanningNumber"), Integer.valueOf(r.get("JourneyNumber")), r.get("UserStopCode"));
        pt.setTargetArrivalTime((int) DateTimeUtil.getTime(date, r.get("TargetArrivalTime")).toEpochSecond());
        pt.setTargetDepartureTime((int) DateTimeUtil.getTime(date, r.get("TargetDepartureTime")).toEpochSecond());

        if ("ACCESSIBLE".contentEquals(r.get("WheelChairAccessible"))) {
            pt.setWheelchairAccessible(true);
        } else if ("NOTACCESSIBLE".contentEquals(r.get("WheelChairAccessible"))) {
            pt.setWheelchairAccessible(false);
        } // Else null = unknown

        if (r.get("NumberOfCoaches") != null) {
            pt.setNumberOfCoaches(Integer.valueOf(r.get("NumberOfCoaches")));
        }

        Optional<String> quay = StopStore.getQuayFromCode(r.get("DataOwnerCode"), r.get("UserStopCode"));