dnet-applications/apps/dnet-is-application/src/main/java/eu/dnetlib/is/resources/ResourcesUIController.java

30 lines
925 B
Java

package eu.dnetlib.is.resources;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import eu.dnetlib.is.resource.model.SimpleResourceType;
import eu.dnetlib.is.resource.repository.SimpleResourceTypeRepository;
@Controller
public class ResourcesUIController {
@Autowired
private SimpleResourceTypeRepository simpleResourceTypeRepository;
@GetMapping("/simpleResources")
public void simpleResources(@RequestParam final String type, final ModelMap map) {
map.addAttribute("type", type);
map.addAttribute("types", simpleResourceTypeRepository.findAll()
.stream()
.map(SimpleResourceType::getType)
.sorted()
.collect(Collectors.toList()));
}
}