Search in sources :

Example 6 with MultilingualContentService

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;
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) MultilingualContentService(org.alfresco.service.cmr.ml.MultilingualContentService) UserPreferencesBean(org.alfresco.web.bean.users.UserPreferencesBean)

Aggregations

MultilingualContentService (org.alfresco.service.cmr.ml.MultilingualContentService)6 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 Map (java.util.Map)3 Node (org.alfresco.web.bean.repository.Node)3 Locale (java.util.Locale)2 FacesContext (javax.faces.context.FacesContext)2 NodeService (org.alfresco.service.cmr.repository.NodeService)2 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)1 FileExistsException (org.alfresco.service.cmr.model.FileExistsException)1 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 CopyService (org.alfresco.service.cmr.repository.CopyService)1 QName (org.alfresco.service.namespace.QName)1 NavigationBean (org.alfresco.web.bean.NavigationBean)1 UserPreferencesBean (org.alfresco.web.bean.users.UserPreferencesBean)1