private String getAttributeFieldColunm(EntitySearchFilter filter) { Object object = null; if (null != filter.getAllowedValues() && filter.getAllowedValues().size() > 0) { object = filter.getAllowedValues().get(0); } else if (null != filter.getValue()) { object = filter.getValue(); } else if (null != filter.getStart()) { object = filter.getStart(); } else if (null != filter.getEnd()) { object = filter.getEnd(); } else { return null; } return this.getAttributeFieldColunm(object); }
private void addAttributeOrderQueryBlock( String searchTableNameAlias, StringBuffer query, EntitySearchFilter filter, String order) { if (order == null) { order = ""; } Object object = filter.getValue(); if (object == null) { object = filter.getStart(); } if (object == null) { object = filter.getEnd(); } if (null == object) { query .append(searchTableNameAlias) .append(".textvalue ") .append(order) .append(", ") .append(searchTableNameAlias) .append(".datevalue ") .append(order) .append(", ") .append(searchTableNameAlias) .append(".numvalue ") .append(order); return; } query .append(searchTableNameAlias) .append(".") .append(this.getAttributeFieldColunm(object)) .append(" "); query.append(order); }
private boolean appendValuedAttributeFilterQueryBlocks( EntitySearchFilter filter, int index, StringBuffer query, boolean hasAppendWhereClause) { String searchTableNameAlias = this.getEntitySearchTableName() + index; hasAppendWhereClause = this.verifyWhereClauseAppend(query, hasAppendWhereClause); query.append(searchTableNameAlias).append(".attrname = ? "); hasAppendWhereClause = this.addAttributeLangQueryBlock(searchTableNameAlias, query, filter, hasAppendWhereClause); if (filter.isLikeOption() && this.isForceTextCaseSearch()) { return hasAppendWhereClause; } if (filter.getAllowedValues() != null && filter.getAllowedValues().size() > 0) { hasAppendWhereClause = this.verifyWhereClauseAppend(query, hasAppendWhereClause); List<Object> allowedValues = filter.getAllowedValues(); for (int j = 0; j < allowedValues.size(); j++) { Object allowedValue = allowedValues.get(j); if (j == 0) { query.append(" ( "); } else { query.append(" OR "); } String operator = filter.isLikeOption() ? this.getLikeClause() : "= ? "; query .append(searchTableNameAlias) .append(".") .append(this.getAttributeFieldColunm(allowedValue)) .append(" "); query.append(operator); if (j == (allowedValues.size() - 1)) { query.append(" ) "); } } } else if (filter.getValue() != null) { Object object = filter.getValue(); String operator = filter.isLikeOption() ? this.getLikeClause() : "= ? "; hasAppendWhereClause = this.addAttributeObjectSearchQueryBlock( searchTableNameAlias, query, object, operator, hasAppendWhereClause, filter.getLangCode()); } else { // creazione blocco selezione su tabella ricerca if (null != filter.getStart()) { hasAppendWhereClause = this.addAttributeObjectSearchQueryBlock( searchTableNameAlias, query, filter.getStart(), ">= ? ", hasAppendWhereClause, filter.getLangCode()); } if (null != filter.getEnd()) { hasAppendWhereClause = this.addAttributeObjectSearchQueryBlock( searchTableNameAlias, query, filter.getEnd(), "<= ? ", hasAppendWhereClause, filter.getLangCode()); } if (null == filter.getStart() && null == filter.getEnd()) { hasAppendWhereClause = this.verifyWhereClauseAppend(query, hasAppendWhereClause); query .append(" (") .append(searchTableNameAlias) .append(".datevalue IS NOT NULL OR ") .append(searchTableNameAlias) .append(".textvalue IS NOT NULL OR ") .append(searchTableNameAlias) .append(".numvalue IS NOT NULL) "); } } return hasAppendWhereClause; }