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
|
|
@ -163,15 +163,7 @@ public final class CategoryAdminPane extends BaseAdminPane {
|
||||||
boolean isDefaultContext =
|
boolean isDefaultContext =
|
||||||
(context == null) || DEFAULT_USE_CONTEXT.equals(context);
|
(context == null) || DEFAULT_USE_CONTEXT.equals(context);
|
||||||
|
|
||||||
|
if ((isDefaultContext && cat.isRoot()) || !cat.getChildren().isEmpty()) {
|
||||||
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()) {
|
|
||||||
m_alternativeLabel.generateXML(state, parent);
|
m_alternativeLabel.generateXML(state, parent);
|
||||||
} else {
|
} else {
|
||||||
super.generateXML(state, parent);
|
super.generateXML(state, parent);
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,6 @@ class CategoryItemPane extends BaseItemPane {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
final Form orderItemsForm = new OrderItemsForm(m_category);
|
final Form orderItemsForm = new OrderItemsForm(m_category);
|
||||||
final Form orderItemsForm2 = new OrderItemsForm(m_category);
|
final Form orderItemsForm2 = new OrderItemsForm(m_category);
|
||||||
add(orderItemsForm);
|
add(orderItemsForm);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import com.arsdigita.categorization.Category;
|
||||||
import com.arsdigita.categorization.CategoryCollection;
|
import com.arsdigita.categorization.CategoryCollection;
|
||||||
import com.arsdigita.categorization.CategoryListener;
|
import com.arsdigita.categorization.CategoryListener;
|
||||||
import com.arsdigita.domain.DomainCollection;
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
import com.arsdigita.kernel.ACSObject;
|
import com.arsdigita.kernel.ACSObject;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
|
@ -29,8 +30,18 @@ import com.arsdigita.persistence.SessionManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create new term in the proper terms domain
|
* Used to sync terms and categories.
|
||||||
* whenever a new category is created through CMS interface.
|
*
|
||||||
|
* <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 {
|
public class TermCategoryListener implements CategoryListener {
|
||||||
|
|
||||||
|
|
@ -38,6 +49,13 @@ public class TermCategoryListener implements CategoryListener {
|
||||||
TermCategoryListener.class);
|
TermCategoryListener.class);
|
||||||
|
|
||||||
public void onDelete(Category cat) {
|
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) {
|
public void onAddChild(Category cat, Category child) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue