Korrekturen für RelatedLink

* Ändern der Reihenfolge funktioniert nun
 * Da leere Strings nicht funktionieren, müssen *alle* RelatedLinks ein linkListName haben. Dieser wird für die bisherigen RelatedLinks auf "genericLink" gesetzt. Update-Skript fehlt noch.

git-svn-id: https://svn.libreccm.org/ccm/trunk@797 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-03-26 19:07:54 +00:00
parent 0a355d7e68
commit f2a7fb18c6
6 changed files with 51 additions and 28 deletions

View File

@ -48,7 +48,8 @@ data operation swapRelatedLinkWithNextInGroup {
and 2 = (select count(*) from cms_links l, cms_related_links r and 2 = (select count(*) from cms_links l, cms_related_links r
where l.link_id=r.related_link_id where l.link_id=r.related_link_id
and (link_order = :linkOrder or link_order = :nextLinkOrder) and (link_order = :linkOrder or link_order = :nextLinkOrder)
and owner_id = :ownerID) and owner_id = :ownerID
and r.link_list_name = :linkListName)
} }
} }

View File

@ -215,18 +215,22 @@ public class RelatedLink extends Link {
* Swaps this <code>RelatedLink</code> with the next one, * Swaps this <code>RelatedLink</code> with the next one,
* according to the linkOrder * according to the linkOrder
*/ */
@Override
public void swapWithNext() { public void swapWithNext() {
swapWithNext("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem", swapWithNext("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem",
"com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup"); "com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup",
this.getLinkListName());
} }
/** /**
* Swaps this <code>RelatedLink</code> with the previous one, * Swaps this <code>RelatedLink</code> with the previous one,
* according to the linkOrder * according to the linkOrder
*/ */
@Override
public void swapWithPrevious() { public void swapWithPrevious() {
swapWithPrevious("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem", swapWithPrevious("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem",
"com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup"); "com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup",
this.getLinkListName());
} }
/** /**
@ -239,6 +243,7 @@ public class RelatedLink extends Link {
* @param queryName name of the DataQuery to use * @param queryName name of the DataQuery to use
* @return the DataQuery * @return the DataQuery
*/ */
@Override
protected DataQuery getSwapQuery(String queryName) { protected DataQuery getSwapQuery(String queryName) {
DataQuery query = super.getSwapQuery(queryName); DataQuery query = super.getSwapQuery(queryName);
query.setParameter("ownerID", getLinkOwner().getID()); query.setParameter("ownerID", getLinkOwner().getID());
@ -255,6 +260,7 @@ public class RelatedLink extends Link {
* *
* @return the DataOperation used to swap the sort keys. * @return the DataOperation used to swap the sort keys.
*/ */
@Override
protected DataOperation getSwapOperation(String operationName) { protected DataOperation getSwapOperation(String operationName) {
DataOperation operation = super.getSwapOperation(operationName); DataOperation operation = super.getSwapOperation(operationName);
operation.setParameter("ownerID", getLinkOwner().getID()); operation.setParameter("ownerID", getLinkOwner().getID());
@ -270,6 +276,7 @@ public class RelatedLink extends Link {
* null. This implementation sorts all RelatedLinks owned by this * null. This implementation sorts all RelatedLinks owned by this
* RelatedLink's "linkOwner" by title. * RelatedLink's "linkOwner" by title.
*/ */
@Override
protected void alphabetize() { protected void alphabetize() {
Session session = SessionManager.getSession(); Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE); DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
@ -314,6 +321,7 @@ public class RelatedLink extends Link {
} }
@Override
public void beforeSave() { public void beforeSave() {
super.beforeSave(); super.beforeSave();
if (getOrder() == null) { if (getOrder() == null) {

View File

@ -29,7 +29,7 @@ import com.arsdigita.cms.contenttypes.ui.LinkTable;
*/ */
public class RelatedLinkPropertiesStep extends LinkPropertiesStep { public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
protected String m_linkListName = ""; protected static String s_linkListName = "genericLink";
protected ContentType m_contentType = null; protected ContentType m_contentType = null;
/** /**
@ -68,9 +68,9 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
LinkTable table; LinkTable table;
if (ContentSection.getConfig().isHideAdditionalResourceFields()) { if (ContentSection.getConfig().isHideAdditionalResourceFields()) {
table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel()); table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel());
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), m_linkListName)); table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), s_linkListName));
} else { } else {
table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), m_linkListName); table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), s_linkListName);
} }
container.add(table); container.add(table);
@ -86,7 +86,7 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
protected FormSection getEditSheet() { protected FormSection getEditSheet() {
return new RelatedLinkPropertyForm(getItemSelectionModel(), return new RelatedLinkPropertyForm(getItemSelectionModel(),
getLinkSelectionModel(), getLinkSelectionModel(),
m_linkListName, s_linkListName,
m_contentType); m_contentType);
} }
} }

View File

@ -50,7 +50,7 @@ import com.arsdigita.util.Assert;
public class RelatedLinkPropertyForm extends LinkPropertyForm { public class RelatedLinkPropertyForm extends LinkPropertyForm {
private static boolean isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields(); private static boolean isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
private String m_linkListName = ""; private String m_linkListName;
/** /**
* Creates a new form to edit the RelatedLink object specified * Creates a new form to edit the RelatedLink object specified
@ -186,7 +186,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
MimeType mType = MimeType.loadMimeType(typeName); MimeType mType = MimeType.loadMimeType(typeName);
rl.setResourceType(mType); rl.setResourceType(mType);
} }
rl.setLinkListName(data.getString(RelatedLink.LINK_LIST_NAME)); rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME));
super.setLinkProperties(link, fse); super.setLinkProperties(link, fse);
} }
} }

View File

@ -36,7 +36,7 @@ public class RelatedLinkTableModelBuilder extends LinkTableModelBuilder {
Logger.getLogger(RelatedLinkTableModelBuilder.class); Logger.getLogger(RelatedLinkTableModelBuilder.class);
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
private String m_linkListName = ""; private String m_linkListName;
/** /**
* Constructor. Creates a <code>LinkTableModelBuilder</code> given an * Constructor. Creates a <code>LinkTableModelBuilder</code> given an
@ -58,6 +58,7 @@ public class RelatedLinkTableModelBuilder extends LinkTableModelBuilder {
* @param s The <code>PageState</code> for the current request * @param s The <code>PageState</code> for the current request
* @return The DataCollection of RelatedLinks * @return The DataCollection of RelatedLinks
*/ */
@Override
public DataCollection getLinks(PageState s) { public DataCollection getLinks(PageState s) {
Assert.isTrue(m_itemModel.isSelected(s), "item selected"); Assert.isTrue(m_itemModel.isSelected(s), "item selected");
ContentItem item = m_itemModel.getSelectedItem(s); ContentItem item = m_itemModel.getSelectedItem(s);

View File

@ -207,8 +207,7 @@ public class Link extends ACSObject {
// If acsObject is instance of ContentBundle // If acsObject is instance of ContentBundle
if (acsObject instanceof ContentBundle) { if (acsObject instanceof ContentBundle) {
// get the negotiated language version of this ContentBundle // get the negotiated language version of this ContentBundle
ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper. ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.getRequest().getLocales());
getRequest().getLocales());
} else { } else {
// else there are no language versions so just use the acsObject // else there are no language versions so just use the acsObject
ci = (ContentItem) acsObject; ci = (ContentItem) acsObject;
@ -398,7 +397,11 @@ public class Link extends ACSObject {
* @param operationName name of the DataOperation to use * @param operationName name of the DataOperation to use
*/ */
public void swapWithNext(String queryName, String operationName) { public void swapWithNext(String queryName, String operationName) {
swapKeys(true, queryName, operationName); swapKeys(true, queryName, operationName, "");
}
public void swapWithNext(String queryName, String operationName, String linkListName) {
swapKeys(true, queryName, operationName, linkListName);
} }
/** /**
@ -411,8 +414,11 @@ public class Link extends ACSObject {
* @param operationName name of the DataOperation to use * @param operationName name of the DataOperation to use
*/ */
public void swapWithPrevious(String queryName, String operationName) { public void swapWithPrevious(String queryName, String operationName) {
swapKeys(false, queryName, operationName); swapKeys(false, queryName, operationName, "");
}
public void swapWithPrevious(String queryName, String operationName, String linkListName) {
swapKeys(false, queryName, operationName, linkListName);
} }
/** /**
@ -452,6 +458,11 @@ public class Link extends ACSObject {
*/ */
protected void swapKeys(boolean swapNext, String queryName, protected void swapKeys(boolean swapNext, String queryName,
String operationName) { String operationName) {
this.swapKeys(swapNext, queryName, operationName, "");
}
protected void swapKeys(boolean swapNext, String queryName,
String operationName, String linkListName) {
String methodName = null; String methodName = null;
if (swapNext) { if (swapNext) {
@ -478,6 +489,7 @@ public class Link extends ACSObject {
int key = currentKey.intValue(); int key = currentKey.intValue();
DataQuery query = getSwapQuery(queryName); DataQuery query = getSwapQuery(queryName);
query.setParameter("linkListName", (String) linkListName);
int otherKey = key; int otherKey = key;
@ -502,6 +514,7 @@ public class Link extends ACSObject {
DataOperation operation = getSwapOperation(operationName); DataOperation operation = getSwapOperation(operationName);
operation.setParameter("linkOrder", new Integer(key)); operation.setParameter("linkOrder", new Integer(key));
operation.setParameter("nextLinkOrder", new Integer(otherKey)); operation.setParameter("nextLinkOrder", new Integer(otherKey));
operation.setParameter("linkListName", linkListName);
operation.execute(); operation.execute();
} }