source: ether_2012/web/src/com/ether/Controller.java @ 319

Last change on this file since 319 was 319, checked in by vmipsl, 12 years ago

Import du projet Ether pour le nouveau look 2012

File size: 3.1 KB
Line 
1package com.ether;
2
3import com.ether.annotation.ControllerMethod;
4import com.ether.annotation.Mandatory;
5import com.ether.annotation.ParamName;
6import net.sf.json.JSONObject;
7import org.apache.commons.logging.Log;
8import org.apache.commons.logging.LogFactory;
9import org.jetbrains.annotations.NotNull;
10import org.springframework.beans.factory.annotation.Required;
11import org.springframework.web.servlet.ModelAndView;
12
13import javax.servlet.http.HttpServletRequest;
14import javax.servlet.http.HttpServletResponse;
15import java.util.HashMap;
16import java.util.List;
17import java.util.Map;
18
19/**
20 * @author vmipsl
21 * @date 17 feb 2011
22 */
23public class Controller
24        extends ControllerEther
25{
26    /** *********************************************************** **/
27    /** *********************** VIEWS ***************************** **/
28    /**
29     * ********************************************************** *
30     */
31    // Default view if url's methodName is unknown
32    @ControllerMethod(view = "init")
33    public Map<String, Object> home()
34            throws WebException
35    {
36         return new HashMap<String, Object>();
37    }
38
39    @ControllerMethod(view = VIEW_VISUALIZATION)
40    public Map<String, Object> view()
41            throws ServiceException
42    {
43        return new HashMap<String, Object>();
44    }
45
46    @ControllerMethod(view = VIEW_VISUALIZATION_PLATEFORM)
47    public Map<String, Object> viewAllPlateforms()
48            throws ServiceException
49    {
50        final List<Plateform> plateforms = _etherService.getAllPlateforms();
51
52        final Map<String, Object> model = new HashMap<String, Object>();
53        model.put( "plateforms", getJsonHelper().toJSON( plateforms ) );
54        return model;
55    }
56
57    /** *********************************************************** **/
58    /** *********************** CALLS ***************************** **/
59    /**
60     * ********************************************************** *
61     */
62    @ControllerMethod(jsonResult = true)
63    public JSONObject searchParametersByPlateform( @Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId )
64            throws ServiceException, WebException
65    {
66//        final List<Parameter> parameters = new ArrayList<Parameter>( 3 );
67//        parameters.add( new Parameter( Long.valueOf( 1 ), "parameter1" ) );
68//        parameters.add( new Parameter( Long.valueOf( 2 ), "parameter2" ) );
69//        parameters.add( new Parameter( Long.valueOf( 3 ), "parameter3" ) );
70
71        final List<Parameter> parameters = _etherService.getAllParametersByPlateformId( plateformId );
72        final JSONObject result = new JSONObject();
73        result.put( "parameters", getJsonHelper().toJSON( parameters ) );
74        return result;
75    }
76
77    @Required
78    public void setEtherService( @NotNull final EtherService etherService )
79    {
80        _etherService = etherService;
81    }
82
83    private static final Log LOGGER = LogFactory.getLog( Controller.class );
84
85    private static final String VIEW_VISUALIZATION = "visualization/visu";
86    private static final String VIEW_VISUALIZATION_PLATEFORM = "visualization/visu_plateform";
87
88    private EtherService _etherService;
89}
Note: See TracBrowser for help on using the repository browser.