1 | package com.ether; |
---|
2 | |
---|
3 | import com.ether.annotation.ControllerMethod; |
---|
4 | import com.ether.annotation.Mandatory; |
---|
5 | import com.ether.annotation.ParamName; |
---|
6 | import com.medias.database.objects.Parametre; |
---|
7 | import com.medias.database.objects.Plateforme; |
---|
8 | import net.sf.json.JSONObject; |
---|
9 | import org.apache.commons.logging.Log; |
---|
10 | import org.apache.commons.logging.LogFactory; |
---|
11 | import org.jetbrains.annotations.NotNull; |
---|
12 | import org.springframework.beans.factory.annotation.Required; |
---|
13 | import org.springframework.web.servlet.ModelAndView; |
---|
14 | |
---|
15 | import javax.servlet.http.HttpServletRequest; |
---|
16 | import javax.servlet.http.HttpServletResponse; |
---|
17 | import java.util.HashMap; |
---|
18 | import java.util.List; |
---|
19 | import java.util.Map; |
---|
20 | |
---|
21 | /** |
---|
22 | * @author vmipsl |
---|
23 | * @date 17 feb 2011 |
---|
24 | */ |
---|
25 | public class Controller |
---|
26 | extends ControllerEther |
---|
27 | { |
---|
28 | /** *********************************************************** **/ |
---|
29 | /** *********************** VIEWS ***************************** **/ |
---|
30 | /** *********************************************************** **/ |
---|
31 | // Default view if methodName is unknown |
---|
32 | public ModelAndView home( final HttpServletRequest request, final HttpServletResponse response ) |
---|
33 | throws WebException |
---|
34 | { |
---|
35 | return new ModelAndView( "index" ); |
---|
36 | } |
---|
37 | |
---|
38 | @ControllerMethod(view = VIEW_VISUALIZATION) |
---|
39 | public Map<String, Object> view() |
---|
40 | throws ServiceException |
---|
41 | { |
---|
42 | return new HashMap<String, Object>(); |
---|
43 | } |
---|
44 | |
---|
45 | @ControllerMethod(view = VIEW_VISUALIZATION_PARAMETER_BY_PLATEFORM) |
---|
46 | public Map<String, Object> viewParametersByPlateform() |
---|
47 | throws ServiceException |
---|
48 | { |
---|
49 | final List<Plateforme> plateforms = _etherService.getAllPlateforms(); |
---|
50 | |
---|
51 | final Map<String, Object> model = new HashMap<String, Object>(); |
---|
52 | model.put( "plateforms", getJsonHelper().toJSON( plateforms ) ); |
---|
53 | return model; |
---|
54 | } |
---|
55 | |
---|
56 | /** *********************************************************** **/ |
---|
57 | /** *********************** CALLS ***************************** **/ |
---|
58 | /** ********************************************************** **/ |
---|
59 | @ControllerMethod(jsonResult = true) |
---|
60 | public JSONObject searchParametersByPlateform( @Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId ) |
---|
61 | throws ServiceException, WebException |
---|
62 | { |
---|
63 | final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); |
---|
64 | |
---|
65 | final JSONObject result = new JSONObject(); |
---|
66 | result.put( ParameterConstants.PARAMETER_PARAMETERS, getJsonHelper().toJSON( parametersByPlateform ) ); |
---|
67 | return result; |
---|
68 | } |
---|
69 | |
---|
70 | @Required |
---|
71 | public void setEtherService( @NotNull final EtherService etherService ) |
---|
72 | { |
---|
73 | _etherService = etherService; |
---|
74 | } |
---|
75 | |
---|
76 | private static final Log LOGGER = LogFactory.getLog( Controller.class ); |
---|
77 | |
---|
78 | private static final String VIEW_VISUALIZATION = "visualization/visu"; |
---|
79 | private static final String VIEW_VISUALIZATION_PARAMETER_BY_PLATEFORM = "visualization/visu_parameter_by_pf"; |
---|
80 | |
---|
81 | private EtherService _etherService; |
---|
82 | } |
---|