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
|
||||
where l.link_id=r.related_link_id
|
||||
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,
|
||||
* according to the linkOrder
|
||||
*/
|
||||
@Override
|
||||
public void swapWithNext() {
|
||||
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,
|
||||
* according to the linkOrder
|
||||
*/
|
||||
@Override
|
||||
public void swapWithPrevious() {
|
||||
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
|
||||
* @return the DataQuery
|
||||
*/
|
||||
@Override
|
||||
protected DataQuery getSwapQuery(String queryName) {
|
||||
DataQuery query = super.getSwapQuery(queryName);
|
||||
query.setParameter("ownerID", getLinkOwner().getID());
|
||||
|
|
@ -255,6 +260,7 @@ public class RelatedLink extends Link {
|
|||
*
|
||||
* @return the DataOperation used to swap the sort keys.
|
||||
*/
|
||||
@Override
|
||||
protected DataOperation getSwapOperation(String operationName) {
|
||||
DataOperation operation = super.getSwapOperation(operationName);
|
||||
operation.setParameter("ownerID", getLinkOwner().getID());
|
||||
|
|
@ -270,6 +276,7 @@ public class RelatedLink extends Link {
|
|||
* null. This implementation sorts all RelatedLinks owned by this
|
||||
* RelatedLink's "linkOwner" by title.
|
||||
*/
|
||||
@Override
|
||||
protected void alphabetize() {
|
||||
Session session = SessionManager.getSession();
|
||||
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||
|
|
@ -314,6 +321,7 @@ public class RelatedLink extends Link {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeSave() {
|
||||
super.beforeSave();
|
||||
if (getOrder() == null) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.arsdigita.cms.contenttypes.ui.LinkTable;
|
|||
*/
|
||||
public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
|
||||
|
||||
protected String m_linkListName = "";
|
||||
protected static String s_linkListName = "genericLink";
|
||||
protected ContentType m_contentType = null;
|
||||
|
||||
/**
|
||||
|
|
@ -68,9 +68,9 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
|
|||
LinkTable table;
|
||||
if (ContentSection.getConfig().isHideAdditionalResourceFields()) {
|
||||
table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel());
|
||||
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), m_linkListName));
|
||||
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), s_linkListName));
|
||||
} else {
|
||||
table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), m_linkListName);
|
||||
table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), s_linkListName);
|
||||
}
|
||||
|
||||
container.add(table);
|
||||
|
|
@ -86,7 +86,7 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
|
|||
protected FormSection getEditSheet() {
|
||||
return new RelatedLinkPropertyForm(getItemSelectionModel(),
|
||||
getLinkSelectionModel(),
|
||||
m_linkListName,
|
||||
s_linkListName,
|
||||
m_contentType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import com.arsdigita.util.Assert;
|
|||
public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
||||
|
||||
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
|
||||
|
|
@ -186,7 +186,7 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
|
|||
MimeType mType = MimeType.loadMimeType(typeName);
|
||||
rl.setResourceType(mType);
|
||||
}
|
||||
rl.setLinkListName(data.getString(RelatedLink.LINK_LIST_NAME));
|
||||
rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME));
|
||||
super.setLinkProperties(link, fse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class RelatedLinkTableModelBuilder extends LinkTableModelBuilder {
|
|||
Logger.getLogger(RelatedLinkTableModelBuilder.class);
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
private String m_linkListName = "";
|
||||
private String m_linkListName;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return The DataCollection of RelatedLinks
|
||||
*/
|
||||
@Override
|
||||
public DataCollection getLinks(PageState s) {
|
||||
Assert.isTrue(m_itemModel.isSelected(s), "item selected");
|
||||
ContentItem item = m_itemModel.getSelectedItem(s);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class Link extends ACSObject {
|
|||
public static final String ORDER = "linkOrder";
|
||||
/** Data object type for this domain object */
|
||||
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.
|
||||
|
|
@ -166,7 +166,7 @@ public class Link extends ACSObject {
|
|||
*/
|
||||
public void setTargetType(String type) {
|
||||
Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals(
|
||||
INTERNAL_LINK)));
|
||||
INTERNAL_LINK)));
|
||||
set(TARGET_TYPE, type);
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ public class Link extends ACSObject {
|
|||
public ContentItem getTargetItem() {
|
||||
DataObject object = (DataObject) get(TARGET_ITEM);
|
||||
ACSObject acsObject =
|
||||
(ACSObject) DomainObjectFactory.newInstance(object);
|
||||
(ACSObject) DomainObjectFactory.newInstance(object);
|
||||
|
||||
// Quasimodo: BEGIN
|
||||
// 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 instanceof ContentBundle) {
|
||||
// get the negotiated language version of this ContentBundle
|
||||
ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.
|
||||
getRequest().getLocales());
|
||||
ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.getRequest().getLocales());
|
||||
} else {
|
||||
// else there are no language versions so just use the acsObject
|
||||
ci = (ContentItem) acsObject;
|
||||
|
|
@ -307,7 +306,7 @@ public class Link extends ACSObject {
|
|||
|
||||
if (item == null) {
|
||||
s_log.error(getOID()
|
||||
+ " is internal link, but has null target item");
|
||||
+ " is internal link, but has null target item");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +333,7 @@ public class Link extends ACSObject {
|
|||
String.format(
|
||||
"Internal link with parameters found. Generated URL is: %s",
|
||||
URL.there(state.getRequest(), url,
|
||||
parameters).
|
||||
parameters).
|
||||
toString()));
|
||||
return URL.there(state.getRequest(), url, parameters).
|
||||
toString();
|
||||
|
|
@ -357,8 +356,8 @@ public class Link extends ACSObject {
|
|||
Session session = SessionManager.getSession();
|
||||
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
|
||||
Filter filter =
|
||||
links.addInSubqueryFilter("id",
|
||||
"com.arsdigita.cms.contenttypes.getReferringLinks");
|
||||
links.addInSubqueryFilter("id",
|
||||
"com.arsdigita.cms.contenttypes.getReferringLinks");
|
||||
filter.set("itemID", item.getID());
|
||||
|
||||
return links;
|
||||
|
|
@ -398,7 +397,11 @@ public class Link extends ACSObject {
|
|||
* @param operationName name of the DataOperation to use
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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;
|
||||
if (swapNext) {
|
||||
|
|
@ -461,7 +472,7 @@ public class Link extends ACSObject {
|
|||
}
|
||||
|
||||
Assert.isTrue(!isNew(), methodName + " cannot be called on an "
|
||||
+ "object that is new");
|
||||
+ "object that is new");
|
||||
|
||||
Integer currentKey = (Integer) get(ORDER);
|
||||
// if the current item is not already ordered, alphabetize
|
||||
|
|
@ -472,12 +483,13 @@ public class Link extends ACSObject {
|
|||
return;
|
||||
}
|
||||
Assert.isTrue(currentKey != null, methodName + " cannot be "
|
||||
+ "called on an object that is not currently in the "
|
||||
+ "list");
|
||||
+ "called on an object that is not currently in the "
|
||||
+ "list");
|
||||
|
||||
int key = currentKey.intValue();
|
||||
|
||||
DataQuery query = getSwapQuery(queryName);
|
||||
query.setParameter("linkListName", (String) linkListName);
|
||||
|
||||
int otherKey = key;
|
||||
|
||||
|
|
@ -485,13 +497,13 @@ public class Link extends ACSObject {
|
|||
otherKey = key + 1;
|
||||
query.addOrder("linkOrder ASC");
|
||||
query.addFilter(query.getFilterFactory().greaterThan("linkOrder",
|
||||
currentKey,
|
||||
true));
|
||||
currentKey,
|
||||
true));
|
||||
} else {
|
||||
otherKey = key - 1;
|
||||
query.addOrder("linkOrder DESC");
|
||||
query.addFilter(query.getFilterFactory().lessThan("linkOrder",
|
||||
currentKey, true));
|
||||
currentKey, true));
|
||||
}
|
||||
|
||||
if (query.next()) {
|
||||
|
|
@ -502,6 +514,7 @@ public class Link extends ACSObject {
|
|||
DataOperation operation = getSwapOperation(operationName);
|
||||
operation.setParameter("linkOrder", new Integer(key));
|
||||
operation.setParameter("nextLinkOrder", new Integer(otherKey));
|
||||
operation.setParameter("linkListName", linkListName);
|
||||
operation.execute();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue