Foren

AssetEntryQuery and Article structure sorting

Sebastian Wikholm, geändert vor 10 Jahren.

AssetEntryQuery and Article structure sorting

Regular Member Beiträge: 104 Beitrittsdatum: 10.03.11 Neueste Beiträge
Im trying to do a custom portlet, which more or less lists articles and displays them in different ways. Opted for doing a new portlet instead of making a hook for asset publisher as it seemed more complex to hook than create a new one for my specific needs.

The problem is with sorting the articles by a custom fields in a structure. I have a date field in my article structure and i want to be able to sort the list of articles by that date field. Ive used a assetEntryQuery.setOrderByCol1 to sort things, this works great with the default fields but not with my structure fields.

EDIT: because one is able to sort the items according to the assets structure fields in the asset publisher, i should be able to do the same thing in my portlet, but i cant find a sollution, for now my only sollution for this problem is to list all assets and do a java comparator for the data, which is less than optimal.

My question is: how do i sort assetentries with a assetentryquery by a field in the assetentrys structure? To clarify: I have an article with a structure that has a date field, but when i list assetentries i do not get access to the article structures field by setting it in setOrderByCol1, there must be a way to do this as its done in the asset publisher

UPDATE: Im making this portlet as a vaadin portlet, vaadin seems to cache the data searched per session (it seems), I have a really limited set of articles right now so its still fast, but there are going to be 160 articles to sort different way, so it remains to be seen ifall listing internally all 160 articles with all content and then sorting them internally will be fast enough. Optimal would be that to query content so that only items needed are returned.
Linh Lê Ngoc, geändert vor 10 Jahren.

RE: AssetEntryQuery and Article structure sorting

New Member Beiträge: 10 Beitrittsdatum: 08.10.10 Neueste Beiträge
Hi,

Your date field is a xml field in article content. A sql query won't be very efficient to fetch this data.
Maybe you can use a Lucene query instead.

There's an exemple in JournalArticleLocalServiceImpl :
public Hits search(
			long companyId, long groupId, long classNameId, String articleId,
			String title, String description, String content, String type,
			String status, String structureId, String templateId,
			LinkedHashMap<string, object> params, boolean andSearch, int start,
			int end, Sort sort)</string,>


The sort parameter seems to be what you are looking for.



Linh