1 package eu
.etaxonomy
.cdm
.remote
.controller
;
3 import java
.io
.IOException
;
6 import javax
.servlet
.http
.HttpServletRequest
;
7 import javax
.servlet
.http
.HttpServletResponse
;
9 import org
.apache
.log4j
.Logger
;
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
;
17 import eu
.etaxonomy
.cdm
.api
.service
.IStatisticsService
;
18 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.Statistics
;
19 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsConfigurator
;
20 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsPartEnum
;
21 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsTypeEnum
;
25 * @created 07.11.2012 this class provides counting of different entities in a
30 @RequestMapping(value
= { "/statistic" })
31 public class StatisticsController
{
33 private static final Logger logger
= Logger
34 .getLogger(StatisticsController
.class);
36 private static final List
<StatisticsTypeEnum
> D
= null;
38 private IStatisticsService service
;
41 public void setService(IStatisticsService service
) {
42 this.service
= service
;
45 StatisticsConfigurator configurator
;
51 * part=ALL&part=CLASSIFICATION&type=DESCRIPTIVE_SOURCE_REFERENCES&type=ALL_TAXA&type=ACCEPTED_TAXA&type=SYNONYMS&type=TAXON_NAMES&type=ALL_REFERENCES&type=NOMECLATURAL_REFERENCES
61 @RequestMapping(method
= RequestMethod
.GET
)
62 public ModelAndView
doStatistics(
63 @RequestParam(value
= "part", required
= false) String
[] part
,
64 @RequestParam(value
= "type", required
= false) String
[] type
,
65 HttpServletRequest request
, HttpServletResponse response
)
68 configurator
= new StatisticsConfigurator();
69 ModelAndView mv
= new ModelAndView();
71 createConfigurator(part
, type
);
72 // service.getStatistics(configurator);
73 Statistics statistics
= service
.getCountStatistics(configurator
);
74 logger
.info("doStatistics() - " + request
.getServletPath());
76 mv
.addObject(statistics
);
80 private void createConfigurator(String
[] part
, String
[] type
) {
83 for (String string
: part
) {
84 configurator
.addPart(StatisticsPartEnum
.valueOf(string
));
87 configurator
.addPart(StatisticsPartEnum
.ALL
);
90 for (String string
: type
) {
91 configurator
.addType(StatisticsTypeEnum
.valueOf(string
));
97 private void setDefaultType() {
98 // for default choose all types:
99 for (StatisticsTypeEnum type
: StatisticsTypeEnum
.values()) {
100 configurator
.addType(type
);