How to obtain Choices from Filters?
Hi there,
I'm trying to obtain the options from a saved filter. "Choices"

try {
java.lang.String username = "testuser";
wt.session.SessionHelper.manager.setPrincipal(username);
wt.filter.NavigationCriteria navigationCriteria = wt.filter.NavigationCriteriaHelper.service.getNavigationCriteria("MyFilter");
if (navigationCriteria == null) {
java.lang.System.out.println("Filter 'MyFilter' not found or user does not have access.");
} else {
java.lang.System.out.println("Navigation Criteria Name: " + navigationCriteria.toString());
java.util.List<wt.filter.NavigationFilter2> filters = (java.util.List<wt.filter.NavigationFilter2>)navigationCriteria.getFilters();
if (filters == null || filters.isEmpty()) {
java.lang.System.out.println("No filters found for the Navigation Criteria.");
} else {
for (wt.filter.NavigationFilter2 filter : filters) {
java.lang.System.out.println("Filter Name: " + filter.toString());
java.lang.System.out.println("Filter Type: " + filter.getType());
}
}
}
} catch (java.lang.Exception e) {
java.lang.System.out.println("Error switching session: " + e.getMessage());
} finally {
java.lang.System.out.println("Process completed.");
}Here my logs:
Navigation Criteria Name: wt.filter.NavigationCriteria:xxxxxx Filter Name: com.ptc.windchill.option.model.ATONavigationFilter:xxxxxx Filter Type: ATONavigation Filter Process completed.
I think I'm sucessfully obtain the filter but i can't reach the Choices from this type. I need to parse the Choices.
Also i'm trying to get it from NavigationFilter2, i've found a javadoc for this i think i can parse it from the json if i call "getJSONFromFilter(NavigationFilter2 navFilter)" getJSONFromFilter function.

So i've used code like that;
java.util.List<wt.filter.NavigationFilter2> filters =
(java.util.List<wt.filter.NavigationFilter2>) navigationCriteria.getFilters();
for (wt.filter.NavigationFilter2 navFilter : filters) {
String jsonRepresentation = wt.filter.NavigationFilterDelegate2.getJSONFromFilter(navFilter);
System.out.println(jsonRepresentation);
}But i couldn't compile this code because NavigationFilterDelegate2 is an interface so i can't call it directly.
Regards,



