use of org.mycore.parsers.bool.MCRCondition in project mycore by MyCoRe-Org.
the class MCRConditionTransformer method groupConditionsByIndex.
/**
* Build a table from index ID to a List of conditions referencing this
* index
*/
@SuppressWarnings("rawtypes")
public static HashMap<String, List<MCRCondition>> groupConditionsByIndex(MCRSetCondition cond) {
HashMap<String, List<MCRCondition>> table = new HashMap<>();
@SuppressWarnings("unchecked") List<MCRCondition> children = cond.getChildren();
for (MCRCondition child : children) {
String index = getIndex(child);
table.computeIfAbsent(index, k -> new ArrayList<>()).add(child);
}
return table;
}
use of org.mycore.parsers.bool.MCRCondition in project mycore by MyCoRe-Org.
the class MCRQLSearchUtils method getSolrQuery.
@SuppressWarnings("rawtypes")
public static SolrQuery getSolrQuery(MCRQuery query, Document input, HttpServletRequest request) {
int rows = Integer.parseInt(input.getRootElement().getAttributeValue("numPerPage", "10"));
List<String> returnFields = query.getReturnFields();
MCRCondition condition = query.getCondition();
HashMap<String, List<MCRCondition>> table;
if (condition instanceof MCRSetCondition) {
table = MCRConditionTransformer.groupConditionsByIndex((MCRSetCondition) condition);
} else {
// if there is only one condition its no set condition. we don't need to group
LOGGER.warn("Condition is not SetCondition.");
table = new HashMap<>();
ArrayList<MCRCondition> conditionList = new ArrayList<>();
conditionList.add(condition);
table.put("metadata", conditionList);
}
boolean booleanAnd = !(condition instanceof MCROrCondition<?>);
SolrQuery mergedSolrQuery = MCRConditionTransformer.buildMergedSolrQuery(query.getSortBy(), false, booleanAnd, table, rows, returnFields);
String mask = input.getRootElement().getAttributeValue("mask");
if (mask != null) {
mergedSolrQuery.setParam("mask", mask);
mergedSolrQuery.setParam("_session", request.getParameter("_session"));
}
return mergedSolrQuery;
}
Aggregations