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.document.business.portlet;
35
36 import fr.paris.lutece.portal.service.util.AppPropertiesService;
37
38
39
40
41
42
43
44 public class PortletFilter
45 {
46 public static final String CONSTANTE_SPACE_STRING = " ";
47 public static final String PAGE_NAME = AppPropertiesService.getProperty( "document.filter.page_name", "page_name" );
48 public static final String PORTLET_NAME = AppPropertiesService.getProperty( "document.filter.portlet_name",
49 "portlet_name" );
50 public static final String PAGE_ID = AppPropertiesService.getProperty( "document.filter.page_id", "page_id" );
51 public static final int PROPERTY_NUMBER_OF_MAX_LATEST_PORTLETS_DISPLAY = AppPropertiesService.getPropertyInt( "document.filter.number_of_max_latest_portlets_display",
52 10 );
53 private static final String SQL_FILTER_PAGE_NAME = " f.name like ? ";
54 private static final String SQL_FILTER_BY_PAGE_ID = " a.id_page=? ";
55 private static final String SQL_FILTER_BY_PORTLET_NAME = " a.name like ? ";
56 private boolean _bIsDisplayLatestPortlets;
57 private String[] _tabPageName;
58 private String[] _tabPortletName;
59 private Integer _nIdPage;
60 private String _portletFilterType;
61 private String _strSearchValue;
62
63
64
65
66
67 public void setPageName( String[] strPageTitle )
68 {
69 this._tabPageName = strPageTitle;
70 }
71
72
73
74
75
76 public String[] getPageName( )
77 {
78 return _tabPageName;
79 }
80
81
82
83
84
85 public void setPortletName( String[] strPortletTitle )
86 {
87 this._tabPortletName = strPortletTitle;
88 }
89
90
91
92
93
94 public String[] getPortletName( )
95 {
96 return _tabPortletName;
97 }
98
99
100
101
102
103 public void setIdPage( Integer nIdPage )
104 {
105 this._nIdPage = nIdPage;
106 }
107
108
109
110
111
112 public Integer getIdPage( )
113 {
114 return _nIdPage;
115 }
116
117
118
119
120
121
122 public void setDisplayLatestPortlets( boolean bIsDisplayLatestPortlets )
123 {
124 this._bIsDisplayLatestPortlets = bIsDisplayLatestPortlets;
125 }
126
127
128
129
130
131 public boolean isDisplayLatestPortlets( )
132 {
133 return _bIsDisplayLatestPortlets;
134 }
135
136
137
138
139
140 public void setPortletFilterType( String portletFilterType )
141 {
142 this._portletFilterType = portletFilterType;
143 }
144
145
146
147
148
149 public String getPortletFilterType( )
150 {
151 return _portletFilterType;
152 }
153
154
155
156
157
158
159 public String getSQLFilter( )
160 {
161 if ( ( _portletFilterType != null ) && !_bIsDisplayLatestPortlets )
162 {
163 StringBuilder sbSQL = new StringBuilder( );
164
165 if ( _portletFilterType.equals( PAGE_NAME ) && ( _tabPageName != null ) )
166 {
167 sbSQL.append( " ( " );
168
169 for ( int i = 0; i < _tabPageName.length; i++ )
170 {
171 sbSQL.append( SQL_FILTER_PAGE_NAME );
172
173 if ( i != ( _tabPageName.length - 1 ) )
174 {
175 sbSQL.append( " OR " );
176 }
177 }
178
179 sbSQL.append( " ) " );
180 }
181 else if ( _portletFilterType.equals( PORTLET_NAME ) && ( _tabPortletName != null ) )
182 {
183 sbSQL.append( " ( " );
184
185 for ( int i = 0; i < _tabPortletName.length; i++ )
186 {
187 sbSQL.append( SQL_FILTER_BY_PORTLET_NAME );
188
189 if ( i != ( _tabPortletName.length - 1 ) )
190 {
191 sbSQL.append( " OR " );
192 }
193 }
194
195 sbSQL.append( " ) " );
196 }
197 else if ( _portletFilterType.equals( PAGE_ID ) && ( _nIdPage != null ) )
198 {
199 sbSQL.append( SQL_FILTER_BY_PAGE_ID );
200 }
201
202 return sbSQL.toString( );
203 }
204
205 return null;
206 }
207
208
209
210
211
212 public void setSearchValue( String strSearchValue )
213 {
214 this._strSearchValue = strSearchValue;
215 }
216
217
218
219
220
221 public String getSearchValue( )
222 {
223 return _strSearchValue;
224 }
225 }