package com.oguerreiro.resilient.service;

import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oguerreiro.resilient.domain.Dashboard;
import com.oguerreiro.resilient.repository.DashboardRepository;
import com.oguerreiro.resilient.service.dto.DashboardDTO;
import com.oguerreiro.resilient.service.mapper.DashboardMapper;

/**
 * Service Implementation for managing {@link com.oguerreiro.resilient.domain.DashboardComponent}.
 */
@Service
@Transactional
public class DashboardService extends AbstractResilientService<DashboardDTO, Dashboard, Long> {

  private final DashboardMapper dashboardMapper;
  private final DashboardRepository dashboardRepository;

  public DashboardService(DashboardRepository dashboardRepository, DashboardMapper dashboardMapper) {
    super(Dashboard.class, dashboardRepository, dashboardMapper);

    this.dashboardMapper = dashboardMapper;
    this.dashboardRepository = dashboardRepository;
  }

  @Transactional(readOnly = true)
  public List<DashboardDTO> findAllInternal() {
    log.debug("Request to get all active Dashboard's.");
    return this.dashboardRepository.findAllInternal().stream().map(dashboardMapper::toDto).collect(
        Collectors.toCollection(LinkedList::new));
  }
}
