source: ether_megapoli/trunk/web/src/com/ether/Controller.java @ 129

Last change on this file since 129 was 129, checked in by vmipsl, 13 years ago

Commit intermédiaire : plot dynamique (version instable et pas clean)

File size: 3.0 KB
Line 
1package com.ether;
2
3import com.ether.annotation.ControllerMethod;
4import com.ether.annotation.Mandatory;
5import com.ether.annotation.ParamName;
6import com.medias.database.objects.Parametre;
7import com.medias.database.objects.Plateforme;
8import net.sf.json.JSONObject;
9import org.apache.commons.logging.Log;
10import org.apache.commons.logging.LogFactory;
11import org.jetbrains.annotations.NotNull;
12import org.springframework.beans.factory.annotation.Required;
13import org.springframework.web.servlet.ModelAndView;
14
15import javax.servlet.http.HttpServletRequest;
16import javax.servlet.http.HttpServletResponse;
17import java.util.HashMap;
18import java.util.List;
19import java.util.Map;
20
21/**
22 * @author vmipsl
23 * @date 17 feb 2011
24 */
25public 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}
Note: See TracBrowser for help on using the repository browser.