#set ($journalArticleUtil = $utilLocator.findUtil('fr.afpa.utils.journalArticle.JournalArticleUtils'))
#set ($assetCategoryPropertyLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetCategoryPropertyLocalService"))
#set ($journalArticleResourceLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleResourceLocalService"))
#set ($journalArticleService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($longGroupId = $getterUtil.getLong($groupId))
#foreach ($entry in $entries)
#set ($article = $entry.getAssetRenderer().article)
#set ($document = $saxReaderUtil.read($article.getContent()))
#set ($rootElement = $document.getRootElement())
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='Formation']") )
#set( $codeAfpa = $xPathSelector.selectSingleNode($rootElement).getStringValue())
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='Titre']") )
#set( $title = $xPathSelector.selectSingleNode($rootElement).getStringValue())
## On set le nom de la formation dynamiquement en titre de page
#if($title)
##Take layout id
#set($layoutId = $request.get("theme-display").get("plid"))
## get the service for layout
#set($layoutService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
##convert the layout id into long
#set($layoutLong = $getterUtil.getLong($layoutId))
##take a layout object
#set($layout = $layoutService.getLayout($layoutLong))
$layout.setTitle($title, $locale)
#end
#set ($codeAfpa = $codeAfpa.trim())
#set ($articleId = "FORMATION-$codeAfpa")
#set ($formation = $journalArticleService.getArticle($longGroupId,$articleId))
#set ($primKey = $formation.getResourcePrimKey())
################################################
##Recuperation des categories de la formation ##
################################################
## On recupere les categories de type "type de formation" de la formation
#set ($typeFormations = $journalArticleUtil.getAssetEntryAssetCategoriesByVocabularyAndArticleId($primKey, $vocabularyname_TYPE_FORMATION))
#if (!$typeFormations.isEmpty())
#set ($typeFormation = $typeFormations.get(0))
#set ($codeTypeFormation = $assetCategoryPropertyLocalService.getCategoryProperty($typeFormation.categoryId, "code-formation").value)
#end
####################################################
##Fin Recuperation des categories de la formation ##
####################################################
## Template de détail d'une formation déficitaire
$taglibLiferay.journalArticle($article.getArticleId(), $themeDisplay.getScopeGroupId(), "Formation-Deficitaire-Detail")
##portlet session formation
#if ($formation)
#set ($portletFormationSession = "afpaformationsessionsportlet_WAR_afpaformationsessionportlet")
#set ($queryString = "typeFormation=$codeTypeFormation&idArticle=$article.getId()&codeFormation=$codeAfpa&title=$title")
$taglibLiferay.runtime($portletFormationSession, $queryString,$velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())
#end
#end