Categories can now be deleted from the Content Center (again). The corresponding Term object is removed using the TermCategoryListener. The CategoryListener interface has a method onDelete(Category), which is called if a category is deleted. But the implementation of this method was empty in the TermCategoryListener, which is used to create a term object for a category which is not created using the Terms Application.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2317 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
eba04df78f
commit
c957dfd301
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ class CategoryItemPane extends BaseItemPane {
|
|||
|
||||
};
|
||||
|
||||
|
||||
final Form orderItemsForm = new OrderItemsForm(m_category);
|
||||
final Form orderItemsForm2 = new OrderItemsForm(m_category);
|
||||
add(orderItemsForm);
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
* <ul>
|
||||
* <li>Attempts to create new term in the proper terms domain
|
||||
* whenever a new category is created through CMS interface.</li>
|
||||
* <li>Attempts to delete the corresponding term object if a category is deleted (if there is
|
||||
* an term object for the category)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue