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-94f89814c4dfmaster
parent
0a355d7e68
commit
f2a7fb18c6
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class Link extends ACSObject {
|
||||||
public static final String ORDER = "linkOrder";
|
public static final String ORDER = "linkOrder";
|
||||||
/** Data object type for this domain object */
|
/** Data object type for this domain object */
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.contenttypes.Link";
|
"com.arsdigita.cms.contenttypes.Link";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. This creates a new Link.
|
* Default constructor. This creates a new Link.
|
||||||
|
|
@ -166,7 +166,7 @@ public class Link extends ACSObject {
|
||||||
*/
|
*/
|
||||||
public void setTargetType(String type) {
|
public void setTargetType(String type) {
|
||||||
Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals(
|
Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals(
|
||||||
INTERNAL_LINK)));
|
INTERNAL_LINK)));
|
||||||
set(TARGET_TYPE, type);
|
set(TARGET_TYPE, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ public class Link extends ACSObject {
|
||||||
public ContentItem getTargetItem() {
|
public ContentItem getTargetItem() {
|
||||||
DataObject object = (DataObject) get(TARGET_ITEM);
|
DataObject object = (DataObject) get(TARGET_ITEM);
|
||||||
ACSObject acsObject =
|
ACSObject acsObject =
|
||||||
(ACSObject) DomainObjectFactory.newInstance(object);
|
(ACSObject) DomainObjectFactory.newInstance(object);
|
||||||
|
|
||||||
// Quasimodo: BEGIN
|
// Quasimodo: BEGIN
|
||||||
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible
|
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -307,7 +306,7 @@ public class Link extends ACSObject {
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
s_log.error(getOID()
|
s_log.error(getOID()
|
||||||
+ " is internal link, but has null target item");
|
+ " is internal link, but has null target item");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,7 +333,7 @@ public class Link extends ACSObject {
|
||||||
String.format(
|
String.format(
|
||||||
"Internal link with parameters found. Generated URL is: %s",
|
"Internal link with parameters found. Generated URL is: %s",
|
||||||
URL.there(state.getRequest(), url,
|
URL.there(state.getRequest(), url,
|
||||||
parameters).
|
parameters).
|
||||||
toString()));
|
toString()));
|
||||||
return URL.there(state.getRequest(), url, parameters).
|
return URL.there(state.getRequest(), url, parameters).
|
||||||
toString();
|
toString();
|
||||||
|
|
@ -357,8 +356,8 @@ public class Link extends ACSObject {
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
Filter filter =
|
Filter filter =
|
||||||
links.addInSubqueryFilter("id",
|
links.addInSubqueryFilter("id",
|
||||||
"com.arsdigita.cms.contenttypes.getReferringLinks");
|
"com.arsdigita.cms.contenttypes.getReferringLinks");
|
||||||
filter.set("itemID", item.getID());
|
filter.set("itemID", item.getID());
|
||||||
|
|
||||||
return links;
|
return links;
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -451,7 +457,12 @@ public class Link extends ACSObject {
|
||||||
* @param queryName This is used to find the key with which to swap
|
* @param queryName This is used to find the key with which to swap
|
||||||
*/
|
*/
|
||||||
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) {
|
||||||
|
|
@ -461,7 +472,7 @@ public class Link extends ACSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.isTrue(!isNew(), methodName + " cannot be called on an "
|
Assert.isTrue(!isNew(), methodName + " cannot be called on an "
|
||||||
+ "object that is new");
|
+ "object that is new");
|
||||||
|
|
||||||
Integer currentKey = (Integer) get(ORDER);
|
Integer currentKey = (Integer) get(ORDER);
|
||||||
// if the current item is not already ordered, alphabetize
|
// if the current item is not already ordered, alphabetize
|
||||||
|
|
@ -472,12 +483,13 @@ public class Link extends ACSObject {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert.isTrue(currentKey != null, methodName + " cannot be "
|
Assert.isTrue(currentKey != null, methodName + " cannot be "
|
||||||
+ "called on an object that is not currently in the "
|
+ "called on an object that is not currently in the "
|
||||||
+ "list");
|
+ "list");
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
@ -485,13 +497,13 @@ public class Link extends ACSObject {
|
||||||
otherKey = key + 1;
|
otherKey = key + 1;
|
||||||
query.addOrder("linkOrder ASC");
|
query.addOrder("linkOrder ASC");
|
||||||
query.addFilter(query.getFilterFactory().greaterThan("linkOrder",
|
query.addFilter(query.getFilterFactory().greaterThan("linkOrder",
|
||||||
currentKey,
|
currentKey,
|
||||||
true));
|
true));
|
||||||
} else {
|
} else {
|
||||||
otherKey = key - 1;
|
otherKey = key - 1;
|
||||||
query.addOrder("linkOrder DESC");
|
query.addOrder("linkOrder DESC");
|
||||||
query.addFilter(query.getFilterFactory().lessThan("linkOrder",
|
query.addFilter(query.getFilterFactory().lessThan("linkOrder",
|
||||||
currentKey, true));
|
currentKey, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.next()) {
|
if (query.next()) {
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue