package com.oguerreiro.resilient.service;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oguerreiro.resilient.domain.enumeration.OrganizationNature;
import com.oguerreiro.resilient.repository.OrganizationTypeExtendedRepository;
import com.oguerreiro.resilient.repository.OrganizationTypeRepository;
import com.oguerreiro.resilient.service.dto.OrganizationTypeDTO;
import com.oguerreiro.resilient.service.mapper.OrganizationTypeMapper;

/**
 * Service Implementation for managing {@link com.oguerreiro.resilient.domain.OrganizationType}.
 */
@Service
@Transactional
public class OrganizationTypeExtendedService extends OrganizationTypeService {

    private final Logger log = LoggerFactory.getLogger(OrganizationTypeExtendedService.class);

    private final OrganizationTypeExtendedRepository organizationTypeRepository;
    private final OrganizationTypeMapper organizationTypeMapper;

    public OrganizationTypeExtendedService(OrganizationTypeExtendedRepository organizationTypeRepository, OrganizationTypeMapper organizationTypeMapper) {
    	super(organizationTypeRepository, organizationTypeMapper);
    	
        this.organizationTypeRepository = organizationTypeRepository;
        this.organizationTypeMapper = organizationTypeMapper;
    }

    @Transactional(readOnly = true)
    public List<OrganizationTypeDTO> findByNatureIn(List<OrganizationNature> natures) {
        log.debug("Request to get OrganizationTypes restricted by OrganizationNature's");
        return organizationTypeRepository
            .findByNatureIn(natures)
            .stream()
            .map(organizationTypeMapper::toDto)
            .collect(Collectors.toCollection(LinkedList::new));
    }

}
