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.VariableClass;
import com.oguerreiro.resilient.repository.VariableClassRepository;
import com.oguerreiro.resilient.service.dto.VariableClassDTO;
import com.oguerreiro.resilient.service.mapper.VariableClassMapper;

/**
 * Service Implementation for managing {@link com.oguerreiro.resilient.domain.VariableClass}.
 */
@Service
@Transactional
public class VariableClassService extends AbstractResilientService<VariableClassDTO, VariableClass, Long> {
  private final VariableClassRepository variableClassRepository;
  private final VariableClassMapper variableClassMapper;

  public VariableClassService(VariableClassRepository variableClassRepository,
      VariableClassMapper variableClassMapper) {
    super(VariableClass.class, variableClassRepository, variableClassMapper);
    this.variableClassRepository = variableClassRepository;
    this.variableClassMapper = variableClassMapper;
  }

  public List<VariableClassDTO> getAllForVariable(Long variableId) {
    log.debug("REST request to get all getAllForVariable Id : {}", variableId);
    //@formatter:off
    return variableClassRepository.getAllForVariable(variableId)
            .stream()
            .map(variableClassMapper::toDto).collect(Collectors.toCollection(LinkedList::new));
    //@formatter:on
  }
}
