@Test public void tokensToJSONString() throws Exception { TaskMonitorController taskMonitorController = new TaskMonitorController(); taskMonitorController.getPhraseTextJSON(); }
public String getPhraseTextJSON(){ List<Phrase> phraseList = phraseService.findAll(); JSONObject phraseJSON = new JSONObject(); JSONObject phraseChartJSON = new JSONObject(); JSONArray phraseDataJSONArray = new JSONArray(); phraseChartJSON.put("caption", "Phrase Statistics"); phraseChartJSON.put("theme", "ocean"); phraseJSON.put("chart", phraseChartJSON); HashMap<String, Integer> phraseCount = (HashMap<String, Integer>) getPhraseTextCount(phraseList); Set<String> keySet = phraseCount.keySet(); Iterator<String> keyIterator = keySet.iterator(); while(keyIterator.hasNext()){ JSONObject dataJSON = new JSONObject(); String key = keyIterator.next(); dataJSON.put("label" , key); dataJSON.put("value", phraseCount.get(key)); phraseDataJSONArray.put(dataJSON); } phraseJSON.put("data", phraseDataJSONArray); System.out.println(phraseList.size()); return phraseJSON.toString(); }
TaskMonitorController { public String getPhraseTextJSON(){ List<Phrase> phraseList = phraseService.findAll(); JSONObject phraseJSON = new JSONObject(); JSONObject phraseChartJSON = new JSONObject(); JSONArray phraseDataJSONArray = new JSONArray(); phraseChartJSON.put("caption", "Phrase Statistics"); phraseChartJSON.put("theme", "ocean"); phraseJSON.put("chart", phraseChartJSON); HashMap<String, Integer> phraseCount = (HashMap<String, Integer>) getPhraseTextCount(phraseList); Set<String> keySet = phraseCount.keySet(); Iterator<String> keyIterator = keySet.iterator(); while(keyIterator.hasNext()){ JSONObject dataJSON = new JSONObject(); String key = keyIterator.next(); dataJSON.put("label" , key); dataJSON.put("value", phraseCount.get(key)); phraseDataJSONArray.put(dataJSON); } phraseJSON.put("data", phraseDataJSONArray); System.out.println(phraseList.size()); return phraseJSON.toString(); } }
TaskMonitorController { public String getPhraseTextJSON(){ List<Phrase> phraseList = phraseService.findAll(); JSONObject phraseJSON = new JSONObject(); JSONObject phraseChartJSON = new JSONObject(); JSONArray phraseDataJSONArray = new JSONArray(); phraseChartJSON.put("caption", "Phrase Statistics"); phraseChartJSON.put("theme", "ocean"); phraseJSON.put("chart", phraseChartJSON); HashMap<String, Integer> phraseCount = (HashMap<String, Integer>) getPhraseTextCount(phraseList); Set<String> keySet = phraseCount.keySet(); Iterator<String> keyIterator = keySet.iterator(); while(keyIterator.hasNext()){ JSONObject dataJSON = new JSONObject(); String key = keyIterator.next(); dataJSON.put("label" , key); dataJSON.put("value", phraseCount.get(key)); phraseDataJSONArray.put(dataJSON); } phraseJSON.put("data", phraseDataJSONArray); System.out.println(phraseList.size()); return phraseJSON.toString(); }  }
TaskMonitorController { public String getPhraseTextJSON(){ List<Phrase> phraseList = phraseService.findAll(); JSONObject phraseJSON = new JSONObject(); JSONObject phraseChartJSON = new JSONObject(); JSONArray phraseDataJSONArray = new JSONArray(); phraseChartJSON.put("caption", "Phrase Statistics"); phraseChartJSON.put("theme", "ocean"); phraseJSON.put("chart", phraseChartJSON); HashMap<String, Integer> phraseCount = (HashMap<String, Integer>) getPhraseTextCount(phraseList); Set<String> keySet = phraseCount.keySet(); Iterator<String> keyIterator = keySet.iterator(); while(keyIterator.hasNext()){ JSONObject dataJSON = new JSONObject(); String key = keyIterator.next(); dataJSON.put("label" , key); dataJSON.put("value", phraseCount.get(key)); phraseDataJSONArray.put(dataJSON); } phraseJSON.put("data", phraseDataJSONArray); System.out.println(phraseList.size()); return phraseJSON.toString(); }  @GetMapping("/tasks") String showTaskMonitor(Map<String, Object> model); List<Phrase> removeDuplicate(List<Phrase> input); String getPhrasePosJSON(); String getPhraseTextJSON(); Map<String, Integer> getPhrasePosCount(List<Phrase> phraseList); Map<String, Integer> getPhraseTextCount(List<Phrase> phraseList); }
TaskMonitorController { public String getPhraseTextJSON(){ List<Phrase> phraseList = phraseService.findAll(); JSONObject phraseJSON = new JSONObject(); JSONObject phraseChartJSON = new JSONObject(); JSONArray phraseDataJSONArray = new JSONArray(); phraseChartJSON.put("caption", "Phrase Statistics"); phraseChartJSON.put("theme", "ocean"); phraseJSON.put("chart", phraseChartJSON); HashMap<String, Integer> phraseCount = (HashMap<String, Integer>) getPhraseTextCount(phraseList); Set<String> keySet = phraseCount.keySet(); Iterator<String> keyIterator = keySet.iterator(); while(keyIterator.hasNext()){ JSONObject dataJSON = new JSONObject(); String key = keyIterator.next(); dataJSON.put("label" , key); dataJSON.put("value", phraseCount.get(key)); phraseDataJSONArray.put(dataJSON); } phraseJSON.put("data", phraseDataJSONArray); System.out.println(phraseList.size()); return phraseJSON.toString(); }  @GetMapping("/tasks") String showTaskMonitor(Map<String, Object> model); List<Phrase> removeDuplicate(List<Phrase> input); String getPhrasePosJSON(); String getPhraseTextJSON(); Map<String, Integer> getPhrasePosCount(List<Phrase> phraseList); Map<String, Integer> getPhraseTextCount(List<Phrase> phraseList);  }