1 package org.cateproject.controller.common.annotation;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 import java.util.UUID;
6
7 import org.cateproject.controller.Cacheable;
8 import org.cateproject.controller.GenericController;
9 import org.cateproject.controller.GenericListController;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Controller;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RequestMethod;
14 import org.springframework.web.bind.annotation.RequestParam;
15 import org.springframework.web.servlet.ModelAndView;
16
17 import eu.etaxonomy.cdm.api.service.IAnnotationService;
18 import eu.etaxonomy.cdm.api.service.pager.Pager;
19 import eu.etaxonomy.cdm.model.common.Annotation;
20 import eu.etaxonomy.cdm.persistence.query.OrderHint;
21
22 @Controller
23 @RequestMapping(value = {"/annotation"})
24 public class AnnotationListController extends GenericListController<Annotation,UUID,IAnnotationService> {
25
26 public AnnotationListController() {
27 super(Annotation.class);
28 }
29
30 @Override
31 @Autowired
32 public void setService(IAnnotationService service) {
33 this.service = service;
34 }
35
36 @Override
37 @RequestMapping(method = RequestMethod.GET)
38 @Cacheable(value="annotation/list")
39 public ModelAndView get(@RequestParam(value = "class", required = false) Class<? extends Annotation> clazz,
40 @RequestParam(value = "page", required = false, defaultValue = GenericController.DEFAULT_PAGE) Integer page,
41 @RequestParam(value = "limit", required = false, defaultValue = GenericController.DEFAULT_LIMIT) Integer limit,
42 @RequestParam(value = "sort", required = false, defaultValue = GenericController.DEFAULT_SORT) List<OrderHint> orderHints) {
43 ModelAndView modelAndView = new ModelAndView("annotation/list");
44 List<String> propertyPaths = new ArrayList<String>();
45 propertyPaths.add("annotatedObj");
46 propertyPaths.add("createdBy");
47 propertyPaths.add("annotations");
48 Pager<Annotation> annotations = service.page(null,limit,page,orderHints,propertyPaths);
49 modelAndView.addObject(GenericController.ORDER_HINTS_KEY,orderHints);
50 modelAndView.addObject(GenericController.LIST_KEY,annotations);
51
52 return modelAndView;
53 }
54 }