use of org.alfresco.service.cmr.ml.MultilingualContentService in project acs-community-packaging by Alfresco.
the class AddTranslationEvaluator method evaluate.
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node) {
boolean isNodeMultililingal = node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
boolean isMLContainer = node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER);
// the node must be multiligual (translation or ml container)
if (isNodeMultililingal || isMLContainer) {
FacesContext fc = FacesContext.getCurrentInstance();
// where the pivot translation is located in
if (MultilingualUtils.canAddChildrenToPivotSpace(node, fc)) {
MultilingualContentService mlservice = (MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
UserPreferencesBean userprefs = (UserPreferencesBean) FacesHelper.getManagedBean(fc, "UserPreferencesBean");
// the number of translation of this document
int availableTranslationCount = mlservice.getTranslations(node.getNodeRef()).size();
// the total number of available languages for the translation
int contentFilterLanguagesCount = userprefs.getContentFilterLanguages(false).length;
// the number of translation must be < to the total number of available language for the content filter
return (availableTranslationCount < contentFilterLanguagesCount);
} else {
return false;
}
} else {
return false;
}
}
Aggregations