1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.crm.web.portlet;
35
36 import java.util.HashMap;
37
38 import javax.servlet.http.HttpServletRequest;
39
40 import fr.paris.lutece.plugins.crm.business.portlet.DemandTypePortlet;
41 import fr.paris.lutece.plugins.crm.business.portlet.DemandTypePortletHome;
42 import fr.paris.lutece.plugins.crm.service.category.CategoryService;
43 import fr.paris.lutece.plugins.crm.util.CrmUtils;
44 import fr.paris.lutece.plugins.crm.util.constants.CRMConstants;
45 import fr.paris.lutece.portal.business.portlet.PortletHome;
46 import fr.paris.lutece.portal.web.portlet.PortletJspBean;
47 import fr.paris.lutece.util.html.HtmlTemplate;
48
49
50
51
52 public class DemandTypePortletJspBean extends PortletJspBean
53 {
54
55
56 private CategoryService _categoryService = CategoryService.getService( );
57
58
59
60
61 @Override
62 public String getCreate( HttpServletRequest request )
63 {
64 HashMap<String, Object> model = new HashMap<String, Object>( );
65 String strIdPage = request.getParameter( PARAMETER_PAGE_ID );
66 String strIdPortletType = request.getParameter( PARAMETER_PORTLET_TYPE_ID );
67 model.put( CRMConstants.MARK_CATEGORIES_LIST, _categoryService.getCategories( getLocale( ), true, true ) );
68 HtmlTemplate template = getCreateTemplate( strIdPage, strIdPortletType, model );
69
70 return template.getHtml( );
71 }
72
73
74
75
76 @Override
77 public String getModify( HttpServletRequest request )
78 {
79
80 HashMap<String, Object> model = new HashMap<String, Object>( );
81 String strPortletId = request.getParameter( PARAMETER_PORTLET_ID );
82 int nPortletId = CrmUtils.convertStringToInt( strPortletId );
83 DemandTypePortlet../../../fr/paris/lutece/plugins/crm/business/portlet/DemandTypePortlet.html#DemandTypePortlet">DemandTypePortlet portlet = (DemandTypePortlet) PortletHome.findByPrimaryKey( nPortletId );
84 model.put( CRMConstants.MARK_CATEGORIES_LIST, _categoryService.getCategories( getLocale( ), true, true ) );
85 model.put( CRMConstants.MARK_CATEGORY_ID_CATEGORY, portlet.getIdCategory( ) );
86
87 HtmlTemplate template = getModifyTemplate( portlet, model );
88
89 return template.getHtml( );
90 }
91
92
93
94
95 @Override
96 public String doCreate( HttpServletRequest request )
97 {
98
99 DemandTypePortletiness/portlet/DemandTypePortlet.html#DemandTypePortlet">DemandTypePortlet portlet = new DemandTypePortlet( );
100
101 String strCategory = request.getParameter( CRMConstants.PARAMETER_CATEGORY_ID_CATEGORY );
102 int nIdCategory = CrmUtils.convertStringToInt( strCategory );
103
104 String strErrorUrl = setPortletCommonData( request, portlet );
105
106 if ( strErrorUrl != null )
107 {
108 return strErrorUrl;
109 }
110
111 portlet.setIdCategory( nIdCategory );
112
113
114 DemandTypePortletHome.getInstance( ).create( portlet );
115
116
117 return getPageUrl( portlet.getPageId( ) );
118 }
119
120
121
122
123 @Override
124 public String doModify( HttpServletRequest request )
125 {
126
127 String strPortletId = request.getParameter( PARAMETER_PORTLET_ID );
128 String strCategory = request.getParameter( CRMConstants.PARAMETER_CATEGORY_ID_CATEGORY );
129
130 int nPortletId = CrmUtils.convertStringToInt( strPortletId );
131 int nIdCategory = CrmUtils.convertStringToInt( strCategory );
132
133 DemandTypePortlet../../../fr/paris/lutece/plugins/crm/business/portlet/DemandTypePortlet.html#DemandTypePortlet">DemandTypePortlet portlet = (DemandTypePortlet) PortletHome.findByPrimaryKey( nPortletId );
134
135 String strErrorUrl = setPortletCommonData( request, portlet );
136
137 if ( strErrorUrl != null )
138 {
139 return strErrorUrl;
140 }
141
142 portlet.setIdCategory( nIdCategory );
143
144
145 DemandTypePortletHome.getInstance( ).update( portlet );
146
147
148 return getPageUrl( portlet.getPageId( ) );
149 }
150
151 }