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