0

My final goal is I want to get plid and portletId that can be display my article(or entry with any type if it is possible).

I have sql query that return me any portlet availble for display my article. But when I have to use dynamicQuery to get the same results, I get problem with xPath and array comparison, please help!

SELECT * FROM portletpreferences pr
WHERE pr.preferences != '<portlet-preferences />' AND pr.ownerid = 0 AND pr.portletid ilike '%_INSTANCE_%' AND pr.plid IN(
    SELECT layout.plid FROM layout 
          WHERE layout.type_ = 'portlet' AND layout.groupid = 19 AND layout.hidden_ is false)
AND pr.portletpreferencesid IN (
        SELECT pr.portletpreferencesid FROM portletpreferences pr
          WHERE 'true' = ANY(xpath('//preference[name="anyAssetType"]/value/text()', XMLPARSE(DOCUMENT pr.preferences))::text[])
               OR (SELECT (array(SELECT id_ FROM journalstructure))::text[]) &&  xpath('//preference[name="classTypeIds"]/value/text()', XMLPARSE(DOCUMENT pr.preferences))::text[] )
user1487380
  • 362
  • 2
  • 9
  • 26
  • Why do you use queries and not the APIs and services that Liferay provides? – fimez Aug 10 '12 at 08:00
  • :-? i dont know, when create new display type for assetpublisher on liferay portal, I just copy existed file and edit the code, it always include many file I needed, however, when do that, i only can use liferay API and services – user1487380 Aug 10 '12 at 09:30
  • To add a new asset publisher display style you should be able to use this: http://www.liferay.com/community/wiki/-/wiki/Main/Asset+Publisher+Portlet. You just need 1 JSP file and a property file change. I don't quite understand why you would need to do a DynamicQuery to achieve a new display style? – fimez Aug 10 '12 at 13:47
  • I want to open my content in another page and portlet, so I need to custom viewURL, using dynamicQuery to find out which page(plid and portletId) can be display my content – user1487380 Aug 11 '12 at 00:48
  • If you just want to show the content on another page you could maybe use the 'Display Page' option of the Asset Publisher: http://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/lp-6-1-ugen03-using-the-asset-publisher-portlet-0 – fimez Aug 12 '12 at 14:47
  • hmm, I dont want to give end user permission to choose which pages his content will display, It must be automatically. In my case, i had changed my alg, use dynamicQuery to find out which pages - and - assetpublisher have a same title with structure name, or at least any asset publisher with a same title with it. However, thanks for reply – user1487380 Aug 13 '12 at 01:00
  • The configuration of these settings are only for users with enough permissions and usually you wouldn't give end users these kinds of permissions, only administrators. – fimez Aug 13 '12 at 07:09

2 Answers2

0

If you are bent upon using this same query, then use this query directly with Custom-SQL in liferay by creating custom-finders instead of using DynamicQuery. That would give you a lot of flexibility in using any type of SQL query directly.

I don't think this query can be converted to DynamicQuery, but if you do manage to convert it then please do post it here :-)

Prakash K
  • 11,669
  • 6
  • 51
  • 109
0

DynamicQuery is very powerful, see e.g. my answer how to find layouts with specific JournalArticles. I think your requirement is similar to this one: Liferay: How to find all Layouts with the specific JournalArticle in AssetPublisher portlets?

Community
  • 1
  • 1