/** * Create a map from string paths to index of QueryNodes in the ObjectStore query * * @return a map from string paths to the index of QueryNodes */ protected LinkedHashMap<String, Integer> getPathToIndex() { List<QuerySelectable> select = flatResults.getFlatSelect(); List<QuerySelectable> convSelect = new ArrayList<QuerySelectable>(); for (QuerySelectable qs : select) { while (qs instanceof PathExpressionField) { QueryObjectPathExpression qope = ((PathExpressionField) qs).getQope(); qs = qope.getSelect().get(((PathExpressionField) qs).getFieldNumber()); if (qs.equals(qope.getDefaultClass())) { qs = qope; } } convSelect.add(qs); } select = convSelect; LinkedHashMap<String, Integer> returnMap = new LinkedHashMap<String, Integer>(); for (String path : pathToQueryNode.keySet()) { QuerySelectable queryNode = pathToQueryNode.get(path); if ((queryNode instanceof QueryClass) || (queryNode instanceof QueryObjectPathExpression) || (queryNode instanceof QueryCollectionPathExpression)) { int index = select.indexOf(queryNode); if (index != -1) { returnMap.put(path, new Integer(index)); } } else if (queryNode instanceof QueryField) { String parentPath = path.substring(0, path.lastIndexOf('.')); queryNode = pathToQueryNode.get(parentPath); int index = select.indexOf(queryNode); if (index != -1) { returnMap.put(path, new Integer(index)); } } else { throw new RuntimeException(); } } return returnMap; }
/** * Return a List containing a ResultElement object for each element in the given row. The List * will be the same length as the view List. * * @param index the row of the results to fetch * @return the results row as ResultElement objects */ public MultiRow<ResultsRow<MultiRowValue<ResultElement>>> getResultElements(int index) { return translateRow(flatResults.get(index)); }