Teil 1 der Fehlerbehebung für Ticket #1318 (Sortierung der Objektliste nach Republizieren). Noch nicht vollständig und funktioniert daher noch nicht.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1838 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
3ffa2d01cc
commit
1b69863fa6
|
|
@ -670,7 +670,8 @@ public class ContentBundle extends ContentItem {
|
|||
CategoryCollection categories = source.getCategoryCollection();
|
||||
while (categories.next()) {
|
||||
final Category category = categories.getCategory();
|
||||
category.addChild(this);
|
||||
|
||||
category.addChild(this, categories.getSortKey());
|
||||
category.save(); // XXX remove me
|
||||
}
|
||||
categories.close();
|
||||
|
|
|
|||
|
|
@ -1893,6 +1893,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
|
|||
}
|
||||
|
||||
// If live Bundle already exists, recategorize.
|
||||
// jensp 2012: Behavior changed. The ContentBundle will also be republished.
|
||||
if (PARENT.equals(attribute)) {
|
||||
ACSObject parent = ((ContentItem) source).getParent();
|
||||
if (parent != null && copier.getCopyType()
|
||||
|
|
@ -1906,9 +1907,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
|
|||
//published because the ContentBundle was not republished.
|
||||
//Moved the next lines out of the if below to enable
|
||||
//republishing of the ContentBundle
|
||||
final ContentBundle liveBundle =
|
||||
(ContentBundle) bundle.
|
||||
createPendingVersion(null);
|
||||
final ContentBundle liveBundle = (ContentBundle) bundle.createPendingVersion(null);
|
||||
/*
|
||||
* if (liveBundle == null) { } else { Set liveCatSet = new
|
||||
* HashSet(); Set draftCatSet = new HashSet();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import com.arsdigita.util.LockableImpl;
|
|||
import java.math.BigDecimal;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
|
||||
/**
|
||||
* A List of all objects currently categorized under this category
|
||||
*
|
||||
|
|
@ -52,14 +51,13 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
|
||||
setModelBuilder(new CategorizedObjectsModelBuilder());
|
||||
|
||||
Label label = new Label(GlobalizationUtil.globalize
|
||||
("cms.ui.category.item.none"));
|
||||
Label label = new Label(GlobalizationUtil.globalize("cms.ui.category.item.none"));
|
||||
label.setFontWeight(Label.ITALIC);
|
||||
setEmptyView(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* This actually performs the sorting
|
||||
* This actually performs the sorting
|
||||
*/
|
||||
public void respond(PageState ps) throws ServletException {
|
||||
String event = ps.getControlEventName();
|
||||
|
|
@ -67,10 +65,17 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) {
|
||||
BigDecimal selectedID = new BigDecimal(ps.getControlEventValue());
|
||||
Category parent = getCategory(ps);
|
||||
|
||||
final ContentItem selectedItem = new ContentItem(selectedID);
|
||||
final BigDecimal selectedDraftId = selectedItem.getDraftVersion().getID();
|
||||
|
||||
if (CMS.getContext().getSecurityManager().canAccess
|
||||
(SecurityManager.CATEGORY_ADMIN)) {
|
||||
parent.swapSortKeys(selectedID, getSwapID(parent,selectedID,event));
|
||||
if (CMS.getContext().getSecurityManager().canAccess(SecurityManager.CATEGORY_ADMIN)) {
|
||||
BigDecimal swapId = getSwapID(parent, selectedID, event);
|
||||
parent.swapSortKeys(selectedID, swapId);
|
||||
final ContentItem draftSwapItem = new ContentItem(swapId);
|
||||
final BigDecimal draftSwapId = selectedItem.getDraftVersion().getID();
|
||||
parent.swapSortKeys(selectedDraftId, draftSwapId);
|
||||
|
||||
}
|
||||
} else {
|
||||
super.respond(ps);
|
||||
|
|
@ -83,9 +88,8 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
boolean foundSelectedID = false;
|
||||
|
||||
if (category != null && category.hasChildObjects()) {
|
||||
CategorizedCollection items = category.getObjects
|
||||
(ContentItem.BASE_DATA_OBJECT_TYPE);
|
||||
items.addEqualsFilter(ContentItem.VERSION,ContentItem.LIVE);
|
||||
CategorizedCollection items = category.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
|
||||
items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
|
||||
items.sort(true);
|
||||
while (items.next()) {
|
||||
BigDecimal thisID = items.getACSObject().getID();
|
||||
|
|
@ -111,14 +115,14 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
|
||||
private class CategorizedObjectsModelBuilder extends LockableImpl
|
||||
implements ListModelBuilder {
|
||||
|
||||
public final ListModel makeModel(final List list,
|
||||
final PageState state) {
|
||||
final Category category = getCategory(state);
|
||||
|
||||
if (category != null && category.hasChildObjects()) {
|
||||
CategorizedCollection items = category.getObjects
|
||||
(ContentItem.BASE_DATA_OBJECT_TYPE);
|
||||
items.addEqualsFilter(ContentItem.VERSION,ContentItem.LIVE);
|
||||
CategorizedCollection items = category.getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
|
||||
items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
|
||||
items.sort(true);
|
||||
return new CategorizedCollectionListModel(items);
|
||||
} else {
|
||||
|
|
@ -131,6 +135,7 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
* A {@link ListModel} that iterates over categorized objects via an iterator
|
||||
*/
|
||||
private static class CategorizedCollectionListModel implements ListModel {
|
||||
|
||||
private CategorizedCollection m_objs;
|
||||
private ACSObject m_object;
|
||||
|
||||
|
|
@ -140,7 +145,7 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
}
|
||||
|
||||
public boolean next() {
|
||||
if ( m_objs.next() ) {
|
||||
if (m_objs.next()) {
|
||||
m_object = (ACSObject) m_objs.getDomainObject();
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -150,14 +150,23 @@ public class OrderedCategorizedObjectsList extends CategorizedObjectsList {
|
|||
|
||||
if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) {
|
||||
try {
|
||||
ContentItem child =
|
||||
new ContentItem(new BigDecimal(ps.getControlEventValue()));
|
||||
ContentItem child = new ContentItem(new BigDecimal(ps.getControlEventValue()));
|
||||
ContentItem draft = null;
|
||||
if (ContentItem.LIVE.equals(child.getVersion())) {
|
||||
draft = child.getDraftVersion();
|
||||
}
|
||||
final Category parent = getCategory(ps);
|
||||
|
||||
if (NEXT_EVENT.equals(event)) {
|
||||
parent.swapWithNext(child);
|
||||
if (draft != null) {
|
||||
parent.swapWithNext(draft);
|
||||
}
|
||||
} else {
|
||||
parent.swapWithPrevious(child);
|
||||
if (draft != null) {
|
||||
parent.swapWithPrevious(draft);
|
||||
}
|
||||
}
|
||||
parent.save();
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,7 @@ public class Category extends ACSObject {
|
|||
remove(RELATED_CATEGORIES, cursor.getDataObject());
|
||||
if ("child".equals(relationType)) {
|
||||
Category category = new Category(cursor.getDataObject());
|
||||
parent.addChild(category);
|
||||
parent.addChild(category, null);
|
||||
if (Boolean.TRUE.equals(isDefault)) {
|
||||
category.setDefaultParentCategory(parent);
|
||||
}
|
||||
|
|
@ -1104,13 +1104,18 @@ public class Category extends ACSObject {
|
|||
* categories and becomes a CHILD category.</p>
|
||||
*
|
||||
* @param object the domain object to categorize
|
||||
* @param sortKey optional sort key. May be <code>null</code>
|
||||
*
|
||||
* @pre !isAbstract()
|
||||
* @pre canMap()
|
||||
*
|
||||
*/
|
||||
public void addChild(ACSObject object, BigDecimal sortKey) {
|
||||
addMapping(object, "child", sortKey);
|
||||
}
|
||||
|
||||
public void addChild(ACSObject object) {
|
||||
addMapping(object, "child");
|
||||
addChild(object, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1149,10 +1154,14 @@ public class Category extends ACSObject {
|
|||
|
||||
/**
|
||||
* Adds the passed in object to the correct association.
|
||||
*
|
||||
* @param acsObj Object to add to the category
|
||||
* @param relationType Type of the relation
|
||||
* @param sortKey Optional sort key. May be <code>null</code>.
|
||||
*
|
||||
* @pre canMap()
|
||||
*/
|
||||
private void addMapping(ACSObject acsObj, String relationType) {
|
||||
private void addMapping(ACSObject acsObj, String relationType, BigDecimal sortKey) {
|
||||
if (acsObj instanceof Category) {
|
||||
addMapping((Category) acsObj, relationType);
|
||||
return;
|
||||
|
|
@ -1177,7 +1186,10 @@ public class Category extends ACSObject {
|
|||
if (cursor.size() == 0) {
|
||||
// if the cursor.size() > 0 then the object is already
|
||||
// a child and does not need to be added again.
|
||||
add(CHILD_OBJECTS, acsObj);
|
||||
DataObject link = add(CHILD_OBJECTS, acsObj);
|
||||
if (sortKey != null) {
|
||||
link.set("sortKey", sortKey);
|
||||
}
|
||||
Categorization.triggerMapEvent(this, acsObj);
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug(acsObj + " added to " + CHILD_OBJECTS + " of catID="
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package com.arsdigita.categorization;
|
|||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.kernel.ACSObjectCollection;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Represents a collection of categories.
|
||||
|
|
@ -84,6 +85,10 @@ public class CategoryCollection extends ACSObjectCollection {
|
|||
return getCategory();
|
||||
}
|
||||
|
||||
public BigDecimal getSortKey() {
|
||||
return (BigDecimal) get("link.sortKey");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the category collection by the category sort key.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue