From: <ssk...@vh...> - 2005-12-05 15:26:45
|
Author: sskracic Date: 2005-12-05 16:24:09 +0100 (Mon, 05 Dec 2005) New Revision: 1022 Modified: trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java Log: Reverting back to r850, since I didn't like the way the additional parameter 'descend' will be interfaced to Lucene search. Modified: trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl =================================================================== --- trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-12-02 16:07:27 UTC (rev 1021) +++ trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-12-05 15:24:09 UTC (rev 1022) @@ -32,18 +32,3 @@ id = m.object_id; } } - -query categoryObjectsDescend { - BigDecimal id; - - do { - select m.object_id - from cat_object_category_map m, - cat_cat_subcat_trans_index cc - where - m.category_id = cc.subcategory_id - and cc.category_id in :ids - } map { - id = m.object_id; - } -} Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-12-02 16:07:27 UTC (rev 1021) +++ trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-12-05 15:24:09 UTC (rev 1022) @@ -27,29 +27,18 @@ * to the category membership filter type */ public class CategoryFilterSpecification extends FilterSpecification { - + public static final String CATEGORIES = "categories"; - public static final String DESCEND = "descend"; /** * Creates a new category filter spec * @param cats the categories to check membership of */ public CategoryFilterSpecification(Category[] cats) { - this(cats, false); - } - - /** - * Creates a new category filter spec - * @param cats the categories to check membership of - * @param descend whether the membership of specified categories' children - * also satisfies the filter - */ - public CategoryFilterSpecification(Category[] cats, boolean descend) { - super(new Object[] { CATEGORIES, cats, DESCEND, new Boolean(descend) }, + super(new Object[] { CATEGORIES, cats }, new CategoryFilterType()); } - + /** * Returns the list of categories to check * @return the list of categories @@ -57,11 +46,4 @@ public Category[] getCategories() { return (Category[])get(CATEGORIES); } - - /** - * @return the flag indicating whether the category children are included in match - */ - public boolean shouldDescend() { - return Boolean.TRUE.equals(get(DESCEND)); - } } Modified: trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-12-02 16:07:27 UTC (rev 1021) +++ trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-12-05 15:24:09 UTC (rev 1022) @@ -59,13 +59,13 @@ /** * This provides the basic intermedia query engine implementation - * which can restrict based on category, object type and + * which can restrict based on category, object type and * permissions * @see com.arsdigita.search.QueryEngine */ public class BaseQueryEngine extends LockableImpl implements QueryEngine { - private static final Logger s_log = + private static final Logger s_log = Logger.getLogger(BaseQueryEngine.class); public static final String OBJECT_ID= "object_id"; @@ -91,7 +91,7 @@ addColumn("c.link_text", LINK_TEXT); addColumn("c.summary", SUMMARY); addColumn("c.language", LANGUAGE); - addColumn("c.content_section", CONTENT_SECTION); + addColumn("c.content_section", CONTENT_SECTION); // XML content is labeled as "1" and raw content is labeled as "2" // in buildQueryString(). Those labels must match the arguments // to the "score()" operator used here. @@ -113,7 +113,7 @@ } String terms = cleanSearchString(spec.getTerms()); - + if (terms == null || "".equals(terms)) { return Search.EMPTY_RESULT_SET; } @@ -121,19 +121,19 @@ DataQuery q = buildQuery(terms, spec.allowPartialMatch()); addFilters(q, spec.getFilters()); - - - + + + return new DataQueryResultSet(q); } - + protected DataQuery buildQuery(String terms, boolean partial) { List props = new ArrayList(); String query = buildQueryString(terms, partial, props); - + if (s_log.isDebugEnabled()) { s_log.debug("Query before adding any filters {\n" + query + "}"); } @@ -141,7 +141,7 @@ Session session = SessionManager.getSession(); SearchDataQuery q = new SearchDataQuery( - session, + session, query, (String[])props.toArray(new String[props.size()])); return q; @@ -151,7 +151,7 @@ boolean partial, List props) { StringBuffer sb = new StringBuffer("select \n"); - + Iterator columns = m_columns.keySet().iterator(); while (columns.hasNext()) { String field = (String)columns.next(); @@ -179,7 +179,7 @@ sb.append("\n"); } } - + sb.append("where\n"); Iterator conditions = m_conditions.iterator(); @@ -193,7 +193,7 @@ return sb.toString(); } - protected void addColumn(String field, + protected void addColumn(String field, String propName) { Assert.unlocked(this); m_columns.put(field, propName); @@ -204,32 +204,32 @@ Assert.unlocked(this); m_tables.put(table, alias); } - + protected void addCondition(String condition) { Assert.unlocked(this); m_conditions.add(condition); } - + protected String cleanSearchString(String terms) { return SimpleSearchSpecification.cleanSearchString(terms, " and "); } - + protected void addFilters(DataQuery query, FilterSpecification[] filters) { Assert.locked(this); for (int i = 0 ; i < filters.length ; i++) { - s_log.debug("adding filter " + filters[i]); + s_log.debug("adding filter " + filters[i]); addFilter(query, filters[i]); } } - + protected void addFilter(DataQuery query, FilterSpecification filter) { Assert.locked(this); FilterType type = filter.getType(); - + if (PermissionFilterType.KEY.equals(type.getKey())) { addPermissionFilter(query, (PermissionFilterSpecification)filter); } else if (ObjectTypeFilterType.KEY.equals(type.getKey())) { @@ -237,11 +237,11 @@ } else if (CategoryFilterType.KEY.equals(type.getKey())) { addCategoryFilter(query, (CategoryFilterSpecification)filter); } else if (ContentSectionFilterType.KEY.equals(type.getKey())) { - s_log.debug("adding the ContentSectionFilterSpecification filter"); - addContentSectionFilter(query, (ContentSectionFilterSpecification)filter); - } + s_log.debug("adding the ContentSectionFilterSpecification filter"); + addContentSectionFilter(query, (ContentSectionFilterSpecification)filter); + } } - + protected void addPermissionFilter(DataQuery query, PermissionFilterSpecification filter) { Assert.locked(this); @@ -286,43 +286,36 @@ ids.add(categories[i].getID()); } - Filter f = null; - if (filter.shouldDescend()) { - f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.search.categoryObjectsDescend"); - } else { - f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.search.categoryObjects"); - } + Filter f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.search.categoryObjects"); + f.set("ids", ids); } } protected void addContentSectionFilter(DataQuery query, - ContentSectionFilterSpecification filter) { - Assert.locked(this); + ContentSectionFilterSpecification filter) { + Assert.locked(this); Object[] contentSections = filter.getSections(); - s_log.debug("there are " + contentSections.length + " contentSections"); - if (contentSections != null && contentSections.length > 0) { - List contentSectionsList = Arrays.asList(contentSections); - Iterator i = contentSectionsList.iterator(); - StringBuffer filterSql = new StringBuffer(); - while (i.hasNext()) { - filterSql.append("content_section = '"); - filterSql.append((String)i.next()); - filterSql.append("'"); - if (i.hasNext()) { - filterSql.append(" or "); - } - } - s_log.debug("filterSql is " + filterSql.toString()); - query.addFilter(filterSql.toString()); - } + s_log.debug("there are " + contentSections.length + " contentSections"); + if (contentSections != null && contentSections.length > 0) { + List contentSectionsList = Arrays.asList(contentSections); + Iterator i = contentSectionsList.iterator(); + StringBuffer filterSql = new StringBuffer(); + while (i.hasNext()) { + filterSql.append("content_section = '"); + filterSql.append((String)i.next()); + filterSql.append("'"); + if (i.hasNext()) { + filterSql.append(" or "); + } + } + s_log.debug("filterSql is " + filterSql.toString()); + query.addFilter(filterSql.toString()); + } } - + } |