/** * Return the clause to constrain the browse to a specific value. Will return something of the * form: <code> * [field] = '[value]' * </code> such as: <code> * sort_value = 'some author' * </code> * * @return the value clause */ private void buildWhereClauseFilterValue(StringBuffer queryBuf, List params) { // assemble the value clause if we are to have one if (value != null && valueField != null) { buildWhereClauseOpInsert(queryBuf); queryBuf.append(" "); if (tableDis != null && tableMap != null) { queryBuf.append(table).append(".item_id=mappings.item_id "); } else { queryBuf.append(valueField); if (valuePartial) { queryBuf.append(" LIKE ? "); if (valueField.startsWith("sort_")) { params.add("%" + utils.truncateSortValue(value) + "%"); } else { params.add("%" + utils.truncateValue(value) + "%"); } } else { queryBuf.append("=? "); if (valueField.startsWith("sort_")) { params.add(utils.truncateSortValue(value)); } else { params.add(utils.truncateValue(value)); } } } } }
/** * Build the clauses required for the view used in focused or scoped queries. * * @param queryBuf * @param params */ private void buildFocusedSelectClauses(StringBuffer queryBuf, List<Serializable> params) { if (tableMap != null && tableDis != null) { queryBuf.append(tableMap).append(".distinct_id=").append(tableDis).append(".id"); queryBuf.append(" AND "); if (authority == null) { queryBuf.append(tableDis).append(".authority IS NULL"); queryBuf.append(" AND "); queryBuf.append(tableDis).append(".").append(valueField); if (valuePartial) { queryBuf.append(" LIKE ? "); if (valueField.startsWith("sort_")) { params.add("%" + utils.truncateSortValue(value) + "%"); } else { params.add("%" + utils.truncateValue(value) + "%"); } } else { queryBuf.append("=? "); if (valueField.startsWith("sort_")) { params.add(utils.truncateSortValue(value)); } else { params.add(utils.truncateValue(value)); } } } else { queryBuf.append(tableDis).append(".authority=?"); params.add(utils.truncateValue(authority, 100)); } } if (containerTable != null && containerIDField != null && containerID != -1) { if (tableMap != null) { if (tableDis != null) { queryBuf.append(" AND "); } queryBuf .append(tableMap) .append(".item_id=") .append(containerTable) .append(".item_id AND "); } queryBuf.append(containerTable).append(".").append(containerIDField); queryBuf.append("=? "); params.add(Integer.valueOf(containerID)); } }
/** * Get the clause to get the browse to start from a given focus value. Will return something of * the form: <code> * [field] (<[=] | >[=]) '[value]' * </code> such as: <code> * sort_value <= 'my text' * </code> * * @return the focus clause */ private void buildWhereClauseJumpTo(StringBuffer queryBuf, List params) { // get the operator (<[=] | >[=]) which the focus of the browse will // be matched using String focusComparator = getFocusComparator(); // assemble the focus clase if we are to have one // it will look like one of the following // - sort_value <= myvalue // - sort_1 >= myvalue if (focusField != null && focusValue != null) { buildWhereClauseOpInsert(queryBuf); queryBuf.append(" "); queryBuf.append(focusField); queryBuf.append(focusComparator); queryBuf.append("? "); if (focusField.startsWith("sort_")) { params.add(utils.truncateSortValue(focusValue)); } else { params.add(utils.truncateValue(focusValue)); } } }