source: project_source/trunk/web/src/com/ether/Controller.java @ 94

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

Import du projet source

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 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_PLATEFORM)
46    public Map<String, Object> viewAllPlateforms()
47            throws ServiceException
48    {
49        final List<Plateform> 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     * ********************************************************** *
60     */
61    @ControllerMethod(jsonResult = true)
62    public JSONObject searchParametersByPlateform( @Mandatory @ParamName(ParameterConstants.PARAMETER_ID) final Integer plateformId )
63            throws ServiceException, WebException
64    {
65//        final List<Parameter> parameters = new ArrayList<Parameter>( 3 );
66//        parameters.add( new Parameter( Long.valueOf( 1 ), "parameter1" ) );
67//        parameters.add( new Parameter( Long.valueOf( 2 ), "parameter2" ) );
68//        parameters.add( new Parameter( Long.valueOf( 3 ), "parameter3" ) );
69
70        final List<Parameter> parameters = _etherService.getAllParametersByPlateformId( plateformId );
71        final JSONObject result = new JSONObject();
72        result.put( "parameters", getJsonHelper().toJSON( parameters ) );
73        return result;
74    }
75
76    @Required
77    public void setEtherService( @NotNull final EtherService etherService )
78    {
79        _etherService = etherService;
80    }
81
82    private static final Log LOGGER = LogFactory.getLog( Controller.class );
83
84    private static final String VIEW_VISUALIZATION = "visualization/visu";
85    private static final String VIEW_VISUALIZATION_PLATEFORM = "visualization/visu_plateform";
86
87    private EtherService _etherService;
88}
Note: See TracBrowser for help on using the repository browser.