Reputation: 29
Im currently trying to retrieve the column header used in a flexible search using java. However i cannot find any method in hybris to do so.
Here is my method to process the flexible search:
private List<List<Object>> processFlexibleQuery(final String flexibleQuery, final List<String> paramValues, final List<String> paramNames, final int headersCount)
{
final Map<String, Object> params = new HashMap<>();
final FlexibleSearchQuery query = new FlexibleSearchQuery(flexibleQuery);
final Class[] resultTypesArray = new Class[headersCount];
for (int i = 0; i < headersCount; i++)
{
resultTypesArray[i] = String.class;
}
query.setResultClassList(Arrays.asList(resultTypesArray));
if (paramValues.size() > 0 && paramNames.size() == paramValues.size())
{
for (int i = 0; i < paramValues.size(); i++)
{
params.put(paramNames.get(i).trim(), paramValues.get(i).trim());
}
}
query.addQueryParameters(params);
final SearchResult<List<Object>> result = flexibleSearchService.search(query);
final List<List<Object>> productList = result.getResult();
return productList;
}
My method work fine. I have looked up a couple of class provided by hybris to put the column header of the flexible search in a list but i cannot find any method. Basically if i process this FS in my method:
SELECT {p.code} as potato,
{p.name} as name
FROM {product as p}
I want to have "potato" and "name" in a list. I dont want to parse directly the query using the "as" because if there is a subquery in the flexible search this will bug out. Any idea?
Upvotes: 2
Views: 1882
Reputation: 5758
This functionality doing by hac already, so there must be solution for it. I haven't got exact solution but I can share tools which are similar functionality. You can check their source code for finding your way.
While I am searching urls, I find exact point for you.
Upvotes: 2