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.directory.modules.gismap.business.portlet;
35
36 import java.util.List;
37
38 import javax.servlet.http.HttpServletRequest;
39
40 import org.apache.commons.lang.BooleanUtils;
41
42 import fr.paris.lutece.plugins.directory.modules.gismap.business.DirectoryGismapSourceQuery;
43 import fr.paris.lutece.plugins.directory.modules.gismap.service.GismapDirectoryService;
44 import fr.paris.lutece.portal.business.portlet.Portlet;
45 import fr.paris.lutece.portal.business.portlet.PortletHome;
46 import fr.paris.lutece.portal.service.util.AppPropertiesService;
47 import fr.paris.lutece.util.xml.XmlUtil;
48
49
50
51
52 public class GismapDirectoryPortlet extends Portlet
53 {
54
55
56 private static final String TAG_GISMAP_PORTLET = "gismap-portlet";
57 private static final String TAG_GISMAP_PORTLET_CONTENT = "gismap-portlet-content";
58
59
60
61 public static final String GISMAP_DEFAULT_VIEW_PROPERTIES = "gismap.mainmap.defaultview";
62 public static final String MAX_LAYER_GEOJSON_PROPERTY = "directory-gismap.portlet.maxLayerGeojson";
63
64
65 private int _nPortletId;
66 private int _nStatus;
67 private int _nview;
68 private List<DirectoryGismapSourceQuery> _listMapSource;
69
70
71
72
73
74 public GismapDirectoryPortlet( )
75 {
76 }
77
78
79
80
81
82
83
84 @Override
85 public String getXml( HttpServletRequest request )
86 {
87 GismapDirectoryPortlet portlet = ( GismapDirectoryPortlet ) PortletHome.findByPrimaryKey( getId( ) );
88 List<DirectoryGismapSourceQuery> listGeojsonSources = portlet.getListMapSource( );
89
90 String viewId = String.valueOf( portlet.getView( ) );
91
92 StringBuffer strXml = new StringBuffer( );
93 XmlUtil.beginElement( strXml, TAG_GISMAP_PORTLET );
94 if ( !BooleanUtils.toBoolean( portlet.getDisplayPortletTitle( ) ) )
95 {
96 XmlUtil.addElementHtml( strXml, TAG_GISMAP_PORTLET_CONTENT, "<h3>" + portlet.getName( ) + "</h3>" );
97 }
98 XmlUtil.addElementHtml( strXml, TAG_GISMAP_PORTLET_CONTENT, GismapDirectoryService.getInstance( ).getMapTemplateWithDirectoryGismapSources(request, viewId, listGeojsonSources) );
99
100 XmlUtil.endElement( strXml, TAG_GISMAP_PORTLET );
101
102 return addPortletTags( strXml );
103 }
104
105
106
107
108
109
110
111 @Override
112 public String getXmlDocument( HttpServletRequest request )
113 {
114 return XmlUtil.getXmlHeader( ) + getXml( request );
115 }
116
117
118
119
120 public void update( )
121 {
122 GismapDirectoryPortletHome.getInstance( ).update( this );
123 }
124
125
126
127
128 @Override
129 public void remove( )
130 {
131 GismapDirectoryPortletHome.getInstance( ).remove( this );
132 }
133
134
135
136
137
138
139 public int getPortletId( )
140 {
141 return _nPortletId;
142 }
143
144
145
146
147
148
149 public void setPortletId( int nPortletId )
150 {
151 _nPortletId = nPortletId;
152 }
153
154
155
156
157
158
159
160 @Override
161 public int getStatus( )
162 {
163 return _nStatus;
164 }
165
166
167
168
169
170
171 @Override
172 public void setStatus( int nStatus )
173 {
174 _nStatus = nStatus;
175 }
176
177
178
179
180
181
182
183 public int getView( )
184 {
185
186 return _nview;
187 }
188
189
190
191
192
193
194 public void setView( int nView )
195 {
196 _nview = nView;
197 }
198
199
200
201
202
203
204 public List<DirectoryGismapSourceQuery> getListMapSource( )
205 {
206 return this._listMapSource;
207
208 }
209
210
211
212
213
214
215 public void setListMapSource(List<DirectoryGismapSourceQuery> listDirectoryGismapSource)
216 {
217 this._listMapSource = listDirectoryGismapSource;
218 }
219 }