org.exoplatform.faq.service.impl
Class MultiLanguages

java.lang.Object
  extended by org.exoplatform.faq.service.impl.MultiLanguages

public class MultiLanguages
extends java.lang.Object

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
static java.lang.String COMMENTS
          The Constant COMMENTS.
static java.lang.String EXO_LANGUAGE
          The Constant EXO_LANGUAGE.
static java.lang.String JCR_MIMETYPE
          The Constant JCR_MIMETYPE.
static java.lang.String JCRCONTENT
          The Constant JCRCONTENT.
static java.lang.String JCRDATA
          The Constant JCRDATA.
static java.lang.String NTUNSTRUCTURED
          The Constant NTUNSTRUCTURED.
 
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, java.lang.Boolean[] bools)
           
static void deleteAnswerQuestionLang(javax.jcr.Node questionNode, java.lang.String answerId, java.lang.String language)
           
static void deleteCommentQuestionLang(javax.jcr.Node questionNode, java.lang.String commentId, java.lang.String language)
           
static Answer getAnswerById(javax.jcr.Node questionNode, java.lang.String answerid, java.lang.String language)
           
static Comment getCommentById(javax.jcr.Node questionNode, java.lang.String commentId, java.lang.String language)
           
static QuestionLanguage getQuestionLanguageByLanguage(javax.jcr.Node questionNode, java.lang.String language)
           
static void removeLanguage(javax.jcr.Node questionNode, java.util.List<java.lang.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, java.lang.String language)
           
static void saveAnswer(javax.jcr.Node quesNode, QuestionLanguage questionLanguage)
           
static void saveComment(javax.jcr.Node questionNode, Comment comment, java.lang.String language)
           
static void unVoteQuestion(javax.jcr.Node questionNode, java.lang.String userName)
           
static void voteAnswer(javax.jcr.Node answerNode, java.lang.String userName, boolean isUp)
           
static void voteQuestion(javax.jcr.Node questionNode, java.lang.String userName, int number)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXO_LANGUAGE

public static final java.lang.String EXO_LANGUAGE
The Constant EXO_LANGUAGE.

See Also:
Constant Field Values

COMMENTS

public static final java.lang.String COMMENTS
The Constant COMMENTS.


JCRCONTENT

public static final java.lang.String JCRCONTENT
The Constant JCRCONTENT.

See Also:
Constant Field Values

JCRDATA

public static final java.lang.String JCRDATA
The Constant JCRDATA.

See Also:
Constant Field Values

JCR_MIMETYPE

public static final java.lang.String JCR_MIMETYPE
The Constant JCR_MIMETYPE.

See Also:
Constant Field Values

NTUNSTRUCTURED

public static final java.lang.String NTUNSTRUCTURED
The Constant NTUNSTRUCTURED.

See Also:
Constant Field Values
Constructor Detail

MultiLanguages

public MultiLanguages()
               throws java.lang.Exception
Class constructor, instantiates a new multi languages.

Throws:
java.lang.Exception - the exception
Method Detail

addLanguage

public static void addLanguage(javax.jcr.Node questionNode,
                               QuestionLanguage language)
                        throws java.lang.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:
java.lang.Exception - throw an exception when save a new language node

deleteAnswerQuestionLang

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

deleteCommentQuestionLang

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

getQuestionLanguageByLanguage

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

getCommentById

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

getAnswerById

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

saveAnswer

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

saveAnswer

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

saveComment

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

booleanToValues

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

removeLanguage

public static void removeLanguage(javax.jcr.Node questionNode,
                                  java.util.List<java.lang.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,
                              java.lang.String userName,
                              boolean isUp)
                       throws java.lang.Exception
Throws:
java.lang.Exception

voteQuestion

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

unVoteQuestion

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


Copyright © 2011 eXo Platform SAS. All Rights Reserved.