@RequiresPermissions({"categoryWord-get"}) @RequestMapping( method = RequestMethod.GET, value = "/getAll", headers = "Accept=application/json") public @ResponseBody Map<String, Object> getAll(HttpServletRequest req) { int pageNo = Integer.parseInt(req.getParameter("page")); int rowCount = Integer.parseInt(req.getParameter("rows")); String englishWord = req.getParameter("englishWord"); String chineseWord = req.getParameter("chineseWord"); String esglisgAb = req.getParameter("esglisgAb"); String remark = req.getParameter("remark"); List<SearchCondition> searchConds = new ArrayList<SearchCondition>(); StringBuffer hql = new StringBuffer("select c from CategoryWord c where 1=1 "); if (null != englishWord && !"".equals(englishWord)) { hql.append(" and englishWord like ?"); searchConds.add(new SearchCondition("englishWord", "%" + englishWord + "%")); } if (null != chineseWord && !"".equals(chineseWord)) { hql.append(" and chineseWord like ?"); try { chineseWord = URLDecoder.decode(chineseWord, "utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } searchConds.add(new SearchCondition("chineseWord", "%" + chineseWord + "%")); } if (null != esglisgAb && !"".equals(esglisgAb)) { hql.append(" and esglisgAb like ?"); searchConds.add(new SearchCondition("esglisgAb", "%" + esglisgAb + "%")); } if (null != remark && !"".equals(remark)) { hql.append(" and remark like ?"); try { remark = URLDecoder.decode(remark, "utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } searchConds.add(new SearchCondition("remark", "%" + remark + "%")); } hql.append(" order by esglisgAb"); // Page page = categoryWordService.getAll(rowCount); Page page = new Page(); if (searchConds.size() <= 0) { page = categoryWordService.getPageBy(hql.toString(), rowCount); } else { page = categoryWordService.getPageBy(hql.toString(), rowCount, searchConds); } page.setPage(pageNo); List<CategoryWord> list = categoryWordService.findBy(hql.toString(), page, searchConds); HashMap<String, Object> map = new HashMap<String, Object>(); map.put("total", page.getResultCount()); map.put("rows", list); return map; }
/** @return poolConfigurationId => poolStatus map with a single entry. */ @RequestMapping(value = "/admin/pools/{poolId}/status", method = RequestMethod.GET) @ResponseBody public Map<Long, PoolStatus> getPoolStatus(@PathVariable("poolId") Long poolConfigurationId) { PoolConfigurationModel poolConfiguration = poolDao.readPoolById(poolConfigurationId); HashMap<Long, PoolStatus> resultMap = new HashMap<Long, PoolStatus>(); resultMap.put(poolConfigurationId, _getPoolStatus(poolConfiguration)); return resultMap; }
/** * 선택한 시작 날짜 및 종료 날짜에 해당하는 Audit Log를 조회한다. * * @param clusterName Hadoop Cluster명 * @param searchType 조회 유형 * @param startDate 시작 날짜 (yyyy-MM-dd HH) * @param endDate 종료 날짜 (yyyy-MM-dd HH) * @return trend 목록 */ @RequestMapping(value = "trend", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody public Response trend( @RequestParam(defaultValue = "") String clusterName, @RequestParam(defaultValue = "ACT") String searchType, @RequestParam(defaultValue = "") String startDate, @RequestParam(defaultValue = "") String endDate) { EngineService engineService = this.getEngineService(clusterName); FileSystemAuditRemoteService service = engineService.getFileSystemAuditRemoteService(); int level = getSessionUserLevel(); String username = level == 1 ? "" : getSessionUsername(); SimpleDateFormat hoursFormat = new SimpleDateFormat("yyyy-MM-dd HH"); SimpleDateFormat daysFormat = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); List<Trend> trendList; Date startTime; Date endTime; try { if ("".equals(startDate) && "".equals(endDate)) { calendar.setTime(new Date()); calendar.add(Calendar.HOUR, -12); trendList = trends(hoursFormat, calendar, Calendar.HOUR, 12); } else if ("".equals(startDate) && !"".equals(endDate)) { calendar.setTime(daysFormat.parse(endDate)); calendar.add(Calendar.HOUR, -1); trendList = trends(hoursFormat, calendar, Calendar.HOUR, 24); } else { startTime = daysFormat.parse(startDate); calendar.setTime(new Date()); endTime = (endDate.equals("")) ? daysFormat.parse(daysFormat.format(calendar.getTime())) : daysFormat.parse(endDate); long difference = (endTime.getTime() - startTime.getTime()) / (1000 * 60 * 60 * 24); calendar.setTime(startTime); calendar.add(Calendar.DATE, -1); trendList = trends(daysFormat, calendar, Calendar.DATE, (int) difference + 1); calendar.add(Calendar.DATE, 1); } } catch (ParseException e) { throw new ServiceException("Unable to parse the date.", e); } List<Trends> trendsList = service.auditTrend(startDate, endDate, searchType, username); HashMap<String, String> trendTitle = new HashMap<>(); for (Trends trends : trendsList) { String trendsSearchType = trends.getSearchType(); if (!trendTitle.containsKey(trendsSearchType)) { trendTitle.put(trendsSearchType, "data" + (trendTitle.size() + 1)); } /** 날짜가 같은 필드에 데이터 삽입 */ for (Trend trend : trendList) { if (trend.getTime().equals(trends.getTime())) { Integer position = Integer.parseInt(trendTitle.get(trendsSearchType).replaceAll("[^\\d]", "")); trend.setData(position, trend.getData(position) + trends.getCount()); } } } Response response = new Response(); response.getMap().putAll(trendTitle); response.getList().addAll(trendList); response.setTotal(trendList.size()); response.setSuccess(true); return response; }