use of org.alfresco.web.bean.repository.MapNode in project acs-community-packaging by Alfresco.
the class MultilingualManageDialog method getTranslations.
/**
* Returns a list of objects representing the translations of the current document
*
* @return List of translations
*/
public List getTranslations() {
List<MapNode> translations = new ArrayList<MapNode>();
Node document = getDocument();
boolean canNewEdtion = MultilingualUtils.canStartNewEditon(document, FacesContext.getCurrentInstance());
if (document.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) || ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(document.getType())) {
Map<Locale, NodeRef> translationsMap = getMultilingualContentService().getTranslations(getDocument().getNodeRef());
if (translationsMap != null && translationsMap.size() > 0) {
for (Map.Entry entry : translationsMap.entrySet()) {
NodeRef nodeRef = (NodeRef) entry.getValue();
// create a map node representation of the translation
MapNode mapNode = new MapNode(nodeRef);
Locale locale = (Locale) getNodeService().getProperty(nodeRef, ContentModel.PROP_LOCALE);
String lgge = (locale != null) ? // convert the locale into new ISO codes
getContentFilterLanguagesService().convertToNewISOCode(locale.getLanguage()).toUpperCase() : null;
mapNode.put("name", getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME));
mapNode.put("language", lgge);
mapNode.put("url", DownloadContentServlet.generateBrowserURL(nodeRef, mapNode.getName()));
boolean isEmpty = new Boolean(getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION));
mapNode.put("notEmpty", !isEmpty);
mapNode.put("userHasRight", new Boolean(canNewEdtion && !isEmpty));
// add the client side version to the list
translations.add(mapNode);
}
}
}
return translations;
}
Aggregations