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
master
pb 2008-02-15 20:58:45 +00:00
parent 8dc90db636
commit 9428bd1ffc
6 changed files with 201 additions and 6 deletions

View File

@ -2,8 +2,8 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/ccm-cms"/>
<classpathentry combineaccessrules="false" kind="src" path="/ccm-core"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/ccm-cms"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/ccm-core"/>
<classpathentry combineaccessrules="false" kind="src" path="/ccm-ldn-navigation"/>
<classpathentry combineaccessrules="false" kind="src" path="/ccm-ldn-subsite"/>
<classpathentry combineaccessrules="false" kind="src" path="/ccm-ldn-terms"/>

View File

@ -3,7 +3,7 @@
name="ccm-ldn-atoz"
prettyName="A-Z"
version="6.5.0"
release="1">
release="2">
<ccm:dependencies>
<ccm:requires name="ccm-core" version="6.2.0" relation="ge"/>
<ccm:requires name="ccm-cms" version="6.2.0" relation="ge"/>

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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