コード例 #1
0
  @RequestMapping(value = "/getAllQuestionsPaged")
  public ModelAndView GetAllQuestionsPaged(
      HttpServletRequest request,
      @RequestParam(value = "SubCategoryName", required = false) String SubCategoryName,
      @RequestParam(value = "PageNo", required = false) int PageNo,
      @RequestParam(value = "ProfileId", required = false) String ProfileId,
      @RequestParam(value = "PageSize", required = false) int PageSize) {

    ModelAndView mav = new ModelAndView();
    String Status = "3";
    String queryText = "";
    String numFound = "0";

    String friendListResult2 = null;
    String folderListResult2 = null;
    String blockListResult2 = null;
    String canSendMessagesResult2 = null;

    String friendListResult = null;
    String folderListResult = null;
    String blockListResult = null;
    String canSendMessagesResult = null;

    try {
      friendListResult2 =
          mamCacheClient.mamCachefriendList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (friendListResult2 != null) friendListResult = friendListResult2.replace(",", " , ");

      folderListResult2 =
          mamCacheClient.mamCachefolderList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (folderListResult2 != null) folderListResult = folderListResult2.replace(",", " , ");

      blockListResult2 =
          mamCacheClient.mamCacheblockList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (blockListResult2 != null) blockListResult = blockListResult2.replace(",", " , ");

      canSendMessagesResult2 =
          mamCacheClient.mamCachecanSendMessages(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (canSendMessagesResult2 != null)
        canSendMessagesResult = canSendMessagesResult2.replace(",", " , ");

    } catch (Exception e) {
      e.printStackTrace();
    }

    List<DiscussionQuestion> questions = new ArrayList<DiscussionQuestion>();
    Object[] resultArrDiscussion = null;
    long numFoundDiscussion = 0;
    /*	if((SubCategoryName!="" || SubCategoryName!=null )& ProfileId!="0" & (blockListResult!=null || blockListResult!="") ){
    //	queryText = "(SubCategorySafeName:"+SubCategoryName+")";

    	queryText = "(SubCategorySafeName:"+SubCategoryName+" OR CreatedUserID:"+ProfileId+" AND(Everyone:1 OR (CreatedUserID:"+friendListResult+" AND FoldersShowList:"+folderListResult+" AND ContactsShowList:"+ProfileId+"))" +
    	" NOT (Onlyme:1 OR ContactsHideList:"+ProfileId+"))";

    }else if((SubCategoryName!="" || SubCategoryName!=null) & ProfileId!="0"){
    	queryText = "(SubCategorySafeName:"+SubCategoryName+" OR CreatedUserID:"+ProfileId+"  AND(Everyone:1 OR (CreatedBy:"+friendListResult+" AND FoldersShowList:"+folderListResult+" AND ContactsShowList:"+ProfileId+"))" +
    	" NOT (Onlyme:1 OR FoldersHideList:"+blockListResult+" OR ContactsHideList:"+ProfileId+" OR CreatedBy:"+blockListResult+" ))";
    }else{

    	queryText = "(SubCategorySafeName:"+SubCategoryName+" AND Everyone:1)";

    }*/

    /*	if((SubCategoryName!="" || SubCategoryName!=null ) && ProfileId!="0" && (blockListResult!=null || blockListResult!="" || blockListResult!="0") ){
    //		if((SubCategoryName!="" || SubCategoryName!=null )& ProfileId!="0" ){

    				queryText = "(((SubCategorySafeName:"+SubCategoryName+" AND ( Everyone:1 OR (CreatedUserID:"+friendListResult+" AND FoldersShowList:"+folderListResult+" AND ContactsShowList:"+ProfileId+")) NOT (Onlyme:1 OR ContactsHideList:"+ProfileId+")) OR (CreatedUserID:"+ProfileId+" OR SubCategorySafeName:"+SubCategoryName+")) NOT (ContactsHideList:"+ProfileId+" OR Onlyme:1 ))";

    			}else if((SubCategoryName!="" || SubCategoryName!=null) && ProfileId!="0"){
    				queryText = "(((SubCategorySafeName:"+SubCategoryName+" AND ( Everyone:1 OR (CreatedUserID:"+friendListResult+" AND FoldersShowList:"+folderListResult+" AND ContactsShowList:"+ProfileId+")) NOT (Onlyme:1 OR ContactsHideList:"+ProfileId+")) OR (CreatedUserID:"+ProfileId+" OR SubCategorySafeName:"+SubCategoryName+")) NOT (ContactsHideList:"+ProfileId+" OR Onlyme:1 ))";
    			}else{

    				queryText = "(SubCategorySafeName:"+SubCategoryName+" AND Everyone:1)";

    			}*/

    if (blockListResult.equals("") || blockListResult == null) blockListResult = "1";

    if (folderListResult.equals("") || folderListResult == null) folderListResult = "0";

    if (friendListResult.equals("") || friendListResult == null) friendListResult = "0";

    if ((SubCategoryName != "" && SubCategoryName != null)
        && ProfileId != "0"
        && (blockListResult != null && blockListResult != "" && blockListResult != "0")
        && (folderListResult != null && folderListResult != "")) {
      //			if((SubCategoryName!="" || SubCategoryName!=null )& ProfileId!="0" ){

      queryText =
          "(SubCategorySafeName:"
              + SubCategoryName
              + " AND -CreatedUserID:"
              + ProfileId
              + " AND (Everyone:1 OR((CreatedUserID:"
              + friendListResult
              + ") AND (ContactsShowList:0) AND (FoldersShowList:"
              + folderListResult
              + " OR FoldersShowList:0))) NOT ((Onlyme:1) OR (ContactsHideList:"
              + ProfileId
              + ") OR (FoldersHideList:"
              + folderListResult
              + "))) OR (SubCategorySafeName:"
              + SubCategoryName
              + "  AND CreatedUserID:"
              + ProfileId
              + ") OR    (SubCategorySafeName:"
              + SubCategoryName
              + "  AND CreatedUserID:"
              + friendListResult
              + " AND ContactsShowList:"
              + ProfileId
              + ") -CreatedUserID:"
              + blockListResult
              + " ";

    } else if ((SubCategoryName != "" && SubCategoryName != null) && ProfileId != "0") {
      queryText =
          "(SubCategorySafeName:"
              + SubCategoryName
              + " AND -CreatedUserID:"
              + ProfileId
              + " AND (Everyone:1 OR((ContactsShowList:0) AND (FoldersShowList:0))) NOT ((Onlyme:1) OR (ContactsHideList:"
              + ProfileId
              + "))) OR (SubCategorySafeName:"
              + SubCategoryName
              + "  AND CreatedUserID:"
              + ProfileId
              + ") OR    (SubCategorySafeName:"
              + SubCategoryName
              + "  AND ContactsShowList:"
              + ProfileId
              + ") ";
    } else {

      queryText = "(SubCategorySafeName:" + SubCategoryName + " AND Everyone:1)";
    }

    if (ProfileId.equals("0")) {
      queryText = "(SubCategorySafeName:" + SubCategoryName + " AND Everyone:1)";
    }

    System.out.println("------------->Query" + queryText);

    //	Earlier
    //	resultArrDiscussion =
    // discussionQuestionClient.fetchAllQuestionsPaged(queryText,PageNo,PageSize ,
    // "LastRepliedDate","desc" , request);

    // Changed

    resultArrDiscussion =
        discussionQuestionClient.fetchAllQuestionsPaged(
            queryText, PageNo, PageSize, "LastRepliedDate", "desc", request);
    numFoundDiscussion = Integer.parseInt(resultArrDiscussion[1].toString());
    questions = (List<DiscussionQuestion>) resultArrDiscussion[0];
    // Collections.sort(questions);
    mav.addObject("TotalRecords", numFoundDiscussion);
    mav.addObject("StatusOutput", SubCategoryName);
    mav.addObject("Collection", questions);
    mav.addObject("IsConnected", "1");

    return mav;
  }
コード例 #2
0
  @RequestMapping(value = "/findmainautocomplete")
  public @ResponseBody AutoCompleteResponse findQuestionsMainAutoComplete(
      HttpServletRequest request,
      @RequestParam(value = "ProfileId", required = false) String ProfileId,
      @RequestParam(value = "query", required = false) String Keyword) {
    ModelAndView mav = new ModelAndView();

    String friendListResult2 = null;
    String folderListResult2 = null;
    String blockListResult2 = null;
    String canSendMessagesResult2 = null;

    String friendListResult = null;
    String folderListResult = null;
    String blockListResult = null;
    String canSendMessagesResult = null;

    try {
      friendListResult2 =
          mamCacheClient.mamCachefriendList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (friendListResult2 != null) friendListResult = friendListResult2.replace(",", " , ");

      folderListResult2 =
          mamCacheClient.mamCachefolderList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (folderListResult2 != null) folderListResult = folderListResult2.replace(",", " , ");

      blockListResult2 =
          mamCacheClient.mamCacheblockList(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (blockListResult2 != null) blockListResult = blockListResult2.replace(",", " , ");

      canSendMessagesResult2 =
          mamCacheClient.mamCachecanSendMessages(
              ServerurlConstants.MEMCACHE_URL,
              ServerurlConstants.MEMCACHE_PORT,
              ProfileId,
              request);
      if (canSendMessagesResult2 != null)
        canSendMessagesResult = canSendMessagesResult2.replace(",", " , ");

    } catch (Exception e) {
      e.printStackTrace();
    }

    if (friendListResult.equals("") || friendListResult == null) friendListResult = "1000000000";

    List<DiscussionQuestion> questions = new ArrayList<DiscussionQuestion>();
    Object[] resultArrDiscussion = null;
    String queryText = null;
    long numFoundDiscussion = 0;

    // **********	Older query  ************/
    //	queryText = "(QuestionText:"+Keyword.toLowerCase()+"*) OR (Tags:"+Keyword.toLowerCase()+"*)";

    if ((Keyword != "" || Keyword != null)
        && ProfileId != "0"
        && (blockListResult != null && blockListResult != "" && blockListResult != "0")
        && (folderListResult != null && folderListResult != "")) {
      //				if((SubCategoryName!="" || SubCategoryName!=null )& ProfileId!="0" ){

      queryText =
          "(((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)) AND -CreatedUserID:"
              + ProfileId
              + " AND (Everyone:1 OR((CreatedUserID:"
              + friendListResult
              + ") AND (ContactsShowList:0) AND (FoldersShowList:"
              + folderListResult
              + " OR FoldersShowList:0))) NOT ((Onlyme:1) OR (ContactsHideList:"
              + ProfileId
              + ") OR (FoldersHideList:"
              + folderListResult
              + "))) OR ((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*) AND CreatedUserID:"
              + ProfileId
              + ") OR    ((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)  AND CreatedUserID:"
              + friendListResult
              + " AND ContactsShowList:"
              + ProfileId
              + ") -CreatedUserID:"
              + blockListResult
              + " ";

    } else if ((Keyword != "" || Keyword != null) && ProfileId != "0") {
      queryText =
          "(((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)) AND -CreatedUserID:"
              + ProfileId
              + " AND (Everyone:1 OR((CreatedUserID:"
              + friendListResult
              + ") AND (ContactsShowList:0) AND (FoldersShowList:0))) NOT ((Onlyme:1) OR (ContactsHideList:"
              + ProfileId
              + "))) OR ((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)  AND CreatedUserID:"
              + ProfileId
              + ") OR    ((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)  AND ContactsShowList:"
              + ProfileId
              + ")";
    } else {

      queryText =
          "(((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*)) AND Everyone:1)";
    }
    if (ProfileId.equals("0")) {
      queryText =
          "((QuestionText:"
              + Keyword.toLowerCase()
              + "*) OR (Tags:"
              + Keyword.toLowerCase()
              + "*) AND Everyone:1)";
    }

    System.out.println("Query-->" + queryText);

    resultArrDiscussion = this.fetchDiscussionData(queryText, 0, 10);
    numFoundDiscussion = Integer.parseInt(resultArrDiscussion[1].toString());
    questions = (List<DiscussionQuestion>) resultArrDiscussion[0];
    List data = new ArrayList();
    List suggestions = new ArrayList();
    for (DiscussionQuestion question : questions) {
      data.add(question.getID());
      suggestions.add(question.getQuestionText());
    }
    AutoCompleteResponse autoComplete = new AutoCompleteResponse();
    autoComplete.setQuery(Keyword);
    autoComplete.setData(data);
    autoComplete.setSuggestions(suggestions);
    // mav.addObject(autoComplete);
    return autoComplete;
  }