diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java index 39ddc86bd..e45c69bb3 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryAdminPane.java @@ -162,16 +162,8 @@ public final class CategoryAdminPane extends BaseAdminPane { String context = getUseContext(state); boolean isDefaultContext = (context == null) || DEFAULT_USE_CONTEXT.equals(context); - - - final Session session = SessionManager.getSession(); - final DataCollection collection = session.retrieve("com.arsdigita.london.terms.Term"); - collection.addPath("model.id"); - collection.addPath("model.name"); - - collection.addFilter(String.format("model.id = %s", cat.getID().toString())); - - if ((isDefaultContext && cat.isRoot()) || !collection.isEmpty()) { + + if ((isDefaultContext && cat.isRoot()) || !cat.getChildren().isEmpty()) { m_alternativeLabel.generateXML(state, parent); } else { super.generateXML(state, parent); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java index e3dbf5366..99a0a8ce6 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java @@ -116,7 +116,6 @@ class CategoryItemPane extends BaseItemPane { }; - final Form orderItemsForm = new OrderItemsForm(m_category); final Form orderItemsForm2 = new OrderItemsForm(m_category); add(orderItemsForm); diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java index 60d3eb83d..289c9c85e 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java @@ -22,6 +22,7 @@ import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.categorization.CategoryListener; import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.kernel.ACSObject; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; @@ -29,8 +30,18 @@ import com.arsdigita.persistence.SessionManager; import org.apache.log4j.Logger; /** - * Attempts to create new term in the proper terms domain - * whenever a new category is created through CMS interface. + * Used to sync terms and categories. + * + * + * + * @author Unkwown + * @author Jens Pelzetter + * @version $Id$ */ public class TermCategoryListener implements CategoryListener { @@ -38,6 +49,13 @@ public class TermCategoryListener implements CategoryListener { TermCategoryListener.class); public void onDelete(Category cat) { + final DataCollection collection = SessionManager.getSession().retrieve(Term.BASE_DATA_OBJECT_TYPE); + collection.addPath("model.id"); + collection.addEqualsFilter("model.id", cat.getID()); + if (collection.next()) { + final Term term = (Term) DomainObjectFactory.newInstance(collection.getDataObject()); + term.delete(); + } } public void onAddChild(Category cat, Category child) {