Pergunta

I am using Asset Publisher and need to dynamically get the articleId of the latest journal article published.

I am using in abstracts.jsp hook:

version=JournalArticleLocalServiceUtil.getLatestVersion(assetRenderer.getGroupId(), "14405");
journalArticle = JournalArticleLocalServiceUtil.getArticle(assetRenderer.getGroupId() , "14405",version);

I have hardcoded the articleId here. How do I avoid this??

Kindly help. Thanks.

Foi útil?

Solução

Use a dynamic query to get the latest Article from JournalArticleLocalServiceUtil maybe you can use ProjectionFactoryUtil.max("createDate"); to get the latest Date

DynamicQueryFactoryUtil.forClass(JournalArticle.class)  
  .add(ProjectionFactoryUtil.max("createDate"))  
  .add(PropertyFactoryUtil.forName("groupId").eq(new Long(groupId)));  
List results =JournalArticleLocalServiceUtil.dynamicQuery(query);`
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top