Anpassung ccm-ldn-aplaws an Änderungen für forum-categorised.

git-svn-id: https://svn.libreccm.org/ccm/trunk@458 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2010-06-13 08:11:53 +00:00
parent db9c206db9
commit 04557f2a9a
10 changed files with 383 additions and 178 deletions

View File

@ -9,7 +9,7 @@ ccm-ldn-dublin
# Content types # Content types
ccm-cms-types-article ccm-cms-types-article
ccm-cms-types-contact ccm-cms-types-contact
ccm-cms-types-esdservice # ccm-cms-types-esdservice
ccm-cms-types-filestorageitem ccm-cms-types-filestorageitem
ccm-cms-types-formitem ccm-cms-types-formitem
ccm-cms-types-formsectionitem ccm-cms-types-formsectionitem
@ -17,19 +17,20 @@ ccm-cms-types-inlinesite
ccm-cms-types-mparticle ccm-cms-types-mparticle
ccm-cms-types-newsitem ccm-cms-types-newsitem
ccm-cms-types-pressrelease ccm-cms-types-pressrelease
ccm-cms-types-siteproxy
ccm-cms-types-xmlfeed ccm-cms-types-xmlfeed
# Applications # Applications
ccm-ldn-util ccm-ldn-aplaws
ccm-ldn-atoz ccm-ldn-atoz
ccm-ldn-rss
ccm-ldn-portal
ccm-ldn-navigation ccm-ldn-navigation
ccm-ldn-portal
ccm-ldn-rss
ccm-ldn-search ccm-ldn-search
ccm-ldn-shortcuts ccm-ldn-shortcuts
ccm-ldn-subsite ccm-ldn-subsite
ccm-ldn-terms ccm-ldn-terms
ccm-ldn-aplaws ccm-ldn-util
# Extra apps # Extra apps
ccm-forum ccm-forum

View File

@ -37,7 +37,8 @@ public class AplawsConfig extends AbstractConfig {
private final Parameter m_autocatServiceURL = new StringParameter("com.arsdigita.aplaws.autocat_url", Parameter.OPTIONAL, "http://demo.masprovider.com/searchLightWS/services/textMiner"); private final Parameter m_autocatServiceURL = new StringParameter("com.arsdigita.aplaws.autocat_url", Parameter.OPTIONAL, "http://demo.masprovider.com/searchLightWS/services/textMiner");
private final Parameter m_autocatServiceUsername = new StringParameter("com.arsdigita.aplaws.autocat_username", Parameter.OPTIONAL, null); private final Parameter m_autocatServiceUsername = new StringParameter("com.arsdigita.aplaws.autocat_username", Parameter.OPTIONAL, null);
private final Parameter m_autocatServicePassword = new StringParameter("com.arsdigita.aplaws.autocat_password", Parameter.OPTIONAL, null); private final Parameter m_autocatServicePassword = new StringParameter("com.arsdigita.aplaws.autocat_password", Parameter.OPTIONAL, null);
private final Parameter m_ajaxExpandAllBranches = new BooleanParameter("com.arsdigita.aplaws.ajax_expand_on_all_branches", Parameter.OPTIONAL, Boolean.FALSE); // moved into c.ad.london.terms.TermsConfig
// private final Parameter m_ajaxExpandAllBranches = new BooleanParameter("com.arsdigita.aplaws.ajax_expand_on_all_branches", Parameter.OPTIONAL, Boolean.FALSE);
@ -46,7 +47,8 @@ public class AplawsConfig extends AbstractConfig {
register(m_autocatServiceURL); register(m_autocatServiceURL);
register(m_autocatServiceUsername); register(m_autocatServiceUsername);
register(m_autocatServicePassword); register(m_autocatServicePassword);
register(m_ajaxExpandAllBranches); // moved into c.ad.london.terms.TermsConfig
// register(m_ajaxExpandAllBranches);
loadInfo(); loadInfo();
} }
@ -69,7 +71,8 @@ public class AplawsConfig extends AbstractConfig {
return password; return password;
} }
public boolean ajaxExpandAllBranches () { // moved into c.ad.london.terms.TermsConfig
return ((Boolean)get(m_ajaxExpandAllBranches)).booleanValue(); // public boolean ajaxExpandAllBranches () {
} // return ((Boolean)get(m_ajaxExpandAllBranches)).booleanValue();
// }
} }

View File

@ -10,8 +10,3 @@ com.arsdigita.aplaws.autocat_password.title=Cintra service password
com.arsdigita.aplaws.autocat_password.purpose=Username for the autocategorisation web service com.arsdigita.aplaws.autocat_password.purpose=Username for the autocategorisation web service
com.arsdigita.aplaws.autocat_password.example=pass com.arsdigita.aplaws.autocat_password.example=pass
com.arsdigita.aplaws.autocat_password.format=[string] com.arsdigita.aplaws.autocat_password.format=[string]
com.arsdigita.aplaws.ajax_expand_on_all_branches.title=Use Ajax on all branch expansions
com.arsdigita.aplaws.ajax_expand_on_all_branches.purpose=Use Ajax on all branches, or bring back entire subtree on expansion of top level root
com.arsdigita.aplaws.ajax_expand_on_all_branches.example=true|false
com.arsdigita.aplaws.ajax_expand_on_all_branches.format=[boolean]

View File

@ -57,6 +57,8 @@ import com.arsdigita.search.ContentType;
import com.arsdigita.search.MetadataProvider; import com.arsdigita.search.MetadataProvider;
import com.arsdigita.search.MetadataProviderRegistry; import com.arsdigita.search.MetadataProviderRegistry;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
/** /**
* Command line tool to automatically assign terms. * Command line tool to automatically assign terms.
* *
@ -207,6 +209,7 @@ public class AutoCategorisation extends com.arsdigita.packaging.Program {
</unformated_data> </unformated_data>
</tags> </tags>
*/ */
@Override
public void endElement(String uri, String localName, String qName) public void endElement(String uri, String localName, String qName)
throws SAXException { throws SAXException {
if (isDebug) { if (isDebug) {
@ -250,6 +253,7 @@ public class AutoCategorisation extends com.arsdigita.packaging.Program {
} // if qName } // if qName
} }
@Override
public void endDocument() throws SAXException { public void endDocument() throws SAXException {
if (isDebug) { if (isDebug) {
out("endDoc"); out("endDoc");

View File

@ -5,12 +5,12 @@
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of * as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -18,27 +18,23 @@
package com.arsdigita.aplaws.ui; package com.arsdigita.aplaws.ui;
import com.arsdigita.aplaws.Aplaws; import com.arsdigita.aplaws.Aplaws;
// import com.arsdigita.bebop.Label; // import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener; import com.arsdigita.bebop.event.ActionListener;
// import com.arsdigita.bebop.form.Widget; // import com.arsdigita.bebop.form.Widget;
import com.arsdigita.persistence.SessionManager; // import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
import com.arsdigita.persistence.DataCollection; // import com.arsdigita.persistence.SessionManager;
import com.arsdigita.domain.DomainCollection; // import com.arsdigita.persistence.DataCollection;
import com.arsdigita.domain.DomainObjectFactory; // import com.arsdigita.domain.DomainCollection;
// import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.london.terms.Term; import com.arsdigita.london.terms.Term;
import com.arsdigita.london.terms.Domain; import com.arsdigita.london.terms.Domain;
import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
// unused imports
// import com.arsdigita.cms.ContentItem;
// import com.arsdigita.cms.CMS;
// import com.arsdigita.cms.ui.authoring.ItemCategoryForm;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -48,36 +44,36 @@ import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* abstracted from original version of ItemCategoryPicker r1297 * Extends com.arsdigita.london.terms.ui.ACSObjectCategoryPicker and overwrites
* chris gilbert * the private class ItemCategoryFormCompletion to add functionality to its
* lgclSelected() method.
*
*/ */
public abstract class ACSObjectCategoryPicker extends SimpleContainer { public abstract class ACSObjectCategoryPicker
extends com.arsdigita.london.terms.ui.ACSObjectCategoryPicker{
private static final Logger s_log = Logger.getLogger(ACSObjectCategoryPicker.class); private static final Logger s_log = Logger.getLogger(ACSObjectCategoryPicker.class);
private ACSObjectCategoryForm m_form; /**
private BigDecimalParameter m_root; * Constructor
*
* @param root
* @param mode
*/
public ACSObjectCategoryPicker(BigDecimalParameter root, public ACSObjectCategoryPicker(BigDecimalParameter root,
StringParameter mode) { StringParameter mode) {
super(root,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); * Overwrites private class of the parent class to add functionality for
* processing or mapping from LGCL to APLAWS-NAV in method lgclSelected().
*/
private class ItemCategoryFormCompletion implements ActionListener { private class ItemCategoryFormCompletion implements ActionListener {
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
PageState state = ev.getPageState(); PageState state = ev.getPageState();
Domain domain = getDomain(state); Domain domain = getDomain(state);
String domainKey = domain.getKey(); String domainKey = domain.getKey();
@ -87,7 +83,7 @@ public abstract class ACSObjectCategoryPicker extends SimpleContainer {
} }
ACSObject object = getObject(state); ACSObject object = getObject(state);
if ("LGCL".equals(domainKey)) { if ("LGCL".equals(domainKey)) {
lgclSelected(domain, object); lgclSelected(domain, object);
} }
@ -96,9 +92,20 @@ public abstract class ACSObjectCategoryPicker extends SimpleContainer {
lgdlSelected(domain, object); lgdlSelected(domain, object);
} }
fireCompletionEvent(state); fireCompletionEvent(state);
} }
/**
* Adds processing or mapping from LGCL to APLAWS-NAV too.
*
* ANav and the corresponding configuration parameter in module
* ccm-ldn-aplaws are highly specific to the needs of British Local
* Authorities and should not be used in more general parts of the
* code.
*
* @param domain
* @param object
*/
private void lgclSelected(Domain domain, ACSObject object) { private void lgclSelected(Domain domain, ACSObject object) {
List lgclTerms = getCurrentCategories(domain, object); List lgclTerms = getCurrentCategories(domain, object);
@ -116,7 +123,8 @@ public abstract class ACSObjectCategoryPicker extends SimpleContainer {
//assignTerms(lgslTerms, object); //assignTerms(lgslTerms, object);
// adding processing or mapping from LGCL to APLAWS-NAV too // adding processing or mapping from LGCL to APLAWS-NAV too
boolean lgclOverrideAnav = Aplaws.getAplawsConfig().getOverrideAnavFromLGCLMappings().booleanValue(); boolean lgclOverrideAnav = Aplaws.getAplawsConfig().
getOverrideAnavFromLGCLMappings().booleanValue();
if (lgclOverrideAnav) { if (lgclOverrideAnav) {
Domain aplawsNav = Domain.retrieve("APLAWS-NAV"); Domain aplawsNav = Domain.retrieve("APLAWS-NAV");
Collection aplawsNavTerms = getRelatedTerms(lgclTerms, aplawsNav); Collection aplawsNavTerms = getRelatedTerms(lgclTerms, aplawsNav);
@ -155,126 +163,6 @@ public abstract class ACSObjectCategoryPicker extends SimpleContainer {
assignTerms(gclTerms, 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;
}
} }

View File

@ -0,0 +1,290 @@
/*
* 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.aplaws.ui;
import com.arsdigita.aplaws.Aplaws;
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.bebop.form.Widget;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.london.terms.Term;
import com.arsdigita.london.terms.Domain;
import com.arsdigita.categorization.ui.ACSObjectCategoryForm;
// unused imports
// import com.arsdigita.cms.ContentItem;
// import com.arsdigita.cms.CMS;
// import com.arsdigita.cms.ui.authoring.ItemCategoryForm;
import java.util.Collection;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;
import org.apache.log4j.Logger;
// /////////////////////////////////////////////////////////////////////////////
// Has to be refactored to extend
// com.arsdigita.london.terms.ui.ACSObjectCategoryPicker and to
// overwrite the method lgclSelected(Domain domain, ACSObject object)
// to add the lgl / ANav stuff
// (which is not included in the c.ad.ldn.terms.ui version)
//
// Then ItemCategoryPicker should use this aplaws version.
// /////////////////////////////////////////////////////////////////////////////
/**
* abstracted from original version of ItemCategoryPicker r1297
* chris gilbert
*/
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
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;
}
}

View File

@ -16,14 +16,25 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.london.terms.Term; import com.arsdigita.london.terms.Term;
import com.arsdigita.london.terms.ui.TermWidget;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
/**
*
* @author pb
*/
public class AutoTerms extends SimpleComponent { public class AutoTerms extends SimpleComponent {
private static final Logger LOG = Logger.getLogger(AutoTerms.class); private static final Logger LOG = Logger.getLogger(AutoTerms.class);
BigDecimalParameter itemIDparam = new BigDecimalParameter("itemID"); BigDecimalParameter itemIDparam = new BigDecimalParameter("itemID");
/**
*
* @param state
* @param p
*/
@Override
public void generateXML(PageState state, Element p) { public void generateXML(PageState state, Element p) {
try { try {
BigDecimal itemID = (BigDecimal) state.getValue(itemIDparam); BigDecimal itemID = (BigDecimal) state.getValue(itemIDparam);
@ -45,6 +56,11 @@ public class AutoTerms extends SimpleComponent {
} }
} }
/**
*
* @param p
*/
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addGlobalStateParam(itemIDparam); p.addGlobalStateParam(itemIDparam);

View File

@ -1,8 +1,8 @@
package com.arsdigita.aplaws.ui; package com.arsdigita.aplaws.ui;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Iterator; // import java.util.Iterator;
import java.util.Map; // import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -10,11 +10,12 @@ import org.apache.log4j.Logger;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.parameters.BigDecimalParameter; // import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.IntegerParameter; // import com.arsdigita.bebop.parameters.IntegerParameter;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.london.terms.ui.TermWidget;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
@ -22,18 +23,22 @@ import com.arsdigita.xml.Element;
* Generate part of the category tree. Used by Assign Category authoring step. * Generate part of the category tree. Used by Assign Category authoring step.
* *
* @author Alan Pevec * @author Alan Pevec
* @deprecated use com.arsdigita.london.terms.ui.CategorySubtree instead!
*/ */
public class CategorySubtree extends SimpleComponent { public class CategorySubtree extends SimpleComponent {
StringParameter nodeIDparam = new StringParameter("nodeID"); StringParameter nodeIDparam = new StringParameter("nodeID");
private static Logger s_log = Logger.getLogger(CategorySubtree.class); private static Logger s_log = Logger.getLogger(CategorySubtree.class);
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addGlobalStateParam(nodeIDparam); p.addGlobalStateParam(nodeIDparam);
} }
@Override
public void generateXML(PageState state, Element p) { public void generateXML(PageState state, Element p) {
String node = (String)state.getValue(nodeIDparam); String node = (String)state.getValue(nodeIDparam);

View File

@ -28,6 +28,9 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ui.authoring.*; import com.arsdigita.cms.ui.authoring.*;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
// import com.arsdigita.london.terms.ui.ACSObjectCategoryPicker;
import com.arsdigita.london.terms.ui.TermWidget;
/** /**
* *
@ -35,8 +38,6 @@ import com.arsdigita.kernel.ACSObject;
* cms specific Concrete implementation of ACSObjectCategoryPicker * cms specific Concrete implementation of ACSObjectCategoryPicker
* *
*/ */
public class ItemCategoryPicker extends ACSObjectCategoryPicker { public class ItemCategoryPicker extends ACSObjectCategoryPicker {
private static final Logger s_log = Logger.getLogger(ItemCategoryPicker.class); private static final Logger s_log = Logger.getLogger(ItemCategoryPicker.class);

View File

@ -61,6 +61,8 @@ import com.arsdigita.xml.XML;
* nb - widget applies to allocation of categories to any ACSObject hence * nb - widget applies to allocation of categories to any ACSObject hence
* xml prefix should be more generic eg bebop rather than cms. cms retained * xml prefix should be more generic eg bebop rather than cms. cms retained
* for compatibility with existing stylesheets * for compatibility with existing stylesheets
*
* @deprecated Use c.ad.london.terms.ui.TermWidget instead!
*/ */
public class TermWidget extends Widget { public class TermWidget extends Widget {
private StringParameter m_mode; private StringParameter m_mode;