Created
January 6, 2012 14:41
-
-
Save jdmr/1570874 to your computer and use it in GitHub Desktop.
Búsqueda por Etiquetas en Liferay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(params = "action=contenido") | |
public String contenido(RenderRequest request, @RequestParam("cursoId") Long id, Model model) throws SystemException { | |
log.debug("Edita contenido"); | |
curso = cursoDao.obtiene(id); | |
model.addAttribute("curso", curso); | |
// Obtiene los datos del usuario de session | |
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); | |
try { | |
// Obtiene el grupo en el que se encuentra trabajando el usuario firmado | |
long scopeGroupId = themeDisplay.getScopeGroupId(); | |
// Obtiene los id's de los contenidos que se encuentren en el grupo y esten etiquetados con curso.getCodigo() | |
long[] entryIds = TagsEntryLocalServiceUtil.getEntryIds(scopeGroupId, StringUtil.split(curso.getCodigo())); | |
// Lista de id's que deseo exluir de la búsqueda | |
long[] notEntryIds = new long[0]; | |
// Lista de tipos de contenido, en este caso busca de todos los tipos | |
long[] classNameIds = new long[0]; | |
// Total de contenidos con esos filtros | |
int total = TagsAssetLocalServiceUtil.getAssetsCount(scopeGroupId, entryIds, notEntryIds, false, false); | |
log.debug("TOTAL: "+total); | |
// Por fin, la lista de contenidos con los filtros | |
List<TagsAsset> assets = TagsAssetLocalServiceUtil.getAssets(scopeGroupId, classNameIds, entryIds, notEntryIds, false, false, 0, total); | |
// Iteración sobre los contenidos encontrados con esas etiquetas | |
for(TagsAsset asset : assets) { | |
log.debug("Asset: "+ asset.getTitle() + " : "+ asset.getDescription() + " : "+ asset.getMimeType() + " : " + asset.getClassName()); | |
} | |
} catch (Exception e) { | |
log.error(e); | |
throw new RuntimeException("Error al obtener los tags",e); | |
} | |
return "curso/contenido"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment