@@ -188,6 +188,42 @@ public String getCssStyle()
188188 return sb .toString ();
189189 }
190190
191+ /**
192+ * Converts the XML filter entries for a single conditional format into a URL query string suitable for
193+ * use as a {@link GWTConditionalFormat} filter value.
194+ */
195+ @ NotNull
196+ public static String buildFilterQueryString (@ Nullable ConditionalFormatFiltersType filters )
197+ {
198+ SimpleFilter simpleFilter = new SimpleFilter ();
199+ if (null != filters )
200+ {
201+ ConditionalFormatFilterType [] filterArray = filters .getFilterArray ();
202+ if (filterArray != null )
203+ {
204+ for (ConditionalFormatFilterType filter : filterArray )
205+ {
206+ CompareType compareType = CompareType .getByURLKey (filter .getOperator ().toString ());
207+ if (compareType != null )
208+ simpleFilter .addClause (compareType .createFilterClause (FieldKey .fromParts (COLUMN_NAME ), filter .getValue ()));
209+ else
210+ LOG .warn ("Could not find CompareType for " + filter .getOperator () + ", ignoring" );
211+ }
212+ }
213+ }
214+ try
215+ {
216+ // Process it through a URL to get the query string equivalent
217+ URLHelper url = new URLHelper ("/test" );
218+ simpleFilter .applyToURL (url , DATA_REGION_NAME );
219+ return url .getQueryString ();
220+ }
221+ catch (URISyntaxException e )
222+ {
223+ throw UnexpectedException .wrap (e );
224+ }
225+ }
226+
191227 /** Converts from the XMLBean representation to our standard class. Does not save to the database */
192228 @ NotNull
193229 public static List <ConditionalFormat > convertFromXML (ConditionalFormatsType conditionalFormats )
@@ -200,38 +236,7 @@ public static List<ConditionalFormat> convertFromXML(ConditionalFormatsType cond
200236 for (ConditionalFormatType xmlFormat : conditionalFormats .getConditionalFormatArray ())
201237 {
202238 ConditionalFormat format = new ConditionalFormat ();
203- SimpleFilter simpleFilter = new SimpleFilter ();
204- ConditionalFormatFiltersType filters = xmlFormat .getFilters ();
205- if (null != filters )
206- {
207- ConditionalFormatFilterType [] filterArray = filters .getFilterArray ();
208- if (filterArray != null )
209- {
210- for (ConditionalFormatFilterType filter : filterArray )
211- {
212- CompareType compareType = CompareType .getByURLKey (filter .getOperator ().toString ());
213- if (compareType != null )
214- {
215- simpleFilter .addClause (compareType .createFilterClause (FieldKey .fromParts (COLUMN_NAME ), filter .getValue ()));
216- }
217- else
218- {
219- LOG .warn ("Could not find CompareType for " + filter .getOperator () + ", ignoring" );
220- }
221- }
222- }
223- }
224- try
225- {
226- // Process it through a URL to get the query string equivalent
227- URLHelper url = new URLHelper ("/test" );
228- simpleFilter .applyToURL (url , DATA_REGION_NAME );
229- format .setFilter (url .getQueryString ());
230- }
231- catch (URISyntaxException e )
232- {
233- throw UnexpectedException .wrap (e );
234- }
239+ format .setFilter (buildFilterQueryString (xmlFormat .getFilters ()));
235240 if (xmlFormat .isSetBold () && xmlFormat .getBold ())
236241 {
237242 format .setBold (true );
0 commit comments