org.exoplatform.faq.service.impl
Class MultiLanguages

java.lang.Object
  extended by org.exoplatform.faq.service.impl.MultiLanguages
All Implemented Interfaces:
FAQNodeTypes

public class MultiLanguages
extends Object
implements FAQNodeTypes

MultiLanguages class allow question and category have multi language. Question content and category's name is can written by one or more languages. But only default language (only one language is default in system) is set as property of question/ category, other languages is children of question/category.

Since:
Jul 10, 2007
Author:
Hung Nguyen Quang

Field Summary
 
Fields inherited from interface org.exoplatform.faq.service.FAQNodeTypes
ASCENDING, AT, DESCENDING, EMPTY_STR, EXO_ACTIVATE_RESPONSES, EXO_ANSWER, EXO_ANSWER_HOME, EXO_ANSWER_PATH, EXO_APPROVE_RESPONSES, EXO_AUTHOR, EXO_CATEGORY_ID, EXO_COMMENT, EXO_COMMENT_BY, EXO_COMMENT_HOME, EXO_COMMENT_LANGUAGE, EXO_COMMENTS, EXO_CONTENT, EXO_CREATED_DATE, EXO_DATE_COMMENT, EXO_DATE_RESPONSE, EXO_DESCRIPTION, EXO_EMAIL, EXO_EMAIL_WATCHING, EXO_FAQ_ATTACHMENT, EXO_FAQ_CATEGORY, EXO_FAQ_CATEGORY_HOME, EXO_FAQ_HOME, EXO_FAQ_LANGUAGE, EXO_FAQ_QUESTION, EXO_FAQ_QUESTION_HOME, EXO_FAQ_R_S_S, EXO_FAQ_RESOURCE, EXO_FAQ_SETTING_HOME, EXO_FAQ_USER_SETTING, EXO_FAQ_USER_SETTING_HOME, EXO_FAQ_WATCHING, EXO_FILE_NAME, EXO_FULL_NAME, EXO_ID, EXO_INDEX, EXO_IS_ACTIVATED, EXO_IS_APPROVED, EXO_IS_MODERATE_ANSWERS, EXO_IS_MODERATE_QUESTIONS, EXO_IS_VIEW, EXO_LANGUAGE, EXO_LAST_ACTIVITY, EXO_LINK, EXO_MARK_VOTE, EXO_MARK_VOTES, EXO_MODERATORS, EXO_NAME, EXO_NAME_ATTACHS, EXO_NUMBER_OF_PUBLIC_ANSWERS, EXO_ORDE_BY, EXO_ORDE_TYPE, EXO_POST_ID, EXO_QUESTION_ID, EXO_QUESTION_LANGUAGE_HOME, EXO_QUESTION_PATH, EXO_RELATIVES, EXO_RESPONSE_BY, EXO_RESPONSE_LANGUAGE, EXO_RESPONSES, EXO_RSS_WATCHING, EXO_SORT_QUESTION_BY_VOTE, EXO_TEMPLATE_HOME, EXO_TITLE, EXO_TOPIC_ID_DISCUSS, EXO_USER_PRIVATE, EXO_USER_WATCHING, EXO_USERS_VOTE, EXO_USERS_VOTE_ANSWER, EXO_VIEW_AUTHOR_INFOR, JCR_CONTENT, JCR_DATA, JCR_LAST_MODIFIED, JCR_MIME_TYPE, JCR_ROOT, JCR_SCORE, MIX_FAQ_SUB_CATEGORY, MIX_FAQI_1_8N, NT_FILE, NT_RESOURCE, REP_EXCERPT, REP_EXCERPT_PATTERN, TEXT_HTML
 
Constructor Summary
MultiLanguages()
          Class constructor, instantiates a new multi languages.
 
Method Summary
static void addLanguage(javax.jcr.Node questionNode, QuestionLanguage language)
          Adds the language node, when question have multi language, each language is a child node of question node.
protected  javax.jcr.Value[] booleanToValues(javax.jcr.Node node, Boolean[] bools)
           
static void deleteAnswerQuestionLang(javax.jcr.Node questionNode, String answerId, String language)
           
static void deleteCommentQuestionLang(javax.jcr.Node questionNode, String commentId, String language)
           
static Answer getAnswerById(javax.jcr.Node questionNode, String answerid, String language)
           
