2121import org .apache .commons .lang3 .StringUtils ;
2222import org .apache .logging .log4j .LogManager ;
2323import org .jetbrains .annotations .NotNull ;
24+ import org .jetbrains .annotations .Nullable ;
2425import org .labkey .api .collections .CaseInsensitiveHashMap ;
2526import org .labkey .api .data .Aggregate ;
2627import org .labkey .api .data .AnalyticsProviderItem ;
5253import java .util .List ;
5354import java .util .Map ;
5455
55- import static org .apache .commons .lang3 .StringUtils .isNotBlank ;
56-
5756public class QuerySettings
5857{
5958 public static final String URL_PARAMETER_PREFIX = "param." ;
@@ -98,7 +97,6 @@ public class QuerySettings
9897
9998 private final Map <String , Object > _queryParameters = new CaseInsensitiveHashMap <>();
10099
101-
102100 protected QuerySettings (String dataRegionName )
103101 {
104102 _dataRegionName = dataRegionName ;
@@ -118,7 +116,6 @@ public QuerySettings(ViewContext context, String dataRegionName)
118116 assert MemTracker .getInstance ().put (this );
119117 }
120118
121-
122119 /**
123120 * Init the QuerySettings using all the request parameters, from context.getPropertyValues().
124121 * @see UserSchema#getSettings(org.labkey.api.view.ViewContext, String, String)
@@ -132,7 +129,6 @@ public QuerySettings(ViewContext context, String dataRegionName, String queryNam
132129 assert MemTracker .getInstance ().put (this );
133130 }
134131
135-
136132 /**
137133 * @param params all parameters from URL or POST, including dataregion.filter parameters
138134 * @param dataRegionName prefix for filter params etc
@@ -146,7 +142,6 @@ public QuerySettings(PropertyValues params, String dataRegionName)
146142 assert MemTracker .getInstance ().put (this );
147143 }
148144
149-
150145 protected PropertyValues getPropertyValues (ViewContext context )
151146 {
152147 PropertyValues pvs = context .getBindPropertyValues ();
@@ -158,7 +153,6 @@ protected PropertyValues getPropertyValues(ViewContext context)
158153 return pvs ;
159154 }
160155
161-
162156 /**
163157 * @param url parameters for filter/sort
164158 */
@@ -167,7 +161,6 @@ public void setSortFilterURL(ActionURL url)
167161 setSortFilter (url .getPropertyValues ());
168162 }
169163
170-
171164 public void setSortFilter (PropertyValues pvs )
172165 {
173166 _filterSort = pvs ;
@@ -185,7 +178,7 @@ public void setSortFilter(PropertyValues pvs)
185178 }
186179 }
187180
188- protected String _getParameter (String param )
181+ protected @ Nullable String _getParameter (String param )
189182 {
190183 PropertyValue pv = _filterSort .getPropertyValue (param );
191184 if (pv == null )
@@ -198,18 +191,17 @@ protected String _getParameter(String param)
198191 Object [] a = (Object [])v ;
199192 v = a .length == 0 ? null : a [0 ];
200193 }
201- return v == null ? null : String .valueOf (v );
194+ return v == null ? null : StringUtils . trimToNull ( String .valueOf (v ) );
202195 }
203196
204197 public void init (ViewContext context )
205198 {
206199 init (getPropertyValues (context ));
207200 }
208201
209-
210202 /**
211203 * Initialize QuerySettings from the PropertyValues, binds all fields that are supported on the URL
212- *. such as viewName. Use setSortFilter() to provide sort filter parameters w/o affecting the other
204+ * such as viewName. Use setSortFilter() to provide sort filter parameters w/o affecting the other
213205 * properties.
214206 */
215207 public void init (PropertyValues pvs )
@@ -220,33 +212,35 @@ public void init(PropertyValues pvs)
220212 setAnalyticsProviders (pvs );
221213
222214 // Let URL parameter control which query we show, even if we don't show the Query drop-down menu to let the user choose
223- String param = param (QueryParam .queryName );
224- String queryName = StringUtils .trimToNull (_getParameter (param ));
215+ String queryName = _getParameter (param (QueryParam .queryName ));
225216 if (queryName != null )
226217 {
227218 setQueryName (queryName );
228219 }
229220
230221 if (getAllowChooseView ())
231222 {
232- String viewName = StringUtils . trimToNull ( _getParameter (param (QueryParam .viewName ) ));
223+ String viewName = _getParameter (param (QueryParam .viewName ));
233224 if (viewName != null )
234225 {
235226 setViewName (viewName );
236227 }
228+
237229 String ignoreFilter = _getParameter (param (QueryParam .ignoreFilter ));
238- try
230+ if ( ignoreFilter != null )
239231 {
240- if (isNotBlank (ignoreFilter ))
241- _ignoreUserFilter = (Boolean ) ConvertUtils .convert (ignoreFilter , Boolean .class );
242- }
243- catch (ConversionException e )
244- {
245- throwParameterParseException (QueryParam .ignoreFilter );
232+ try
233+ {
234+ _ignoreViewFilter = (Boolean ) ConvertUtils .convert (ignoreFilter , Boolean .class );
235+ }
236+ catch (ConversionException e )
237+ {
238+ throwParameterParseException (QueryParam .ignoreFilter );
239+ }
246240 }
247241
248242 String reportId = _getParameter (param (QueryParam .reportId ));
249- if (isNotBlank ( reportId ) )
243+ if (reportId != null )
250244 {
251245 var identifier = ReportService .get ().getReportIdentifier (reportId , null , null );
252246 if (null == identifier )
@@ -259,7 +253,7 @@ public void init(PropertyValues pvs)
259253 if (_showRows == ShowRows .PAGINATED )
260254 {
261255 String offsetParam = _getParameter (param (QueryParam .offset ));
262- if (isNotBlank ( offsetParam ) )
256+ if (offsetParam != null )
263257 {
264258 try
265259 {
@@ -274,7 +268,7 @@ public void init(PropertyValues pvs)
274268 }
275269
276270 String maxRowsParam = _getParameter (param (QueryParam .maxRows ));
277- if (isNotBlank ( maxRowsParam ) )
271+ if (maxRowsParam != null )
278272 {
279273 try
280274 {
@@ -295,7 +289,7 @@ public void init(PropertyValues pvs)
295289 }
296290
297291 String containerFilterNameParam = _getParameter (param (QueryParam .containerFilterName ));
298- if (isNotBlank ( containerFilterNameParam ) )
292+ if (containerFilterNameParam != null )
299293 {
300294 // fail fast
301295 if (null == ContainerFilter .getType (containerFilterNameParam ))
@@ -319,7 +313,7 @@ public void init(PropertyValues pvs)
319313 }
320314 }
321315
322- String columns = StringUtils . trimToNull ( _getParameter (param (QueryParam .columns ) ));
316+ String columns = _getParameter (param (QueryParam .columns ));
323317 if (null != columns )
324318 {
325319 String [] colArray = columns .split ("," );
@@ -333,7 +327,7 @@ public void init(PropertyValues pvs)
333327 }
334328 }
335329
336- String extraColumns = StringUtils . trimToNull ( _getParameter (param (QueryParam .extraColumns ) ));
330+ String extraColumns = _getParameter (param (QueryParam .extraColumns ));
337331 if (null != extraColumns )
338332 {
339333 String [] colArray = extraColumns .split ("," );
@@ -347,13 +341,13 @@ public void init(PropertyValues pvs)
347341 }
348342 }
349343
350- String selectionKey = StringUtils . trimToNull ( _getParameter (param (QueryParam .selectionKey ) ));
344+ String selectionKey = _getParameter (param (QueryParam .selectionKey ));
351345 if (null != selectionKey )
352346 setSelectionKey (selectionKey );
353347
354348 _parseQueryParameters (_filterSort );
355349
356- String allowHeaderLock = StringUtils . trimToNull ( _getParameter (param (QueryParam .allowHeaderLock ) ));
350+ String allowHeaderLock = _getParameter (param (QueryParam .allowHeaderLock ));
357351 if (null != allowHeaderLock )
358352 {
359353 try
0 commit comments