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 net.sf.json.JSONObject; |
---|
7 | import org.apache.commons.logging.Log; |
---|
8 | import org.apache.commons.logging.LogFactory; |
---|
9 | import org.jetbrains.annotations.NotNull; |
---|
10 | import org.springframework.beans.factory.annotation.Required; |
---|
11 | import org.springframework.web.servlet.ModelAndView; |
---|
12 | |
---|
13 | import javax.servlet.http.HttpServletRequest; |
---|
14 | import javax.servlet.http.HttpServletResponse; |
---|
15 | import java.util.HashMap; |
---|
16 | import java.util.List; |
---|
17 | import java.util.Map; |
---|
18 | |
---|
19 | /** |
---|
20 | * @author vmipsl |
---|
21 | * @date 17 feb 2011 |
---|
22 | */ |
---|
23 | public 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 | } |
---|