RE: Get all tag of article

Francesco Laquintana, modified 6 Years ago. Junior Member Posts: 44 Join Date: 5/16/19 Recent Posts
How can i get all tags of a journal article  using a query on database ? I use Liferay 6.2
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Francesco,Are you looking for the SQL statement because you want to run some kind of a report against the data? or do you plan to use the results in the site? If  you plan to use it in your site (either through a template, or a custom portlet, etc) then you should go through the API rather than querying the database directly. There are piles of reasons while I say this, and you will find multiple threads in the forum explaining why it is a bad idea. With all that disclaimer stuff out of the way, the table relationships ...
JournalArticle.resourcePrimKey -> AssetEntry.classPKAssetEntry.entryId -> AssetEntries_AssetTags.entryIdAssetEntries_AssetTags.tagId -> AssetTag.tagId
If you write a query joining those columns and tables, you should find what you need. Alternatively, you could just use the Script tab in the Server Administration area of the control panel and leverage the AssetEntryLocalSeviceUtil.getTags(long classNameId, long classPK) method to do that same thing -- classNameId you can lookup in the database our just use the PortalUtil.getClassNameId(JournalArticle.class); to get a hold of it.