Author: apevec Date: 2005-12-13 23:52:55 +0100 (Tue, 13 Dec 2005) New Revision: 1050 Added: trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZSiteProxyProvider.pdl trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-ct_blacklist.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-item_provider.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-item_provider_alias.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-siteproxy_provider.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-6.3.0-6.3.1.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-6.3.0-6.3.1.sql trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyGenerator.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyProvider.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/admin/CategoryProviderContentTypeBlacklist.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/admin/CategoryProviderContentTypeBlockForm.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/admin/SiteProxyProviderAdmin.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/admin/SiteProxyProviderForm.java Removed: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider_alias.sql Modified: trunk/ccm-ldn-atoz/application.xml trunk/ccm-ldn-atoz/doc/atoz.xsd trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.0-1.0.1.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.2-1.0.3.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.0-1.0.1.sql trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.2-1.0.3.sql trunk/ccm-ldn-atoz/src/WEB-INF/resources/atoz-adapters.xml trunk/ccm-ldn-atoz/src/ccm-ldn-atoz.upgrade trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZAtomicEntry.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryGenerator.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZItemGenerator.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/Initializer.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/terms/DomainGenerator.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/AtoZPane.java trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/ui/admin/CategoryProviderAdmin.java trunk/ccm-ldn-atoz/web/__ccm__/apps/atoz/xsl/index.xsl Log: AtoZ application modifications and additions: - content type black list (filter out categories which have given content type(s) as a category index item) - new AtoZ provider displaying SiteProxy items in selected categories (see previous r1049) NB data model change: ccm upgrade ccm-ldn-atoz --from-version 6.3.0 --to-version 6.3.1 Modified: trunk/ccm-ldn-atoz/application.xml =================================================================== --- trunk/ccm-ldn-atoz/application.xml 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/application.xml 2005-12-13 22:52:55 UTC (rev 1050) @@ -2,8 +2,8 @@ <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" name="ccm-ldn-atoz" prettyName="A-Z" - version="6.3.0" - release="4"> + version="6.3.1" + release="1"> <ccm:dependencies> <ccm:requires name="ccm-core" version="6.2.0" relation="ge"/> <ccm:requires name="ccm-cms" version="6.2.0" relation="ge"/> @@ -11,6 +11,7 @@ <ccm:requires name="ccm-ldn-terms" version="6.2.0" relation="ge"/> <ccm:requires name="ccm-ldn-navigation" version="6.2.0" relation="ge"/> <ccm:requires name="ccm-ldn-subsite" version="6.2.0" relation="ge"/> + <ccm:requires name="ccm-cms-types-siteproxy" version="6.2.0" relation="ge"/> </ccm:dependencies> <ccm:contacts> <ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/> Modified: trunk/ccm-ldn-atoz/doc/atoz.xsd =================================================================== --- trunk/ccm-ldn-atoz/doc/atoz.xsd 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/doc/atoz.xsd 2005-12-13 22:52:55 UTC (rev 1050) @@ -70,6 +70,14 @@ <xs:attribute name="title" type="xs:string"/> <xs:attribute name="description" type="xs:string" use="optional"/> <xs:attribute name="url" type="xs:anyURI"/> + <xs:element name="siteProxyContent" minOccurs="0" maxOccurs="1"> + <xs:complexType> + <xs:attribute name="title" type="xs:string" use="required"/> + <xs:attribute name="dataType" type="xs:string"/> + <xs:attribute name="oid" type="xs:string"/> + <xs:any processContents="skip"/> + </xs:complexType> + </xs:element> </xs:complexType> <xs:complexType name="compoundEntry"> Modified: trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl =================================================================== --- trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl 2005-12-13 22:52:55 UTC (rev 1050) @@ -18,6 +18,7 @@ model com.arsdigita.london.atoz; import com.arsdigita.categorization.Category; +import com.arsdigita.cms.ContentType; object type AtoZCategoryProvider extends AtoZProvider { Boolean[1..1] isCompound = atoz_cat_provider.is_compound BIT; @@ -36,7 +37,6 @@ to cat_categories.category_id; } - association { AtoZCategoryProvider[0..n] atozProvider2 = join cat_categories.category_id to atoz_cat_alias_map.category_id, @@ -50,6 +50,17 @@ String[1..1] title = atoz_cat_alias_map.title VARCHAR(200); } +association { + AtoZCategoryProvider[0..n] atozProvider3 = join content_types.type_id + to atoz_cat_ct_blacklist_map.type_id, + join atoz_cat_ct_blacklist_map.provider_id + to atoz_cat_provider.provider_id; + + ContentType[0..n] atozContentTypeBlackList = join atoz_cat_provider.provider_id + to atoz_cat_ct_blacklist_map.provider_id, + join atoz_cat_ct_blacklist_map.type_id + to content_types.type_id; +} query getAtomicCategoryEntries { BigDecimal[1..1] id; @@ -94,6 +105,18 @@ where b.category_id = c.category_id and b.provider_id = :providerID ) + and not exists ( + select 1 + from atoz_cat_ct_blacklist_map b, cat_object_category_map m, + cms_bundles cb, cms_items ci + where b.type_id = ci.type_id + and ci.parent_id = cb.bundle_id + and ci.language = cb.default_language + and cb.bundle_id = m.object_id + and m.category_id = c.category_id + and m.index_p = '1' + and b.provider_id = :providerID + ) union select c.category_id as id, a.object_type as object_type, Added: trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZSiteProxyProvider.pdl =================================================================== --- trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZSiteProxyProvider.pdl 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZSiteProxyProvider.pdl 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,72 @@ +// +// 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 + +model com.arsdigita.london.atoz; + +import com.arsdigita.categorization.Category; + +object type AtoZSiteProxyProvider extends AtoZProvider { + Category[1..1] category = join atoz_siteproxy_provider.category_id to + cat_categories.category_id; + reference key (atoz_siteproxy_provider.provider_id); +} + +query getAtomicSiteProxyEntries { + BigDecimal[1..1] categoryId; + String[1..1] categoryTitle; + String[1..1] categoryDescription; + BigDecimal[1..1] id; + String[1..1] title; + String[1..1] url; + + do { + select c.category_id as cat_id, + c.name as cat_title, + c.description as cat_description, + i.master_id as id, + s.title_atoz as title, + s.url as url + from ct_siteproxy s, + cms_items i, + cat_categories c, + cat_object_category_map m, + cat_cat_subcat_trans_index ci, + atoz_siteproxy_provider p, + cms_bundles b + where s.site_id = i.item_id and + i.parent_id = m.object_id and + i.parent_id = b.bundle_id and + i.language = b.default_language and + m.category_id = c.category_id and + c.enabled_p=1 and + i.version = 'live' and + s.used_in_atoz='1' and + m.category_id = ci.subcategory_id and + ci.category_id = p.category_id and + p.provider_id = :providerID and + lower(c.name) like lower(:letter) + order by + lower(c.name), lower(s.title_atoz) + } map { + categoryId = cat_id; + categoryTitle = cat_title; + categoryDescription = cat_description; + id = id; + title = title; + url = url; + } +} Added: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-ct_blacklist.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-ct_blacklist.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-ct_blacklist.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,16 @@ +create table atoz_cat_ct_blacklist_map ( + provider_id INTEGER not null, + -- referential constraint for provider_id deferred due to circular dependencies + type_id INTEGER not null, + -- referential constraint for type_id deferred due to circular dependencies + constraint atoz_cat_ct_bla_map_pr_p_rqpg1 + primary key(type_id, provider_id) +); + +alter table atoz_cat_ct_blacklist_map add + constraint atoz_cat_ct_bla_map_pr_f_b2b9h foreign key (provider_id) + references atoz_cat_provider(provider_id); +alter table atoz_cat_ct_blacklist_map add + constraint atoz_cat_ct_bla_map_ty_f_lb9wc foreign key (type_id) + references content_types(type_id); + Copied: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-item_provider.sql (from rev 1046, trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider.sql) Copied: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-item_provider_alias.sql (from rev 1046, trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider_alias.sql) Added: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-siteproxy_provider.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-siteproxy_provider.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/default/upgrade/add-siteproxy_provider.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,16 @@ +create table atoz_siteproxy_provider ( + provider_id INTEGER not null + constraint atoz_site_prov_prov_id_p_p1eu6 + primary key, + -- referential constraint for provider_id deferred due to circular dependencies + category_id INTEGER not null + -- referential constraint for category_id deferred due to circular dependencies +); + +alter table atoz_siteproxy_provider add + constraint atoz_site_prov_cate_id_f_ubcwg foreign key (category_id) + references cat_categories(category_id); +alter table atoz_siteproxy_provider add + constraint atoz_site_prov_prov_id_f_3n5mw foreign key (provider_id) + references atoz_provider(provider_id); + Deleted: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider.sql Deleted: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/oracle-se/upgrade/add-item_provider_alias.sql Modified: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.0-1.0.1.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.0-1.0.1.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.0-1.0.1.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -1 +1 @@ -@@ ../oracle-se/upgrade/add-item_provider.sql +@@ ../default/upgrade/add-item_provider.sql Modified: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.2-1.0.3.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.2-1.0.3.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-1.0.2-1.0.3.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -1 +1 @@ -@@ ../oracle-se/upgrade/add-item_provider_alias.sql +@@ ../default/upgrade/add-item_provider_alias.sql Added: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-6.3.0-6.3.1.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-6.3.0-6.3.1.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/oracle-se-6.3.0-6.3.1.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,2 @@ +@@ ../default/upgrade/add-siteproxy_provider.sql +@@ ../default/upgrade/add-ct_blacklist.sql Modified: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.0-1.0.1.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.0-1.0.1.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.0-1.0.1.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -1,3 +1,3 @@ begin; -\i ../postgres/upgrade/add-item_provider.sql +\i ../default/upgrade/add-item_provider.sql commit; Modified: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.2-1.0.3.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.2-1.0.3.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-1.0.2-1.0.3.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -1,3 +1,3 @@ begin; -\i ../postgres/upgrade/add-item_provider_alias.sql +\i ../default/upgrade/add-item_provider_alias.sql commit; Added: trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-6.3.0-6.3.1.sql =================================================================== --- trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-6.3.0-6.3.1.sql 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/sql/ccm-ldn-atoz/upgrade/postgres-6.3.0-6.3.1.sql 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,4 @@ +begin; +\i ../default/upgrade/add-siteproxy_provider.sql +\i ../default/upgrade/add-ct_blacklist.sql +commit; Modified: trunk/ccm-ldn-atoz/src/WEB-INF/resources/atoz-adapters.xml =================================================================== --- trunk/ccm-ldn-atoz/src/WEB-INF/resources/atoz-adapters.xml 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/WEB-INF/resources/atoz-adapters.xml 2005-12-13 22:52:55 UTC (rev 1050) @@ -57,6 +57,21 @@ </xrd:associations> </xrd:adapter> + <xrd:adapter objectType="com.arsdigita.london.atoz.AtoZSiteProxyProvider"> + <xrd:attributes rule="exclude"> + <xrd:property name="/object/id"/> + <xrd:property name="/object/defaultDomainClass"/> + <xrd:property name="/object/displayName"/> + <xrd:property name="/object/category/id"/> + <xrd:property name="/object/category/objectType"/> + <xrd:property name="/object/category/defaultDomainClass"/> + <xrd:property name="/object/category/defaultAncestors"/> + </xrd:attributes> + <xrd:associations rule="include"> + <xrd:property name="/object/category"/> + </xrd:associations> + </xrd:adapter> + </xrd:context> <xrd:context name="com.arsdigita.london.atoz.ui.admin.CategoryProviderBlackList"> @@ -70,6 +85,17 @@ </xrd:adapter> </xrd:context> + <xrd:context name="com.arsdigita.london.atoz.ui.admin.CategoryProviderContentTypeBlacklist"> + <xrd:adapter objectType="com.arsdigita.cms.ContentType"> + <xrd:attributes rule="exclude"> + <xrd:property name="/object/id"/> + <xrd:property name="/object/objectType"/> + <xrd:property name="/object/defaultDomainClass"/> + <xrd:property name="/object/displayName"/> + </xrd:attributes> + </xrd:adapter> + </xrd:context> + <xrd:context name="com.arsdigita.london.atoz.ui.admin.CategoryProviderAliasList"> <xrd:adapter objectType="com.arsdigita.categorization.Category"> <xrd:attributes rule="exclude"> Modified: trunk/ccm-ldn-atoz/src/ccm-ldn-atoz.upgrade =================================================================== --- trunk/ccm-ldn-atoz/src/ccm-ldn-atoz.upgrade 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/ccm-ldn-atoz.upgrade 2005-12-13 22:52:55 UTC (rev 1050) @@ -5,4 +5,7 @@ <version from="1.0.2" to="1.0.3"> <script sql="ccm-ldn-atoz/upgrade/::database::-1.0.2-1.0.3.sql"/> </version> + <version from="6.3.0" to="6.3.1"> + <script sql="ccm-ldn-atoz/upgrade/::database::-6.3.0-6.3.1.sql"/> + </version> </upgrade> Modified: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZAtomicEntry.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZAtomicEntry.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZAtomicEntry.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -18,7 +18,10 @@ package com.arsdigita.london.atoz; +import com.arsdigita.xml.Element; + public interface AtoZAtomicEntry extends AtoZEntry { String getLink(); + Element getContent(); } Modified: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryGenerator.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryGenerator.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryGenerator.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -18,8 +18,6 @@ package com.arsdigita.london.atoz; - - import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.Filter; @@ -27,6 +25,7 @@ import com.arsdigita.web.ParameterMap; import com.arsdigita.web.URL; import com.arsdigita.web.Web; +import com.arsdigita.xml.Element; import java.util.List; import java.util.ArrayList; @@ -38,36 +37,31 @@ } public AtoZEntry[] getEntries(String letter) { - AtoZCategoryProvider provider = (AtoZCategoryProvider)getProvider(); - + AtoZCategoryProvider provider = (AtoZCategoryProvider) getProvider(); + DataQuery entries = provider.getAtomicEntries(); Filter f = entries.addFilter("sortKey like :sortKey"); f.set("sortKey", letter.toLowerCase() + "%"); entries.addOrder("sortKey"); - + List l = new ArrayList(); while (entries.next()) { - l.add(new AtoZCategoryAtomicEntry( - new OID( - (String)entries.get("objectType"), - entries.get("id") - ), - (String)entries.get("title"), - (String)entries.get("description") - )); + l.add(new AtoZCategoryAtomicEntry(new OID((String) entries + .get("objectType"), entries.get("id")), (String) entries + .get("title"), (String) entries.get("description"))); } - - return (AtoZEntry[])l.toArray(new AtoZEntry[l.size()]); + + return (AtoZEntry[]) l.toArray(new AtoZEntry[l.size()]); } - + private class AtoZCategoryAtomicEntry implements AtoZAtomicEntry { private OID m_oid; + private String m_title; + private String m_description; - - public AtoZCategoryAtomicEntry(OID oid, - String title, - String description) { + + public AtoZCategoryAtomicEntry(OID oid, String title, String description) { m_oid = oid; m_title = title; m_description = description; @@ -82,17 +76,18 @@ } public String getLink() { - ParameterMap map = new ParameterMap(); - map.setParameter("oid", m_oid.toString()); + ParameterMap map = new ParameterMap(); + map.setParameter("oid", m_oid.toString()); - URL here = Web.getContext().getRequestURL(); + URL here = Web.getContext().getRequestURL(); - return (new URL(here.getScheme(), - here.getServerName(), - here.getServerPort(), - "", - "", - "/redirect/", map)).toString(); + return (new URL(here.getScheme(), here.getServerName(), here + .getServerPort(), "", "", "/redirect/", map)).toString(); } + + public Element getContent() { + // empty + return null; + } } } Modified: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -18,44 +18,41 @@ package com.arsdigita.london.atoz; +import com.arsdigita.categorization.Category; +import com.arsdigita.cms.ContentType; +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.london.subsite.Site; +import com.arsdigita.london.subsite.Subsite; +import com.arsdigita.london.subsite.SubsiteContext; +import com.arsdigita.persistence.DataAssociation; +import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.OID; -import com.arsdigita.persistence.DataAssociation; -import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.SessionManager; -import com.arsdigita.domain.DomainCollection; -import com.arsdigita.categorization.Category; +public class AtoZCategoryProvider extends AtoZProvider { + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.london.atoz.AtoZCategoryProvider"; -import com.arsdigita.london.subsite.SubsiteContext; -import com.arsdigita.london.subsite.Subsite; -import com.arsdigita.london.subsite.Site; + public static final String IS_COMPOUND = "isCompound"; + public static final String IS_VISIBLE = "isVisible"; -import org.apache.log4j.Logger; + public static final String BLACK_LIST = "atozBlackList"; -public class AtoZCategoryProvider extends AtoZProvider { - - private static final Logger s_log = Logger.getLogger(AtoZCategoryProvider.class); + public static final String CT_BLACK_LIST = "atozContentTypeBlackList"; - public static final String BASE_DATA_OBJECT_TYPE - = "com.arsdigita.london.atoz.AtoZCategoryProvider"; - - public static final String IS_COMPOUND = "isCompound"; - public static final String IS_VISIBLE = "isVisible"; - public static final String BLACK_LIST = "atozBlackList"; public static final String ALIASES = "atozAliases"; - public static final String ATOMIC_ENTRIES = - "com.arsdigita.london.atoz.getAtomicCategoryEntries"; + public static final String CT_TYPE_ID = "type_id"; - public static final String ATOMIC_ENTRIES_FOR_ROOT_CATEGORY = - "com.arsdigita.london.atoz.getAtomicCategoryEntriesForRootCategory"; + public static final String ATOMIC_ENTRIES = "com.arsdigita.london.atoz.getAtomicCategoryEntries"; - public static final String COMPOUND_ENTRIES = - "com.arsdigita.london.atoz.getCompoundCategoryEntries"; + public static final String ATOMIC_ENTRIES_FOR_ROOT_CATEGORY = "com.arsdigita.london.atoz.getAtomicCategoryEntriesForRootCategory"; + public static final String COMPOUND_ENTRIES = "com.arsdigita.london.atoz.getCompoundCategoryEntries"; + public AtoZCategoryProvider() { this(BASE_DATA_OBJECT_TYPE); } @@ -63,7 +60,7 @@ protected AtoZCategoryProvider(String type) { super(type); } - + public AtoZCategoryProvider(DataObject obj) { super(obj); } @@ -74,42 +71,31 @@ public void delete() { Category.clearRootForObject(this); - + super.delete(); } - public static AtoZCategoryProvider create(String title, - String description, - boolean isCompound) { + public static AtoZCategoryProvider create(String title, String description, + boolean isCompound) { AtoZCategoryProvider provider = new AtoZCategoryProvider(); - provider.setup(title, - description, - isCompound); + provider.setup(title, description, isCompound); return provider; } - - - - protected void setup(String title, - String description, - boolean isCompound) { - super.setup(title, - description); + protected void setup(String title, String description, boolean isCompound) { + super.setup(title, description); setCompound(isCompound); } public boolean isCompound() { return Boolean.TRUE.equals(get(IS_COMPOUND)); } - + public void setCompound(boolean isCompound) { set(IS_COMPOUND, new Boolean(isCompound)); } - public void addAlias(Category cat, - String letter, - String title) { + public void addAlias(Category cat, String letter, String title) { DataObject link = add(ALIASES, cat); link.set("letter", letter); link.set("title", title); @@ -122,39 +108,47 @@ public void addBlock(Category cat) { add(BLACK_LIST, cat); } - + public void removeBlock(Category cat) { remove(BLACK_LIST, cat); } public DomainCollection getAliases() { - DataAssociation entries = (DataAssociation)get(ALIASES); + DataAssociation entries = (DataAssociation) get(ALIASES); return new DomainCollection(entries); } - + public DomainCollection getBlackList() { - DataAssociation entries = (DataAssociation)get(BLACK_LIST); + DataAssociation entries = (DataAssociation) get(BLACK_LIST); return new DomainCollection(entries); } - + + public DomainCollection getContentTypeBlackList() { + DataAssociation entries = (DataAssociation) get(CT_BLACK_LIST); + return new DomainCollection(entries); + } + public DataQuery getAtomicEntries() { - DataQuery cats = null; - SubsiteContext subsiteContext = Subsite.getContext(); - boolean useSubsiteSpecificNavigationCategory = AtoZ.getConfig().useSubsiteSpecificNavigationCategory(); // configured using ccm set - boolean hasSite = subsiteContext.hasSite(); - if (hasSite && useSubsiteSpecificNavigationCategory) { - Site site = subsiteContext.getSite(); - Category root = site.getRootCategory(); - cats = SessionManager.getSession().retrieveQuery(ATOMIC_ENTRIES_FOR_ROOT_CATEGORY); - cats.setParameter("providerID", getID()); - cats.setParameter("rootCategoryID", root.getID()); - } else { - cats = SessionManager.getSession().retrieveQuery(ATOMIC_ENTRIES); - cats.setParameter("providerID", getID()); - } + DataQuery cats = null; + SubsiteContext subsiteContext = Subsite.getContext(); + boolean useSubsiteSpecificNavigationCategory = AtoZ.getConfig() + .useSubsiteSpecificNavigationCategory(); // configured using + // ccm set + boolean hasSite = subsiteContext.hasSite(); + if (hasSite && useSubsiteSpecificNavigationCategory) { + Site site = subsiteContext.getSite(); + Category root = site.getRootCategory(); + cats = SessionManager.getSession().retrieveQuery( + ATOMIC_ENTRIES_FOR_ROOT_CATEGORY); + cats.setParameter("providerID", getID()); + cats.setParameter("rootCategoryID", root.getID()); + } else { + cats = SessionManager.getSession().retrieveQuery(ATOMIC_ENTRIES); + cats.setParameter("providerID", getID()); + } return cats; } - + public Category getRootCategory() { return Category.getRootForObject(this); } @@ -162,9 +156,32 @@ public void setRootCategory(Category root) { Category.setRootForObject(this, root); } - + public AtoZGenerator getGenerator() { return new AtoZCategoryGenerator(this); } - + + public void addContentTypeBlock(ContentType contentType) { + if (!isBlocked(contentType)) + add(CT_BLACK_LIST, contentType); + } + + private boolean isBlocked(ContentType contentType) { + DataAssociation da = (DataAssociation) get(CT_BLACK_LIST); + DataAssociationCursor cursor = da.cursor(); + while (cursor.next()) { + if (cursor.getDataObject().getOID() == contentType.getOID()) { + cursor.close(); + return true; + } + } + cursor.close(); + return false; + } + + public void removeContentTypeBlock(ContentType contentType) { + if (isBlocked(contentType)) + remove(CT_BLACK_LIST, contentType); + } + } Modified: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZItemGenerator.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZItemGenerator.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZItemGenerator.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -24,6 +24,7 @@ import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.OID; +import com.arsdigita.xml.Element; import java.math.BigDecimal; import java.util.ArrayList; @@ -36,13 +37,13 @@ } public AtoZEntry[] getEntries(String letter) { - AtoZItemProvider provider = (AtoZItemProvider)getProvider(); + AtoZItemProvider provider = (AtoZItemProvider) getProvider(); DataQuery entries = provider.getAtomicEntries(); Filter f = entries.addFilter("sortKey like :sortKey"); f.set("sortKey", letter.toLowerCase() + "%"); entries.addOrder("sortKey"); - + List l = new ArrayList(); ContentBundle bundle; ContentItem item; @@ -51,43 +52,46 @@ String title; while (entries.next()) { - bundle = new ContentBundle(new BigDecimal(entries.get("id").toString())); - if (bundle != null) { - item = bundle.getPrimaryInstance(); - if (item != null) { - // this is necessary because aliases refer to the non-live version, - // while straight items refer to the live-version (to avoid duplicates) - live = item.getLiveVersion(); - if (live != null) { - // should always be a ContentPage - description = (live instanceof ContentPage) ? - ((ContentPage) live).getSearchSummary() : live.getName(); - title = ""; - if (entries.get("aliasTitle") != null) { - title = entries.get("aliasTitle").toString(); - } - if (title.equals("")) { - title = live.getDisplayName(); - } - l.add(new AtoZItemAtomicEntry(live.getOID(), - title, - description)); - } - } - } + bundle = new ContentBundle(new BigDecimal(entries.get("id") + .toString())); + if (bundle != null) { + item = bundle.getPrimaryInstance(); + if (item != null) { + // this is necessary because aliases refer to the non-live + // version, + // while straight items refer to the live-version (to avoid + // duplicates) + live = item.getLiveVersion(); + if (live != null) { + // should always be a ContentPage + description = (live instanceof ContentPage) ? ((ContentPage) live) + .getSearchSummary() + : live.getName(); + title = ""; + if (entries.get("aliasTitle") != null) { + title = entries.get("aliasTitle").toString(); + } + if (title.equals("")) { + title = live.getDisplayName(); + } + l.add(new AtoZItemAtomicEntry(live.getOID(), title, + description)); + } + } + } } - return (AtoZEntry[])l.toArray(new AtoZEntry[l.size()]); + return (AtoZEntry[]) l.toArray(new AtoZEntry[l.size()]); } private class AtoZItemAtomicEntry implements AtoZAtomicEntry { private OID m_oid; + private String m_title; + private String m_description; - public AtoZItemAtomicEntry(OID oid, - String title, - String description) { + public AtoZItemAtomicEntry(OID oid, String title, String description) { m_oid = oid; m_title = title; m_description = description; @@ -104,5 +108,10 @@ public String getLink() { return "/redirect/?oid=" + m_oid; } + + public Element getContent() { + // empty + return null; + } } } Added: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyGenerator.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyGenerator.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyGenerator.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,176 @@ +/* + * 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.london.atoz; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import com.arsdigita.cms.contenttypes.SiteProxy; +import com.arsdigita.cms.dispatcher.SiteProxyPanel; +import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.OID; +import com.arsdigita.util.url.URLData; +import com.arsdigita.xml.Element; + +public class AtoZSiteProxyGenerator extends AbstractAtoZGenerator { + + /** + * Compound Entry for mathched Categories + * + */ + private class AtoZCategoriesCompoundEntry implements AtoZCompoundEntry { + + private List entries = new ArrayList(); + + private String m_title; + + private String m_description; + + /** + * + */ + public AtoZCategoriesCompoundEntry(String title, String description) { + m_title = title; + m_description = description; + } + + /* + * (non-Javadoc) + * + * @see com.arsdigita.london.atoz.AtoZCompoundEntry#getEntries() + */ + public AtoZEntry[] getEntries() { + return (AtoZEntry[]) entries.toArray(new AtoZEntry[entries.size()]); + } + + /* + * (non-Javadoc) + * + * @see com.arsdigita.london.atoz.AtoZEntry#getTitle() + */ + public String getTitle() { + return m_title; + } + + /* + * (non-Javadoc) + * + * @see com.arsdigita.london.atoz.AtoZEntry#getDescription() + */ + public String getDescription() { + return m_description; + } + + } + + private class AtoZSiteProxyAtomicEntry implements AtoZAtomicEntry { + private static final String ATOZ_SITE_PROXY_CONTENT_NAME = "atoz:siteProxyContent"; + + private OID m_oid; + + private String m_title; + + private String m_url; + + public AtoZSiteProxyAtomicEntry(OID oid, String title, String url) { + m_oid = oid; + m_title = title; + m_url = url; + } + + public String getTitle() { + return m_title; + } + + public String getDescription() { + return null; + } + + public String getLink() { + return "/redirect?oid=" + m_oid.toString(); + } + + public Element getContent() { + if (m_url == null) + return null; + + Element child = new Element( + AtoZSiteProxyAtomicEntry.ATOZ_SITE_PROXY_CONTENT_NAME); + child.addAttribute("title", m_title); + child.addAttribute("oid", m_oid.toString()); + + URLData data = SiteProxyPanel.internalGetRemoteXML(child, + this.m_url); + + /* check for data and exception */ + if (data == null) + return null; + if (data.getException() != null) + return null; + + return child; + } + } + + public AtoZSiteProxyGenerator(AtoZProvider provider) { + super(provider); + } + + public AtoZEntry[] getEntries(String letter) { + AtoZSiteProxyProvider siteProxyProvider = (AtoZSiteProxyProvider) getProvider(); + + DataQuery entries = siteProxyProvider.getAtomicEntries(letter); + + List list = new ArrayList(); + /* init previousCatId */ + BigDecimal previousCatId = new BigDecimal(-1); + /* watch categoryID for changes */ + + AtoZCategoriesCompoundEntry compoundEntry = null; + while (entries.next()) { + /* on category change add previous compoundEntry and create new one */ + if (previousCatId.compareTo(entries.get("categoryId")) != 0) { + if ((compoundEntry != null) + && (compoundEntry.entries.size() > 0)) + list.add(compoundEntry); + + /* create compound entry */ + compoundEntry = new AtoZCategoriesCompoundEntry( + (String) entries.get("categoryTitle"), (String) entries + .get("categoryDescription")); + /* assign current categoryId to previousCatId */ + previousCatId = (BigDecimal) entries.get("categoryId"); + } + + /* create atomic entry */ + AtoZSiteProxyAtomicEntry atomicEntry = new AtoZSiteProxyAtomicEntry( + new OID(SiteProxy.BASE_DATA_OBJECT_TYPE, entries.get("id")), + (String) entries.get("title"), (String) entries.get("url")); + + /* add it to coumpoundEntry if siteProxy content is not null */ + if (atomicEntry.getContent() != null) + compoundEntry.entries.add(atomicEntry); + } + /* finally add compoundEntry if exist and not empty */ + if ((compoundEntry != null) && (compoundEntry.entries.size() > 0)) + list.add(compoundEntry); + + return (AtoZEntry[]) list.toArray(new AtoZEntry[list.size()]); + } +} Added: trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyProvider.java =================================================================== --- trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyProvider.java 2005-12-13 22:39:04 UTC (rev 1049) +++ trunk/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZSiteProxyProvider.java 2005-12-13 22:52:55 UTC (rev 1050) @@ -0,0 +1,71 @@ +package com.arsdigita.london.atoz; + +import com.arsdigita.categorization.Category; +import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.DataQuery; .. |