@Test public void getLatestBufferedAIDRDataTest() { String callbackName = null; int count = 1; float confidence = (float) 0.7; boolean balanced_sampling = true; Response response = getBufferedAIDRData.getLatestBufferedAIDRData(callbackName, count, confidence, balanced_sampling); String statusString = (String)response.getEntity(); assertNotNull(statusString); }
@GET @Path("/channels/latest") @Produces("application/json") public Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName, @DefaultValue("1") @QueryParam("count") Integer count, @DefaultValue("0.7") @QueryParam("confidence") Float confidence, @DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling) { if (null != cbManager.jedisConn && cbManager.jedisConn.isPoolSetup()) { final int messageCount = count; List<String> bufferedMessages = cbManager.getLatestFromAllChannels(messageCount); List<String> filteredMessages = null; if (bufferedMessages != null) { Map<Long, String> sortedFilteredMessages = new TreeMap<Long, String>(); for (String tweet: bufferedMessages) { ClassifiedFilteredTweet classifiedTweet = new ClassifiedFilteredTweet().deserialize(tweet); if (classifiedTweet != null && classifiedTweet.getMaxConfidence() >= confidence && classifiedTweet.getCreatedAt() != null) { sortedFilteredMessages.put(classifiedTweet.getCreatedAt().getTime(), tweet); channelSelector.initializeNew(classifiedTweet.getCrisisCode()); } } filteredMessages = new ArrayList<String>(sortedFilteredMessages.values()); } final JsonDataFormatter taggerOutput = new JsonDataFormatter(callbackName); StringBuilder jsonDataList = null; if (!balanced_sampling) { jsonDataList = taggerOutput.createList(filteredMessages, messageCount, rejectNullFlag); } else { jsonDataList = taggerOutput.createRateLimitedList(filteredMessages, channelSelector, messageCount, rejectNullFlag); } int sendCount = taggerOutput.getMessageCount(); if (0 == sendCount) { if (lastSentLatestTweet != null && lastSentLatestTweet.length() > 0) { jsonDataList.replace(0, jsonDataList.length(), lastSentLatestTweet.toString()); sendCount = 1; } } else { lastSentLatestTweet = new StringBuffer(jsonDataList.length()); lastSentLatestTweet.append(jsonDataList); } return Response.ok(jsonDataList.toString()).build(); } logger.error("Error in jedis connection. Bailing out..."); return returnEmptyJson(callbackName); }
GetBufferedAIDRData implements ServletContextListener { @GET @Path("/channels/latest") @Produces("application/json") public Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName, @DefaultValue("1") @QueryParam("count") Integer count, @DefaultValue("0.7") @QueryParam("confidence") Float confidence, @DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling) { if (null != cbManager.jedisConn && cbManager.jedisConn.isPoolSetup()) { final int messageCount = count; List<String> bufferedMessages = cbManager.getLatestFromAllChannels(messageCount); List<String> filteredMessages = null; if (bufferedMessages != null) { Map<Long, String> sortedFilteredMessages = new TreeMap<Long, String>(); for (String tweet: bufferedMessages) { ClassifiedFilteredTweet classifiedTweet = new ClassifiedFilteredTweet().deserialize(tweet); if (classifiedTweet != null && classifiedTweet.getMaxConfidence() >= confidence && classifiedTweet.getCreatedAt() != null) { sortedFilteredMessages.put(classifiedTweet.getCreatedAt().getTime(), tweet); channelSelector.initializeNew(classifiedTweet.getCrisisCode()); } } filteredMessages = new ArrayList<String>(sortedFilteredMessages.values()); } final JsonDataFormatter taggerOutput = new JsonDataFormatter(callbackName); StringBuilder jsonDataList = null; if (!balanced_sampling) { jsonDataList = taggerOutput.createList(filteredMessages, messageCount, rejectNullFlag); } else { jsonDataList = taggerOutput.createRateLimitedList(filteredMessages, channelSelector, messageCount, rejectNullFlag); } int sendCount = taggerOutput.getMessageCount(); if (0 == sendCount) { if (lastSentLatestTweet != null && lastSentLatestTweet.length() > 0) { jsonDataList.replace(0, jsonDataList.length(), lastSentLatestTweet.toString()); sendCount = 1; } } else { lastSentLatestTweet = new StringBuffer(jsonDataList.length()); lastSentLatestTweet.append(jsonDataList); } return Response.ok(jsonDataList.toString()).build(); } logger.error("Error in jedis connection. Bailing out..."); return returnEmptyJson(callbackName); } }
GetBufferedAIDRData implements ServletContextListener { @GET @Path("/channels/latest") @Produces("application/json") public Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName, @DefaultValue("1") @QueryParam("count") Integer count, @DefaultValue("0.7") @QueryParam("confidence") Float confidence, @DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling) { if (null != cbManager.jedisConn && cbManager.jedisConn.isPoolSetup()) { final int messageCount = count; List<String> bufferedMessages = cbManager.getLatestFromAllChannels(messageCount); List<String> filteredMessages = null; if (bufferedMessages != null) { Map<Long, String> sortedFilteredMessages = new TreeMap<Long, String>(); for (String tweet: bufferedMessages) { ClassifiedFilteredTweet classifiedTweet = new ClassifiedFilteredTweet().deserialize(tweet); if (classifiedTweet != null && classifiedTweet.getMaxConfidence() >= confidence && classifiedTweet.getCreatedAt() != null) { sortedFilteredMessages.put(classifiedTweet.getCreatedAt().getTime(), tweet); channelSelector.initializeNew(classifiedTweet.getCrisisCode()); } } filteredMessages = new ArrayList<String>(sortedFilteredMessages.values()); } final JsonDataFormatter taggerOutput = new JsonDataFormatter(callbackName); StringBuilder jsonDataList = null; if (!balanced_sampling) { jsonDataList = taggerOutput.createList(filteredMessages, messageCount, rejectNullFlag); } else { jsonDataList = taggerOutput.createRateLimitedList(filteredMessages, channelSelector, messageCount, rejectNullFlag); } int sendCount = taggerOutput.getMessageCount(); if (0 == sendCount) { if (lastSentLatestTweet != null && lastSentLatestTweet.length() > 0) { jsonDataList.replace(0, jsonDataList.length(), lastSentLatestTweet.toString()); sendCount = 1; } } else { lastSentLatestTweet = new StringBuffer(jsonDataList.length()); lastSentLatestTweet.append(jsonDataList); } return Response.ok(jsonDataList.toString()).build(); } logger.error("Error in jedis connection. Bailing out..."); return returnEmptyJson(callbackName); }  }
GetBufferedAIDRData implements ServletContextListener { @GET @Path("/channels/latest") @Produces("application/json") public Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName, @DefaultValue("1") @QueryParam("count") Integer count, @DefaultValue("0.7") @QueryParam("confidence") Float confidence, @DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling) { if (null != cbManager.jedisConn && cbManager.jedisConn.isPoolSetup()) { final int messageCount = count; List<String> bufferedMessages = cbManager.getLatestFromAllChannels(messageCount); List<String> filteredMessages = null; if (bufferedMessages != null) { Map<Long, String> sortedFilteredMessages = new TreeMap<Long, String>(); for (String tweet: bufferedMessages) { ClassifiedFilteredTweet classifiedTweet = new ClassifiedFilteredTweet().deserialize(tweet); if (classifiedTweet != null && classifiedTweet.getMaxConfidence() >= confidence && classifiedTweet.getCreatedAt() != null) { sortedFilteredMessages.put(classifiedTweet.getCreatedAt().getTime(), tweet); channelSelector.initializeNew(classifiedTweet.getCrisisCode()); } } filteredMessages = new ArrayList<String>(sortedFilteredMessages.values()); } final JsonDataFormatter taggerOutput = new JsonDataFormatter(callbackName); StringBuilder jsonDataList = null; if (!balanced_sampling) { jsonDataList = taggerOutput.createList(filteredMessages, messageCount, rejectNullFlag); } else { jsonDataList = taggerOutput.createRateLimitedList(filteredMessages, channelSelector, messageCount, rejectNullFlag); } int sendCount = taggerOutput.getMessageCount(); if (0 == sendCount) { if (lastSentLatestTweet != null && lastSentLatestTweet.length() > 0) { jsonDataList.replace(0, jsonDataList.length(), lastSentLatestTweet.toString()); sendCount = 1; } } else { lastSentLatestTweet = new StringBuffer(jsonDataList.length()); lastSentLatestTweet.append(jsonDataList); } return Response.ok(jsonDataList.toString()).build(); } logger.error("Error in jedis connection. Bailing out..."); return returnEmptyJson(callbackName); }  @GET @Path("/channels/list") @Produces("text/html") Response getActiveChannelsList(); @GET @Path("/channels/latest") @Produces("application/json") Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName,
			@DefaultValue("1") @QueryParam("count") Integer count,
			@DefaultValue("0.7") @QueryParam("confidence") Float confidence,
			@DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling); @GET @Path("/channel/{crisisCode}") @Produces({"application/json"}) Response getBufferedAIDRData(@PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); @OPTIONS @Produces(MediaType.APPLICATION_JSON) @Path("/channel/filter/{crisisCode}") Response getBufferedAIDRDataPostFilter(@PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/channel/filter/{crisisCode}") Response getBufferedAIDRDataPostFilter(String queryString, @PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); Response returnEmptyJson(final String callbackName); boolean isChannelPresent(String channel); @GET @Path("/channel/error/{crisisCode}") @Produces({"text/html"}) Response onErrorResponse(); @GET @Path("/manage/restart/{passcode}") @Produces("application/json") Response restartFetchService(@PathParam("passcode") String passcode); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("/channel/test/{crisisCode}") Response testPost(String testString, @PathParam("crisisCode") String channelCode); @GET @Path("/channel/test/jsonmap") Response testJsonMap(); @GET @Path("/channel/test/channelpublic") Response testChannelPublicFlag(@QueryParam("channelCode") String channelCode); @Override void contextDestroyed(ServletContextEvent sce); @Override void contextInitialized(ServletContextEvent sce); }
GetBufferedAIDRData implements ServletContextListener { @GET @Path("/channels/latest") @Produces("application/json") public Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName, @DefaultValue("1") @QueryParam("count") Integer count, @DefaultValue("0.7") @QueryParam("confidence") Float confidence, @DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling) { if (null != cbManager.jedisConn && cbManager.jedisConn.isPoolSetup()) { final int messageCount = count; List<String> bufferedMessages = cbManager.getLatestFromAllChannels(messageCount); List<String> filteredMessages = null; if (bufferedMessages != null) { Map<Long, String> sortedFilteredMessages = new TreeMap<Long, String>(); for (String tweet: bufferedMessages) { ClassifiedFilteredTweet classifiedTweet = new ClassifiedFilteredTweet().deserialize(tweet); if (classifiedTweet != null && classifiedTweet.getMaxConfidence() >= confidence && classifiedTweet.getCreatedAt() != null) { sortedFilteredMessages.put(classifiedTweet.getCreatedAt().getTime(), tweet); channelSelector.initializeNew(classifiedTweet.getCrisisCode()); } } filteredMessages = new ArrayList<String>(sortedFilteredMessages.values()); } final JsonDataFormatter taggerOutput = new JsonDataFormatter(callbackName); StringBuilder jsonDataList = null; if (!balanced_sampling) { jsonDataList = taggerOutput.createList(filteredMessages, messageCount, rejectNullFlag); } else { jsonDataList = taggerOutput.createRateLimitedList(filteredMessages, channelSelector, messageCount, rejectNullFlag); } int sendCount = taggerOutput.getMessageCount(); if (0 == sendCount) { if (lastSentLatestTweet != null && lastSentLatestTweet.length() > 0) { jsonDataList.replace(0, jsonDataList.length(), lastSentLatestTweet.toString()); sendCount = 1; } } else { lastSentLatestTweet = new StringBuffer(jsonDataList.length()); lastSentLatestTweet.append(jsonDataList); } return Response.ok(jsonDataList.toString()).build(); } logger.error("Error in jedis connection. Bailing out..."); return returnEmptyJson(callbackName); }  @GET @Path("/channels/list") @Produces("text/html") Response getActiveChannelsList(); @GET @Path("/channels/latest") @Produces("application/json") Response getLatestBufferedAIDRData(@QueryParam("callback") String callbackName,
			@DefaultValue("1") @QueryParam("count") Integer count,
			@DefaultValue("0.7") @QueryParam("confidence") Float confidence,
			@DefaultValue("true") @QueryParam("balanced_sampling") Boolean balanced_sampling); @GET @Path("/channel/{crisisCode}") @Produces({"application/json"}) Response getBufferedAIDRData(@PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); @OPTIONS @Produces(MediaType.APPLICATION_JSON) @Path("/channel/filter/{crisisCode}") Response getBufferedAIDRDataPostFilter(@PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/channel/filter/{crisisCode}") Response getBufferedAIDRDataPostFilter(String queryString, @PathParam("crisisCode") String channelCode,
			@QueryParam("callback") String callbackName,
			@DefaultValue("1000") @QueryParam("count") int count); Response returnEmptyJson(final String callbackName); boolean isChannelPresent(String channel); @GET @Path("/channel/error/{crisisCode}") @Produces({"text/html"}) Response onErrorResponse(); @GET @Path("/manage/restart/{passcode}") @Produces("application/json") Response restartFetchService(@PathParam("passcode") String passcode); @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.APPLICATION_JSON) @Path("/channel/test/{crisisCode}") Response testPost(String testString, @PathParam("crisisCode") String channelCode); @GET @Path("/channel/test/jsonmap") Response testJsonMap(); @GET @Path("/channel/test/channelpublic") Response testChannelPublicFlag(@QueryParam("channelCode") String channelCode); @Override void contextDestroyed(ServletContextEvent sce); @Override void contextInitialized(ServletContextEvent sce);  }