package kccf.sch.service.impl; import static kccf.sch.common.WNDefine.*; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import kccf.sch.common.WNSearch; import kccf.sch.common.WNUtils; import kccf.sch.service.SearchCollectionResult; import kccf.sch.service.SearchService; import kccf.sch.service.vo.SearchCollectionVO; import kccf.sch.service.vo.SearchVO; import kccf.sch.service.vo.Sf1VO; import org.apache.commons.lang3.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @Service("searchService") public class SearchServiceImpl implements SearchService{ /** SearchDAO @Resource(name="searchDAO") SearchDAO searchDAO; */ /** LOGGER */ @SuppressWarnings("unused") private static final Logger LOGGER = LoggerFactory.getLogger(SearchServiceImpl.class); /** 검색 결과 받기 */ @Override public SearchCollectionResult getSearch(SearchVO searchVO, Sf1VO sf1Vo) throws Exception { try{ boolean isDebug = true; //디버그 설정 String[] collections = null; String[] searchFields = null; boolean isRealTimeKeyword = false; boolean useSuggestedQuery = true; String exquery= ""; String strOperation =""; String exquery_info=""; /** 검색어 */ String query = searchVO.getQuery(); query = StringEscapeUtils.unescapeHtml4(query); query = WNUtils.checkReqXSS(query, ""); searchVO.setQuery(query); /** 결과내 검색어 */ String realQuery = searchVO.getRealQuery(); realQuery = StringEscapeUtils.unescapeHtml4(realQuery); realQuery = WNUtils.checkReqXSS(realQuery, ""); String reQuery = searchVO.getReQuery(); reQuery = StringEscapeUtils.unescapeHtml4(reQuery); reQuery = WNUtils.checkReqXSS(reQuery, ""); searchVO.setReQuery(reQuery); /** 결과내 재검색 체크필드 */ String rt = searchVO.getRt(); rt = StringEscapeUtils.unescapeHtml4(rt); if(!reQuery.equals("")){ rt = WNUtils.checkReqXSS(rt, "1"); }else{ rt = WNUtils.checkReqXSS(rt, ""); } /** 정렬조건 */ String sortField = searchVO.getSortField(); sortField = WNUtils.checkReqXSS(sortField, "RANK/DESC"); searchVO.setSortField(sortField); /** 검색 필드*/ String searchField = searchVO.getSearchField(); searchField = WNUtils.checkReqXSS(searchField, "ALL"); /** 검색 시작날짜 */ String startDate = searchVO.getStartDate(); startDate = WNUtils.checkReqXSS(startDate, "1970/01/01"); /** 검색 종료날짜*/ String endDate = searchVO.getEndDate(); endDate = WNUtils.checkReqXSS(endDate, WNUtils.getCurrentDate()); /** 컬렉션 이름*/ String collection = searchVO.getCollection(); if("".equals(collection)) searchVO.setCollection("ALL"); collection = WNUtils.checkReqXSS(collection, "ALL"); /** 시작위치 */ int startCount = searchVO.getStartCount(); if(startCount == 0 || collection.equals("ALL") || collection.equals("")){ startCount =1; } /** 출력갯수 */ int viewCount = searchVO.getViewCount(); if ( collection.equals("ALL") || collection.equals("") ||viewCount == 0){ viewCount = 4; } /** 디버그 YN*/ String debug = searchVO.getDebug(); debug = WNUtils.checkReqXSS(debug, "Y"); /** 검색 연산자**/ String operator = searchVO.getOperator(); operator = WNUtils.checkReqXSS(operator, "N"); String tmpQuery = query; if("OR".equals(operator)){ tmpQuery = tmpQuery.replaceAll(" ", "|"); } /*********************고급 검색*********************************/ //정확히 일치 String exactQuery = searchVO.getExactQuery(); exactQuery = StringEscapeUtils.unescapeHtml4(exactQuery); exactQuery = WNUtils.checkReqXSS(exactQuery, ""); searchVO.setExactQuery(exactQuery); if(!exactQuery.equals("")){ tmpQuery += "\"" + exactQuery + "\""; } //반드시 포함 String andQuery = searchVO.getAndQuery(); andQuery = StringEscapeUtils.unescapeHtml4(andQuery); andQuery = WNUtils.checkReqXSS(andQuery, ""); searchVO.setAndQuery(andQuery); if(!andQuery.equals("")){ tmpQuery += " " + andQuery +"" ; } //포함하지 않는 String notQuery = searchVO.getNotQuery(); notQuery = StringEscapeUtils.unescapeHtml4(notQuery); notQuery = WNUtils.checkReqXSS(notQuery, ""); searchVO.setNotQuery(notQuery); if(!notQuery.equals("")){ tmpQuery += "!" + notQuery +""; } /**********************상세 검색*********************************/ //상세검색 - 관리번호(입력) String mgnt_no = searchVO.getMgnt_no(); mgnt_no = StringEscapeUtils.unescapeHtml4(mgnt_no); mgnt_no = WNUtils.checkReqXSS(mgnt_no, ""); //searchVO.setMgnt_no(mgnt_no); if ( !mgnt_no.equals("") ) { exquery += " "; } //상세검색 - 시대(선택) String trs_age = searchVO.getTrs_age(); trs_age = StringEscapeUtils.unescapeHtml4(trs_age); trs_age = WNUtils.checkReqXSS(trs_age, ""); trs_age = trs_age.replace(",","|"); if ( !trs_age.equals("") ) { if(trs_age.indexOf("ALL") == -1){ exquery += " "; } } //상세검색 - 주제분야(선택) String second_category = searchVO.getSecond_category(); second_category = StringEscapeUtils.unescapeHtml4(second_category); second_category = WNUtils.checkReqXSS(second_category, ""); second_category = second_category.replace(",","|"); if ( !second_category.equals("") ) { exquery += " "; } //상세검색 - 문화테마(선택) String series_cd = searchVO.getSeries_cd(); series_cd = StringEscapeUtils.unescapeHtml4(series_cd); series_cd = WNUtils.checkReqXSS(series_cd, ""); series_cd = series_cd.replace(",","|"); if ( !series_cd.equals("") ) { exquery += " "; //역사문화유산^유교 } //상세검색 - 자료유형(선택) String second_class = searchVO.getSecond_class(); second_class = StringEscapeUtils.unescapeHtml4(second_class); second_class = WNUtils.checkReqXSS(second_class, ""); second_class = second_class.replace(",","|"); if ( !second_class.equals("") ) { exquery += " "; } //상세검색 - 지역/문화원(선택) String sojang_council = searchVO.getSojang_council(); sojang_council = StringEscapeUtils.unescapeHtml4(sojang_council); sojang_council = WNUtils.checkReqXSS(sojang_council, ""); sojang_council = sojang_council.replace(",","|"); if ( !sojang_council.equals("") && !sojang_council.equals("|")) { exquery += " "; } //상세검색 - 지역 (지역문화정보) String search_area_council_info = searchVO.getSearch_area_council_info(); search_area_council_info = StringEscapeUtils.unescapeHtml4(search_area_council_info); search_area_council_info = WNUtils.checkReqXSS(search_area_council_info, ""); search_area_council_info = search_area_council_info.replace(",","|"); if ( !search_area_council_info.equals("") && !search_area_council_info.equals("|")) { exquery_info+= " "; } //상세검색 - 유형 (지역문화정보) String content_type = searchVO.getContent_type(); content_type = StringEscapeUtils.unescapeHtml4(content_type); content_type = WNUtils.checkReqXSS(content_type, ""); content_type = content_type.replace(",","|"); if ( !content_type.equals("") && !content_type.equals("|")) { exquery_info += " "; } //상세검색 - 발행년도(기간) String genyear_start = searchVO.getGenyear_start(); genyear_start = WNUtils.checkReqXSS(genyear_start, ""); if( !genyear_start.equals("")) { strOperation += " "; } String genyear_end = searchVO.getGenyear_end(); genyear_end = WNUtils.checkReqXSS(genyear_end, ""); if( !genyear_end.equals("")) { strOperation += ""; } //상세검색 - 연대(기간) String chronological_start = searchVO.getChronological_start(); chronological_start = WNUtils.checkReqXSS(chronological_start, ""); if( !chronological_start.equals("")) { strOperation += " "; } String chronological_end = searchVO.getChronological_end(); chronological_end = WNUtils.checkReqXSS(chronological_end, ""); if( !chronological_end.equals("")) { strOperation += ""; } /** 상세검색 컬렉션 체크박스 String chkColls = searchVO.getChkColls(); chkColls = WNUtils.checkReqXSS(chkColls, ""); */ //쿼리 설정 if (rt.equals("1")) { realQuery = tmpQuery + " (" + reQuery+")"; //realQuery } else if (!rt.equals("1") || "".equals(realQuery)) { realQuery = tmpQuery; } String collection_real =""; String[] collections_real = null; // 컬렉션 설정 if(collection.equals("ALL") || collection.equals("")){ collections = new String[]{"info","map","number","pick","reference","story","culturePost","total","toon"}; //COLLECTIONS; collections_real = new String[]{"info","map","number","pick","reference","story","culturePost","total","toon"}; collection_real = collection; } else if(collection.indexOf("_Coll") >= 0){ collection_real = collection.replace("_Coll", ""); if(collection.indexOf("culturePost") >= 0){ collections = new String[]{"info","map","number","pick","reference","story","culturePost","culturePostHot","toon"}; collections_real = new String[]{"culturePost","culturePostHot"}; collection_real = "culturePost"; }else{ collections = new String[]{"info","map","number","pick","reference","story","culturePost","toon"}; collections_real = new String[]{collection_real}; } } WNSearch wnsearch = new WNSearch(isDebug, false, collections, searchFields); wnsearch.setSf1Vo(sf1Vo); for (int i = 0; i < collections.length; i++) { // PAGE_INFO 페이지 int tmpViewCnt =viewCount; if(collections[i].equals("info")){ if(tmpViewCnt == 4){ tmpViewCnt = 6; wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+tmpViewCnt); }else{ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * viewCount) +","+viewCount); } } else if(collections[i].equals("total")){ tmpViewCnt=8; wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+tmpViewCnt); } else if(collections[i].equals("toon")){ //지역문화 툰 그리드형식으로 12건씩 출력 if(collection.equals("ALL")||collection.equals("")){ //collection ALL일 경우 tmpViewCnt = 6; wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+tmpViewCnt); }else if(viewCount == 10){ tmpViewCnt = 12; wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+tmpViewCnt); }else{ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+viewCount); } } else{ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * viewCount) +","+viewCount); } // DATE_RANGE 날짜 if("".equals(query) && "".equals(realQuery)){ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, "1970/01/01,2030/01/01,-"); }else{ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, startDate.replaceAll("\\.","/") + "," + endDate.replaceAll("\\.","/") +",/"); } // SORT_FIELD 정렬 필드 if(collections[i].equals("total")){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, "READ_CNT/DESC,DATE/DESC,RANK/DESC" ); }else{ if((collections[i].equals("info") ||collections[i].equals("culturePost") )&& sortField.equals("READ_CNT/DESC") ){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, "RANK/DESC" ); }else if (collections[i].equals("reference")){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, "MAIN_IMG_EXIST/DESC,ORG_OPEN_EXIST/DESC," + sortField ); }else{ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, sortField ); } } //exquery 설정 if ( !collections[i].equals("map")){ if( !collections[i].equals("info") && !exquery.equals("") ){ wnsearch.setCollectionInfoValue(collections[i], EXQUERY_FIELD, exquery ); }else if( collections[i].equals("info") && (!exquery.equals("") || !exquery_info.equals(""))){ wnsearch.setCollectionInfoValue(collections[i], EXQUERY_FIELD, exquery + exquery_info ); } } //SearchField 값이 있으면 설정, 없으면 기본검색필드 if ( !(searchVO.getSearchField()).equals("") && (searchVO.getSearchField()).indexOf("ALL") == -1 ) wnsearch.setCollectionInfoValue(collections[i], SEARCH_FIELD, (searchVO.getSearchField()) ); //operation 설정 if ( !strOperation.equals("") ) { wnsearch.setCollectionInfoValue(collections[i], FILTER_OPERATION, strOperation); } if(!"ALL".equals(collection)){ if("culturePost".equals(collections[i]) && "culturePost".equals(collection_real)) { wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC,KEYWORDS:1/SC"); // }else if ( "number".equals(collections[i]) && "number".equals(collection_real)){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN,SEARCH_THEME_CD:1/SN,SEARCH_THEME_CD:2/SN,SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN"); }else if ( "story".equals(collections[i]) && "story".equals(collection_real)){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_THEME_CD:1/SN,SEARCH_THEME_CD:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); //TAGS:1/SN,TAGS:1/SN }else if ( "reference".equals(collections[i])&& "reference".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN,SEARCH_CATEGORY:1/SN,SEARCH_CATEGORY:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); }else if ( "info".equals(collections[i])&& "info".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "CONTENT_TYPE_NAME:1/SN,SEARCH_AREA_COUNCIL_INFO:1/SN"); }else if ( "pick".equals(collections[i]) && "pick".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); //TAGS:1/SN,TAGS:1/SN }else if ( "toon".equals(collections[i])&& "toon".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC"); } }else if("ALL".equals(collection)){ if("total".equals(collections[i])) { wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC"); } } } wnsearch.search(realQuery, isRealTimeKeyword, CONNECTION_CLOSE, useSuggestedQuery, sf1Vo.getSearchIp(), sf1Vo.getSearchPort()); searchVO.setRealQuery(realQuery); // 결과 담기 SearchCollectionResult collResultList = new SearchCollectionResult(); // 디버그 메시지 출력 String debugMsg = wnsearch.printDebug() != null ? wnsearch.printDebug().trim() : ""; collResultList.setDebugStr(debugMsg); if(isDebug){ System.out.println("\n\n\n\n\n\n\n/*****************debugMsg********************/"+debugMsg); } // 결과 arrList ArrayList collList = new ArrayList(); for (int i = 0; i < collections.length; i++) { SearchCollectionVO colVo = new SearchCollectionVO(); int totalCount = wnsearch.getResultTotalCount(collections[i]); int resultCount = wnsearch.getResultCount(collections[i]); String collectionName = wnsearch.getCollectionInfoValue(collections[i], INDEX_NAME); String resultField = wnsearch.getCollectionInfoValue(collections[i], RESULT_FIELD); String[] resultFieldArr = resultField.split(","); /** map 방식 1. */ ArrayList> resultList = new ArrayList>(); for(int j = 0 ; j < resultCount ; j++){ Map resultMap = new HashMap(); for(int k = 0 ; k < resultFieldArr.length ; k ++){ String[] documentFields = WNUtils.split(resultFieldArr[k], "/"); resultMap.put(documentFields[0],wnsearch.getField(collections[i],documentFields[0] , j , false).replace("", "").replace("", "") ); } resultList.add(j,resultMap); } colVo.setTotalCount(totalCount); colVo.setResultCount(resultCount); colVo.setCollectionName(collectionName); colVo.setSearchResultList(resultList); collList.add(i,colVo); } int cateListCnt = collections.length ; //자료유형 카테고리 if (collections_real.length == 1 && (collection_real.equals("pick") || collection_real.equals("number") || collection_real.equals("reference") )) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CLASS", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CLASS", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CLASS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CLASS", 1, j); resultMap.put("first_class_nm", node); resultMap.put("first_class_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("first_class_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CLASS", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CLASS", 2, j); resultMap.put("second_class_nm", node); resultMap.put("second_class_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("second_class_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화원 if (collections_real.length == 1 && (collection_real.equals("pick") || collection_real.equals("reference") || collection_real.equals("story"))) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 1, j); resultMap.put("first_council_nm", node); resultMap.put("first_council_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } } colVo.setCollectionName("first_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } } colVo.setCollectionName("second_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } if (collections_real.length == 1 && collection_real.equals("number")) { String collection1 = collection_real; int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 2); //first if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; Map first_resultMap = new HashMap(); for (int j = 0; j < second_class_cnt; j++) { String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2 , j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; } //first String[] first_node = node.split("\\^"); if(first_resultMap.containsKey(first_node[0])){ nodeCnt = first_resultMap.get(first_node[0]) + nodeCnt; } first_resultMap.put(first_node[0],nodeCnt); } for (String key : first_resultMap.keySet()) { Map resultMap = new HashMap(); resultMap.put("first_council_nm", key); resultMap.put("first_council_cnt", first_resultMap.get(key)); resultList.add(j_result, resultMap); j_result +=1; } colVo.setCollectionName("first_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } //second if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); //second resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } } colVo.setCollectionName("second_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역,유형 if (collections_real.length == 1 && collection_real.equals("info")) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL_INFO", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "CONTENT_TYPE_NAME", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL_INFO", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL_INFO", 1, j); resultMap.put("first_council_nm", node); resultMap.put("first_council_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } } colVo.setCollectionName("first_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int nodeCnt_total = 0; int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"CONTENT_TYPE_NAME", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "CONTENT_TYPE_NAME", 1, j); resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("second_council_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //주제분야 if (collections_real.length == 1 && collection_real.equals("reference") ) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CATEGORY", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CATEGORY", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CATEGORY", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CATEGORY", 1, j); resultMap.put("first_category_nm", node); resultMap.put("first_category_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("first_category_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CATEGORY", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CATEGORY", 2, j); resultMap.put("second_category_nm", node); resultMap.put("second_category_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("second_category_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //테마 if (collections_real.length == 1 && ( collection_real.equals("number") || collection_real.equals("story") )) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_THEME_CD", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_THEME_CD", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_THEME_CD", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_THEME_CD", 1, j); resultMap.put("first_theme_cd", node); resultMap.put("first_theme_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("first_theme_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_THEME_CD", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_THEME_CD", 2, j); resultMap.put("second_theme_cd", node); resultMap.put("second_theme_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } } colVo.setCollectionName("second_theme_cate"); colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화포스트 if (collections_real.length == 2 && "culturePost".equals(collection_real) ) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "KEYWORDS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); //int j_result = 0; int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); if (("null").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10 || ("^").equalsIgnoreCase(node)){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("culturePostHot_tags"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int cateCnt = 0; for (int j = 0; j < second_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"KEYWORDS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "KEYWORDS", 1, j); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10){ resultMap.put("keywords_nm", node); resultMap.put("keywords_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("culturePostHot_keywords"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화툰 if (collections_real.length == 1 && "toon".equals(collection_real) ) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); //int j_result = 0; int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); if (("null").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10 || ("^").equalsIgnoreCase(node)){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("toon_tags"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } } //통합검색 total 태그 if (collections_real.length != 1 && "ALL".equals(collection_real) ) { String collection1 = "total"; int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("total_tags"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } } collResultList.setCollectionList(collList); // 연결 종료 if ( wnsearch != null ) { wnsearch.closeServer(); } return collResultList; }catch(Exception e){ e.printStackTrace(); } return null; } @Override public String getSearchEtc(SearchVO searchVO ,Sf1VO sf1Vo) throws Exception { StringBuffer receiverURL = new StringBuffer(); receiverURL.append("http://"); receiverURL.append(sf1Vo.getManagerIp()).append(":"); receiverURL.append(sf1Vo.getManagerPort()); receiverURL.append("/manage/Manager.do?"); receiverURL.append("xml="+URLEncoder.encode(" Monitoring Start Module cmanager1 Program theme_k-static etc undefined undefined ", "UTF-8")); String receiverURLStr = receiverURL.toString(); String ret = ""; try { Thread.sleep(2000); } catch (InterruptedException e) { LOGGER.info("InterruptedException occurred"); } if(getHtmls(receiverURLStr, sf1Vo.getSearchTimeOut())){ ret = "success"; }else{ ret = "fail"; } return ret; } /** * 관리도구 자동완성 URL 호출해야 해당 결과 담기 * @param receiverURL 관리도구 URL 정보 * @param parameter 배치 정보 관련 파라미터값 * @param timeout 연결 시간 고정으로 3000 */ private boolean getHtmls(String receiverURL, int timeout) { boolean result = false; HttpURLConnection uc = null; int errorCode = 0; try { URL servletUrl = new URL(receiverURL); uc = (HttpURLConnection) servletUrl.openConnection(); uc.setRequestProperty("Content-type", "application/x-www-form-urlencoded; charset=UTF-8"); uc.setRequestMethod("POST"); uc.setDoOutput(true); uc.setDoInput(true); uc.setUseCaches(false); uc.setConnectTimeout(timeout); uc.setReadTimeout(timeout); uc.connect(); // -- Network error check //System.out.println("[URLConnection Response Code] " + uc.getResponseCode()); if (uc.getResponseCode() == HttpURLConnection.HTTP_OK) { errorCode = uc.getResponseCode(); result = true; } else { errorCode = uc.getResponseCode(); result = false; } } catch(Exception ex) { LOGGER.debug("[getHtmls() URL]["+receiverURL+"]"); LOGGER.debug("[getHtmls() error][errorCode:"+errorCode+"]["+ex+"]"); } finally { uc.disconnect(); } return result; } /** 검색 결과 count */ @Override public int getSearch_All_cnt(SearchVO searchVO, Sf1VO sf1Vo) throws Exception { try{ boolean isDebug = true; String[] collections = null; String[] searchFields = null; boolean isRealTimeKeyword = false; boolean useSuggestedQuery = true; isDebug = true; //디버그 설정 String exquery= ""; String strOperation =""; /** 검색어 */ String query = searchVO.getQuery(); query = StringEscapeUtils.unescapeHtml4(query); query = WNUtils.checkReqXSS(query, ""); searchVO.setQuery(query); /** 결과내 검색어 */ String realQuery = searchVO.getRealQuery(); realQuery = StringEscapeUtils.unescapeHtml4(realQuery); realQuery = WNUtils.checkReqXSS(realQuery, ""); String reQuery = searchVO.getReQuery(); reQuery = StringEscapeUtils.unescapeHtml4(reQuery); reQuery = WNUtils.checkReqXSS(reQuery, ""); searchVO.setReQuery(reQuery); /** 결과내 재검색 체크필드 */ String rt = searchVO.getRt(); rt = StringEscapeUtils.unescapeHtml4(rt); if(!reQuery.equals("")){ rt = WNUtils.checkReqXSS(rt, "1"); }else{ rt = WNUtils.checkReqXSS(rt, ""); } /** 정렬조건 */ String sortField = searchVO.getSortField(); sortField = WNUtils.checkReqXSS(sortField, "RANK/DESC"); searchVO.setSortField(sortField); /* *//** 정렬 방식*//* String sortOrder = searchVO.getSortOrder(); sortOrder = WNUtils.checkReqXSS(sortOrder, "DESC");*/ /** 검색 필드*/ String searchField = searchVO.getSearchField(); searchField = WNUtils.checkReqXSS(searchField, "ALL"); /** 검색 시작날짜 */ String startDate = searchVO.getStartDate(); startDate = WNUtils.checkReqXSS(startDate, "1970/01/01"); /** 검색 종료날짜*/ String endDate = searchVO.getEndDate(); endDate = WNUtils.checkReqXSS(endDate, WNUtils.getCurrentDate()); /** 컬렉션 이름*/ String collection = searchVO.getCollection(); if("".equals(collection)) searchVO.setCollection("ALL"); collection = WNUtils.checkReqXSS(collection, "ALL"); /** 시작위치 */ int startCount = searchVO.getStartCount(); if(startCount == 0 || collection.equals("ALL") || collection.equals("")){ startCount =1; } /** 출력갯수 */ int viewCount = searchVO.getViewCount(); if ( collection.equals("ALL") || collection.equals("") ||viewCount == 0){ viewCount = 4; } // searchVO.setViewCount(viewCount); /** 디버그 YN*/ String debug = searchVO.getDebug(); debug = WNUtils.checkReqXSS(debug, "Y"); /** 검색 연산자**/ String operator = searchVO.getOperator(); operator = WNUtils.checkReqXSS(operator, "N"); String tmpQuery = query; if("OR".equals(operator)){ tmpQuery = tmpQuery.replaceAll(" ", "|"); } /*********************고급 검색*********************************/ //정확히 일치 String exactQuery = searchVO.getExactQuery(); exactQuery = StringEscapeUtils.unescapeHtml4(exactQuery); exactQuery = WNUtils.checkReqXSS(exactQuery, ""); searchVO.setExactQuery(exactQuery); if(!exactQuery.equals("")){ tmpQuery += "\"" + exactQuery + "\""; } //반드시 포함 String andQuery = searchVO.getAndQuery(); andQuery = StringEscapeUtils.unescapeHtml4(andQuery); andQuery = WNUtils.checkReqXSS(andQuery, ""); searchVO.setAndQuery(andQuery); if(!andQuery.equals("")){ tmpQuery += " " + andQuery +"" ; } //포함하지 않는 String notQuery = searchVO.getNotQuery(); notQuery = StringEscapeUtils.unescapeHtml4(notQuery); notQuery = WNUtils.checkReqXSS(notQuery, ""); searchVO.setNotQuery(notQuery); if(!notQuery.equals("")){ tmpQuery += "!" + notQuery +""; } /**********************상세 검색*********************************/ //상세검색 - 관리번호(입력) String mgnt_no = searchVO.getMgnt_no(); mgnt_no = StringEscapeUtils.unescapeHtml4(mgnt_no); mgnt_no = WNUtils.checkReqXSS(mgnt_no, ""); //searchVO.setMgnt_no(mgnt_no); if ( !mgnt_no.equals("") ) { exquery += " "; } //상세검색 - 시대(선택) String trs_age = searchVO.getTrs_age(); trs_age = StringEscapeUtils.unescapeHtml4(trs_age); trs_age = WNUtils.checkReqXSS(trs_age, ""); trs_age = trs_age.replace(",","|"); if ( !trs_age.equals("") ) { if(trs_age.indexOf("ALL") == -1){ exquery += " "; } } //상세검색 - 주제분야(선택) String second_category = searchVO.getSecond_category(); second_category = StringEscapeUtils.unescapeHtml4(second_category); second_category = WNUtils.checkReqXSS(second_category, ""); second_category = second_category.replace(",","|"); if ( !second_category.equals("") ) { exquery += " "; } //상세검색 - 문화테마(선택) String series_cd = searchVO.getSeries_cd(); series_cd = StringEscapeUtils.unescapeHtml4(series_cd); series_cd = WNUtils.checkReqXSS(series_cd, ""); series_cd = series_cd.replace(",","|"); if ( !series_cd.equals("") ) { exquery += " "; } //상세검색 - 자료유형(선택) String second_class = searchVO.getSecond_class(); second_class = StringEscapeUtils.unescapeHtml4(second_class); second_class = WNUtils.checkReqXSS(second_class, ""); second_class = second_class.replace(",","|"); if ( !second_class.equals("") ) { exquery += " "; }/*else if(second_class.equals("")){ //chk searchVO.setFirst_class(""); }*/ //상세검색 - 지역/문화원(선택) String sojang_council = searchVO.getSojang_council(); sojang_council = StringEscapeUtils.unescapeHtml4(sojang_council); sojang_council = WNUtils.checkReqXSS(sojang_council, ""); sojang_council = sojang_council.replace(",","|"); if ( !sojang_council.equals("") && !sojang_council.equals("|")) { exquery += " "; }/*else if(second_class.equals("")){ //chk searchVO.setSido_name(""); }*/ //System.out.println("\n\n\n\n\n\n\n/*****************[totalCount-exquery]********************"+exquery); //상세검색 - 발행년도(기간) String genyear_start = searchVO.getGenyear_start(); genyear_start = WNUtils.checkReqXSS(genyear_start, ""); if( !genyear_start.equals("")) { strOperation += " "; } String genyear_end = searchVO.getGenyear_end(); genyear_end = WNUtils.checkReqXSS(genyear_end, ""); if( !genyear_end.equals("")) { strOperation += ""; } //상세검색 - 연대(기간) String chronological_start = searchVO.getChronological_start(); chronological_start = WNUtils.checkReqXSS(chronological_start, ""); if( !chronological_start.equals("")) { strOperation += " "; } String chronological_end = searchVO.getChronological_end(); chronological_end = WNUtils.checkReqXSS(chronological_end, ""); if( !chronological_end.equals("")) { strOperation += ""; } //쿼리 설정 if (rt.equals("1")) { realQuery = tmpQuery + " (" + reQuery+")"; //realQuery } else if (!rt.equals("1") || "".equals(realQuery)) { realQuery = tmpQuery; } // 컬렉션 설정 //if(collection.equals("ALL") || collection.equals("")){ collections = new String[]{"info","map","number","pick","reference","story","culturePost", "toon"}; WNSearch wnsearch = new WNSearch(isDebug, false, collections, searchFields); wnsearch.setSf1Vo(sf1Vo); for (int i = 0; i < collections.length; i++) { // PAGE_INFO 페이지 wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * viewCount) +","+viewCount); // DATE_RANGE 날짜 if("".equals(query) && "".equals(realQuery)){ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, "1970/01/01,2030/01/01,-"); }else{ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, startDate.replaceAll("\\.","/") + "," + endDate.replaceAll("\\.","/") +",/"); } // SORT_FIELD 정렬 필드 /* if(collections[i].equals("total")){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, "READ_CNT/DESC" ); }else{ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, sortField ); } else{ if(sortField.equals("READ_CNT/DESC") && collections[i].equals("total") && collections[i].equals("total")){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, sortField ); }else{ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, sortField ); } }*/ //exquery 설정 if ( !exquery.equals("") ){ if(!collections[i].equals("map")){ wnsearch.setCollectionInfoValue(collections[i], EXQUERY_FIELD, exquery ); } } //SearchField 값이 있으면 설정, 없으면 기본검색필드 if ( !(searchVO.getSearchField()).equals("") && (searchVO.getSearchField()).indexOf("ALL") == -1 ) wnsearch.setCollectionInfoValue(collections[i], SEARCH_FIELD, (searchVO.getSearchField()) ); //operation 설정 if ( !strOperation.equals("") ) { wnsearch.setCollectionInfoValue(collections[i], FILTER_OPERATION, strOperation); } } wnsearch.search(realQuery, isRealTimeKeyword, CONNECTION_CLOSE, useSuggestedQuery, sf1Vo.getSearchIp(), sf1Vo.getSearchPort()); searchVO.setRealQuery(realQuery); // 결과 담기 SearchCollectionResult collResultList = new SearchCollectionResult(); // 디버그 메시지 출력 String debugMsg = wnsearch.printDebug() != null ? wnsearch.printDebug().trim() : ""; collResultList.setDebugStr(debugMsg); //System.out.println("\n\n\n\n\n\n\n/*****************[totalCount-debugMsg]********************/"+debugMsg); int totalCount = 0 ; // 결과 arrList for (int i = 0; i < collections.length; i++) { // 컬렉션 for totalCount += wnsearch.getResultTotalCount(collections[i]); } //System.out.println("\n\n\n\n\n\n\n/*****************[totalCount-totalCount]********************/"+totalCount); // 연결 종료 if ( wnsearch != null ) { wnsearch.closeServer(); } return totalCount; }catch(Exception e){ e.printStackTrace(); } return 0; } /** 검색 결과 받기 */ @Override public SearchCollectionResult getSearch_ajax(SearchVO searchVO, Sf1VO sf1Vo) throws Exception { try{ boolean isDebug = true; String[] collections = null; String[] searchFields = null; boolean isRealTimeKeyword = false; boolean useSuggestedQuery = true; isDebug = true; //디버그 설정 String exquery= ""; String strOperation =""; String exquery_info=""; /** 검색어 */ String query = searchVO.getQuery(); query = StringEscapeUtils.unescapeHtml4(query); query = WNUtils.checkReqXSS(query, ""); searchVO.setQuery(query); /** 결과내 검색어 */ String realQuery = searchVO.getRealQuery(); realQuery = StringEscapeUtils.unescapeHtml4(realQuery); realQuery = WNUtils.checkReqXSS(realQuery, ""); String reQuery = searchVO.getReQuery(); reQuery = StringEscapeUtils.unescapeHtml4(reQuery); reQuery = WNUtils.checkReqXSS(reQuery, ""); searchVO.setReQuery(reQuery); /** 결과내 재검색 체크필드 */ String rt = searchVO.getRt(); rt = StringEscapeUtils.unescapeHtml4(rt); if(!reQuery.equals("")){ rt = WNUtils.checkReqXSS(rt, "1"); }else{ rt = WNUtils.checkReqXSS(rt, ""); } /** 정렬조건 */ String sortField = searchVO.getSortField(); sortField = WNUtils.checkReqXSS(sortField, "RANK/DESC"); searchVO.setSortField(sortField); /** 검색 필드*/ String searchField = searchVO.getSearchField(); searchField = WNUtils.checkReqXSS(searchField, "ALL"); /** 검색 시작날짜 */ String startDate = searchVO.getStartDate(); startDate = WNUtils.checkReqXSS(startDate, "1970/01/01"); /** 검색 종료날짜*/ String endDate = searchVO.getEndDate(); endDate = WNUtils.checkReqXSS(endDate, WNUtils.getCurrentDate()); /** 컬렉션 이름*/ String collection = searchVO.getCollection(); if("".equals(collection)) searchVO.setCollection("ALL"); collection = WNUtils.checkReqXSS(collection, "ALL"); /** 시작위치 */ int startCount = searchVO.getStartCount(); if(startCount == 0 || collection.equals("ALL") || collection.equals("")){ startCount =1; } /** 출력갯수 */ int viewCount = searchVO.getViewCount(); if ( collection.equals("ALL") || collection.equals("") ||viewCount == 0){ viewCount = 4; } // searchVO.setViewCount(viewCount); /** 디버그 YN*/ String debug = searchVO.getDebug(); debug = WNUtils.checkReqXSS(debug, "Y"); /** 검색 연산자**/ String operator = searchVO.getOperator(); operator = WNUtils.checkReqXSS(operator, "N"); String tmpQuery = query; if("OR".equals(operator)){ tmpQuery = tmpQuery.replaceAll(" ", "|"); } /*********************고급 검색*********************************/ //정확히 일치 String exactQuery = searchVO.getExactQuery(); exactQuery = StringEscapeUtils.unescapeHtml4(exactQuery); exactQuery = WNUtils.checkReqXSS(exactQuery, ""); searchVO.setExactQuery(exactQuery); if(!exactQuery.equals("")){ tmpQuery += "\"" + exactQuery + "\""; } //반드시 포함 String andQuery = searchVO.getAndQuery(); andQuery = StringEscapeUtils.unescapeHtml4(andQuery); andQuery = WNUtils.checkReqXSS(andQuery, ""); searchVO.setAndQuery(andQuery); if(!andQuery.equals("")){ tmpQuery += " " + andQuery +"" ; } //포함하지 않는 String notQuery = searchVO.getNotQuery(); notQuery = StringEscapeUtils.unescapeHtml4(notQuery); notQuery = WNUtils.checkReqXSS(notQuery, ""); searchVO.setNotQuery(notQuery); if(!notQuery.equals("")){ tmpQuery += "!" + notQuery +""; } /**********************상세 검색*********************************/ //상세검색 - 관리번호(입력) String mgnt_no = searchVO.getMgnt_no(); mgnt_no = StringEscapeUtils.unescapeHtml4(mgnt_no); mgnt_no = WNUtils.checkReqXSS(mgnt_no, ""); //searchVO.setMgnt_no(mgnt_no); if ( !mgnt_no.equals("") ) { exquery += " "; } //상세검색 - 시대(선택) String trs_age = searchVO.getTrs_age(); trs_age = StringEscapeUtils.unescapeHtml4(trs_age); trs_age = WNUtils.checkReqXSS(trs_age, ""); trs_age = trs_age.replace(",","|"); if ( !trs_age.equals("") ) { if(trs_age.indexOf("ALL") == -1){ exquery += " "; } } //상세검색 - 주제분야(선택) String second_category = searchVO.getSecond_category(); second_category = StringEscapeUtils.unescapeHtml4(second_category); second_category = WNUtils.checkReqXSS(second_category, ""); second_category = second_category.replace(",","|"); if ( !second_category.equals("") ) { exquery += " "; } //상세검색 - 문화테마(선택) String series_cd = searchVO.getSeries_cd(); series_cd = StringEscapeUtils.unescapeHtml4(series_cd); series_cd = WNUtils.checkReqXSS(series_cd, ""); series_cd = series_cd.replace(",","|"); if ( !series_cd.equals("") ) { exquery += " "; //역사문화유산^유교 } //상세검색 - 자료유형(선택) String second_class = searchVO.getSecond_class(); second_class = StringEscapeUtils.unescapeHtml4(second_class); second_class = WNUtils.checkReqXSS(second_class, ""); second_class = second_class.replace(",","|"); if ( !second_class.equals("") ) { exquery += " "; }/*else if(second_class.equals("")){ //chk searchVO.setFirst_class(""); }*/ //상세검색 - 지역/문화원(선택) String sojang_council = searchVO.getSojang_council(); sojang_council = StringEscapeUtils.unescapeHtml4(sojang_council); sojang_council = WNUtils.checkReqXSS(sojang_council, ""); sojang_council = sojang_council.replace(",","|"); if ( !sojang_council.equals("") && !sojang_council.equals("|")) { exquery += " "; } //상세검색 - 지역 (지역문화정보) String search_area_council_info = searchVO.getSearch_area_council_info(); search_area_council_info = StringEscapeUtils.unescapeHtml4(search_area_council_info); search_area_council_info = WNUtils.checkReqXSS(search_area_council_info, ""); search_area_council_info = search_area_council_info.replace(",","|"); if ( !search_area_council_info.equals("") && !search_area_council_info.equals("|")) { exquery_info+= " "; } //상세검색 - 유형 (지역문화정보) String content_type = searchVO.getContent_type(); content_type = StringEscapeUtils.unescapeHtml4(content_type); content_type = WNUtils.checkReqXSS(content_type, ""); content_type = content_type.replace(",","|"); if ( !content_type.equals("") && !content_type.equals("|")) { exquery_info += " "; } System.out.println("\n\n\n\n\n\n\n/*****************exquery********************"+exquery + exquery_info); //상세검색 - 발행년도(기간) String genyear_start = searchVO.getGenyear_start(); genyear_start = WNUtils.checkReqXSS(genyear_start, ""); if( !genyear_start.equals("")) { strOperation += " "; } String genyear_end = searchVO.getGenyear_end(); genyear_end = WNUtils.checkReqXSS(genyear_end, ""); if( !genyear_end.equals("")) { strOperation += ""; } //상세검색 - 연대(기간) String chronological_start = searchVO.getChronological_start(); chronological_start = WNUtils.checkReqXSS(chronological_start, ""); if( !chronological_start.equals("")) { strOperation += " "; } String chronological_end = searchVO.getChronological_end(); chronological_end = WNUtils.checkReqXSS(chronological_end, ""); if( !chronological_end.equals("")) { strOperation += ""; } /** 상세검색 컬렉션 체크박스*/ //String chkColls = searchVO.getChkColls(); //chkColls = WNUtils.checkReqXSS(chkColls, ""); //쿼리 설정 if (rt.equals("1")) { realQuery = tmpQuery + " (" + reQuery+")"; //realQuery } else if (!rt.equals("1") || "".equals(realQuery)) { realQuery = tmpQuery; } //System.out.println("\n\n\n\n\n\n\n/*****************tmpQuery********************/"+tmpQuery); String collection_real =""; String[] collections_real = null; // 컬렉션 설정 /*if(collection.indexOf("_Coll") >= 0){ collection_real = collection.replace("_Coll", ""); if(collection.indexOf("culturePost") >= 0){ collections = new String[]{"info","map","number","pick","reference","story","culturePost","culturePostHot"}; collections_real = new String[]{"culturePost","culturePostHot"}; collection_real = "culturePost"; }else{ collections = new String[]{"info","map","number","pick","reference","story","culturePost"}; collections_real = new String[]{collection_real}; } } */ if(collection.equals("ALL") || collection.equals("")){ collections = new String[]{"info","map","number","pick","reference","story","culturePost","total"};//COLLECTIONS; collections_real = new String[]{"info","map","number","pick","reference","story","culturePost","total"}; collection_real = collection; } else if(collection.indexOf("_Coll") >= 0){ collection_real = collection.replace("_Coll", ""); if(collection.indexOf("culturePost") >= 0){ collections = new String[]{"info","map","number","pick","reference","story","culturePost","culturePostHot"}; collections_real = new String[]{"culturePost","culturePostHot"}; collection_real = "culturePost"; }else{ collections = new String[]{"info","map","number","pick","reference","story","culturePost"}; collections_real = new String[]{collection_real}; } } System.out.println("\n\n\n\n#################################[collection_real]: "+collection_real); WNSearch wnsearch = new WNSearch(isDebug, false, collections, searchFields); wnsearch.setSf1Vo(sf1Vo); for (int i = 0; i < collections.length; i++) { // PAGE_INFO 페이지 int tmpViewCnt =viewCount; if(collections[i].equals("info")){ if(tmpViewCnt == 4){ tmpViewCnt = 6; wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+tmpViewCnt); }else{ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * viewCount) +","+viewCount); } } else if(collections[i].equals("total")){ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * tmpViewCnt) +","+8); } else{ wnsearch.setCollectionInfoValue(collections[i], PAGE_INFO, ((startCount - 1 ) * viewCount) +","+viewCount); } // DATE_RANGE 날짜 if("".equals(query) && "".equals(realQuery)){ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, "1970/01/01,2030/01/01,-"); }else{ wnsearch.setCollectionInfoValue(collections[i], DATE_RANGE, startDate.replaceAll("\\.","/") + "," + endDate.replaceAll("\\.","/") +",/"); } // SORT_FIELD 정렬 필드 if(collections[i].equals("total")){ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, "READ_CNT/DESC,DATE/DESC,RANK/DESC" ); }else{ wnsearch.setCollectionInfoValue(collections[i], SORT_FIELD, sortField ); } //exquery 설정 if ( !collections[i].equals("map")){ if( !collections[i].equals("info") && !exquery.equals("") ){ wnsearch.setCollectionInfoValue(collections[i], EXQUERY_FIELD, exquery ); }else if( collections[i].equals("info") && (!exquery.equals("") || !exquery_info.equals(""))){ wnsearch.setCollectionInfoValue(collections[i], EXQUERY_FIELD, exquery + exquery_info ); } } //SearchField 값이 있으면 설정, 없으면 기본검색필드 if ( !(searchVO.getSearchField()).equals("") && (searchVO.getSearchField()).indexOf("ALL") == -1 ) wnsearch.setCollectionInfoValue(collections[i], SEARCH_FIELD, (searchVO.getSearchField()) ); //operation 설정 if ( !strOperation.equals("") ) { wnsearch.setCollectionInfoValue(collections[i], FILTER_OPERATION, strOperation); } if(!"ALL".equals(collection)){ if("culturePost".equals(collections[i]) && "culturePost".equals(collection_real)) { wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC,KEYWORDS:1/SC"); // }else if ( "number".equals(collections[i]) && "number".equals(collection_real)){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN,SEARCH_THEME_CD:1/SN,SEARCH_THEME_CD:2/SN,SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN"); }else if ( "story".equals(collections[i]) && "story".equals(collection_real)){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_THEME_CD:1/SN,SEARCH_THEME_CD:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); //TAGS:1/SN,TAGS:1/SN }else if ( "reference".equals(collections[i])&& "reference".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN,SEARCH_CATEGORY:1/SN,SEARCH_CATEGORY:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); }else if ( "info".equals(collections[i])&& "info".equals(collection_real) ){ wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "CONTENT_TYPE_NAME:1/SN,SEARCH_AREA_COUNCIL_INFO:1/SN"); }else if ( "pick".equals(collections[i]) && "pick".equals(collection_real) ){ System.out.println(collections[i]+"########################pick:" + ( "pick".equals(collections[i]) && "pick".equals(collection_real) )); wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "SEARCH_CLASS:1/SN,SEARCH_CLASS:2/SN,SEARCH_AREA_COUNCIL:1/SN,SEARCH_AREA_COUNCIL:2/SN"); //TAGS:1/SN,TAGS:1/SN }else if("toon".equals(collections[i]) && "toon".equals(collection_real)) { wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC"); // } }else if("ALL".equals(collection)){ if("total".equals(collections[i])) { wnsearch.setCollectionInfoValue(collections[i], CATEGORY_GROUPBY, "TAGS:1/SC"); } } } wnsearch.search(realQuery, isRealTimeKeyword, CONNECTION_CLOSE, useSuggestedQuery, sf1Vo.getSearchIp(), sf1Vo.getSearchPort()); searchVO.setRealQuery(realQuery); // 결과 담기 SearchCollectionResult collResultList = new SearchCollectionResult(); // 디버그 메시지 출력 String debugMsg = wnsearch.printDebug() != null ? wnsearch.printDebug().trim() : ""; collResultList.setDebugStr(debugMsg); if(isDebug){ System.out.println("\n\n\n\n\n\n\n/*****************debugMsg********************/"+debugMsg); } // 결과 arrList ArrayList collList = new ArrayList(); for (int i = 0; i < collections.length; i++) { // 컬렉션 for SearchCollectionVO colVo = new SearchCollectionVO(); int totalCount = wnsearch.getResultTotalCount(collections[i]); int resultCount = wnsearch.getResultCount(collections[i]); //String collectionNameKr = wnsearch.getCollectionFieldValue(collections[i], WNCollection.COLLECTION_KOR); 안써 String collectionName = wnsearch.getCollectionInfoValue(collections[i], INDEX_NAME); String resultField = wnsearch.getCollectionInfoValue(collections[i], RESULT_FIELD); //DOCID,DATE String[] resultFieldArr = resultField.split(","); /** map 방식 1. */ ArrayList> resultList = new ArrayList>(); for(int j = 0 ; j < resultCount ; j++){ // 검색 결과 for Map resultMap = new HashMap(); for(int k = 0 ; k < resultFieldArr.length ; k ++){ // 반환필드 결과 for String[] documentFields = WNUtils.split(resultFieldArr[k], "/"); //resultMap.put(documentFields[0],wnsearch.getField(collections[i],documentFields[0] , j , false)); resultMap.put(documentFields[0],wnsearch.getField(collections[i],documentFields[0] , j , false).replace("", "").replace("", "") ); } resultList.add(j,resultMap); } colVo.setTotalCount(totalCount); //info total colVo.setResultCount(resultCount); colVo.setCollectionName(collectionName); //info colVo.setSearchResultList(resultList); collList.add(i,colVo); } // int cateListCnt = collections.length ; //int cateListCnt = collections_real.length ; int cateListCnt = collections.length ; //자료유형 카테고리 if (collections_real.length == 1 && (collection_real.equals("pick") || collection_real.equals("number") || collection_real.equals("reference") )) { String collection1 = collection_real; /** map 방식 1. */ int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CLASS", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CLASS", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CLASS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CLASS", 1, j); resultMap.put("first_class_nm", node); resultMap.put("first_class_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); //resultList.add(j_result, resultMap); } colVo.setCollectionName("first_class_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CLASS", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CLASS", 2, j); resultMap.put("second_class_nm", node); resultMap.put("second_class_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ //System.out.println("node:" + node + "/cnt:" + nodeCnt); resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_class_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화원 if (collections_real.length == 1 && (collection_real.equals("pick") || collection_real.equals("reference") || collection_real.equals("story"))) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 1, j); //System.out.println("node:" + node + "/cnt:" + nodeCnt); resultMap.put("first_council_nm", node); resultMap.put("first_council_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } //resultList.add(j, resultMap); } colVo.setCollectionName("first_council_cate"); // info colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_council_cate"); // info colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } if (collections_real.length == 1 && collection_real.equals("number")) { String collection1 = collection_real; int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL", 2); //first if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; Map first_resultMap = new HashMap(); for (int j = 0; j < second_class_cnt; j++) { String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2 , j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); //System.out.println("node:" + node + "/cnt:" + nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; } //first String[] first_node = node.split("\\^"); if(first_resultMap.containsKey(first_node[0])){ nodeCnt = first_resultMap.get(first_node[0]) + nodeCnt; } first_resultMap.put(first_node[0],nodeCnt); } for (String key : first_resultMap.keySet()) { // 검색 결과 Map resultMap = new HashMap(); resultMap.put("first_council_nm", key); resultMap.put("first_council_cnt", first_resultMap.get(key)); resultList.add(j_result, resultMap); j_result +=1; //resultList.add(j, resultMap); } colVo.setCollectionName("first_council_cate"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } //second if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL", 2, j); //second resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_council_cate"); // info colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역,유형 if (collections_real.length == 1 && collection_real.equals("info")) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_AREA_COUNCIL_INFO", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "CONTENT_TYPE_NAME", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_AREA_COUNCIL_INFO", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_AREA_COUNCIL_INFO", 1, j); resultMap.put("first_council_nm", node); resultMap.put("first_council_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; } //resultList.add(j, resultMap); } colVo.setCollectionName("first_council_cate"); // info //colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int nodeCnt_total = 0; int j_result = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"CONTENT_TYPE_NAME", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "CONTENT_TYPE_NAME", 1, j); resultMap.put("second_council_nm", node); resultMap.put("second_council_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_council_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //주제분야 if (collections_real.length == 1 && collection_real.equals("reference") ) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CATEGORY", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_CATEGORY", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CATEGORY", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CATEGORY", 1, j); resultMap.put("first_category_nm", node); resultMap.put("first_category_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ System.out.println("node:" + node + "/cnt:" + nodeCnt); resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("first_category_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_CATEGORY", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_CATEGORY", 2, j); resultMap.put("second_category_nm", node); resultMap.put("second_category_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_category_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //테마 if (collections_real.length == 1 && ( collection_real.equals("number") || collection_real.equals("story") )) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_THEME_CD", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "SEARCH_THEME_CD", 2); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_THEME_CD", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_THEME_CD", 1, j); resultMap.put("first_theme_cd", node); resultMap.put("first_theme_cnt", nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("first_theme_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int j_result = 0; int nodeCnt_total = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"SEARCH_THEME_CD", 2, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "SEARCH_THEME_CD", 2, j); resultMap.put("second_theme_cd", node); resultMap.put("second_theme_cnt", nodeCnt); if (("null^null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else{ resultList.add(j_result, resultMap); j_result +=1; nodeCnt_total += nodeCnt; } //resultList.add(j, resultMap); } colVo.setCollectionName("second_theme_cate"); // info colVo.setTotalCount(nodeCnt_total); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화포스트 if (collections_real.length == 2 && "culturePost".equals(collection_real) ) { String collection1 = collection_real; /** map 방식 1. */ int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); int second_class_cnt= wnsearch.getCategoryCount(collection1, "KEYWORDS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); //int j_result = 0; int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); //System.out.println("node:" + node + "/cnt:" + nodeCnt); if (("null").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10 || ("^").equalsIgnoreCase(node)){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("culturePostHot_tags"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } if(second_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int cateCnt = 0; for (int j = 0; j < second_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"KEYWORDS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "KEYWORDS", 1, j); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10){ resultMap.put("keywords_nm", node); resultMap.put("keywords_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("culturePostHot_keywords"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt+=1; } } //지역문화툰 if (collections_real.length == 1 && "toon".equals(collection_real) ) { String collection1 = collection_real; int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); //int j_result = 0; int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); if (("null").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10 || ("^").equalsIgnoreCase(node)){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("toon_tags"); colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } } //통합검색 total 태그 if (collections_real.length != 1 && "ALL".equals(collection_real) ) { String collection1 = "total"; int first_class_cnt= wnsearch.getCategoryCount(collection1, "TAGS", 1); if(first_class_cnt > 0){ ArrayList> resultList = new ArrayList>(); SearchCollectionVO colVo = new SearchCollectionVO(); int cateCnt = 0; for (int j = 0; j < first_class_cnt; j++) { // 검색 결과 Map resultMap = new HashMap(); String node = wnsearch.getCategoryName(collection1,"TAGS", 1, j); int nodeCnt = wnsearch.getDocumentCountInCategory(collection1, "TAGS", 1, j); //System.out.println("node:" + node + "/cnt:" + nodeCnt); if (("null").equalsIgnoreCase(node) || ("^").equalsIgnoreCase(node)) { continue; }else if(cateCnt < 10){ resultMap.put("tags_nm", node); resultMap.put("tags_cnt", nodeCnt); resultList.add(cateCnt, resultMap); cateCnt ++; } } colVo.setCollectionName("total_tags"); // info colVo.setSearchResultList(resultList); collList.add(cateListCnt, colVo); cateListCnt +=1; } } collResultList.setCollectionList(collList); // 연결 종료 if ( wnsearch != null ) { wnsearch.closeServer(); } return collResultList; }catch(Exception e){ e.printStackTrace(); } return null; } }