private void createTaskTranslation( Long taskID, String tweetID, String tweet, String author, String lat, String lon, String url, Long taskQueueID, String created, ClientAppAnswer clientAppAnswer) { if (translationService.findByTaskId(taskID) != null) { return; } System.out.println("createTaskTranslation is called : " + taskQueueID); TaskTranslation translation = new TaskTranslation( taskID, clientAppAnswer.getClientAppID().toString(), tweetID, author, lat, lon, url, taskQueueID, tweet, TaskTranslation.STATUS_NEW); translationService.createTranslation(translation); }
private String[] getQuestion(ClientAppAnswer clientAppAnswer, JSONParser parser) throws ParseException { String answerKey = clientAppAnswer.getActiveAnswerKey(); if (answerKey == null) { answerKey = clientAppAnswer.getAnswer(); } JSONArray questionArrary = (JSONArray) parser.parse(answerKey); int questionSize = questionArrary.size(); String[] questions = new String[questionSize]; for (int i = 0; i < questionSize; i++) { JSONObject obj = (JSONObject) questionArrary.get(i); questions[i] = (String) obj.get("qa"); } return questions; }
public int getCutOffNumber( int responseSize, int maxResponseSize, ClientAppAnswer clientAppAnswer) { int cutOffSize = clientAppAnswer.getVoteCutOff(); if (responseSize > maxResponseSize) { cutOffSize = (int) Math.round(maxResponseSize * 0.5); } return cutOffSize; }
private boolean handleItemAboveCutOff( Long taskQueueID, int responseCount, String answer, JSONObject info, ClientAppAnswer clientAppAnswer, ReportTemplateService reportTemplateService, int cutOffSize) { // MAKE SURE TO MODIFY TEMPLATE HTML Standize OUTPUT FORMAT boolean processed = false; try { String tweetID; String tweet; String author = ""; String lat = ""; String lng = ""; String url = ""; String created = ""; Long taskID = taskQueueID; if (responseCount >= cutOffSize) { Long tid = (Long) info.get("tweetid"); tweetID = tid + ""; if (info.get("tweet") == null) { tweet = (String) info.get("text"); author = ""; lat = ""; lng = ""; url = ""; created = ""; } else { tweet = (String) info.get("tweet"); if (info.get("author") != null) { author = (String) info.get("author"); } if (info.get("lat") != null) { lat = (String) info.get("lat"); } if (info.get("lon") != null) { lng = (String) info.get("lon"); } if (info.get("url") != null) { url = (String) info.get("url"); } created = (String) info.get("timestamp"); taskID = (Long) info.get("taskid"); } if (taskQueueID != null && taskID != null && tweetID != null && (tweet != null && !tweet.isEmpty())) { ReportTemplate template = new ReportTemplate( taskQueueID, taskID, tweetID, tweet, author, lat, lng, url, created, answer, StatusCodeType.TEMPLATE_IS_READY_FOR_EXPORT, clientAppAnswer.getClientAppID()); reportTemplateService.saveReportItem(template); processed = true; } } } catch (Exception e) { System.out.println("handleItemAboveCutOff exception"); System.out.println("exception e :" + e.toString()); } return processed; }