static Comment getCommentById(javax.jcr.Node questionNode, String commentId, String language)
           
static QuestionLanguage getQuestionLanguageByLanguage(javax.jcr.Node questionNode, String language)
           
static void removeLanguage(javax.jcr.Node questionNode, List<String> listLanguage)
          Removes the language, when question have multi language, and now one of them is not helpful, and admin or moderator want to delete it, this function will be called.
static void removeLanguage(javax.jcr.Node questionNode, QuestionLanguage lang)
           
static void saveAnswer(javax.jcr.Node questionNode, Answer answer, String language)
           
static void saveAnswer(javax.jcr.Node quesNode, QuestionLanguage questionLanguage)
           
static void saveComment(javax.jcr.Node questionNode, Comment comment, String language)
           
static void unVoteQuestion(javax.jcr.Node questionNode, String userName)
           
static void voteAnswer(javax.jcr.Node answerNode, String userName, boolean isUp)
           
static void voteQuestion(javax.jcr.Node questionNode, String userName, int number)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiLanguages

public MultiLanguages()
Class constructor, instantiates a new multi languages.

Method Detail

addLanguage

public static void addLanguage(javax.jcr.Node questionNode,
                               QuestionLanguage language)
                        throws Exception
Adds the language node, when question have multi language, each language is a child node of question node.

Parameters:
questionNode - the question node which have multi language
language - the language which is added in to questionNode
Throws:
Exception - throw an exception when save a new language node

deleteAnswerQuestionLang

public static void deleteAnswerQuestionLang(javax.jcr.Node questionNode,
                                            String answerId,
                                            String language)
                                     throws Exception
Throws:
Exception

deleteCommentQuestionLang

public static void deleteCommentQuestionLang(javax.jcr.Node questionNode,
                                             String commentId,
                                             String language)
                                      throws Exception
Throws:
Exception

getQuestionLanguageByLanguage

public static QuestionLanguage getQuestionLanguageByLanguage(javax.jcr.Node questionNode,
                                                             String language)
                                                      throws Exception
Throws:
Exception

getCommentById

public static Comment getCommentById(javax.jcr.Node questionNode,
                                     String commentId,
                                     String language)
                              throws Exception
Throws:
Exception

getAnswerById

public static Answer getAnswerById(javax.jcr.Node questionNode,
                                   String answerid,
                                   String language)
                            throws Exception
Throws:
Exception

saveAnswer

public static void saveAnswer(javax.jcr.Node questionNode,
                              Answer answer,
                              String language)
                       throws Exception
Throws:
Exception

saveAnswer

public static void saveAnswer(javax.jcr.Node quesNode,
                              QuestionLanguage questionLanguage)
                       throws Exception
Throws:
Exception

saveComment

public static void saveComment(javax.jcr.Node questionNode,
                               Comment comment,
                               String language)
                        throws Exception
Throws:
Exception

booleanToValues

protected javax.jcr.Value[] booleanToValues(javax.jcr.Node node,
                                            Boolean[] bools)
                                     throws Exception
Throws:
Exception

removeLanguage

public static void removeLanguage(javax.jcr.Node questionNode,
                                  List<String> listLanguage)
Removes the language, when question have multi language, and now one of them is not helpful, and admin or moderator want to delete it, this function will be called. And this function will do:

Get all children nodes of question node, and compare them with list language is inputted in this function. Each language node, if it's name is not contained in list language, it will be deleted.

After that, the remains of language nodes will be saved as children node of question node.

Parameters:
questionNode - the question node which have multilanguage
listLanguage - the list languages will be saved

removeLanguage

public static void removeLanguage(javax.jcr.Node questionNode,
                                  QuestionLanguage lang)

voteAnswer

public static void voteAnswer(javax.jcr.Node answerNode,
                              String userName,
                              boolean isUp)
                       throws Exception
Throws:
Exception

voteQuestion

public static void voteQuestion(javax.jcr.Node questionNode,
                                String userName,
                                int number)
                         throws Exception
Throws:
Exception

unVoteQuestion

public static void unVoteQuestion(javax.jcr.Node questionNode,
                                  String userName)
                           throws Exception
Throws:
Exception


Copyright © 2003-2013 eXo Platform SAS. All Rights Reserved.