package com.oguerreiro.resilient.web.rest;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.oguerreiro.resilient.domain.VariableClassType;
import com.oguerreiro.resilient.repository.VariableClassTypeRepository;
import com.oguerreiro.resilient.service.VariableClassService;
import com.oguerreiro.resilient.service.VariableClassTypeService;
import com.oguerreiro.resilient.service.dto.VariableClassDTO;
import com.oguerreiro.resilient.service.dto.VariableClassTypeDTO;

/**
 * REST controller for managing {@link com.oguerreiro.resilient.domain.VariableClassType}.
 */
@RestController
@RequestMapping("/api/variable-class-types")
public class VariableClassTypeResource
    extends AbstractResilientResource<VariableClassType, VariableClassTypeDTO, Long> {
  private static final String ENTITY_NAME = "variableClassType";

  private final VariableClassService variableClassService;

  public VariableClassTypeResource(VariableClassTypeService variableClassTypeService,
      VariableClassTypeRepository variableClassTypeRepository, VariableClassService variableClassService) {
    super(VariableClassType.class, variableClassTypeRepository, variableClassTypeService);
    this.variableClassService = variableClassService;
  }

  /* Abstract methods impl*/
  @Override
  protected String getEntityName() {
    return ENTITY_NAME;
  }

  /* VariableClassTypeResource endpoints */
  @GetMapping("/classes/forVariable/{variableId}")
  public List<VariableClassDTO> getAllForVariable(@PathVariable("variableId") Long variableId) {
    log.debug("REST request to get all getAllForVariable Id : {}", variableId);
    return variableClassService.getAllForVariable(variableId);
  }
}
