class LogbookDetailsCheckServiceImpl implements LogbookDetailsCheckService {

    @Override
    public List<LogbookCheckError> checkLFCandOperation(Map<String, EventModel> mapOpEvents,
                                                        Map<String, EventModel> mapLfcEvents) {
        List<LogbookCheckError> logbookCheckErrors = new ArrayList<>();
        LOGGER.debug("Check coherence between logbook operation and Lifecycles");

        EventModel eventLfc;
        EventModel eventOp;
        // check if all lifecylces events exist on the logbook operation and vice versa.
        Set<String> treatedEvents = new HashSet<>();
        for (String evType : mapLfcEvents.keySet()) {
            eventLfc = mapLfcEvents.get(evType);
            eventOp = mapOpEvents.get(evType);
            if (eventOp == null) {
                // case when the lifecycle event is not present in the operation logbook
                logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(),
                    eventLfc.getLfcId(), eventLfc.getEvType(),
                    String.format(SAVED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(),
                        eventLfc.getEvType()),
                    String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_EXISTS_MSG, LogbookEventName.EVTYPE.getValue(),
                        eventLfc.getEvType())));

            } else if (!eventLfc.getOutcome().equals(eventOp.getOutcome())) {
                // case when the logbook operation event is not conform to the lifecycle event
                logbookCheckErrors.add(new LogbookCheckError(eventLfc.getOperationId(),
                    eventLfc.getLfcId(), eventLfc.getEvType(),
                    String.format(SAVED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(),
                        eventLfc.getOutcome()),
                    String.format(EXPECTED_LOGBOOK_OP_LFC_NOT_CONFORME_MSG, LogbookEventName.OUTCOME.getValue(),
                        eventLfc.getOutcome())));
            }
            // collect treated events
            treatedEvents.add(evType);
        }
        // delete the checked logbook operation events
        mapOpEvents.keySet().removeAll(treatedEvents);

        // treat non-conform logbook operation events
        if (!mapOpEvents.isEmpty()) {
            // case when logbook operation contains events without corespondances on Lifecycles.
            mapOpEvents.values().forEach(event -> logbookCheckErrors.add(new LogbookCheckError(event.getOperationId(),
                event.getLfcId(), event.getEvType(),
                String.format(SAVED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(),
                    event.getEvType()),
                String.format(EXPECTED_LOGBOOK_OPERATION_EVENTS_NOT_EXIST_IN_LFC_MSG, LogbookEventName.EVTYPE.getValue(),
                    event.getEvType())))
            );
        }

        return logbookCheckErrors;
    }

}