You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(48) |
Dec
(31) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(22) |
Feb
(68) |
Mar
(185) |
Apr
(11) |
May
(21) |
Jun
(23) |
Jul
(46) |
Aug
(69) |
Sep
(211) |
Oct
(26) |
Nov
(51) |
Dec
(52) |
2006 |
Jan
(13) |
Feb
(13) |
Mar
(8) |
Apr
(21) |
May
(17) |
Jun
(100) |
Jul
(34) |
Aug
(23) |
Sep
(26) |
Oct
(16) |
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(66) |
Oct
(10) |
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
(8) |
Jun
(5) |
Jul
(31) |
Aug
(8) |
Sep
(11) |
Oct
(6) |
Nov
|
Dec
|
2012 |
Jan
(13) |
Feb
(2) |
Mar
(9) |
Apr
(6) |
May
(24) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(120) |
2013 |
Jan
(6) |
Feb
(35) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ap...@vh...> - 2005-12-09 13:12:36
|
Author: apevec Date: 2005-12-09 14:10:03 +0100 (Fri, 09 Dec 2005) New Revision: 1041 Modified: releases/1.0.2/ccm-ldn-theme/application.xml Log: increase release, rebuilt to include fix r982 Modified: releases/1.0.2/ccm-ldn-theme/application.xml =================================================================== --- releases/1.0.2/ccm-ldn-theme/application.xml 2005-12-08 00:18:16 UTC (rev 1040) +++ releases/1.0.2/ccm-ldn-theme/application.xml 2005-12-09 13:10:03 UTC (rev 1041) @@ -3,7 +3,7 @@ name="ccm-ldn-theme" prettyName="Theme" version="1.0.0" - release="11"> + release="12"> <ccm:dependencies> <ccm:requires name="ccm-core" version="6.1.1"/> <ccm:requires name="ccm-ldn-subsite" version="1.4.1"/> |
Author: apevec Date: 2005-12-08 01:18:16 +0100 (Thu, 08 Dec 2005) New Revision: 1040 Modified: trunk/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml trunk/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java trunk/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java trunk/ccm-core/src/com/arsdigita/domain/xml/TraversalHandler.java trunk/ccm-forum/src/com/arsdigita/forum/ui/MessageXMLFormatter.java Log: Implement fallback to supertype formatters, otherwise only formatters directly attached to the most specific type are used. Also don't attach empty formatters to the type i.e. no formats defined in traversal config XML. Experimental: use FullDateFormatter from Fabrice for /object/auditing/*Date Modified: trunk/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml =================================================================== --- trunk/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml 2005-12-07 21:44:44 UTC (rev 1039) +++ trunk/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml 2005-12-08 00:18:16 UTC (rev 1040) @@ -32,9 +32,16 @@ </xrd:adapter> <xrd:adapter objectType="com.arsdigita.cms.ContentPage" extends="com.arsdigita.cms.ContentItem" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter"> + <xrd:attributes rule="exclude"> + <xrd:property name="/object/auditing/id"/> + </xrd:attributes> <xrd:associations rule="include"> <xrd:property name="/object/auditing"/> </xrd:associations> + <xrd:formatter property="/object/auditing/creationDate" + class="com.arsdigita.xml.formatters.FullDateFormatter"/> + <xrd:formatter property="/object/auditing/lastModifiedDate" + class="com.arsdigita.xml.formatters.FullDateFormatter"/> </xrd:adapter> <!-- Adds a text asset --> Modified: trunk/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java 2005-12-07 21:44:44 UTC (rev 1039) +++ trunk/ccm-core/src/com/arsdigita/domain/DomainObjectXMLRenderer.java 2005-12-08 00:18:16 UTC (rev 1040) @@ -86,7 +86,7 @@ String context) { if( s_log.isDebugEnabled() ) { s_log.debug( "Registering formatter " + - formatter.getClass().getName() + " for type " + type + + formatter + " for type " + type + " in context " + context ); } @@ -136,6 +136,9 @@ DomainObjectXMLFormatter formatter = null; while (formatter == null && type != null) { formatter = getFormatter(type, context); + if (s_log.isDebugEnabled()) { + s_log.debug("getFormatter("+type+","+context+")="+formatter); + } type = type.getSupertype(); } return formatter; @@ -155,6 +158,7 @@ private String m_namespacePrefix; private DomainObjectXMLFormatter m_formatter; + private String m_context; /** * Creates a new DomainObject XML renderer @@ -179,10 +183,35 @@ Property prop, Object value) { if (m_formatter != null) { - return m_formatter.format(obj, - appendToPath(path, prop.getName()), + String propertyPath = appendToPath(path, prop.getName()); + String rendered = m_formatter.format(obj, + propertyPath, prop, value); + if (s_log.isDebugEnabled()) { + s_log.debug("FORMAT "+obj+" m_formatter="+m_formatter+" rendered="+rendered); + } + if (rendered == null) { + // try supertype formatters + ObjectType objectType = obj.getObjectType().getSupertype(); + DomainObjectXMLFormatter formatter = m_formatter; + while (rendered == null && formatter != null && objectType != null) { + formatter = findFormatter(objectType, m_context); + if (formatter != null) { + rendered = formatter.format(obj, propertyPath, prop, value); + } else { + rendered = null; + } + if (s_log.isDebugEnabled()) { + s_log.debug("FALLBACK supertype "+objectType+" formatter="+formatter+" rendered="+rendered); + } + objectType = objectType.getSupertype(); + } + } + if (rendered != null) { + return rendered; + } // else fallback to default below } + s_log.debug("DEFAULT XML.format"); return XML.format(value); } @@ -195,6 +224,7 @@ } m_formatter = findFormatter(obj.getObjectType(), context); + m_context = context; if (s_log.isDebugEnabled()) { s_log.debug("Found formatter " + m_formatter); @@ -371,6 +401,6 @@ parent.newChildElement(name, copy) : parent.newChildElement(m_namespacePrefix + ":" + name, m_namespaceURI, - copy); + copy); } } Modified: trunk/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java 2005-12-07 21:44:44 UTC (rev 1039) +++ trunk/ccm-core/src/com/arsdigita/domain/SimpleDomainObjectXMLFormatter.java 2005-12-08 00:18:16 UTC (rev 1040) @@ -50,14 +50,9 @@ Object value) { Formatter formatter = (Formatter)m_formatters.get(path); if (formatter == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("No formatter for " + path + - " for object "+obj+ - " and property "+prop+ - " and value "+value+ - " using default"); - } - return XML.format(value); + // don't fallback to default here + // let the upper layer (XMLRenderer) try super types + return null; } if (s_log.isDebugEnabled()) { s_log.debug("Processing property " + path + @@ -68,5 +63,9 @@ } return formatter.format(value); } + + public boolean isEmpty() { + return m_formatters.isEmpty(); + } } Modified: trunk/ccm-core/src/com/arsdigita/domain/xml/TraversalHandler.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/domain/xml/TraversalHandler.java 2005-12-07 21:44:44 UTC (rev 1039) +++ trunk/ccm-core/src/com/arsdigita/domain/xml/TraversalHandler.java 2005-12-08 00:18:16 UTC (rev 1040) @@ -221,10 +221,12 @@ (m_objectType, m_adapter, m_typeContext == null ? m_context : m_typeContext); - registerFormatter + if (!m_formatters.isEmpty()) { + registerFormatter (m_objectType, m_formatters, m_typeContext == null ? m_context : m_typeContext); + } m_objectType = null; m_adapter = null; m_typeContext = null; Modified: trunk/ccm-forum/src/com/arsdigita/forum/ui/MessageXMLFormatter.java =================================================================== --- trunk/ccm-forum/src/com/arsdigita/forum/ui/MessageXMLFormatter.java 2005-12-07 21:44:44 UTC (rev 1039) +++ trunk/ccm-forum/src/com/arsdigita/forum/ui/MessageXMLFormatter.java 2005-12-08 00:18:16 UTC (rev 1040) @@ -38,4 +38,9 @@ } return super.format(obj, path, prop, value); } + + public boolean isEmpty() { + return false; + } + } |
From: <ap...@vh...> - 2005-12-07 21:47:01
|
Author: apevec Date: 2005-12-07 22:44:44 +0100 (Wed, 07 Dec 2005) New Revision: 1039 Modified: contrib/ccm-ldn-camden-consultation/trunk/src/com/arsdigita/camden/cms/contenttypes/Consultation.java Log: change requested: add a space for better readability Modified: contrib/ccm-ldn-camden-consultation/trunk/src/com/arsdigita/camden/cms/contenttypes/Consultation.java =================================================================== --- contrib/ccm-ldn-camden-consultation/trunk/src/com/arsdigita/camden/cms/contenttypes/Consultation.java 2005-12-07 11:35:50 UTC (rev 1038) +++ contrib/ccm-ldn-camden-consultation/trunk/src/com/arsdigita/camden/cms/contenttypes/Consultation.java 2005-12-07 21:44:44 UTC (rev 1039) @@ -152,7 +152,7 @@ StringBuffer topics = new StringBuffer(); topics.append(Consultation.getPrettyTopic(Integer.valueOf(tok.nextToken())).localize()); while (tok.hasMoreTokens()) { - topics.append(',').append(Consultation.getPrettyTopic(Integer.valueOf(tok.nextToken())).localize()); + topics.append(", ").append(Consultation.getPrettyTopic(Integer.valueOf(tok.nextToken())).localize()); } return topics.toString(); } else { @@ -210,7 +210,7 @@ StringBuffer types = new StringBuffer(); types.append(Consultation.getPrettyType(Integer.valueOf(tok.nextToken())).localize()); while (tok.hasMoreTokens()) { - types.append(',').append(Consultation.getPrettyType(Integer.valueOf(tok.nextToken())).localize()); + types.append(", ").append(Consultation.getPrettyType(Integer.valueOf(tok.nextToken())).localize()); } return types.toString(); } else { @@ -312,7 +312,7 @@ StringBuffer targets = new StringBuffer(); targets.append(Consultation.getPrettyTarget(Integer.valueOf(tok.nextToken())).localize()); while (tok.hasMoreTokens()) { - targets.append(',').append(Consultation.getPrettyTarget(Integer.valueOf(tok.nextToken())).localize()); + targets.append(", ").append(Consultation.getPrettyTarget(Integer.valueOf(tok.nextToken())).localize()); } return targets.toString(); } else { @@ -370,7 +370,7 @@ StringBuffer geos = new StringBuffer(); geos.append(Consultation.getPrettyGeoArea(Integer.valueOf(tok.nextToken())).localize()); while (tok.hasMoreTokens()) { - geos.append(',').append(Consultation.getPrettyGeoArea(Integer.valueOf(tok.nextToken())).localize()); + geos.append(", ").append(Consultation.getPrettyGeoArea(Integer.valueOf(tok.nextToken())).localize()); } return geos.toString(); } else { |
From: <ssk...@vh...> - 2005-12-07 11:38:16
|
Author: sskracic Date: 2005-12-07 12:35:50 +0100 (Wed, 07 Dec 2005) New Revision: 1038 Removed: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java Log: Removing CategoryHierarchyFilterWidget since its functionality is integrated into core CategoryFilterWidget. Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-12-07 11:09:53 UTC (rev 1037) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-12-07 11:35:50 UTC (rev 1038) @@ -33,6 +33,7 @@ import com.arsdigita.search.filters.ContentSectionFilterSpecification; import com.arsdigita.search.ui.BaseQueryComponent; import com.arsdigita.search.ui.filters.PermissionFilterComponent; +import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; import com.arsdigita.web.Application; import com.arsdigita.web.Web; import java.util.ArrayList; @@ -64,9 +65,7 @@ Application app = Web.getContext().getApplication(); Category root = Category.getRootForObject(app); - // amended chr...@we... 29/11/05 - // changed from new SimpleCategoryFilterWidget - add(new CategoryHierarchyFilterWidget(root)); + add(new SimpleCategoryFilterWidget(root)); add(new ContentTypeFilterWidget()); add(new VersionFilterComponent(context)); Deleted: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java |
From: <ssk...@vh...> - 2005-12-07 11:12:22
|
Author: sskracic Date: 2005-12-07 12:09:53 +0100 (Wed, 07 Dec 2005) New Revision: 1037 Modified: trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java Log: Include subcategories parameter checking now done in more bebop-friendly way. Modified: trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java 2005-12-07 10:38:04 UTC (rev 1036) +++ trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java 2005-12-07 11:09:53 UTC (rev 1037) @@ -22,7 +22,6 @@ import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormModel; import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.ArrayParameter; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.categorization.Category; @@ -46,7 +45,7 @@ public abstract class CategoryFilterWidget extends FilterWidget { private Form m_form; - private StringParameter includeCategoryHierarchy; + private StringParameter includeCategoryHierarchy = new StringParameter("subcats"); /** * Creates a new category filter component @@ -67,20 +66,22 @@ cats[i] = (Category)DomainObjectFactory.newInstance(oids[i]); } + return new CategoryFilterSpecification(cats, searchSubcats(state)); + } + + private boolean searchSubcats(PageState state) { FormData fd = m_form.getFormData(state); boolean includeSubCats = false; if (fd != null) { - ParameterData data = - fd.getParameter(includeCategoryHierarchy.getName()); - includeSubCats = data.getValue() != null; + includeSubCats = Boolean.TRUE.toString() + .equals(fd.getString(includeCategoryHierarchy.getName())); } - - return new CategoryFilterSpecification(cats, includeSubCats); + return includeSubCats; } + public void register(Form form, FormModel model) { super.register(form, model); - includeCategoryHierarchy = new StringParameter("subcats"); model.addFormParam(includeCategoryHierarchy); m_form = form; } @@ -98,8 +99,7 @@ Element includeSubCats = Search.newElement("includeSubCats"); includeSubCats.addAttribute("name", includeCategoryHierarchy.getName()); - includeSubCats.addAttribute("value", - String.valueOf(state.getRequest().getParameterMap().containsKey(includeCategoryHierarchy.getName()))); + includeSubCats.addAttribute("value", String.valueOf(searchSubcats(state))); parent.addContent(includeSubCats); OID[] oids = (OID[])getValue(state); |
From: <ssk...@vh...> - 2005-12-07 10:40:36
|
Author: sskracic Date: 2005-12-07 11:38:04 +0100 (Wed, 07 Dec 2005) New Revision: 1036 Modified: trunk/ccm-core/web/packages/search/xsl/search.xsl Log: Modified the category widget so that the additional checkbox is displayed to enable subcategory match. Modified: trunk/ccm-core/web/packages/search/xsl/search.xsl =================================================================== --- trunk/ccm-core/web/packages/search/xsl/search.xsl 2005-12-06 16:23:05 UTC (rev 1035) +++ trunk/ccm-core/web/packages/search/xsl/search.xsl 2005-12-07 10:38:04 UTC (rev 1036) @@ -166,6 +166,16 @@ </option> </xsl:for-each> </select> + <br/> + <input type="checkbox" value="true"> + <xsl:attribute name="name"> + <xsl:value-of select="search:includeSubCats/@name"/> + </xsl:attribute> + <xsl:if test="search:includeSubCats/@value = 'true'"> + <xsl:attribute name="checked">checked</xsl:attribute> + </xsl:if> + </input> + Include subcategories </td> </xsl:template> |
From: <ssk...@vh...> - 2005-12-06 16:25:36
|
Author: sskracic Date: 2005-12-06 17:23:05 +0100 (Tue, 06 Dec 2005) New Revision: 1035 Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java trunk/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java Log: Two things: 1. moved Chris' patches that allow hierarchical category search into core 2. fixed request-specific code that appeared in non-request-specific part of ItemQueryComponent, which required some API extension. Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java 2005-12-06 13:36:47 UTC (rev 1034) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java 2005-12-06 16:23:05 UTC (rev 1035) @@ -35,7 +35,7 @@ public class ContentTypeFilterWidget extends FilterWidget { private ContentType[] m_types; - + public ContentTypeFilterWidget(ContentTypeCollection types) { super(new ContentTypeFilterType(), new ArrayParameter(new StringParameter(ContentTypeFilterType.KEY))); @@ -53,17 +53,21 @@ public ContentTypeFilterWidget() { this(ContentType.getRegisteredContentTypes()); } - + + protected ContentType[] getContentTypes(PageState state) { + return m_types; + } + public FilterSpecification getFilter(PageState state) { String[] types = (String[])getValue(state); - + if (types == null) { types = new String[0]; } - + return new ContentTypeFilterSpecification(types); } - + public void generateBodyXML(PageState state, Element parent) { super.generateBodyXML(state, parent); @@ -73,12 +77,14 @@ types = new String[0]; } - for (int i = 0 ; i < m_types.length ; i++) { + ContentType[] widgetTypes = getContentTypes(state); + + for (int i = 0 ; i < widgetTypes.length ; i++) { Element type = Search.newElement("contentType"); - type.addAttribute("name", m_types[i].getAssociatedObjectType()); - type.addAttribute("title", m_types[i].getLabel()); + type.addAttribute("name", widgetTypes[i].getAssociatedObjectType()); + type.addAttribute("title", widgetTypes[i].getLabel()); for (int j = 0 ; j < types.length ; j++) { - if (types[j].equals(m_types[i].getAssociatedObjectType())) { + if (types[j].equals(widgetTypes[i].getAssociatedObjectType())) { type.addAttribute("isSelected", "1"); break; } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java 2005-12-06 13:36:47 UTC (rev 1034) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java 2005-12-06 16:23:05 UTC (rev 1035) @@ -19,28 +19,29 @@ package com.arsdigita.cms.ui.search; import com.arsdigita.bebop.PageState; -import com.arsdigita.search.FilterType; -import com.arsdigita.search.ui.BaseQueryComponent; -import com.arsdigita.search.ui.filters.PermissionFilterComponent; -import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; -import com.arsdigita.search.ui.filters.DateRangeFilterWidget; -import com.arsdigita.search.ui.filters.PartyFilterWidget; -import com.arsdigita.cms.search.LaunchDateFilterType; -import com.arsdigita.cms.search.CreationDateFilterType; -import com.arsdigita.cms.search.LastModifiedDateFilterType; -import com.arsdigita.cms.search.LastModifiedUserFilterType; -import com.arsdigita.cms.search.CreationUserFilterType; -import com.arsdigita.search.Search; +import com.arsdigita.bebop.form.Submit; import com.arsdigita.categorization.Category; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSectionCollection; +import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.ContentTypeCollection; import com.arsdigita.cms.SecurityManager; +import com.arsdigita.cms.search.CreationDateFilterType; +import com.arsdigita.cms.search.CreationUserFilterType; +import com.arsdigita.cms.search.LastModifiedDateFilterType; +import com.arsdigita.cms.search.LastModifiedUserFilterType; +import com.arsdigita.cms.search.LaunchDateFilterType; import com.arsdigita.cms.ui.ContentSectionPage; -import com.arsdigita.bebop.form.Submit; - +import com.arsdigita.search.FilterType; +import com.arsdigita.search.Search; +import com.arsdigita.search.ui.BaseQueryComponent; +import com.arsdigita.search.ui.filters.DateRangeFilterWidget; +import com.arsdigita.search.ui.filters.PartyFilterWidget; +import com.arsdigita.search.ui.filters.PermissionFilterComponent; +import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; /** * This class provides a basic query form for CMS admin pages @@ -64,23 +65,43 @@ if (Search.getConfig().isIntermediaEnabled() || Search.getConfig().isLuceneEnabled()) { - if (CMS.getContext().hasContentSection()) { - ContentSection section = CMS.getContext().getContentSection(); - add(new SimpleCategoryFilterWidget(section.getRootCategory())); - add(new ContentTypeFilterWidget(section)); - } else { - ContentSectionCollection sections = - ContentSection.getAllSections(); + add(new SimpleCategoryFilterWidget() { + protected Category[] getRoots(PageState state) { + Category[] roots; + if (CMS.getContext().hasContentSection()) { + ContentSection section = CMS.getContext().getContentSection(); + roots = new Category[] { section.getRootCategory() }; + } else { + ContentSectionCollection sections = + ContentSection.getAllSections(); + List cats = new ArrayList(); + while (sections.next()) { + ContentSection section = sections.getContentSection(); + cats.add(section.getRootCategory()); + } + roots = (Category[])cats.toArray(new Category[cats.size()]); + } + return roots; + } + }); - List cats = new ArrayList(); - while (sections.next()) { - ContentSection section = sections.getContentSection(); - cats.add(section.getRootCategory()); + add(new ContentTypeFilterWidget() { + protected ContentType[] getContentTypes(PageState state) { + // override only if there's content section context + if (CMS.getContext().hasContentSection()) { + ContentSection section = CMS.getContext().getContentSection(); + ContentTypeCollection typesCollection = section.getContentTypes(); + ContentType[] typesArray = new ContentType[(int)typesCollection.size()]; + int i = 0; + while (typesCollection.next()) { + typesArray[i++] = typesCollection.getContentType(); + } + return typesArray; + } else { + return super.getContentTypes(state); + } } - add(new SimpleCategoryFilterWidget( - (Category[])cats.toArray(new Category[cats.size()]))); - add(new ContentTypeFilterWidget()); - } + }); add(new VersionFilterComponent(context)); add(new DateRangeFilterWidget(new LastModifiedDateFilterType(), Modified: trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java 2005-12-06 13:36:47 UTC (rev 1034) +++ trunk/ccm-core/src/com/arsdigita/search/ui/filters/CategoryFilterWidget.java 2005-12-06 16:23:05 UTC (rev 1035) @@ -18,29 +18,36 @@ */ package com.arsdigita.search.ui.filters; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormModel; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.parameters.ParameterData; +import com.arsdigita.bebop.parameters.ArrayParameter; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.categorization.Category; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.OID; import com.arsdigita.search.FilterSpecification; import com.arsdigita.search.Search; -import com.arsdigita.search.ui.FilterWidget; import com.arsdigita.search.filters.CategoryFilterSpecification; import com.arsdigita.search.filters.CategoryFilterType; - -import com.arsdigita.categorization.Category; -import com.arsdigita.persistence.OID; -import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.parameters.ArrayParameter; +import com.arsdigita.search.ui.FilterWidget; import com.arsdigita.toolbox.ui.OIDParameter; import com.arsdigita.xml.Element; /** - * A base component for presenting a list of categories + * A base component for presenting a list of categories * for filtering. This class needs to be subclassed to - * implement the method for generating the list of + * implement the method for generating the list of * categories */ public abstract class CategoryFilterWidget extends FilterWidget { - + + private Form m_form; + private StringParameter includeCategoryHierarchy; + /** * Creates a new category filter component */ @@ -60,12 +67,27 @@ cats[i] = (Category)DomainObjectFactory.newInstance(oids[i]); } - return new CategoryFilterSpecification(cats); + FormData fd = m_form.getFormData(state); + boolean includeSubCats = false; + if (fd != null) { + ParameterData data = + fd.getParameter(includeCategoryHierarchy.getName()); + includeSubCats = data.getValue() != null; + } + + return new CategoryFilterSpecification(cats, includeSubCats); } - - + + public void register(Form form, FormModel model) { + super.register(form, model); + includeCategoryHierarchy = new StringParameter("subcats"); + model.addFormParam(includeCategoryHierarchy); + m_form = form; + } + + /** - * Returns a list of categories to display for + * Returns a list of categories to display for * selection */ public abstract Category[] getCategories(PageState state); @@ -74,6 +96,12 @@ Element parent) { super.generateBodyXML(state, parent); + Element includeSubCats = Search.newElement("includeSubCats"); + includeSubCats.addAttribute("name", includeCategoryHierarchy.getName()); + includeSubCats.addAttribute("value", + String.valueOf(state.getRequest().getParameterMap().containsKey(includeCategoryHierarchy.getName()))); + parent.addContent(includeSubCats); + OID[] oids = (OID[])getValue(state); Category[] cats = getCategories(state); Modified: trunk/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java 2005-12-06 13:36:47 UTC (rev 1034) +++ trunk/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java 2005-12-06 16:23:05 UTC (rev 1035) @@ -34,14 +34,21 @@ * subcategories from a specified root */ public class SimpleCategoryFilterWidget extends CategoryFilterWidget { - + private static final Logger s_log = Logger.getLogger(SimpleCategoryFilterWidget.class); private Category[] m_roots; - + /** * Creates a new category filter + */ + protected SimpleCategoryFilterWidget() { + m_roots = new Category[0]; + } + + /** + * Creates a new category filter * @param root the root category */ public SimpleCategoryFilterWidget(Category root) { @@ -57,30 +64,41 @@ } + /** + * Sets root categories (hence the category widget content) + * on per-request basis. Override if category widget contents + * must change across requests. + */ + protected Category[] getRoots(PageState state) { + return m_roots; + } + + public Category[] getCategories(PageState state) { if (s_log.isDebugEnabled()) s_log.debug("getCategories", new Throwable()); + Category[] roots = getRoots(state); Collection cats = new ArrayList(); Set seen = new HashSet(); - for (int i = 0 ; i < m_roots.length ; i++) { - if (seen.contains(m_roots[i])) { + for (int i = 0 ; i < roots.length ; i++) { + if (seen.contains(roots[i])) { if (s_log.isDebugEnabled()) { - s_log.debug("skipping category " + m_roots[i].getOID()); + s_log.debug("skipping category " + roots[i].getOID()); } continue; } if (s_log.isDebugEnabled()) { - s_log.debug("processing category " + m_roots[i].getOID()); + s_log.debug("processing category " + roots[i].getOID()); } - CategoryCollection scions = m_roots[i].getDescendants(); + CategoryCollection scions = roots[i].getDescendants(); while ( scions.next() ) { cats.add(scions.getCategory()); } scions.close(); - seen.add(m_roots[i]); + seen.add(roots[i]); } return (Category[])cats.toArray(new Category[cats.size()]); } |
From: <ssk...@vh...> - 2005-12-06 13:39:15
|
Author: sskracic Date: 2005-12-06 14:36:47 +0100 (Tue, 06 Dec 2005) New Revision: 1034 Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl Log: Completed isDescending() resurrection, files I forgot to submit in r1033. Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl =================================================================== --- trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-12-06 13:18:00 UTC (rev 1033) +++ trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-12-06 13:36:47 UTC (rev 1034) @@ -26,14 +26,20 @@ do { select m.object_id - from cat_object_category_map m - where m.category_id in :ids + from cat_object_category_map m, + cat_cat_subcat_trans_index cc + where cc.category_id in :ids + and cc.subcategory_id = m.category_id + and cc.n_paths <= :pathLimit union select i.item_id from cat_object_category_map cm, + cat_cat_subcat_trans_index cc2, cms_items i - where cm.category_id in :ids - and cm.object_id = i.parent_id + where cc2.category_id in :ids + and cc2.subcategory_id = cm.category_id + and cm.object_id = i.parent_id + and cc2.n_paths <= :pathLimit } map { id = m.object_id; } Modified: trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl =================================================================== --- trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-12-06 13:18:00 UTC (rev 1033) +++ trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-12-06 13:36:47 UTC (rev 1034) @@ -26,8 +26,11 @@ do { select m.object_id - from cat_object_category_map m - where m.category_id in :ids + 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 + and cc.n_paths <= :pathLimit } map { id = m.object_id; } |
Author: sskracic Date: 2005-12-06 14:18:00 +0100 (Tue, 06 Dec 2005) New Revision: 1033 Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java Log: Readding the "descend" option for CategoryFilter. Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -238,6 +238,7 @@ "com.arsdigita.cms.searchCategoryObjects"); f.set("ids", ids); + f.set("pathLimit", new Integer(filter.isDescending() ? 999999 : 0)); } } Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -23,6 +23,8 @@ import com.arsdigita.cms.search.ContentTypeFilterSpecification; import com.arsdigita.cms.search.ContentTypeFilterType; import com.arsdigita.kernel.PartyCollection; +import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.SessionManager; import com.arsdigita.search.FilterSpecification; import com.arsdigita.search.FilterType; import com.arsdigita.search.filters.CategoryFilterSpecification; @@ -128,6 +130,17 @@ if (cats == null || cats.length == 0) { return; } - list.add(new CategoryFilter(cats, "com.arsdigita.cms.searchCategoryObjects")); + list.add(new CategoryFilter(cats, filterSpec.isDescending()) { + protected DataQuery getQuery(List catList, boolean descending) { + DataQuery dq = SessionManager.getSession() + .retrieveQuery("com.arsdigita.cms.searchCategoryObjects"); + dq.setParameter("ids", catList); + // 999999 - just need a number that is grater than max. category + // tree depth + dq.setParameter("pathLimit", new Integer(descending ? 999999 : 0)); + return dq; + } + }); + } } Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -27,23 +27,40 @@ * to the category membership filter type */ public class CategoryFilterSpecification extends FilterSpecification { - + public static final String CATEGORIES = "categories"; + public static final String DESCENDING = "descending"; /** * Creates a new category filter spec * @param cats the categories to check membership of + * @param boolean whether category children trees will be traversed as well */ - public CategoryFilterSpecification(Category[] cats) { - super(new Object[] { CATEGORIES, cats }, + public CategoryFilterSpecification(Category[] cats, boolean descending) { + super(new Object[] { CATEGORIES, cats, DESCENDING, new Boolean(descending) }, new CategoryFilterType()); } - + /** + * Creates a new category filter spec that doesn't check subcategories + * @param cats the categories to check membership of + */ + public CategoryFilterSpecification(Category[] cats) { + this(cats, false); + } + + /** * Returns the list of categories to check * @return the list of categories */ public Category[] getCategories() { return (Category[])get(CATEGORIES); } + + /** + * Checks whether the filter should traverse subcategory tree(s). + */ + public boolean isDescending() { + return Boolean.TRUE.equals(get(DESCENDING)); + } } Modified: trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -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); @@ -290,32 +290,33 @@ "object_id", "id", "com.arsdigita.search.categoryObjects"); - + f.set("ids", ids); + f.set("pathLimit", new Integer( filter.isDescending() ? 100 : 0)); } } 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()); + } } - + } Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -44,43 +44,60 @@ public class CategoryFilter extends Filter { - private String m_query; private List m_cats; + private boolean m_descending; + private static final String SEARCH_CATEGORY_OBJECTS_QUERY = "com.arsdigita.search.categoryObjects"; /** - * Create a new CategoryFilter with the default categorisation membership query + * Create a new CategoryFilter with exact category match. * * @param categories restricts the returned result set to objects * that are members of these categories * **/ public CategoryFilter(Category[] categories) { - this(categories, SEARCH_CATEGORY_OBJECTS_QUERY); + this(categories, false); } /** - * Create a CategoryFilter with a custom categorisation membership query - * passed in ID. The custom query must satisfy these 2 conditions: - * <ol> - * <li> it must accept a collection of BigDecimal category ID's - * as a bind paramater :ids - * <li> the result set must contain a BigDecimal field named "id" - * </ol> + * Create a new CategoryFilter with the optional category subtree(s) traversal + * * @param categories restricts the returned result set to objects * that are members of these categories - * @param query the PDL query name used for categorisation membership check - */ - public CategoryFilter(Category[] categories, String query) { + * @param descending whether the category children subtree(s) should be checked as well + * + **/ + public CategoryFilter(Category[] categories, boolean descending) { m_cats = new ArrayList(); for (int i=0; i<categories.length; i++) { m_cats.add(categories[i].getID()); } - m_query = query; + m_descending = descending; } /** + * Provide a custom categorisation membership query. + * The custom query must return a result set containing + * rows with a BigDecimal field named "id". + * @param catList List of category ID's (BigDecimalS) to + * check membership against + * @param descending whether the result set contains objects + * categorised against any of the catList children + */ + protected DataQuery getQuery(List catList, boolean descending) { + DataQuery dq = SessionManager.getSession() + .retrieveQuery(SEARCH_CATEGORY_OBJECTS_QUERY); + dq.setParameter("ids", catList); + // 999999 - just need a number that is grater than max. category + // tree depth + dq.setParameter("pathLimit", new Integer(descending ? 999999 : 0)); + return dq; + } + + + /** * Returns a BitSet with true for documents which * should be permitted in search results, and false * for those that should not. @@ -88,12 +105,8 @@ final public BitSet bits(IndexReader reader) throws IOException { BooleanQuery bq = new BooleanQuery(); - DataQuery dq = SessionManager.getSession() - .retrieveQuery(m_query); - dq.setParameter("ids", m_cats); - int docCount = 0; + DataQuery dq = getQuery(m_cats, m_descending); while (dq.next()) { - docCount++; bq.add(new TermQuery(new Term(Document.ID, dq.get("id").toString())), false, false); } Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -57,16 +57,17 @@ add(new PermissionFilterComponent( PrivilegeDescriptor.READ)); + } + + if (Search.getConfig().isIntermediaEnabled() || + Search.getConfig().isLuceneEnabled()) { + Application app = Web.getContext().getApplication(); Category root = Category.getRootForObject(app); // amended chr...@we... 29/11/05 // changed from new SimpleCategoryFilterWidget add(new CategoryHierarchyFilterWidget(root)); - } - if (Search.getConfig().isIntermediaEnabled() || - Search.getConfig().isLuceneEnabled()) { - add(new ContentTypeFilterWidget()); add(new VersionFilterComponent(context)); } Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-12-06 10:07:33 UTC (rev 1032) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-12-06 13:18:00 UTC (rev 1033) @@ -17,7 +17,6 @@ package com.arsdigita.london.search.ui; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import com.arsdigita.bebop.Form; @@ -27,7 +26,6 @@ import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.categorization.Category; -import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.OID; import com.arsdigita.search.FilterSpecification; @@ -39,18 +37,18 @@ /** * @author chr...@we... * - * Category filter widget that includes an extra parameter that can be used to + * Category filter widget that includes an extra parameter that can be used to * search all the subcategories of the selected categories - * - * - * + * + * + * */ public class CategoryHierarchyFilterWidget extends SimpleCategoryFilterWidget { private Form m_form; private StringParameter includeCategoryHierarchy; /** - * @param root the root category for categories available for selection + * @param root the root category for categories available for selection */ public CategoryHierarchyFilterWidget(Category root) { this(new Category[] { root }); @@ -73,10 +71,10 @@ } /** - * + * * returns a FilterSpecification that includes the selected categories - * and if subcats parameter has a value, then includes all descendent - * categories of the selected categories + * and if subcats parameter has a value, then includes all descendent + * categories of the selected categories */ public FilterSpecification getFilter(PageState state) { OID[] oids = (OID[]) getValue(state); @@ -90,35 +88,20 @@ fd.getParameter(includeCategoryHierarchy.getName()); includeSubCats = data.getValue() != null; } - Set includedCats = new HashSet(); + Set cats = new HashSet(); for (int i = 0; i < oids.length; i++) { - Category cat = (Category) DomainObjectFactory.newInstance(oids[i]); - if (includeSubCats) { - CategoryCollection subtree = cat.getDescendants(); - while (subtree.next()) { - includedCats.add(subtree.getCategory()); - - } - } else { - includedCats.add(cat); - } + cats.add( (Category) DomainObjectFactory.newInstance(oids[i])); } - Category[] cats = new Category[includedCats.size()]; - Iterator it = includedCats.iterator(); - int i = 0; - while (it.hasNext()) { - cats[i++] = (Category) it.next(); - } - - return new CategoryFilterSpecification(cats); + Category[] catArray = (Category []) cats.toArray(new Category[0]); + return new CategoryFilterSpecification(catArray, includeSubCats); } /** - * + * * adds xml for the extra parameter to the <search:filter param="category" type="category"> element. * The xml for the parameter is <search:includeSubCats name="subcats" value="true" /> which can be - * transformed into a checkbox or a hidden input + * transformed into a checkbox or a hidden input */ public void generateBodyXML(PageState state, Element parent) { super.generateBodyXML(state, parent); |
From: <ssk...@vh...> - 2005-12-06 10:09:53
|
Author: sskracic Date: 2005-12-06 11:07:33 +0100 (Tue, 06 Dec 2005) New Revision: 1032 Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java Log: Fixed a typo that broke the search. Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-05 16:12:11 UTC (rev 1031) +++ trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-06 10:07:33 UTC (rev 1032) @@ -73,7 +73,7 @@ * @param query the PDL query name used for categorisation membership check */ public CategoryFilter(Category[] categories, String query) { - List m_cats = new ArrayList(); + m_cats = new ArrayList(); for (int i=0; i<categories.length; i++) { m_cats.add(categories[i].getID()); } |
From: <ssk...@vh...> - 2005-12-05 16:14:25
|
Author: sskracic Date: 2005-12-05 17:12:11 +0100 (Mon, 05 Dec 2005) New Revision: 1031 Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java Log: Completed killing of 'descend' additional category filter parameter. Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-12-05 16:01:45 UTC (rev 1030) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-12-05 16:12:11 UTC (rev 1031) @@ -16,6 +16,10 @@ */ package com.arsdigita.london.search.ui; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import com.arsdigita.bebop.Form; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormModel; @@ -23,6 +27,7 @@ import com.arsdigita.bebop.parameters.ParameterData; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.categorization.Category; +import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.OID; import com.arsdigita.search.FilterSpecification; @@ -30,24 +35,22 @@ import com.arsdigita.search.filters.CategoryFilterSpecification; import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; import com.arsdigita.xml.Element; -import java.util.HashSet; -import java.util.Set; /** * @author chr...@we... * - * Category filter widget that includes an extra parameter that can be used to + * Category filter widget that includes an extra parameter that can be used to * search all the subcategories of the selected categories - * - * - * + * + * + * */ public class CategoryHierarchyFilterWidget extends SimpleCategoryFilterWidget { private Form m_form; private StringParameter includeCategoryHierarchy; /** - * @param root the root category for categories available for selection + * @param root the root category for categories available for selection */ public CategoryHierarchyFilterWidget(Category root) { this(new Category[] { root }); @@ -70,10 +73,10 @@ } /** - * + * * returns a FilterSpecification that includes the selected categories - * and if subcats parameter has a value, then includes all descendent - * categories of the selected categories + * and if subcats parameter has a value, then includes all descendent + * categories of the selected categories */ public FilterSpecification getFilter(PageState state) { OID[] oids = (OID[]) getValue(state); @@ -91,17 +94,31 @@ for (int i = 0; i < oids.length; i++) { Category cat = (Category) DomainObjectFactory.newInstance(oids[i]); - includedCats.add(cat); + if (includeSubCats) { + CategoryCollection subtree = cat.getDescendants(); + while (subtree.next()) { + includedCats.add(subtree.getCategory()); + + } + } else { + includedCats.add(cat); + } } - Category[] cats = (Category []) includedCats.toArray(new Category[0]); - return new CategoryFilterSpecification(cats, includeSubCats); + Category[] cats = new Category[includedCats.size()]; + Iterator it = includedCats.iterator(); + int i = 0; + while (it.hasNext()) { + cats[i++] = (Category) it.next(); + } + + return new CategoryFilterSpecification(cats); } /** - * + * * adds xml for the extra parameter to the <search:filter param="category" type="category"> element. * The xml for the parameter is <search:includeSubCats name="subcats" value="true" /> which can be - * transformed into a checkbox or a hidden input + * transformed into a checkbox or a hidden input */ public void generateBodyXML(PageState state, Element parent) { super.generateBodyXML(state, parent); |
From: <ssk...@vh...> - 2005-12-05 16:03:56
|
Author: sskracic Date: 2005-12-05 17:01:45 +0100 (Mon, 05 Dec 2005) New Revision: 1030 Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java Log: Forgot to change the PDL query name. Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-05 15:58:22 UTC (rev 1029) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-05 16:01:45 UTC (rev 1030) @@ -235,7 +235,7 @@ Filter f = query.addInSubqueryFilter( "object_id", "id", - "com.arsdigita.cms.searchCategoryItems"); + "com.arsdigita.cms.searchCategoryObjects"); f.set("ids", ids); } |
From: <ssk...@vh...> - 2005-12-05 16:00:46
|
Author: sskracic Date: 2005-12-05 16:58:22 +0100 (Mon, 05 Dec 2005) New Revision: 1029 Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java Log: Reverted to r1016, killed shouldDescend() API change. Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-05 15:50:17 UTC (rev 1028) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-12-05 15:58:22 UTC (rev 1029) @@ -222,6 +222,7 @@ f.set("types", l); } + // Override to use query that takes account of bundles :-( protected void addCategoryFilter(DataQuery query, CategoryFilterSpecification filter) { Category[] categories = filter.getCategories(); @@ -231,18 +232,10 @@ ids.add(categories[i].getID()); } - Filter f = null; - if (filter.shouldDescend()) { - f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.cms.searchCategoryObjectsDescend"); - } else { - f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.cms.searchCategoryObjects"); - } + Filter f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.cms.searchCategoryItems"); f.set("ids", ids); } |
From: <ssk...@vh...> - 2005-12-05 15:52:34
|
Author: sskracic Date: 2005-12-05 16:50:17 +0100 (Mon, 05 Dec 2005) New Revision: 1028 Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java Log: Category filtering is now implemented in Lucene as well. Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java 2005-12-05 15:48:55 UTC (rev 1027) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java 2005-12-05 15:50:17 UTC (rev 1028) @@ -48,7 +48,7 @@ * filters supported by the current search query engine. */ public class ItemQueryComponent extends BaseQueryComponent { - + private String m_context; public ItemQueryComponent(String context) { @@ -57,12 +57,19 @@ if (Search.getConfig().isIntermediaEnabled()) { add(new PermissionFilterComponent( SecurityManager.CMS_READ_ITEM)); + add(new LaunchDateFilterWidget(new LaunchDateFilterType(), + LaunchDateFilterType.KEY)); + } + if (Search.getConfig().isIntermediaEnabled() || + Search.getConfig().isLuceneEnabled()) { + if (CMS.getContext().hasContentSection()) { ContentSection section = CMS.getContext().getContentSection(); add(new SimpleCategoryFilterWidget(section.getRootCategory())); + add(new ContentTypeFilterWidget(section)); } else { - ContentSectionCollection sections = + ContentSectionCollection sections = ContentSection.getAllSections(); List cats = new ArrayList(); @@ -72,33 +79,21 @@ } add(new SimpleCategoryFilterWidget( (Category[])cats.toArray(new Category[cats.size()]))); - } - add(new LaunchDateFilterWidget(new LaunchDateFilterType(), - LaunchDateFilterType.KEY)); - } - - if (Search.getConfig().isIntermediaEnabled() || - Search.getConfig().isLuceneEnabled()) { - - if (CMS.getContext().hasContentSection()) { - ContentSection section = CMS.getContext().getContentSection(); - add(new ContentTypeFilterWidget(section)); - } else { add(new ContentTypeFilterWidget()); } add(new VersionFilterComponent(context)); - add(new DateRangeFilterWidget(new LastModifiedDateFilterType(), + add(new DateRangeFilterWidget(new LastModifiedDateFilterType(), LastModifiedDateFilterType.KEY)); - add(new DateRangeFilterWidget(new CreationDateFilterType(), + add(new DateRangeFilterWidget(new CreationDateFilterType(), CreationDateFilterType.KEY)); add(new PartyFilterWidget(new CreationUserFilterType(), CreationUserFilterType.KEY)); add(new PartyFilterWidget(new LastModifiedUserFilterType(), LastModifiedUserFilterType.KEY)); } - - Submit submit = new Submit(m_context + "_search", + + Submit submit = new Submit(m_context + "_search", ContentSectionPage.globalize("cms.ui.search")); add(submit); } |
From: <ssk...@vh...> - 2005-12-05 15:51:10
|
Author: sskracic Date: 2005-12-05 16:48:55 +0100 (Mon, 05 Dec 2005) New Revision: 1027 Modified: trunk/ccm-cms/src/com/arsdigita/cms/Initializer.java Log: Continuation of r1024, query engines need only a single entry in QueryEngineRegistry. Modified: trunk/ccm-cms/src/com/arsdigita/cms/Initializer.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/Initializer.java 2005-12-05 15:47:43 UTC (rev 1026) +++ trunk/ccm-cms/src/com/arsdigita/cms/Initializer.java 2005-12-05 15:48:55 UTC (rev 1027) @@ -68,7 +68,6 @@ import com.arsdigita.workflow.simple.WorkflowTemplate; import com.arsdigita.search.filters.ContentSectionFilterType; import com.arsdigita.search.filters.ObjectTypeFilterType; -import com.arsdigita.search.lucene.BaseQueryEngine; import com.arsdigita.xml.XML; import com.arsdigita.templating.PatternStylesheetResolver; @@ -122,14 +121,14 @@ URLService.registerFinder( Link.BASE_DATA_OBJECT_TYPE, new URLFinder() { - public String find(OID oid, String context) + public String find(OID oid, String context) throws NoValidURLException { return find(oid); } - public String find( OID oid ) + public String find( OID oid ) throws NoValidURLException { - + Link link; try { link = (Link) DomainObjectFactory.newInstance( oid ); @@ -147,7 +146,7 @@ return URLService.locate( target.getOID() ); } catch( URLFinderNotFoundException ex ) { throw new UncheckedWrapperException( ex ); - } + } } } } @@ -156,17 +155,17 @@ ImageSizerFactory.initialize(); registerInstantiators(e.getFactory()); - registerLuceneEngines(); - registerIntermediaEngines(); + registerLuceneEngine(); + registerIntermediaEngine(); registerPatternGenerators(); // register item adapters - XML.parse(ContentSection.getConfig().getItemAdapters(), + XML.parse(ContentSection.getConfig().getItemAdapters(), new TraversalHandler()); try { - QueueManager.setListener((PublishToFileListener) + QueueManager.setListener((PublishToFileListener) ContentSection.getConfig() .getPublishToFileClass().newInstance()); } catch (InstantiationException ex) { @@ -175,7 +174,7 @@ } catch (IllegalAccessException ex) { throw new UncheckedWrapperException ("Couldn't access the listener class", ex); - } + } MetadataProviderRegistry.registerAdapter( FileAsset.BASE_DATA_OBJECT_TYPE, @@ -196,8 +195,8 @@ new ItemDelegatedURLPatternGenerator() ); } - + /** * Registers object instantiators */ @@ -218,7 +217,7 @@ return new Workflow(dataObject); } }); - + f.registerInstantiator (WorkflowTemplate.BASE_DATA_OBJECT_TYPE, new ACSObjectInstantiator() { @@ -226,152 +225,52 @@ return new WorkflowTemplate(dataObject); } }); - + f.registerInstantiator (TemplateContext.BASE_DATA_OBJECT_TYPE, new DomainObjectInstantiator() { public DomainObject doNewInstance(DataObject dataObject) { return new TemplateContext(dataObject); } - public DomainObjectInstantiator + public DomainObjectInstantiator resolveInstantiator(DataObject obj) { return this; } }); } - private void registerLuceneEngines() { - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new VersionFilterType() - }, - new LuceneQueryEngine()); + private void registerLuceneEngine() { QueryEngineRegistry.registerEngine(IndexerType.LUCENE, new FilterType[] { + new CategoryFilterType(), + new ContentSectionFilterType(), new ContentTypeFilterType(), - new VersionFilterType() - }, - new LuceneQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new ContentTypeFilterType(), - new VersionFilterType(), - new LastModifiedDateFilterType(), new CreationDateFilterType(), new CreationUserFilterType(), - new LastModifiedUserFilterType() + new LastModifiedDateFilterType(), + new LastModifiedUserFilterType(), + new ObjectTypeFilterType(), + new VersionFilterType() }, new LuceneQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new ObjectTypeFilterType(), - new ContentSectionFilterType() - }, - new BaseQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new VersionFilterType(), - new ContentSectionFilterType() - }, - new LuceneQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new VersionFilterType(), - new ContentSectionFilterType(), - new ObjectTypeFilterType() - }, - new LuceneQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.LUCENE, - new FilterType[] { - new VersionFilterType(), - new ContentTypeFilterType(), - new ContentSectionFilterType() - }, - new LuceneQueryEngine()); - - } - - private void registerIntermediaEngines() { - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new PermissionFilterType(), - new VersionFilterType(), - }, - new IntermediaQueryEngine()); - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new PermissionFilterType(), - new VersionFilterType(), - new ContentSectionFilterType() - }, - new IntermediaQueryEngine()); + private void registerIntermediaEngine() { - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new ObjectTypeFilterType(), - new ContentSectionFilterType() - }, - new BaseQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new VersionFilterType(), - new ContentSectionFilterType() - }, - new IntermediaQueryEngine()); - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new VersionFilterType(), - new ContentSectionFilterType(), - new ObjectTypeFilterType() - }, - new IntermediaQueryEngine()); - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new VersionFilterType(), - new ContentTypeFilterType(), - new ContentSectionFilterType() - }, - new IntermediaQueryEngine()); - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, new FilterType[] { - new PermissionFilterType(), - new ContentTypeFilterType(), new CategoryFilterType(), - new VersionFilterType(), - }, - new IntermediaQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new PermissionFilterType(), + new ContentSectionFilterType(), new ContentTypeFilterType(), - new CategoryFilterType(), - new VersionFilterType(), - new LaunchDateFilterType() - }, - new IntermediaQueryEngine()); - - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] { - new PermissionFilterType(), - new ContentTypeFilterType(), - new CategoryFilterType(), - new VersionFilterType(), - new LaunchDateFilterType(), - new LastModifiedDateFilterType(), new CreationDateFilterType(), new CreationUserFilterType(), - new LastModifiedUserFilterType() + new LastModifiedDateFilterType(), + new LastModifiedUserFilterType(), + new LaunchDateFilterType(), + new ObjectTypeFilterType(), + new PermissionFilterType(), + new VersionFilterType() }, new IntermediaQueryEngine()); } |
From: <ssk...@vh...> - 2005-12-05 15:49:54
|
Author: sskracic Date: 2005-12-05 16:47:43 +0100 (Mon, 05 Dec 2005) New Revision: 1026 Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java Log: In CMS, we search for categorised bundles, so the addCategoryFilter is overridden, alla IntermediaQueryEngine. Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java 2005-12-05 15:45:52 UTC (rev 1025) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/LuceneQueryEngine.java 2005-12-05 15:47:43 UTC (rev 1026) @@ -18,28 +18,28 @@ */ package com.arsdigita.cms.search; +import com.arsdigita.categorization.Category; import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.search.ContentTypeFilterSpecification; +import com.arsdigita.cms.search.ContentTypeFilterType; +import com.arsdigita.kernel.PartyCollection; +import com.arsdigita.search.FilterSpecification; import com.arsdigita.search.FilterType; -import com.arsdigita.search.FilterSpecification; +import com.arsdigita.search.filters.CategoryFilterSpecification; +import com.arsdigita.search.filters.DateRangeFilterSpecification; +import com.arsdigita.search.filters.PartyFilterSpecification; import com.arsdigita.search.lucene.BaseQueryEngine; -import com.arsdigita.search.lucene.UnionFilter; -import com.arsdigita.search.lucene.UnionFilter; +import com.arsdigita.search.lucene.CategoryFilter; +import com.arsdigita.search.lucene.Document; import com.arsdigita.search.lucene.ObjectTypeFilter; import com.arsdigita.search.lucene.PartyFilter; import com.arsdigita.search.lucene.TypeSpecificFilter; -import com.arsdigita.search.lucene.Document; -import com.arsdigita.search.filters.DateRangeFilterSpecification; -import com.arsdigita.search.filters.PartyFilterSpecification; -import com.arsdigita.cms.search.ContentTypeFilterSpecification; -import com.arsdigita.cms.search.ContentTypeFilterType; -import com.arsdigita.kernel.PartyCollection; - -import java.util.List; +import com.arsdigita.search.lucene.UnionFilter; import java.util.ArrayList; import java.util.Date; - +import java.util.List; +import org.apache.lucene.search.DateFilter; import org.apache.lucene.search.Filter; -import org.apache.lucene.search.DateFilter; public class LuceneQueryEngine extends BaseQueryEngine { @@ -49,18 +49,18 @@ super.addFilter(list, filter); FilterType type = filter.getType(); - + if (ContentTypeFilterType.KEY.equals(type.getKey())) { addContentTypeFilter(list, (ContentTypeFilterSpecification)filter); } else if (VersionFilterType.KEY.equals(type.getKey())) { addVersionFilter(list, (VersionFilterSpecification)filter); } else if (LastModifiedDateFilterType.KEY.equals(type.getKey())) { - addDateRangeFilter(list, - (DateRangeFilterSpecification)filter, + addDateRangeFilter(list, + (DateRangeFilterSpecification)filter, Document.LAST_MODIFIED_DATE); } else if (CreationDateFilterType.KEY.equals(type.getKey())) { - addDateRangeFilter(list, - (DateRangeFilterSpecification)filter, + addDateRangeFilter(list, + (DateRangeFilterSpecification)filter, Document.CREATION_DATE); } else if (LastModifiedUserFilterType.KEY.equals(type.getKey())) { addPartyFilter(list, (PartyFilterSpecification)filter, @@ -82,7 +82,7 @@ list.add(DateFilter.After(paramName, startDate)); } else if (endDate != null) { list.add(DateFilter.Before(paramName, startDate)); - } + } } protected void addPartyFilter(List list, @@ -116,9 +116,18 @@ } Filter[] filters = new Filter[types.length]; - for (int i = 0 ; i < types.length ; i++) { + for (int i = 0 ; i < types.length ; i++) { filters[i] = new ObjectTypeFilter(types[i].getAssociatedObjectType()); } list.add(new UnionFilter(filters)); - } + } + + protected void addCategoryFilter(List list, + CategoryFilterSpecification filterSpec) { + Category[] cats = filterSpec.getCategories(); + if (cats == null || cats.length == 0) { + return; + } + list.add(new CategoryFilter(cats, "com.arsdigita.cms.searchCategoryObjects")); + } } |
From: <ssk...@vh...> - 2005-12-05 15:48:07
|
Author: sskracic Date: 2005-12-05 16:45:52 +0100 (Mon, 05 Dec 2005) New Revision: 1025 Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl Log: This is continuation of r1022, where the changes that bring additional parameter 'descend' to the category filter are reverted. This time for CMS. Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl =================================================================== --- trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-12-05 15:35:53 UTC (rev 1024) +++ trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-12-05 15:45:52 UTC (rev 1025) @@ -39,25 +39,3 @@ } } -query searchCategoryObjectsDescend { - 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 - union - select i.item_id - from cat_object_category_map cm, - cat_cat_subcat_trans_index cc2, - cms_items i - where cc2.category_id in :ids - and cc2.subcategory_id = cm.category_id - and cm.object_id = i.parent_id - } map { - id = m.object_id; - } -} - |
From: <ssk...@vh...> - 2005-12-05 15:38:22
|
Author: sskracic Date: 2005-12-05 16:35:53 +0100 (Mon, 05 Dec 2005) New Revision: 1024 Modified: trunk/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java trunk/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java trunk/ccm-core/src/com/arsdigita/search/lucene/Initializer.java Log: Simplified the way the QueryEngineRegistry dispatches the search requests to query engines. QueryEngine implementations should now only register all of their capabilities under a single engine key, and the query will be dispatched for the first engine which has all the required filtering capabilities, ie. match is produced on containsAll() instead of equals(). Modified: trunk/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java 2005-12-05 15:32:04 UTC (rev 1023) +++ trunk/ccm-core/src/com/arsdigita/search/QueryEngineRegistry.java 2005-12-05 15:35:53 UTC (rev 1024) @@ -19,27 +19,28 @@ package com.arsdigita.search; import com.arsdigita.util.Assert; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.Map; -import java.util.HashMap; import java.util.Set; -import java.util.HashSet; - import org.apache.log4j.Logger; /** - * Provides a registry of query engine implementations for + * Provides a registry of query engine implementations for * various sets of filters. Application programmers do not need * to access instances of this class directly, rather they * should use the <code>process</code> method in the <code>Search</code> * class. - * + * * @see com.arsdigita.search.QueryEngine */ public class QueryEngineRegistry { - + private static Map s_engines = new HashMap(); - private static final Logger s_log = + private static final Logger s_log = Logger.getLogger(QueryEngineRegistry.class); static { @@ -50,11 +51,11 @@ /** * Registers a new query engine implementation for an - * indexer capable of accepting a specific set of filter + * indexer capable of accepting a specific set of filter * types. * @param indexer the search engine type * @param filters the filter types supported - * @param engine the engine implementation + * @param engine the engine implementation */ public static void registerEngine(IndexerType indexer, FilterType[] filters, @@ -66,11 +67,11 @@ /** * Registers a new query engine implementation for an - * indexer capable of accepting a specific set of filter + * indexer capable of accepting a specific set of filter * types. * @param indexer the search engine type * @param filters the filter types supported - * @param engine the engine implementation + * @param engine the engine implementation */ public static void registerEngine(String indexer, FilterType[] filters, @@ -78,16 +79,16 @@ Assert.exists(indexer, String.class); Assert.exists(filters, FilterType.class); Assert.exists(engine, QueryEngine.class); - + if (s_log.isDebugEnabled()) { s_log.debug("Register engine " + engine.getClass() + " for " + indexer); for (int i = 0 ; i < filters.length ; i++) { - s_log.debug(" Filter: " + filters[i].getKey() + " (" + + s_log.debug(" Filter: " + filters[i].getKey() + " (" + filters[i].getClass() + ")"); } } - - s_engines.put(new EngineKey(indexer, filters), + + s_engines.put(new EngineKey(indexer, filters), engine); } @@ -98,7 +99,7 @@ * @param filters the filter types requested * @return a search engine implementation, or null */ - public static QueryEngine getEngine(String indexer, + public static QueryEngine getEngine(String indexer, FilterType[] filters) { Assert.exists(indexer, String.class); Assert.exists(filters, FilterType.class); @@ -106,18 +107,32 @@ if (s_log.isDebugEnabled()) { s_log.debug("Lookup engine for " + indexer); for (int i = 0 ; i < filters.length ; i++) { - s_log.debug(" Filter: " + filters[i].getKey() + " (" + + s_log.debug(" Filter: " + filters[i].getKey() + " (" + filters[i].getClass() + ")"); } } - - return (QueryEngine)s_engines.get(new EngineKey(indexer, filters)); + QueryEngine engine = null; + for (Iterator it = s_engines.keySet().iterator(); it.hasNext(); ) { + EngineKey current = (EngineKey) it.next(); + if (current.containsAllFilters(filters)) { + if (s_log.isDebugEnabled()) { + s_log.debug("Found match: " + current); + } + engine = (QueryEngine) s_engines.get(current); + break; + } + } + if (s_log.isDebugEnabled()) { + s_log.debug("Returning: " + engine); + } + return engine; } + private static class EngineKey { private String m_indexer; private Set m_filters; - + public EngineKey(String indexer, FilterType[] filters) { m_indexer = indexer; @@ -126,7 +141,11 @@ m_filters.add(filters[i]); } } - + + public boolean containsAllFilters(FilterType[] filters) { + return m_filters.containsAll(Arrays.asList(filters)); + } + public int hashCode() { return m_filters.hashCode(); } @@ -135,14 +154,18 @@ if (!(o instanceof EngineKey)) { return false; } - + EngineKey key = (EngineKey)o; if (!m_indexer.equals(key.m_indexer)) { return false; } - + return m_filters.equals(key.m_filters); } + + public String toString() { + return "EngineKey[indexer: " + m_indexer + ", filters: " + m_filters + "]"; + } } } Modified: trunk/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java 2005-12-05 15:32:04 UTC (rev 1023) +++ trunk/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java 2005-12-05 15:35:53 UTC (rev 1024) @@ -18,17 +18,16 @@ */ package com.arsdigita.search.intermedia; +import com.arsdigita.db.DbHelper; import com.arsdigita.initializer.Configuration; import com.arsdigita.initializer.InitializationException; -import com.arsdigita.db.DbHelper; - -import com.arsdigita.search.Search; -import com.arsdigita.search.IndexerType; import com.arsdigita.search.FilterType; +import com.arsdigita.search.IndexerType; import com.arsdigita.search.QueryEngineRegistry; -import com.arsdigita.search.filters.PermissionFilterType; -import com.arsdigita.search.filters.ObjectTypeFilterType; +import com.arsdigita.search.Search; import com.arsdigita.search.filters.CategoryFilterType; +import com.arsdigita.search.filters.ObjectTypeFilterType; +import com.arsdigita.search.filters.PermissionFilterType; /** * Initializer @@ -154,9 +153,6 @@ BuildIndex.startTimer(); s_log.debug("Registering query engines"); QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, - new FilterType[] {}, - new BaseQueryEngine()); - QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, new FilterType[] { new PermissionFilterType(), new ObjectTypeFilterType(), Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/Initializer.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/lucene/Initializer.java 2005-12-05 15:32:04 UTC (rev 1023) +++ trunk/ccm-core/src/com/arsdigita/search/lucene/Initializer.java 2005-12-05 15:35:53 UTC (rev 1024) @@ -24,15 +24,16 @@ import com.arsdigita.search.IndexerType; import com.arsdigita.search.QueryEngineRegistry; import com.arsdigita.search.Search; - +import com.arsdigita.search.filters.CategoryFilterType; +import com.arsdigita.search.filters.ObjectTypeFilterType; import java.io.File; import java.io.IOException; import java.util.Date; - import org.apache.log4j.Logger; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.search.BooleanQuery; /** * Initializer @@ -69,6 +70,7 @@ Analyzer analyzer = conf.getAnalyzer(); LOG.info("Lucene index location: " + location); LOG.info("Lucene Analyzer = " + analyzer.getClass().getName()); + BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE); try { if (!IndexReader.indexExists(location)) { @@ -96,7 +98,10 @@ ((long)interval * 1000l)); QueryEngineRegistry.registerEngine - (IndexerType.LUCENE, new FilterType[] {}, + (IndexerType.LUCENE, new FilterType[] { + new CategoryFilterType(), + new ObjectTypeFilterType() + }, new BaseQueryEngine()); } } |
From: <ssk...@vh...> - 2005-12-05 15:34:17
|
Author: sskracic Date: 2005-12-05 16:32:04 +0100 (Mon, 05 Dec 2005) New Revision: 1023 Added: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/BaseQueryEngine.java Log: Implemented CategoryFilter for Lucene search engine. Modified: trunk/ccm-core/src/com/arsdigita/search/lucene/BaseQueryEngine.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/lucene/BaseQueryEngine.java 2005-12-05 15:24:09 UTC (rev 1022) +++ trunk/ccm-core/src/com/arsdigita/search/lucene/BaseQueryEngine.java 2005-12-05 15:32:04 UTC (rev 1023) @@ -18,33 +18,28 @@ */ package com.arsdigita.search.lucene; - +import com.arsdigita.categorization.Category; +import com.arsdigita.persistence.metadata.ObjectType; +import com.arsdigita.search.FilterSpecification; +import com.arsdigita.search.FilterType; import com.arsdigita.search.QueryEngine; +import com.arsdigita.search.QuerySpecification; +import com.arsdigita.search.ResultSet; import com.arsdigita.search.Search; -import com.arsdigita.search.ResultSet; -import com.arsdigita.search.QuerySpecification; -import com.arsdigita.search.FilterSpecification; -import com.arsdigita.search.FilterType; - +import com.arsdigita.search.filters.CategoryFilterSpecification; +import com.arsdigita.search.filters.CategoryFilterType; +import com.arsdigita.search.filters.ContentSectionFilterSpecification; +import com.arsdigita.search.filters.ContentSectionFilterType; import com.arsdigita.search.filters.ObjectTypeFilterSpecification; import com.arsdigita.search.filters.ObjectTypeFilterType; -import com.arsdigita.search.filters.ContentSectionFilterSpecification; -import com.arsdigita.search.filters.ContentSectionFilterType; - -import com.arsdigita.persistence.metadata.ObjectType; - - +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; - - +import org.apache.log4j.Logger; import org.apache.lucene.search.Filter; -import org.apache.log4j.Logger; - /** * This provides the basic lucene query engine implementation - * which can restrict based on object type + * which can restrict based on object type and categories. * @see com.arsdigita.search.QueryEngine */ public class BaseQueryEngine implements QueryEngine { @@ -59,49 +54,59 @@ */ public ResultSet process(QuerySpecification spec) { String terms = spec.getTerms(); - + if (terms == null || "".equals(terms)) { return Search.EMPTY_RESULT_SET; } - - s_log.debug("terms are " + terms); + s_log.debug("terms are " + terms); + List filters = new ArrayList(); addFilters(filters, spec.getFilters()); - s_log.debug("filters size is " + filters.size()); + s_log.debug("filters size is " + filters.size()); LuceneSearch search = null; if (filters.size() == 0) { search = new LuceneSearch(terms); } else { search = new LuceneSearch( - terms, + terms, new IntersectionFilter((Filter[])filters .toArray(new Filter[filters.size()]))); } - + return new LuceneResultSet(search); } - + protected void addFilters(List list, FilterSpecification[] filters) { for (int i = 0 ; i < filters.length ; i++) { addFilter(list, filters[i]); } } - + protected void addFilter(List list, FilterSpecification filter) { FilterType type = filter.getType(); - + if (ObjectTypeFilterType.KEY.equals(type.getKey())) { addObjectTypeFilter(list, (ObjectTypeFilterSpecification)filter); + } else if (ContentSectionFilterType.KEY.equals(type.getKey())) { + addContentSectionFilter(list, (ContentSectionFilterSpecification)filter); + } else if (CategoryFilterType.KEY.equals(type.getKey())) { + addCategoryFilter(list, (CategoryFilterSpecification)filter); } + } - if (ContentSectionFilterType.KEY.equals(type.getKey())) { - addContentSectionFilter(list, (ContentSectionFilterSpecification)filter); - } + protected void addCategoryFilter(List list, + CategoryFilterSpecification filterSpec) { + Category[] cats = filterSpec.getCategories(); + if (cats == null || cats.length == 0) { + return; + } + list.add(new CategoryFilter(cats)); } - + + protected void addObjectTypeFilter(List list, ObjectTypeFilterSpecification filter) { List l = new ArrayList(); @@ -111,7 +116,7 @@ } Filter[] filters = new Filter[types.length]; - for (int i = 0 ; i < types.length ; i++) { + for (int i = 0 ; i < types.length ; i++) { filters[i] = new ObjectTypeFilter(types[i].getQualifiedName()); } if (filter.isExclusion()) { @@ -119,23 +124,23 @@ } else { list.add(new UnionFilter(filters)); } - } + } protected void addContentSectionFilter(List list, - ContentSectionFilterSpecification filter) { - List l = new ArrayList(); - Object[] contentSections = filter.getSections(); - if (contentSections == null || contentSections.length == 0) { - return; - } - s_log.debug("Adding content section filter to search"); - Filter[] filters = new Filter[contentSections.length]; - for (int i = 0 ; i < contentSections.length ; i++) { - s_log.debug("content section filter is " + (String)contentSections[i]); + ContentSectionFilterSpecification filter) { + List l = new ArrayList(); + Object[] contentSections = filter.getSections(); + if (contentSections == null || contentSections.length == 0) { + return; + } + s_log.debug("Adding content section filter to search"); + Filter[] filters = new Filter[contentSections.length]; + for (int i = 0 ; i < contentSections.length ; i++) { + s_log.debug("content section filter is " + (String)contentSections[i]); filters[i] = new ContentSectionFilter((String)contentSections[i]); } - list.add(new UnionFilter(filters)); - + list.add(new UnionFilter(filters)); + // if (filter.isExclusion()) { // list.add(new NegationFilter(new UnionFilter(filters))); // } else { Added: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-05 15:24:09 UTC (rev 1022) +++ trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java 2005-12-05 15:32:04 UTC (rev 1023) @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2005 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.search.lucene; + +import com.arsdigita.categorization.Category; +import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.SessionManager; +import com.arsdigita.search.lucene.Document; +import java.io.IOException; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.Filter; +import org.apache.lucene.search.QueryFilter; +import org.apache.lucene.search.TermQuery; + +/** + * + * A filter based on the category membership. + * + * @author Sebastian Skracic (ssk...@re...) + * @version $Id$ + * + **/ + +public class CategoryFilter extends Filter { + + private String m_query; + private List m_cats; + private static final String + SEARCH_CATEGORY_OBJECTS_QUERY = "com.arsdigita.search.categoryObjects"; + + /** + * Create a new CategoryFilter with the default categorisation membership query + * + * @param categories restricts the returned result set to objects + * that are members of these categories + * + **/ + public CategoryFilter(Category[] categories) { + this(categories, SEARCH_CATEGORY_OBJECTS_QUERY); + } + + /** + * Create a CategoryFilter with a custom categorisation membership query + * passed in ID. The custom query must satisfy these 2 conditions: + * <ol> + * <li> it must accept a collection of BigDecimal category ID's + * as a bind paramater :ids + * <li> the result set must contain a BigDecimal field named "id" + * </ol> + * @param categories restricts the returned result set to objects + * that are members of these categories + * @param query the PDL query name used for categorisation membership check + */ + public CategoryFilter(Category[] categories, String query) { + List m_cats = new ArrayList(); + for (int i=0; i<categories.length; i++) { + m_cats.add(categories[i].getID()); + } + m_query = query; + } + + /** + * Returns a BitSet with true for documents which + * should be permitted in search results, and false + * for those that should not. + **/ + final public BitSet bits(IndexReader reader) throws IOException { + + BooleanQuery bq = new BooleanQuery(); + DataQuery dq = SessionManager.getSession() + .retrieveQuery(m_query); + dq.setParameter("ids", m_cats); + int docCount = 0; + while (dq.next()) { + docCount++; + bq.add(new TermQuery(new Term(Document.ID, dq.get("id").toString())), + false, false); + } + return new QueryFilter(bq).bits(reader); + } +} Property changes on: trunk/ccm-core/src/com/arsdigita/search/lucene/CategoryFilter.java ___________________________________________________________________ Name: svn:keywords + Id Author URL |
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()); + } } - + } |
From: <ssk...@vh...> - 2005-12-02 16:10:07
|
Author: sskracic Date: 2005-12-02 17:07:27 +0100 (Fri, 02 Dec 2005) New Revision: 1021 Modified: trunk/ccm-core/application.xml trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig.java trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig_parameter.properties trunk/ccm-core/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java Log: Adding another configuration parameter: waf.runtime.jdbc_resultset_windowsize. It denotes the width of the in-memory window for the fetched result set. Setting it to 0 means 'unlimited', ie. all rows from the retrieved result set are kept in memory until the result set is closed. This was the default persistence behavior and it's bad bad bad. The default setting is now 1 (a single row), which means keep as little as possible in memory. This alleviates the frequently reported OutOfMemory exception on Postgres. BUT, for this to work, both server and client must be on 8.0 or greater. This patch is not yet fully tested on Oracle, and it's currently unknown whether the memory usage is affected with it. Modified: trunk/ccm-core/application.xml =================================================================== --- trunk/ccm-core/application.xml 2005-11-30 16:28:00 UTC (rev 1020) +++ trunk/ccm-core/application.xml 2005-12-02 16:07:27 UTC (rev 1021) @@ -3,7 +3,7 @@ name="ccm-core" prettyName="Core" version="6.3.0" - release="4" + release="5" webapp="ROOT" buildHooks="build-hooks.xml"> <ccm:dependencies> Modified: trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig.java 2005-11-30 16:28:00 UTC (rev 1020) +++ trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig.java 2005-12-02 16:07:27 UTC (rev 1021) @@ -61,6 +61,7 @@ private final Parameter m_pingInterval; private final Parameter m_queryCacheSize; private final Parameter m_threadTagging; + private final Parameter m_resultSetWindowSize; /** * Constructs an empty RuntimeConfig object. @@ -81,12 +82,16 @@ ("waf.runtime.thread_tagging", Parameter.REQUIRED, Boolean.TRUE); + m_resultSetWindowSize = new IntegerParameter + ("waf.runtime.jdbc_resultset_windowsize", Parameter.REQUIRED, + new Integer(1)); register(m_url); register(m_poolSize); register(m_pingInterval); register(m_queryCacheSize); register(m_threadTagging); + register(m_resultSetWindowSize); loadInfo(); } @@ -115,6 +120,15 @@ return ((Integer) get(m_pingInterval)).longValue(); } + /** + * Returns the size of in-memory window of a fetched result set. + * + * @return 0 if all fetched rows are kept in memory (beware!) + */ + public final int getResultSetWindowSize() { + return ((Integer) get(m_resultSetWindowSize)).intValue(); + } + public final int getQueryCacheSize() { return ((Integer) get(m_queryCacheSize)).intValue(); } Modified: trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig_parameter.properties =================================================================== --- trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig_parameter.properties 2005-11-30 16:28:00 UTC (rev 1020) +++ trunk/ccm-core/src/com/arsdigita/runtime/RuntimeConfig_parameter.properties 2005-12-02 16:07:27 UTC (rev 1021) @@ -9,4 +9,8 @@ waf.runtime.jdbc_ping_interval.title=JDBC ping interval waf.runtime.jdbc_ping_interval.purpose=Interval used to test for idle connections to be returned to the pool waf.runtime.jdbc_ping_interval.example=30000 -waf.runtime.jdbc_ping_interval.format=[number] \ No newline at end of file +waf.runtime.jdbc_ping_interval.format=[number] +waf.runtime.jdbc_resultset_windowsize.title=ResultSet memory window size +waf.runtime.jdbc_resultset_windowsize.purpose=Number of result set rows kept in memory, 0=keep all rows in memory +waf.runtime.jdbc_resultset_windowsize.example=1 +waf.runtime.jdbc_resultset_windowsize.format=[number] Modified: trunk/ccm-core/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java =================================================================== --- trunk/ccm-core/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-11-30 16:28:00 UTC (rev 1020) +++ trunk/ccm-core/src/com/redhat/persistence/engine/rdbms/RDBMSEngine.java 2005-12-02 16:07:27 UTC (rev 1021) @@ -18,15 +18,18 @@ */ package com.redhat.persistence.engine.rdbms; +import com.arsdigita.runtime.RuntimeConfig; +import com.arsdigita.util.UncheckedWrapperException; +import com.arsdigita.util.WrappedError; import com.redhat.persistence.DataSet; import com.redhat.persistence.Engine; import com.redhat.persistence.Event; import com.redhat.persistence.PropertyMap; import com.redhat.persistence.QuerySource; import com.redhat.persistence.RecordSet; +import com.redhat.persistence.SQLWriterException; import com.redhat.persistence.SetEvent; import com.redhat.persistence.Signature; -import com.redhat.persistence.SQLWriterException; import com.redhat.persistence.common.CompoundKey; import com.redhat.persistence.common.Path; import com.redhat.persistence.metadata.Adapter; @@ -38,8 +41,6 @@ import com.redhat.persistence.oql.Expression; import com.redhat.persistence.oql.Query; import com.redhat.persistence.oql.Size; -import com.arsdigita.util.UncheckedWrapperException; -import com.arsdigita.util.WrappedError; import java.sql.Connection; import java.sql.PreparedStatement; @@ -80,6 +81,9 @@ private ArrayList m_mutations = new ArrayList(); private ArrayList m_mutationTypes = new ArrayList(); + private static int s_windowSize = + RuntimeConfig.getConfig().getResultSetWindowSize(); + private ConnectionSource m_source; private Connection m_conn = null; private int m_connUsers = 0; @@ -109,28 +113,28 @@ if (m_conn == null) { m_conn = m_source.acquire(); } - m_connUsers++; + m_connUsers++; } void release() { - if (m_conn == null) { - return; - } + if (m_conn == null) { + return; + } - m_connUsers--; + m_connUsers--; - if (m_connUsers == 0) { + if (m_connUsers == 0) { m_source.release(m_conn); m_conn = null; } } void releaseAll() { - if (m_conn != null) { - m_source.release(m_conn); - m_conn = null; - m_connUsers = 0; - } + if (m_conn != null) { + m_source.release(m_conn); + m_conn = null; + m_connUsers = 0; + } } void addOperation(Object obj, DML dml) { @@ -138,7 +142,7 @@ if (dml instanceof Delete) { DML prev = (DML) m_operationMap.get(key); if (prev != null) { - removeOperation(obj, prev); + removeOperation(obj, prev); } } m_operationMap.put(key, dml); @@ -147,8 +151,8 @@ void removeOperation(Object obj, DML dml) { Object key = new CompoundKey(obj, dml.getTable()); - m_operationMap.remove(key); - m_operations.remove(dml); + m_operationMap.remove(key); + m_operations.remove(dml); } DML getOperation(Object obj, Table table) { @@ -161,7 +165,7 @@ } void clearUpdates(Object obj) { - m_operationMap.remove(obj); + m_operationMap.remove(obj); } void removeUpdates(Object obj) { @@ -171,31 +175,31 @@ LOG.debug("found: " + ops); for (Iterator it = ops.iterator(); it.hasNext(); ) { Operation op = (Operation) it.next(); - if (op instanceof DML) { - removeOperation(obj, (DML) op); - } else { - m_operations.remove(op); - } + if (op instanceof DML) { + removeOperation(obj, (DML) op); + } else { + m_operations.remove(op); + } it.remove(); } } - clearUpdates(obj); + clearUpdates(obj); } void markUpdate(Object obj) { - if (!hasUpdates(obj)) { - m_operationMap.put(obj, new ArrayList()); - } + if (!hasUpdates(obj)) { + m_operationMap.put(obj, new ArrayList()); + } } void markUpdate(Object obj, Operation op) { - markUpdate(obj); - ArrayList ops = (ArrayList) m_operationMap.get(obj); - ops.add(op); + markUpdate(obj); + ArrayList ops = (ArrayList) m_operationMap.get(obj); + ops.add(op); } boolean hasUpdates(Object obj) { - return m_operationMap.containsKey(obj); + return m_operationMap.containsKey(obj); } void addOperation(Operation op) { @@ -485,6 +489,10 @@ try { if (cycle != null) { cycle.beginExecute(); } + if (s_windowSize > 0) { + ps.setFetchDirection(ResultSet.FETCH_FORWARD); + ps.setFetchSize(s_windowSize); + } if (ps.execute()) { if (cycle != null) { cycle.endExecute(0); } return new ResultCycle(this, ps.getResultSet(), cycle); |
From: <ssk...@vh...> - 2005-11-30 16:30:09
|
Author: sskracic Date: 2005-11-30 17:28:00 +0100 (Wed, 30 Nov 2005) New Revision: 1020 Added: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java Log: Integrated sourceforge patch [ 1369317 ] Search by category can include subcats. Modified: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-11-30 16:01:55 UTC (rev 1019) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java 2005-11-30 16:28:00 UTC (rev 1020) @@ -5,12 +5,12 @@ * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -18,35 +18,29 @@ package com.arsdigita.london.search.ui; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Form; -import com.arsdigita.bebop.FormModel; import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormModel; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.parameters.ParameterData; - +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.categorization.Category; +import com.arsdigita.cms.ui.search.ContentTypeFilterWidget; +import com.arsdigita.cms.ui.search.VersionFilterComponent; import com.arsdigita.kernel.permissions.PrivilegeDescriptor; +import com.arsdigita.search.FilterSpecification; +import com.arsdigita.search.Search; +import com.arsdigita.search.filters.ContentSectionFilterSpecification; import com.arsdigita.search.ui.BaseQueryComponent; import com.arsdigita.search.ui.filters.PermissionFilterComponent; -import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; -import com.arsdigita.search.Search; -import com.arsdigita.categorization.Category; import com.arsdigita.web.Application; import com.arsdigita.web.Web; -import com.arsdigita.cms.ui.search.VersionFilterComponent; -import com.arsdigita.cms.ui.search.ContentTypeFilterWidget; -import com.arsdigita.cms.SecurityManager; - -import com.arsdigita.search.FilterSpecification; -import com.arsdigita.search.filters.ContentSectionFilterSpecification; - -import org.apache.log4j.Logger; - import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; +import org.apache.log4j.Logger; public class AdvancedQueryComponent extends BaseQueryComponent { @@ -59,14 +53,15 @@ public AdvancedQueryComponent(String context) { - // XXX READ instead of CMS_READ_ITEM if (Search.getConfig().isIntermediaEnabled()) { add(new PermissionFilterComponent( PrivilegeDescriptor.READ)); - + Application app = Web.getContext().getApplication(); Category root = Category.getRootForObject(app); - add(new SimpleCategoryFilterWidget(root)); + // amended chr...@we... 29/11/05 + // changed from new SimpleCategoryFilterWidget + add(new CategoryHierarchyFilterWidget(root)); } if (Search.getConfig().isIntermediaEnabled() || @@ -78,11 +73,11 @@ } public void register(Form form, FormModel model) { - s_log.debug("Adding " + m_hiddenAllowedContentSectionsList.getName() + " to form model"); - m_hiddenAllowedContentSectionsList.setPassIn(true); - model.addFormParam(m_hiddenAllowedContentSectionsList); - super.register(form, model); - m_form = form; + s_log.debug("Adding " + m_hiddenAllowedContentSectionsList.getName() + " to form model"); + m_hiddenAllowedContentSectionsList.setPassIn(true); + model.addFormParam(m_hiddenAllowedContentSectionsList); + super.register(form, model); + m_form = form; } @@ -92,16 +87,16 @@ * If present the search will only return content items from these content sections. **/ protected String getContentSections(PageState state) { - FormData formData = m_form.getFormData(state); - if (formData != null) { - ParameterData contentSectionListParam = formData.getParameter(m_hiddenAllowedContentSectionsList.getName()); - String paramValue = (String)contentSectionListParam.getValue(); - m_paramValue = paramValue; - s_log.debug("content sections list is " + paramValue); - is_restricted = (m_paramValue != null && !"".equals(m_paramValue)); - return (String)contentSectionListParam.getValue(); - } - return null; + FormData formData = m_form.getFormData(state); + if (formData != null) { + ParameterData contentSectionListParam = formData.getParameter(m_hiddenAllowedContentSectionsList.getName()); + String paramValue = (String)contentSectionListParam.getValue(); + m_paramValue = paramValue; + s_log.debug("content sections list is " + paramValue); + is_restricted = (m_paramValue != null && !"".equals(m_paramValue)); + return (String)contentSectionListParam.getValue(); + } + return null; } @@ -109,17 +104,17 @@ * Gets an array of content section titles for creation of an inclusion filter. **/ public String[] getContentSectionsArray(PageState state) { - String contentSections = getContentSections(state); - if (contentSections == null) { return null; } - StringTokenizer st = new StringTokenizer(getContentSections(state), ","); - contentSectionTitles = new String[st.countTokens()]; - int index = 0; + String contentSections = getContentSections(state); + if (contentSections == null) { return null; } + StringTokenizer st = new StringTokenizer(getContentSections(state), ","); + contentSectionTitles = new String[st.countTokens()]; + int index = 0; while (st.hasMoreTokens()) { contentSectionTitles[index] = st.nextToken().trim(); s_log.info("Restricting to content section : "+contentSectionTitles[index]); index++; } - return contentSectionTitles; + return contentSectionTitles; } @@ -127,26 +122,26 @@ * Adds the content section filter to any existing filters. **/ protected FilterSpecification[] getFilters(PageState state) { - FilterSpecification[] existingfilters = super.getFilters(state); - List n = new ArrayList(); - try { - List filters = Arrays.asList(existingfilters); // this will throw a NullPointerException if there are no existing filters - n.addAll(filters); - } catch (NullPointerException e) { - // do we need to catch it if we're doing nothing with it? - } - String[] contentSections = getContentSectionsArray(state); - if (contentSections == null) { return existingfilters; } - ContentSectionFilterSpecification csfs = new ContentSectionFilterSpecification(contentSections); - n.add(csfs); - FilterSpecification[] newFilters = new FilterSpecification[n.size()]; - Iterator i = n.iterator(); - int c = 0; - while (i.hasNext()) { - newFilters[c] = (FilterSpecification)i.next(); - c++; - } + FilterSpecification[] existingfilters = super.getFilters(state); + List n = new ArrayList(); + try { + List filters = Arrays.asList(existingfilters); // this will throw a NullPointerException if there are no existing filters + n.addAll(filters); + } catch (NullPointerException e) { + // do we need to catch it if we're doing nothing with it? + } + String[] contentSections = getContentSectionsArray(state); + if (contentSections == null) { return existingfilters; } + ContentSectionFilterSpecification csfs = new ContentSectionFilterSpecification(contentSections); + n.add(csfs); + FilterSpecification[] newFilters = new FilterSpecification[n.size()]; + Iterator i = n.iterator(); + int c = 0; + while (i.hasNext()) { + newFilters[c] = (FilterSpecification)i.next(); + c++; + } - return newFilters; + return newFilters; } } Added: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java =================================================================== --- trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-11-30 16:01:55 UTC (rev 1019) +++ trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java 2005-11-30 16:28:00 UTC (rev 1020) @@ -0,0 +1,115 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.london.search.ui; + +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormModel; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.parameters.ParameterData; +import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.categorization.Category; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.persistence.OID; +import com.arsdigita.search.FilterSpecification; +import com.arsdigita.search.Search; +import com.arsdigita.search.filters.CategoryFilterSpecification; +import com.arsdigita.search.ui.filters.SimpleCategoryFilterWidget; +import com.arsdigita.xml.Element; +import java.util.HashSet; +import java.util.Set; + +/** + * @author chr...@we... + * + * Category filter widget that includes an extra parameter that can be used to + * search all the subcategories of the selected categories + * + * + * + */ +public class CategoryHierarchyFilterWidget extends SimpleCategoryFilterWidget { + + private Form m_form; + private StringParameter includeCategoryHierarchy; + /** + * @param root the root category for categories available for selection + */ + public CategoryHierarchyFilterWidget(Category root) { + this(new Category[] { root }); + + } + + public CategoryHierarchyFilterWidget(Category[] roots) { + super(roots); + includeCategoryHierarchy = new StringParameter("subcats"); + + } + + /** + * adds additional parameter to the underlying form model + */ + public void register(Form form, FormModel model) { + super.register(form, model); + model.addFormParam(includeCategoryHierarchy); + m_form = form; + } + + /** + * + * returns a FilterSpecification that includes the selected categories + * and if subcats parameter has a value, then includes all descendent + * categories of the selected categories + */ + public FilterSpecification getFilter(PageState state) { + OID[] oids = (OID[]) getValue(state); + if (oids == null) { + oids = new OID[0]; + } + FormData fd = m_form.getFormData(state); + boolean includeSubCats = false; + if (fd != null) { + ParameterData data = + fd.getParameter(includeCategoryHierarchy.getName()); + includeSubCats = data.getValue() != null; + } + Set includedCats = new HashSet(); + + for (int i = 0; i < oids.length; i++) { + Category cat = (Category) DomainObjectFactory.newInstance(oids[i]); + includedCats.add(cat); + } + Category[] cats = (Category []) includedCats.toArray(new Category[0]); + return new CategoryFilterSpecification(cats, includeSubCats); + } + + /** + * + * adds xml for the extra parameter to the <search:filter param="category" type="category"> element. + * The xml for the parameter is <search:includeSubCats name="subcats" value="true" /> which can be + * transformed into a checkbox or a hidden input + */ + public void generateBodyXML(PageState state, Element parent) { + super.generateBodyXML(state, parent); + Element includeSubCats = Search.newElement("includeSubCats"); + includeSubCats.addAttribute("name", includeCategoryHierarchy.getName()); + includeSubCats.addAttribute("value", "true"); + + parent.addContent(includeSubCats); + } + +} Property changes on: trunk/ccm-ldn-search/src/com/arsdigita/london/search/ui/CategoryHierarchyFilterWidget.java ___________________________________________________________________ Name: svn:keywords + Id Author URL |
From: <ssk...@vh...> - 2005-11-30 16:04:00
|
Author: sskracic Date: 2005-11-30 17:01:55 +0100 (Wed, 30 Nov 2005) New Revision: 1019 Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java Log: Adding support for querying membership of any category in the tree. Further, merged one of Chris' patches for IntermediaQueryEngine so that result set consists of both the rows from cms_items which have parents categorised, and rows from acs_objects that are categorised themselves. While it sounds weird at a first glance, b/c the filter would actually match items *and* their bundles, there's no harm done since bundles are not present in search_content table to which an inner join is performed. This functionality enables the content outside of cms_items to be searched if such is properly indexed in search_content. Modified: trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl =================================================================== --- trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-11-30 13:26:18 UTC (rev 1018) +++ trunk/ccm-cms/pdl/com/arsdigita/content-section/Search.pdl 2005-11-30 16:01:55 UTC (rev 1019) @@ -21,16 +21,43 @@ -query searchCategoryItems { +query searchCategoryObjects { BigDecimal id; do { + select m.object_id + from cat_object_category_map m + where m.category_id in :ids + union select i.item_id + from cat_object_category_map cm, + cms_items i + where cm.category_id in :ids + and cm.object_id = i.parent_id + } map { + id = m.object_id; + } +} + +query searchCategoryObjectsDescend { + 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 + union + select i.item_id + from cat_object_category_map cm, + cat_cat_subcat_trans_index cc2, cms_items i - where m.category_id in :ids - and m.object_id = i.parent_id + where cc2.category_id in :ids + and cc2.subcategory_id = cm.category_id + and cm.object_id = i.parent_id } map { - id = i.item_id; + id = m.object_id; } } + Modified: trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-11-30 13:26:18 UTC (rev 1018) +++ trunk/ccm-cms/src/com/arsdigita/cms/search/IntermediaQueryEngine.java 2005-11-30 16:01:55 UTC (rev 1019) @@ -222,7 +222,6 @@ f.set("types", l); } - // Override to use query that takes account of bundles :-( protected void addCategoryFilter(DataQuery query, CategoryFilterSpecification filter) { Category[] categories = filter.getCategories(); @@ -232,10 +231,18 @@ ids.add(categories[i].getID()); } - Filter f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.cms.searchCategoryItems"); + Filter f = null; + if (filter.shouldDescend()) { + f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.cms.searchCategoryObjectsDescend"); + } else { + f = query.addInSubqueryFilter( + "object_id", + "id", + "com.arsdigita.cms.searchCategoryObjects"); + } f.set("ids", ids); } |
From: <ssk...@vh...> - 2005-11-30 13:28:19
|
Author: sskracic Date: 2005-11-30 14:26:18 +0100 (Wed, 30 Nov 2005) New Revision: 1018 Modified: trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java Log: Added support for "descend" option in category filter. Modified: trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl =================================================================== --- trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-11-30 13:21:46 UTC (rev 1017) +++ trunk/ccm-core/pdl/com/arsdigita/search/Search.pdl 2005-11-30 13:26:18 UTC (rev 1018) @@ -32,3 +32,18 @@ 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/intermedia/BaseQueryEngine.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-11-30 13:21:46 UTC (rev 1017) +++ trunk/ccm-core/src/com/arsdigita/search/intermedia/BaseQueryEngine.java 2005-11-30 13:26:18 UTC (rev 1018) @@ -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,36 +286,43 @@ ids.add(categories[i].getID()); } - Filter f = query.addInSubqueryFilter( - "object_id", - "id", - "com.arsdigita.search.categoryObjects"); - + 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"); + } 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()); + } } - + } |
From: <ssk...@vh...> - 2005-11-30 13:24:12
|
Author: sskracic Date: 2005-11-30 14:21:46 +0100 (Wed, 30 Nov 2005) New Revision: 1017 Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java Log: CategoryFilter can now accept additional parameter, instructing the filter to look the membership of children categories as well. Modified: trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-11-30 12:05:40 UTC (rev 1016) +++ trunk/ccm-core/src/com/arsdigita/search/filters/CategoryFilterSpecification.java 2005-11-30 13:21:46 UTC (rev 1017) @@ -27,18 +27,29 @@ * 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) { - super(new Object[] { CATEGORIES, 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) }, new CategoryFilterType()); } - + /** * Returns the list of categories to check * @return the list of categories @@ -46,4 +57,11 @@ 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)); + } } |