forum-categorized Abhängigkeit von ccm-ldn-aplaws beseitigt.
Dazu mussten 3 Klassen von c.ad.london.aplaws.ui nach c.ad.london.terms.ui verlegt werden. Aus aplaws.config wurde der Parameter ajax-expand-on-all-branches nach terms verlegt. forum-categorized compiliert und startet. Auf der Seite wird das Navigationsmenue eingeblendet und ein neuer Tabulator "Categories" erscheint. Darunter ist noch keine Aktion möglich, es werden noch nicht alle tags in XSLT verarbeitet. git-svn-id: https://svn.libreccm.org/ccm/trunk@457 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
213b29cca9
commit
db9c206db9
|
|
@ -11,7 +11,8 @@
|
|||
<ccm:requires name="ccm-forum" version="6.4.0" relation="ge"/>
|
||||
<ccm:requires name="ccm-ldn-navigation" version="6.4.0" relation="ge"/>
|
||||
<ccm:requires name="ccm-ldn-terms" version="6.4.0" relation="ge"/>
|
||||
<!-- <ccm:requires name="ccm-ldn-aplaws" version="6.4.0" relation="ge"/> -->
|
||||
<!-- <ccm:requires name="ccm-ldn-aplaws" version="6.4.0" relation="ge"/>
|
||||
<ccm:requires name="ccm-gen-aplaws" version="6.4.0" relation="ge"/> -->
|
||||
</ccm:dependencies>
|
||||
|
||||
<ccm:directories>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<table name="acs_objects"/>
|
||||
</requires>
|
||||
<provides>
|
||||
<initializer class="com.arsdigita.categorisedforum.Initializer"/>
|
||||
<initializer class="com.arsdigita.forum.categorised.Initializer"/>
|
||||
</provides>
|
||||
|
||||
</load>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
<upgrade>
|
||||
<version from="1.4.2" to="1.4.3">
|
||||
<script sql="ccm-forum/upgrade/::database::-1.4.2-1.4.3.sql"/>
|
||||
</version>
|
||||
<version from="1.4.3" to="1.4.4">
|
||||
<script sql="ccm-forum/upgrade/::database::-1.4.3-1.4.4.sql"/>
|
||||
</version>
|
||||
<version from="1.4.4" to="1.4.5">
|
||||
<script sql="ccm-forum/upgrade/::database::-1.4.4-1.4.5.sql"/>
|
||||
</version>
|
||||
|
||||
</upgrade>
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.bebop.Label;
|
||||
// import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
|
|
@ -19,16 +19,17 @@ import com.arsdigita.bebop.event.ActionEvent;
|
|||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
|
||||
// import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
|
||||
import com.arsdigita.categorization.ui.ACSObjectCategorySummary;
|
||||
import com.arsdigita.forum.ui.Constants;
|
||||
import com.arsdigita.web.RedirectSignal;
|
||||
|
||||
/**
|
||||
* @author cgyg9330
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments.
|
||||
*
|
||||
* @author cgyg9330
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class AssignCategoryView extends SimpleContainer implements Constants {
|
||||
|
||||
|
|
@ -38,6 +39,10 @@ public class AssignCategoryView extends SimpleContainer implements Constants {
|
|||
private StringParameter m_mode;
|
||||
Logger s_log = Logger.getLogger(AssignCategoryView.class);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public AssignCategoryView() {
|
||||
super();
|
||||
|
||||
|
|
@ -59,6 +64,11 @@ public class AssignCategoryView extends SimpleContainer implements Constants {
|
|||
add(m_add);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
|
||||
|
|
@ -68,6 +78,10 @@ public class AssignCategoryView extends SimpleContainer implements Constants {
|
|||
p.addGlobalStateParam(m_mode);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void reset(PageState state) {
|
||||
state.setValue(m_root, null);
|
||||
state.setValue(m_mode, null);
|
||||
|
|
@ -76,6 +90,9 @@ public class AssignCategoryView extends SimpleContainer implements Constants {
|
|||
m_add.setVisible(state, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private class AddActionListener implements ActionListener {
|
||||
private String m_mode;
|
||||
|
||||
|
|
@ -97,17 +114,16 @@ public class AssignCategoryView extends SimpleContainer implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private class ResetListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
reset(state);
|
||||
throw new RedirectSignal(state.toURL(), true);
|
||||
}
|
||||
}/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
// import javax.servlet.ServletException;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.forum.Forum;
|
||||
|
|
@ -21,10 +21,11 @@ import com.arsdigita.kernel.security.UserContext;
|
|||
import com.arsdigita.xml.Element;
|
||||
|
||||
/**
|
||||
* @author cgyg9330
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*
|
||||
* @author cgyg9330
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class CategorisedForumComponent extends ForumComponent {
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
|
|
@ -4,17 +4,17 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import com.arsdigita.aplaws.ui.CategorySubtree;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
// import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.cms.ui.authoring.EmptyPage;
|
||||
import com.arsdigita.forum.ForumPageBuilder;
|
||||
// import com.arsdigita.forum.ForumPageBuilder;
|
||||
import com.arsdigita.forum.PageBuilder;
|
||||
import com.arsdigita.forum.ThreadPageBuilder;
|
||||
import com.arsdigita.london.navigation.ui.category.Menu;
|
||||
import com.arsdigita.london.navigation.ui.category.Path;
|
||||
// import com.arsdigita.forum.ThreadPageBuilder;
|
||||
// import com.arsdigita.london.navigation.ui.category.Menu;
|
||||
// import com.arsdigita.london.navigation.ui.category.Path;
|
||||
import com.arsdigita.london.terms.ui.CategorySubtree;
|
||||
|
||||
/**
|
||||
* @author cgyg9330
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.categorization.Category;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -16,19 +16,24 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.aplaws.ui.ACSObjectCategoryPicker;
|
||||
import com.arsdigita.aplaws.ui.TermWidget;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
|
||||
import com.arsdigita.forum.ForumContext;
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.london.terms.ui.ACSObjectCategoryPicker;
|
||||
import com.arsdigita.london.terms.ui.TermWidget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Chris Gilbert
|
||||
* @version $Id: $
|
||||
*/
|
||||
public class ForumTermPicker extends ACSObjectCategoryPicker {
|
||||
private static final Logger s_log = Logger.getLogger(ForumTermPicker.class);
|
||||
|
||||
|
|
@ -12,14 +12,14 @@
|
|||
* governing rights and limitations under the License.
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.forum.Forum;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
// import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.NoValidURLException;
|
||||
import com.arsdigita.kernel.URLFinder;
|
||||
import com.arsdigita.persistence.OID;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.categorisedforum;
|
||||
package com.arsdigita.forum.categorised;
|
||||
import com.arsdigita.db.DbHelper;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
|
||||
|
|
@ -68,10 +68,6 @@ import org.apache.log4j.Logger;
|
|||
* @version $Id: Initializer.java,v 1.1 2006/03/03 10:54:45 cgyg9330 Exp $
|
||||
*/
|
||||
public class Initializer extends CompoundInitializer {
|
||||
public final static String versionId =
|
||||
"$Id: Initializer.java,v 1.1 2006/03/03 10:54:45 cgyg9330 Exp $" +
|
||||
"$Author: cgyg9330 $" +
|
||||
"$DateTime: 2004/08/17 23:26:27 $";
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(Initializer.class);
|
||||
|
||||
|
|
@ -20,6 +20,7 @@ package com.arsdigita.london.terms;
|
|||
|
||||
import com.arsdigita.runtime.AbstractConfig;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.BooleanParameter;
|
||||
import com.arsdigita.util.parameter.ResourceParameter;
|
||||
import com.arsdigita.util.parameter.StringParameter;
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ public class TermsConfig extends AbstractConfig {
|
|||
|
||||
private Parameter m_adapters;
|
||||
private Parameter m_defaultDomain;
|
||||
private final Parameter m_ajaxExpandAllBranches;
|
||||
|
||||
public TermsConfig() {
|
||||
m_adapters = new ResourceParameter
|
||||
|
|
@ -50,9 +52,17 @@ public class TermsConfig extends AbstractConfig {
|
|||
"com.arsdigita.london.terms.default_domain",
|
||||
Parameter.REQUIRED,
|
||||
"LGCL");
|
||||
|
||||
/** Wether to expand all Subcategories in order to retain behavious prior
|
||||
* to use AJAX to expand dynamically. */
|
||||
m_ajaxExpandAllBranches = new BooleanParameter(
|
||||
"com.arsdigita.london.terms.ajax_expand_on_all_branches",
|
||||
Parameter.OPTIONAL,
|
||||
Boolean.FALSE);
|
||||
|
||||
register(m_adapters);
|
||||
register(m_defaultDomain);
|
||||
register(m_ajaxExpandAllBranches);
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
|
|
@ -79,4 +89,13 @@ public class TermsConfig extends AbstractConfig {
|
|||
public Domain getDefaultDomain() {
|
||||
return Domain.retrieve(getDefaultDomainKey());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean ajaxExpandAllBranches () {
|
||||
return ((Boolean)get(m_ajaxExpandAllBranches)).booleanValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,3 +7,8 @@ com.arsdigita.london.terms.default_domain.title=Default domain
|
|||
com.arsdigita.london.terms.default_domain.purpose=The default navigation domain
|
||||
com.arsdigita.london.terms.default_domain.format=[string]
|
||||
com.arsdigita.london.terms.default_domain.example=LGCL
|
||||
|
||||
com.arsdigita.london.terms.ajax_expand_on_all_branches.title=Use Ajax on all branch expansions
|
||||
com.arsdigita.london.terms.ajax_expand_on_all_branches.purpose=Use Ajax on all branches, or bring back entire subtree on expansion of top level root
|
||||
com.arsdigita.london.terms.ajax_expand_on_all_branches.example=true|false
|
||||
com.arsdigita.london.terms.ajax_expand_on_all_branches.format=[boolean]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,282 @@
|
|||
/*
|
||||
* Copyright (C) 2001-2004 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.terms.ui;
|
||||
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.london.terms.Term;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* abstracted from original version of
|
||||
* c.ad.aplaws.ui.ItemCategoryPicker r1297
|
||||
*
|
||||
* @author Chris Gilbert
|
||||
*/
|
||||
// NON JavaDoc:
|
||||
// copied from c.ad.aplaws.ui (module ccm-ldn-aplaws) in order to avoid a
|
||||
// dependency from the integration layer for forum-categorised. Otherwise you
|
||||
// have had to specify the specific integration layer (i.e. ccm-???-aplaws) in
|
||||
// application.xml for compiling, which may be different for each installation.
|
||||
public abstract class ACSObjectCategoryPicker extends SimpleContainer {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ACSObjectCategoryPicker.class);
|
||||
|
||||
private ACSObjectCategoryForm m_form;
|
||||
private BigDecimalParameter m_root;
|
||||
|
||||
public ACSObjectCategoryPicker(BigDecimalParameter root,
|
||||
StringParameter mode) {
|
||||
|
||||
m_form = getForm(root, mode);
|
||||
m_root = root;
|
||||
|
||||
add(m_form);
|
||||
m_form.addCompletionListener(new ItemCategoryFormCompletion());
|
||||
}
|
||||
|
||||
protected abstract ACSObjectCategoryForm getForm(BigDecimalParameter root, StringParameter mode);
|
||||
|
||||
protected abstract ACSObject getObject(PageState state);
|
||||
|
||||
|
||||
|
||||
|
||||
private class ItemCategoryFormCompletion implements ActionListener {
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
|
||||
PageState state = ev.getPageState();
|
||||
Domain domain = getDomain(state);
|
||||
String domainKey = domain.getKey();
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Saving categories in: " + domainKey);
|
||||
}
|
||||
|
||||
ACSObject object = getObject(state);
|
||||
|
||||
if ("LGCL".equals(domainKey)) {
|
||||
lgclSelected(domain, object);
|
||||
}
|
||||
|
||||
else if ("LGDL".equals(domainKey)) {
|
||||
lgdlSelected(domain, object);
|
||||
}
|
||||
|
||||
fireCompletionEvent(state);
|
||||
}
|
||||
|
||||
private void lgclSelected(Domain domain, ACSObject object) {
|
||||
List lgclTerms = getCurrentCategories(domain, object);
|
||||
|
||||
Domain gcl = Domain.retrieve("GCL");
|
||||
Collection gclTerms = getRelatedTerms(lgclTerms, gcl);
|
||||
clearTerms(gcl, object);
|
||||
assignTerms(gclTerms, object);
|
||||
|
||||
// The assignment below is removed to satisfy requirement 4.1,
|
||||
// use case 1 of the document "Metadata Improvements" version 1
|
||||
// by Camden, dated 23/01/05.
|
||||
//Domain lgsl = Domain.retrieve("LGSL");
|
||||
//Collection lgslTerms = getRelatedTerms(lgclTerms, lgsl);
|
||||
//clearTerms(lgsl, object);
|
||||
//assignTerms(lgslTerms, object);
|
||||
|
||||
// adding processing or mapping from LGCL to APLAWS-NAV too
|
||||
// Deactivated here.
|
||||
// If needed
|
||||
// boolean lgclOverrideAnav = Aplaws.getAplawsConfig().getOverrideAnavFromLGCLMappings().booleanValue();
|
||||
// if (lgclOverrideAnav) {
|
||||
// Domain aplawsNav = Domain.retrieve("APLAWS-NAV");
|
||||
// Collection aplawsNavTerms = getRelatedTerms(lgclTerms, aplawsNav);
|
||||
// clearTerms(aplawsNav, object);
|
||||
// assignTerms(aplawsNavTerms, object);
|
||||
// }
|
||||
}
|
||||
|
||||
// User has selected a term in the LGDL hierarchy, which includes
|
||||
// terms from the LGSL. We're only interested in LGSL terms here.
|
||||
private void lgdlSelected(Domain domain, ACSObject object) {
|
||||
Domain lgsl = Domain.retrieve("LGSL");
|
||||
Domain gcl = Domain.retrieve("GCL");
|
||||
Domain lgcl = Domain.retrieve("LGCL");
|
||||
|
||||
// We have a mapping LGSL -> LGCL based on the reverse of a
|
||||
// published mapping. We don't have a mapping LGSL -> GCL, so we
|
||||
// do LGSL -> LGCL -> GCL instead.
|
||||
|
||||
List lgslTerms = getCurrentCategories(lgsl, object);
|
||||
Collection lgclTerms = getRelatedTerms(lgslTerms, lgcl);
|
||||
|
||||
LinkedList lgclIDs = new LinkedList();
|
||||
Iterator i = lgclTerms.iterator();
|
||||
while (i.hasNext()) {
|
||||
Term term = (Term) i.next();
|
||||
lgclIDs.add(term.getModel().getID());
|
||||
}
|
||||
|
||||
Collection gclTerms = getRelatedTerms(lgclIDs, gcl);
|
||||
|
||||
clearTerms(lgcl, object);
|
||||
assignTerms(lgclTerms, object);
|
||||
|
||||
clearTerms(gcl, object);
|
||||
assignTerms(gclTerms, object);
|
||||
}
|
||||
}
|
||||
|
||||
protected List getCurrentCategories(Domain domain,
|
||||
ACSObject object) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting terms from " + domain + " to " + object);
|
||||
}
|
||||
DomainCollection terms = domain.getTerms();
|
||||
terms.addEqualsFilter("model.childObjects.id", object.getID());
|
||||
terms.addPath("model.id");
|
||||
|
||||
List current = new LinkedList();
|
||||
while (terms.next()) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got term " + terms.get("model.id"));
|
||||
}
|
||||
current.add(terms.get("model.id"));
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
// TODO move out of UI code
|
||||
public static Collection getCurrentTerms(Domain domain,
|
||||
ACSObject object) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting terms from " + domain + " to " + object);
|
||||
}
|
||||
Collection current = new LinkedList();
|
||||
DomainCollection terms = domain.getTerms();
|
||||
terms.addEqualsFilter("model.childObjects.id", object.getID());
|
||||
terms.addPath("model.id");
|
||||
while (terms.next()) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got term " + terms.get("model.id"));
|
||||
}
|
||||
current.add(terms.getDomainObject());
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
// TODO move out of UI code
|
||||
public static Collection getRelatedTerms(Collection src,
|
||||
Domain domain) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting related terms to " + domain);
|
||||
|
||||
}
|
||||
if (src.isEmpty()) {
|
||||
// this is a hack, it would be better not to use a completion event listener as
|
||||
// this is called even when the form is cancelled...
|
||||
return new LinkedList();
|
||||
}
|
||||
DomainCollection terms = domain.getTerms();
|
||||
// these next two lines build the query
|
||||
terms.addEqualsFilter("model.parents.link.relationType", "related");
|
||||
terms.addFilter("model.parents.id in :ids").set("ids", src);
|
||||
|
||||
Collection related = new LinkedList();
|
||||
while (terms.next()) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got term " + terms.getDomainObject());
|
||||
}
|
||||
related.add(terms.getDomainObject());
|
||||
}
|
||||
return related;
|
||||
}
|
||||
|
||||
protected void clearTerms(Domain domain,
|
||||
ACSObject object) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing terms from " + domain + " to " + object);
|
||||
}
|
||||
Iterator terms = getCurrentTerms(domain, object).iterator();
|
||||
while (terms.hasNext()) {
|
||||
Term term = (Term)terms.next();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Removing term " + term + " from " + object);
|
||||
}
|
||||
term.removeObject(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO move out of UI code
|
||||
public static void assignTerms(Collection terms,
|
||||
ACSObject object) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Assigning terms to " + object);
|
||||
}
|
||||
Iterator i = terms.iterator();
|
||||
while (i.hasNext()) {
|
||||
Term term = (Term)i.next();
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Assigning term " + term + " to " + object);
|
||||
}
|
||||
term.addObject(object);
|
||||
}
|
||||
}
|
||||
|
||||
protected Domain getDomain(PageState state) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Getting domain for " + state.getValue(m_root));
|
||||
}
|
||||
|
||||
DataCollection domains = SessionManager.getSession()
|
||||
.retrieve(Domain.BASE_DATA_OBJECT_TYPE);
|
||||
domains.addEqualsFilter("model.id",
|
||||
state.getValue(m_root));
|
||||
|
||||
if (domains.next()) {
|
||||
Domain domain = (Domain)DomainObjectFactory
|
||||
.newInstance(domains.getDataObject());
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Got domain " + domain);
|
||||
}
|
||||
domains.close();
|
||||
return domain;
|
||||
}
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("No domain found");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.arsdigita.london.terms.ui;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
// import java.util.Iterator;
|
||||
// import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SimpleComponent;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.xml.Element;
|
||||
|
||||
/**
|
||||
* Generate part of the category tree. Used by Assign Category authoring step.
|
||||
*
|
||||
* @author Alan Pevec
|
||||
*/
|
||||
public class CategorySubtree extends SimpleComponent {
|
||||
|
||||
StringParameter nodeIDparam = new StringParameter("nodeID");
|
||||
|
||||
private static Logger s_log = Logger.getLogger(CategorySubtree.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
super.register(p);
|
||||
p.addGlobalStateParam(nodeIDparam);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param state
|
||||
* @param p
|
||||
*/
|
||||
@Override
|
||||
public void generateXML(PageState state, Element p) {
|
||||
|
||||
String node = (String)state.getValue(nodeIDparam);
|
||||
s_log.debug("selected node = " + node);
|
||||
String[] pathElements = StringUtils.split(node, "-");
|
||||
|
||||
Category root = (Category) DomainObjectFactory.newInstance(new OID(
|
||||
Category.BASE_DATA_OBJECT_TYPE, new BigDecimal(pathElements[pathElements.length - 1])));
|
||||
s_log.debug("generating subtree for cat " + root.getID());
|
||||
TermWidget.generateSubtree(p, root);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
* Copyright (C) 2004 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.terms.ui;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.form.Widget;
|
||||
import com.arsdigita.bebop.parameters.ArrayParameter;
|
||||
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.domain.DomainCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.london.terms.Domain;
|
||||
import com.arsdigita.london.terms.Term;
|
||||
import com.arsdigita.london.terms.Terms;
|
||||
import com.arsdigita.london.terms.indexing.Indexer;
|
||||
import com.arsdigita.london.terms.indexing.RankedTerm;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.xml.Element;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
||||
/**
|
||||
* A Widget for selecting Terms. Based heavily on CategoryWidget.
|
||||
*
|
||||
* @author mbooth@redhat.com
|
||||
*
|
||||
* Chris Gilbert - updated to identify each node uniquely (correct behaviour
|
||||
* for polyhierarchical trees) - also, allow ajax update on all branches or
|
||||
* just top level branch
|
||||
*
|
||||
* nb - widget applies to allocation of categories to any ACSObject hence
|
||||
* xml prefix should be more generic eg bebop rather than cms. cms retained
|
||||
* for compatibility with existing stylesheets
|
||||
*/
|
||||
// NON Javadoc comment:
|
||||
// Copied from c.ad.aplaws.ui in order to make forum-categorised independend from
|
||||
// a specific ccm-???-aplaws, i.e. a specific integration layer.
|
||||
public class TermWidget extends Widget {
|
||||
|
||||
private StringParameter m_mode;
|
||||
private ACSObjectCategoryPicker m_picker;
|
||||
|
||||
public TermWidget(StringParameter mode, ACSObjectCategoryPicker picker) {
|
||||
super(new ArrayParameter(new BigDecimalParameter("category")));
|
||||
|
||||
m_mode = mode;
|
||||
m_picker = picker;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String getType() {
|
||||
return "category";
|
||||
}
|
||||
|
||||
public boolean isCompound() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void generateWidget(PageState state,
|
||||
Element parent) {
|
||||
Domain domain = m_picker.getDomain(state);
|
||||
|
||||
Element widget = parent.newChildElement("cms:categoryWidget",
|
||||
CMS.CMS_XML_NS);
|
||||
exportAttributes(widget);
|
||||
|
||||
widget.addAttribute("mode", (String)state.getValue(m_mode));
|
||||
widget.addAttribute("name", getName());
|
||||
|
||||
Set ids = new HashSet();
|
||||
|
||||
BigDecimal[] values = (BigDecimal[])getValue(state);
|
||||
if (values != null) {
|
||||
for (int i = 0 ; i < values.length ; i++) {
|
||||
ids.add(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// only root terms at first, the rest is loaded on-demand via AJAX
|
||||
DomainCollection terms = domain.getRootTerms();
|
||||
terms.addPath("model.parents.link.sortKey");
|
||||
terms.addPath("model.parents.id");
|
||||
terms.addPath("domain.key");
|
||||
|
||||
// Pull out everything related to the category, otherwise
|
||||
// another query per row is executed when doing term.getModel();
|
||||
terms.addPath("model.objectType");
|
||||
terms.addPath("model.displayName");
|
||||
terms.addPath("model.defaultDomainClass");
|
||||
terms.addPath("model.name");
|
||||
terms.addPath("model.description");
|
||||
terms.addPath("model.url");
|
||||
terms.addPath("model.isEnabled");
|
||||
terms.addPath("model.isAbstract");
|
||||
terms.addPath("model.defaultAncestors");
|
||||
|
||||
List roots = new LinkedList();
|
||||
while (terms.next()) {
|
||||
Term term = (Term) terms.getDomainObject();
|
||||
roots.add(new TermSortKeyPair
|
||||
(term,(BigDecimal)terms.get("model.parents.link.sortKey")));
|
||||
}
|
||||
|
||||
Element el = generateCategory(widget, domain.getModel(), ids, null);
|
||||
|
||||
/**
|
||||
* Used by kea based keyphrase extraction facility.
|
||||
* (Added r1885)
|
||||
*
|
||||
* @Author: terry_permeance
|
||||
*/
|
||||
Indexer indexer = Indexer.retrieve(domain);
|
||||
if (indexer != null) {
|
||||
ContentItem item = CMS.getContext().getContentItem();
|
||||
List<RankedTerm> autoTerms = indexer.index(item, 16);
|
||||
Element autoCategories = widget.newChildElement("cms:autoCategories", CMS.CMS_XML_NS);
|
||||
for (Iterator<RankedTerm> i = autoTerms.iterator(); i.hasNext(); ) {
|
||||
RankedTerm nextRankedTerm = i.next();
|
||||
Category cat = nextRankedTerm.getTerm().getModel();
|
||||
if (!ids.contains(cat.getID())) {
|
||||
String fullname = cat.getQualifiedName(" > ", false);
|
||||
if (fullname != null) {
|
||||
Element catEl = autoCategories.newChildElement("cms:category", CMS.CMS_XML_NS);
|
||||
catEl.addAttribute("id", XML.format(cat.getID()));
|
||||
catEl.addAttribute("name", cat.getName());
|
||||
catEl.addAttribute("description", cat.getDescription());
|
||||
catEl.addAttribute("isAbstract", cat.isAbstract() ? "1" : "0");
|
||||
catEl.addAttribute("isEnabled", cat.isEnabled() ? "1" : "0");
|
||||
catEl.addAttribute("sortKey", nextRankedTerm.getRanking().toString());
|
||||
catEl.addAttribute("fullname", fullname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Terms.getConfig().ajaxExpandAllBranches()) {
|
||||
// add attribute to the parent node, so that in stylesheet
|
||||
// we can look for any ancestor with this attribute (can't
|
||||
// add attribute to categoryWidget element as that is not
|
||||
// visible when subbranches are transformed)
|
||||
el.addAttribute("expand", "all" );
|
||||
}
|
||||
|
||||
for (Iterator i=roots.iterator(); i.hasNext(); ) {
|
||||
TermSortKeyPair pair = (TermSortKeyPair) i.next();
|
||||
Term term = pair.getTerm();
|
||||
BigDecimal sortKey = pair.getSortKey();
|
||||
|
||||
generateRootTerm(el, term, ids, sortKey);
|
||||
}
|
||||
}
|
||||
|
||||
public static Element generateCategory(Element parent,
|
||||
Category cat,
|
||||
Set selected,
|
||||
BigDecimal sortKey) {
|
||||
Element el = parent.newChildElement("cms:category", CMS.CMS_XML_NS);
|
||||
|
||||
el.addAttribute("id", XML.format(cat.getID()));
|
||||
el.addAttribute("name", cat.getName());
|
||||
el.addAttribute("description", cat.getDescription());
|
||||
el.addAttribute("isSelected", selected.contains(cat.getID()) ? "1" : "0");
|
||||
el.addAttribute("isAbstract", cat.isAbstract() ? "1" : "0");
|
||||
el.addAttribute("isEnabled", cat.isEnabled() ? "1" : "0");
|
||||
if (sortKey != null) {
|
||||
el.addAttribute("sortKey", sortKey.toString());
|
||||
}
|
||||
// sort order attribute added to every node so that we can
|
||||
// correctly transform xml fragments returned by ajax
|
||||
el.addAttribute("order", ContentSection.getConfig().getCategoryTreeOrder());
|
||||
|
||||
StringBuffer path = new StringBuffer(parent.getAttribute("fullname"));
|
||||
if (path.length() > 0) path.append(" > ");
|
||||
path.append(cat.getName());
|
||||
el.addAttribute("fullname", path.toString());
|
||||
|
||||
// need to uniquely identify each node in polyhierarchical trees
|
||||
// so that expand/contract is applied to the correct node by
|
||||
// javascript getElementByID function
|
||||
StringBuffer nodeID = new StringBuffer(parent.getAttribute("node-id"));
|
||||
if (nodeID.length() > 0) nodeID.append("-");
|
||||
nodeID.append(cat.getID());
|
||||
el.addAttribute("node-id", nodeID.toString());
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
public static Element generateTerm(Element parent,
|
||||
Term term,
|
||||
Set selected,
|
||||
BigDecimal sortKey) {
|
||||
Category cat = term.getModel();
|
||||
Element el = generateCategory(parent, cat, selected, sortKey);
|
||||
|
||||
el.addAttribute("pid", term.getUniqueID().toString());
|
||||
el.addAttribute("domain", term.getDomain().getKey());
|
||||
return el;
|
||||
}
|
||||
|
||||
private static void generateRootTerm(Element parent,
|
||||
Term term,
|
||||
Set selected,
|
||||
BigDecimal sortKey) {
|
||||
Element el = generateTerm(parent, term, selected, sortKey);
|
||||
el.addAttribute("root","1");
|
||||
}
|
||||
|
||||
public static void generateSubtree(Element parent, Category root) {
|
||||
DataCollection terms = SessionManager.getSession().retrieve(
|
||||
Term.BASE_DATA_OBJECT_TYPE);
|
||||
terms.addEqualsFilter("model.roTransParents.id", root.getID());
|
||||
terms.addEqualsFilter("model.parents.link.relationType", "child");
|
||||
|
||||
Map children = new HashMap();
|
||||
while (terms.next()) {
|
||||
Term term = (Term) DomainObjectFactory.newInstance(terms
|
||||
.getDataObject());
|
||||
BigDecimal parentID = (BigDecimal) terms.get("model.parents.id");
|
||||
|
||||
List childList = (List) children.get(parentID);
|
||||
if (childList == null) {
|
||||
childList = new LinkedList();
|
||||
children.put(parentID, childList);
|
||||
}
|
||||
|
||||
childList.add(new TermSortKeyPair(term, (BigDecimal) terms
|
||||
.get("model.parents.link.sortKey")));
|
||||
}
|
||||
|
||||
// XXX for isSelected
|
||||
Set ids = new HashSet();
|
||||
|
||||
Element el = generateCategory(parent, root, ids, null);
|
||||
el.addAttribute("fullname", root.getName());
|
||||
el.addAttribute("node-id", root.getID().toString());
|
||||
el.addAttribute("order", ContentSection.getConfig().getCategoryTreeOrder());
|
||||
if (Terms.getConfig().ajaxExpandAllBranches()) {
|
||||
// recognisable attribute has to be in the XML for each snippet that is transformed,
|
||||
// hence add it to the parent
|
||||
el.addAttribute("expand", "all" );
|
||||
}
|
||||
|
||||
List roots = (List) children.get(root.getID());
|
||||
if (null != roots) {
|
||||
Iterator i = roots.iterator();
|
||||
while (i.hasNext()) {
|
||||
TermSortKeyPair pair = (TermSortKeyPair) i.next();
|
||||
Term term = pair.getTerm();
|
||||
BigDecimal sortKey = pair.getSortKey();
|
||||
|
||||
generateTermWithChildren(el, term, ids, sortKey, children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateTermWithChildren(Element parent,
|
||||
Term term,
|
||||
Set selected,
|
||||
BigDecimal sortKey,
|
||||
Map children) {
|
||||
Category cat = term.getModel();
|
||||
Element el = generateCategory(parent, cat, selected, sortKey);
|
||||
|
||||
el.addAttribute("pid", term.getUniqueID().toString());
|
||||
el.addAttribute("domain", term.getDomain().getKey());
|
||||
|
||||
List c = (List) children.get(cat.getID());
|
||||
if (c != null) {
|
||||
Iterator i = c.iterator();
|
||||
while (i.hasNext()) {
|
||||
TermSortKeyPair pair = (TermSortKeyPair) i.next();
|
||||
Term child = pair.getTerm();
|
||||
BigDecimal childSortKey = pair.getSortKey();
|
||||
|
||||
// either generate next level down, or get all levels below current
|
||||
|
||||
if (Terms.getConfig().ajaxExpandAllBranches()) {
|
||||
generateTerm(el, child, selected, childSortKey);
|
||||
|
||||
} else {
|
||||
generateTermWithChildren(el, child, selected, childSortKey,
|
||||
children);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class TermSortKeyPair {
|
||||
private Term m_term;
|
||||
private BigDecimal m_sortKey;
|
||||
|
||||
public TermSortKeyPair(Term term, BigDecimal sortKey) {
|
||||
m_term = term;
|
||||
m_sortKey = sortKey;
|
||||
}
|
||||
public Term getTerm() {
|
||||
return m_term;
|
||||
}
|
||||
public BigDecimal getSortKey() {
|
||||
return m_sortKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue