From 9428bd1ffc4dc5081ddb9b8d2f510c47e725379e Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 15 Feb 2008 20:58:45 +0000 Subject: [PATCH] incorporating APLAWS patch r1685 | francois | 2007-10-15 09:57:47 +0200 (Mo, 15 Okt 2007) Add pdl quieries to return a category list containing only category with published content. Preserve default behaviour of a list containing all categories with an optional boolean ccm configuration parameter "com.arsdigita.london.atoz.filterCategoryProviders". Set to TRUE will return the filtered list. git-svn-id: https://svn.libreccm.org/ccm/trunk@34 8810af33-2d31-482b-a856-94f89814c4df --- ccm-ldn-atoz/.classpath | 4 +- ccm-ldn-atoz/application.xml | 2 +- .../london/atoz/AtoZCategoryProvider.pdl | 165 ++++++++++++++++++ .../london/atoz/AtoZCategoryProvider.java | 19 +- .../com/arsdigita/london/atoz/AtoZConfig.java | 13 +- .../atoz/AtoZConfig_parameter.properties | 4 + 6 files changed, 201 insertions(+), 6 deletions(-) diff --git a/ccm-ldn-atoz/.classpath b/ccm-ldn-atoz/.classpath index 8ad4c231f..cd815ef8c 100755 --- a/ccm-ldn-atoz/.classpath +++ b/ccm-ldn-atoz/.classpath @@ -2,8 +2,8 @@ - - + + diff --git a/ccm-ldn-atoz/application.xml b/ccm-ldn-atoz/application.xml index 10aadcee9..ba7a61374 100755 --- a/ccm-ldn-atoz/application.xml +++ b/ccm-ldn-atoz/application.xml @@ -3,7 +3,7 @@ name="ccm-ldn-atoz" prettyName="A-Z" version="6.5.0" - release="1"> + release="2"> diff --git a/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl b/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl index 88dd68fd5..ebf737d41 100755 --- a/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl +++ b/ccm-ldn-atoz/pdl/com/arsdigita/london/atoz/AtoZCategoryProvider.pdl @@ -217,3 +217,168 @@ query getAtomicCategoryEntriesForRootCategory { sortKey = sort_key; } } + + +query getAtomicFilteredCategoryEntries { + BigDecimal[1..1] id; + String[1..1] objectType; + String[1..1] title; + String[1..1] description; + String[1..1] sortKey; + + do { + select c.category_id as id, + a.object_type as object_type, + c.name as title, + c.description as description, + lower(c.name) as sort_key + from cat_categories c, + acs_objects a, + cat_cat_subcat_trans_index i, + cat_root_cat_object_map m + where c.category_id = a.object_id + and c.enabled_p = '1' + and c.category_id = i.subcategory_id + and i.category_id = m.category_id + and m.object_id = :providerID + and not exists ( + select 1 + from cat_cat_subcat_trans_index i2 + where i2.category_id in ( + select c2.category_id + from cat_categories c2 + where c2.enabled_p = '0' + ) + and i2.subcategory_id = c.category_id + ) + and not exists ( + select 1 + from atoz_cat_blacklist_map b + where b.category_id = c.category_id + and b.provider_id = :providerID + ) + and not exists ( + select 1 + from atoz_cat_alias_map b + 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 + ) + AND EXISTS ( + select 1 + from cat_object_category_map cocm + where cocm.category_id = c.category_id + ) + union + select c.category_id as id, + a.object_type as object_type, + m.title as title, + c.description as description, + lower(m.letter) as sort_key + from cat_categories c, + acs_objects a, + atoz_cat_alias_map m + where c.category_id = m.category_id + and c.category_id = a.object_id + and c.enabled_p = '1' + and m.provider_id = :providerID + } map { + id = id; + objectType = object_type; + title = title; + description = description; + sortKey = sort_key; + } +} + +query getAtomicFilteredCategoryEntriesForRootCategory { + BigDecimal[1..1] id; + String[1..1] objectType; + String[1..1] title; + String[1..1] description; + String[1..1] sortKey; + + do { + select c.category_id as id, + a.object_type as object_type, + c.name as title, + c.description as description, + lower(c.name) as sort_key + from cat_categories c, + acs_objects a, + cat_cat_subcat_trans_index i + where c.category_id = a.object_id + and c.category_id = i.subcategory_id + and c.enabled_p = '1' + and i.category_id = :rootCategoryID + and not exists ( + select 1 + from atoz_cat_blacklist_map b + where b.category_id = c.category_id + and b.provider_id = :providerID + ) + and not exists ( + select 1 + from cat_cat_subcat_trans_index i2 + where i2.category_id in ( + select c2.category_id + from cat_categories c2 + where c2.enabled_p = '0' + ) + and i2.subcategory_id = c.category_id + ) + and not exists ( + select 1 + from atoz_cat_alias_map b + 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 + ) + AND EXISTS ( + select 1 + from cat_object_category_map cocm + where cocm.category_id = c.category_id + ) + union + select c.category_id as id, + a.object_type as object_type, + m.title as title, + c.description as description, + lower(m.letter) as sort_key + from cat_categories c, + acs_objects a, + atoz_cat_alias_map m + where c.category_id = m.category_id + and c.category_id = a.object_id + and c.enabled_p = '1' + and m.provider_id = :providerID + } map { + id = id; + objectType = object_type; + title = title; + description = description; + sortKey = sort_key; + } +} diff --git a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java index 1e6eff08c..28102df4b 100755 --- a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java +++ b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZCategoryProvider.java @@ -56,6 +56,10 @@ public class AtoZCategoryProvider extends AtoZProvider { public static final String COMPOUND_ENTRIES = "com.arsdigita.london.atoz.getCompoundCategoryEntries"; + public static final String FILTERED_ATOMIC_ENTRIES = "com.arsdigita.london.atoz.getAtomicFilteredCategoryEntries"; + + public static final String FILTERED_ATOMIC_ENTRIES_FOR_ROOT_CATEGORY = "com.arsdigita.london.atoz.getAtomicFilteredCategoryEntriesForRootCategory"; + public AtoZCategoryProvider() { this(BASE_DATA_OBJECT_TYPE); } @@ -138,15 +142,26 @@ public class AtoZCategoryProvider extends AtoZProvider { .useSubsiteSpecificNavigationCategory(); // configured using // ccm set boolean hasSite = subsiteContext.hasSite(); + boolean filterCats = AtoZ.getConfig().filterCategoryProviders(); + if (hasSite && useSubsiteSpecificNavigationCategory) { Site site = subsiteContext.getSite(); Category root = site.getRootCategory(); + if(filterCats){ cats = SessionManager.getSession().retrieveQuery( - ATOMIC_ENTRIES_FOR_ROOT_CATEGORY); + FILTERED_ATOMIC_ENTRIES_FOR_ROOT_CATEGORY); + }else{ + 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); + if(filterCats){ + cats = SessionManager.getSession().retrieveQuery(FILTERED_ATOMIC_ENTRIES); + }else{ + cats = SessionManager.getSession().retrieveQuery(ATOMIC_ENTRIES); + } cats.setParameter("providerID", getID()); } return cats; diff --git a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig.java b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig.java index b4407d2cd..e286619a7 100755 --- a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig.java +++ b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig.java @@ -45,6 +45,7 @@ public class AtoZConfig extends AbstractConfig { private Parameter m_adapters; private Parameter m_rootCategoryPicker; private BooleanParameter m_useSubsiteSpecificNavigationCategory; + private BooleanParameter m_filterCategoryProdiver; public AtoZConfig() { m_types = new HashSet(); @@ -67,10 +68,16 @@ public class AtoZConfig extends AbstractConfig { ("com.arsdigita.london.atoz.use_subsite_specific_navigation_category", Parameter.OPTIONAL, Boolean.FALSE); + + m_filterCategoryProdiver = new BooleanParameter ( + "com.arsdigita.london.atoz.filterCategoryProviders", + Parameter.OPTIONAL, + Boolean.FALSE); register(m_adapters); register(m_rootCategoryPicker); - register(m_useSubsiteSpecificNavigationCategory); + register(m_useSubsiteSpecificNavigationCategory); + register(m_filterCategoryProdiver); loadInfo(); } @@ -100,4 +107,8 @@ public class AtoZConfig extends AbstractConfig { public boolean useSubsiteSpecificNavigationCategory() { return ((Boolean) get(m_useSubsiteSpecificNavigationCategory)).booleanValue(); } + + public boolean filterCategoryProviders () { + return ((Boolean) get(m_filterCategoryProdiver)).booleanValue(); + } } diff --git a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig_parameter.properties b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig_parameter.properties index a569881b2..4fcb7bb83 100755 --- a/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig_parameter.properties +++ b/ccm-ldn-atoz/src/com/arsdigita/london/atoz/AtoZConfig_parameter.properties @@ -10,3 +10,7 @@ com.arsdigita.london.atoz.use_subsite_specific_navigation_category.title=Make At com.arsdigita.london.atoz.use_subsite_specific_navigation_category.purpose=Set this to yes, and the AtoZ will use the subsite-specific navigation categories if you define *any* CategoryProvider com.arsdigita.london.atoz.use_subsite_specific_navigation_category.format=[boolean] com.arsdigita.london.atoz.use_subsite_specific_navigation_category.example=true +com.arsdigita.london.atoz.filterCategoryProviders.title=To filter out category without published items +com.arsdigita.london.atoz.filterCategoryProviders.purpose=if TRUE, the AtoZ category providers will only return Categories with published items +com.arsdigita.london.atoz.filterCategoryProviders.format=[boolean] +com.arsdigita.london.atoz.filterCategoryProviders.example=false \ No newline at end of file