List of usage examples for com.mongodb Block Block
Block
From source file:br.com.locadora.DAO.mongoDB.ClienteDAOMongo.java
public List<Cliente> buscarClientes(Cliente clienteFiltro) throws Exception { MongoConnection connection = MongoConnection.getInstance(); Document filter = new Document(); if (clienteFiltro.getNome() != null && !clienteFiltro.getNome().trim().equals("")) { filter = new Document("nome", "/" + clienteFiltro.getNome() + "/"); }// w ww.j av a2 s . c o m FindIterable<Document> find = connection.getDB().getCollection("cliente").find(filter); final List<Cliente> clientes = new ArrayList<Cliente>(); find.forEach(new Block<Document>() { @Override public void apply(final Document dCliente) { String nome = dCliente.getString("nome"); String cpf = dCliente.getString("cpf"); int idade = dCliente.getInteger("idade"); Long id = new Long(dCliente.getLong("_id")); Cliente cliente = new Cliente(id, nome, cpf, idade); clientes.add(cliente); } }); return clientes; }
From source file:cl.diinf.sdmongo.Principal.java
public static void main(String[] args) { MongoClient mongoClient = new MongoClient(); MongoDatabase db = mongoClient.getDatabase("test"); FindIterable<Document> iterable = db.getCollection("restaurants").find(); iterable.forEach(new Block<Document>() { @Override// w w w .j a v a 2 s . co m public void apply(final Document document) { System.out.println(document); } }); System.out.println("Hola mundo"); }
From source file:com.AlertMailerWebPage.servlet.GetDaily.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w. j ava 2s .c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_requirementLog"); String collection = (String) defaultProps.get("collection_requirementLog"); String serverAddress = (String) defaultProps.get("IP_mbstats"); String initial = request.getParameter("initial"); //if(initial.equals("yes")) //{ prsMap = getMapper(); psmMap = getMapper(); rentalMap = getMapper(); final JSONArray counts1 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts3 = new JSONArray(); JSONObject counts = new JSONObject(); AggregateIterable<Document> countsPRS = getCounts(database, collection, serverAddress); countsPRS.forEach(new Block<Document>() { @Override public void apply(final Document document) { Document doc1 = (Document) document.get("_id"); int hour = (int) doc1.get("hour"); type = (String) doc1.get("type"); val = (int) document.get("count"); if (type.equalsIgnoreCase("PRS")) { prsMap.put(hour, val); } else if (type.equalsIgnoreCase("PSM")) { psmMap.put(hour, val); } else if (type.equalsIgnoreCase("RENTAL")) { rentalMap.put(hour, val); } } }); for (Map.Entry<Integer, Integer> map : prsMap.entrySet()) { counts1.put(map.getValue()); } for (Map.Entry<Integer, Integer> map : psmMap.entrySet()) { counts2.put(map.getValue()); } for (Map.Entry<Integer, Integer> map : rentalMap.entrySet()) { counts3.put(map.getValue()); } try { counts.put("countsPRS", counts1); counts.put("countsPSM", counts2); counts.put("countsRENTAL", counts3); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetDailyOpenMail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w . jav a2 s .c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { prsMap = getMapper(); psmMap = getMapper(); rentalMap = getMapper(); Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_mailOpenLog"); String collection = (String) defaultProps.get("collection_mailOpenLog"); String serverAddress = (String) defaultProps.get("IP_alertracker"); String initial = request.getParameter("initial"); //if(initial.equals("yes")) //{ final JSONArray counts1 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts3 = new JSONArray(); JSONObject counts = new JSONObject(); //AggregateIterable<Document> countsPRS=getCounts("PRS","alertracker","mailOpenLog"); AggregateIterable<Document> counts_alert = getCounts(database, collection, serverAddress); counts_alert.forEach(new Block<Document>() { @Override public void apply(final Document document) { Document doc1 = (Document) document.get("_id"); int hour = (int) doc1.get("hour"); type = (String) doc1.get("type"); val = (int) document.get("count"); if (type.equalsIgnoreCase("PRS")) { prsMap.put(hour, val); } else if (type.equalsIgnoreCase("PSM")) { psmMap.put(hour, val); } else if (type.equalsIgnoreCase("RENTAL")) { rentalMap.put(hour, val); } } }); for (Map.Entry<Integer, Integer> map : prsMap.entrySet()) { counts1.put(map.getValue()); } for (Map.Entry<Integer, Integer> map : psmMap.entrySet()) { counts2.put(map.getValue()); } for (Map.Entry<Integer, Integer> map : rentalMap.entrySet()) { counts3.put(map.getValue()); } try { counts.put("countsPRS", counts1); counts.put("countsPSM", counts2); counts.put("countsRENTAL", counts3); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetDailyPRSProcessStats.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww. j a v a2 s.c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_PRSProcessStats"); String collection = (String) defaultProps.get("collection_PRSProcessStats"); String serverAddress = (String) defaultProps.get("IP_AlertsProcess"); final JSONArray counts1 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts3 = new JSONArray(); //AggregateIterable<Document> counts_PRS_daily=getCounts("AlertsProcess","PRSProcessStats","daily"); AggregateIterable<Document> counts_PRS_daily = getCounts(database, collection, serverAddress, "daily"); AggregateIterable<Document> counts_PRS_weekly = getCounts(database, collection, serverAddress, "weekly"); AggregateIterable<Document> counts_PRS_monthly = getCounts(database, collection, serverAddress, "monthly"); counts_PRS_daily.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts1.put(counts); } catch (Exception e) { } } }); counts_PRS_weekly.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts2.put(counts); } catch (Exception e) { } } }); counts_PRS_monthly.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts3.put(counts); } catch (Exception e) { } } }); JSONObject counts4 = new JSONObject(); try { counts4.put("today", counts1); counts4.put("weekly", counts2); counts4.put("monthly", counts3); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts4.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetMonthlyOpenMailServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww . j av a 2s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { prsMap = getMapper(); psmMap = getMapper(); rentalMap = getMapper(); Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_mailOpenLog"); String collection = (String) defaultProps.get("collection_mailOpenLog"); String serverAddress = (String) defaultProps.get("IP_alertracker"); String initial = request.getParameter("initial"); //if(initial.equals("yes")) //{ final JSONArray counts1 = new JSONArray(); final JSONArray counts11 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts22 = new JSONArray(); final JSONArray counts3 = new JSONArray(); final JSONArray counts33 = new JSONArray(); final JSONArray labels = new JSONArray(); JSONObject counts = new JSONObject(); //AggregateIterable<Document> countsPRS=getCounts("PRS","alertracker","mailOpenLog"); AggregateIterable<Document> countsPRS = getCounts(database, collection, serverAddress); Calendar labeldate = Calendar.getInstance(); labeldate.add(Calendar.DATE, -29); for (i = 0; i <= 29; i++) { Date date = labeldate.getTime(); SimpleDateFormat format1 = new SimpleDateFormat("dd MMMM"); String date1 = format1.format(date); labels.put(date1); labeldate.add(Calendar.DATE, 1); } countsPRS.forEach(new Block<Document>() { @Override public void apply(final Document document) { Document doc1 = (Document) document.get("_id"); long date = (long) doc1.get("date"); type = (String) doc1.get("type"); val = (int) document.get("count"); if (type.equalsIgnoreCase("PRS")) { prsMap.put(date, val); } else if (type.equalsIgnoreCase("PSM")) { psmMap.put(date, val); } else if (type.equalsIgnoreCase("RENTAL")) { rentalMap.put(date, val); } } }); for (Map.Entry<Long, Integer> map : prsMap.entrySet()) { counts1.put(map.getValue()); } for (Map.Entry<Long, Integer> map : psmMap.entrySet()) { counts2.put(map.getValue()); } for (Map.Entry<Long, Integer> map : rentalMap.entrySet()) { counts3.put(map.getValue()); } //-------------------------------------------------------- try { counts.put("countsPRS", counts1); counts.put("countsPSM", counts2); counts.put("countsRENTAL", counts3); counts.put("labels", labels); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetMonthlyServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w .java 2s .co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { prsMap = getMapper(); psmMap = getMapper(); rentalMap = getMapper(); Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_requirementLog"); String collection = (String) defaultProps.get("collection_requirementLog"); String serverAddress = (String) defaultProps.get("IP_mbstats"); String initial = request.getParameter("initial"); //if(initial.equals("yes")) //{ final JSONArray counts1 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts3 = new JSONArray(); final JSONArray labels = new JSONArray(); JSONObject counts = new JSONObject(); AggregateIterable<Document> countsPRS = getCounts("PRS", database, collection, serverAddress); Calendar labeldate = Calendar.getInstance(); labeldate.add(Calendar.DATE, -29); for (i = 0; i <= 29; i++) { Date date = labeldate.getTime(); SimpleDateFormat format1 = new SimpleDateFormat("dd MMMM"); String date1 = format1.format(date); labels.put(date1); labeldate.add(Calendar.DATE, 1); } countsPRS.forEach(new Block<Document>() { @Override public void apply(final Document document) { Document doc1 = (Document) document.get("_id"); long date = (long) doc1.get("date"); type = (String) doc1.get("type"); val = (int) document.get("count"); if (type.equalsIgnoreCase("PRS")) { prsMap.put(date, val); } else if (type.equalsIgnoreCase("PSM")) { psmMap.put(date, val); } else if (type.equalsIgnoreCase("RENTAL")) { rentalMap.put(date, val); } } }); // System.out.println("PRS MAP "+prsMap.toString()); // System.out.println("Psm MAP "+psmMap.toString()); //System.out.println("rental MAP "+rentalMap.toString()); for (Map.Entry<Long, Integer> map : prsMap.entrySet()) { counts1.put(map.getValue()); } for (Map.Entry<Long, Integer> map : psmMap.entrySet()) { counts2.put(map.getValue()); } for (Map.Entry<Long, Integer> map : rentalMap.entrySet()) { counts3.put(map.getValue()); } //--------------------------------------------------------------- try { counts.put("countsPRS", counts1); counts.put("countsPSM", counts2); counts.put("countsRENTAL", counts3); counts.put("labels", labels); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetProcessSpeed.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . java2 s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_requirementLog"); String collection = (String) defaultProps.get("collection_requirementLog"); String serverAddress = (String) defaultProps.get("IP_mbstats"); AggregateIterable<Document> count_alert_S = getProcessSpeed(database, collection, serverAddress, "speed"); AggregateIterable<Document> count_alert = getProcessSpeed(database, collection, serverAddress, "count"); count_alert.forEach(new Block<Document>() { @Override public void apply(final Document document) { String type = (String) document.get("_id"); if (type.equals("PRS")) { countPRS = (int) document.get("count"); } else if (type.equals("PSM")) { countPSM = (int) document.get("count"); } else if (type.equals("RENTAL")) { countRENTAL = (int) document.get("count"); } } }); count_alert_S.forEach(new Block<Document>() { @Override public void apply(final Document document) { String type = (String) document.get("_id"); if (type.equals("PRS")) { countPRS_S = (int) document.get("count"); countPRS_S = (countPRS_S / 900); //for speed per sec countPRS_S = Math.round(countPRS_S * 100.0) / 100.0; } else if (type.equals("PSM")) { countPSM_S = (int) document.get("count"); countPSM_S = (countPSM_S / 900); //for speed per sec countPSM_S = Math.round(countPSM_S * 100.0) / 100.0; } else if (type.equals("RENTAL")) { countRENTAL_S = (int) document.get("count"); countRENTAL_S = (countRENTAL_S / 900); //for speed per sec countRENTAL_S = Math.round(countRENTAL_S * 100.0) / 100.0; } } }); JSONObject json = new JSONObject(); try { json.put("speedPRS", countPRS_S); json.put("speedPSM", countPSM_S); json.put("speedRENTAL", countRENTAL_S); json.put("countPRS", countPRS); json.put("countPSM", countPSM); json.put("countRENTAL", countRENTAL); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(json.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetPRSCompilation.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w .j a va 2 s .co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_PRSCompilation"); String database_sent = (String) defaultProps.get("database_requirementLog"); String collection = (String) defaultProps.get("collection_PRSCompilation"); String collection_sent = (String) defaultProps.get("collection_requirementLog"); String serverAddress = (String) defaultProps.get("IP_AlertsProcess"); String serverAddress_sent = (String) defaultProps.get("IP_mbstats"); //final JSONObject counts= new JSONObject(); AggregateIterable<Document> counts_PRS_daily = getCounts(database, collection, serverAddress, "daily"); counts_PRS_daily.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts1.put(counts); } catch (Exception e) { } } }); //System.out.println("counts1 " + counts1); AggregateIterable<Document> counts_PRS_weekly = getCounts(database, collection, serverAddress, "weekly"); counts_PRS_weekly.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts2.put(counts); } catch (Exception e) { } } }); // System.out.println("counts2 " + counts2); AggregateIterable<Document> counts_PRS_monthly = getCounts(database, collection, serverAddress, "monthly"); counts_PRS_monthly.forEach(new Block<Document>() { @Override public void apply(final Document document) { String errorcode = (String) document.get("_id"); int count1 = (int) document.get("count"); JSONObject counts = new JSONObject(); try { counts.put(errorcode, count1); counts22.put(counts); } catch (Exception e) { } } }); //System.out.println("counts22 " + counts22); AggregateIterable<Document> counts_PRS_daily_total = getCounts(database, collection, serverAddress, "daily_total"); counts_PRS_daily_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("daily_total_compilation", count); } catch (Exception e) { } } }); //System.out.println("counts3 -1" + counts3); AggregateIterable<Document> counts_PRS_weekly_total = getCounts(database, collection, serverAddress, "weekly_total"); counts_PRS_weekly_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("weekly_total_compilation", count); } catch (Exception e) { } } }); // System.out.println("counts3 -2" + counts3); AggregateIterable<Document> counts_PRS_monthly_total = getCounts(database, collection, serverAddress, "monthly_total"); counts_PRS_monthly_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("monthly_total_compilation", count); } catch (Exception e) { } } }); // System.out.println("counts3 -3" + counts3); AggregateIterable<Document> counts_PRSSent_daily_total = getCounts(database_sent, collection_sent, serverAddress_sent, "daily_total"); counts_PRSSent_daily_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("daily_total_sent", count); } catch (Exception e) { } } }); //System.out.println("counts3 -4" + counts3); AggregateIterable<Document> counts_PRSSent_weekly_total = getCounts(database_sent, collection_sent, serverAddress_sent, "weekly_total"); counts_PRSSent_weekly_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("weekly_total_sent", count); } catch (Exception e) { } } }); //System.out.println("counts3 -5" + counts3); AggregateIterable<Document> counts_PRSSent_monthly_total = getCounts(database_sent, collection_sent, serverAddress_sent, "monthly_total"); counts_PRSSent_monthly_total.forEach(new Block<Document>() { @Override public void apply(final Document document) { try { int count = (int) document.get("count"); counts3.put("monthly_total_sent", count); } catch (Exception e) { } } }); //System.out.println("counts3 -6" + counts3); try { counts3.put("today", counts1); counts3.put("weekly", counts2); counts3.put("monthly", counts22); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts3.toString()); } }
From source file:com.AlertMailerWebPage.servlet.GetWeeklyOpenMail.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w . j a v a2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { prsMap = getMapper(); psmMap = getMapper(); rentalMap = getMapper(); Properties defaultProps = new Properties(); InputStream in = GetProcessSpeed.class.getResourceAsStream("configuration.properties"); defaultProps.load(in); in.close(); String database = (String) defaultProps.get("database_mailOpenLog"); String collection = (String) defaultProps.get("collection_mailOpenLog"); String serverAddress = (String) defaultProps.get("IP_alertracker"); String initial = request.getParameter("initial"); //if(initial.equals("yes")) //{ final JSONArray counts1 = new JSONArray(); final JSONArray counts11 = new JSONArray(); final JSONArray counts2 = new JSONArray(); final JSONArray counts22 = new JSONArray(); final JSONArray counts3 = new JSONArray(); final JSONArray counts33 = new JSONArray(); final JSONArray labels = new JSONArray(); JSONObject counts = new JSONObject(); AggregateIterable<Document> countsPRS = getCounts(database, collection, serverAddress); Calendar current = Calendar.getInstance(); Calendar min_13 = Calendar.getInstance(); //min_13.set(2015,4,18,0,0,0); //current.set(2015,4,18,0,0,0); //current.add(Calendar.DATE,13); min_13.add(Calendar.DATE, -13); int day = current.get(Calendar.DAY_OF_WEEK); if (day == 1) { String[] label = { "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday(today)" }; labels.put(label); } else if (day == 2) { String[] label = { "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", "monday(today)" }; labels.put(label); } else if (day == 3) { String[] label = { "wednesday", "thursday", "friday", "saturday", "sunday", "monday", "tuesday(today)" }; labels.put(label); } else if (day == 4) { String[] label = { "thursday", "friday", "saturday", "sunday", "monday", "tuesday", "wednesday(today)" }; labels.put(label); } else if (day == 5) { String[] label = { "friday", "saturday", "sunday", "monday", "tuesday", "wednesday", "thursday(today)" }; labels.put(label); } else if (day == 6) { String[] label = { "saturday", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday(today)" }; labels.put(label); } else if (day == 7) { String[] label = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday(today)" }; labels.put(label); } //labels.put(label); countsPRS.forEach(new Block<Document>() { @Override public void apply(final Document document) { Document doc1 = (Document) document.get("_id"); long date = (long) doc1.get("date"); type = (String) doc1.get("type"); val = (int) document.get("count"); if (type.equalsIgnoreCase("PRS")) { prsMap.put(date, val); } else if (type.equalsIgnoreCase("PSM")) { psmMap.put(date, val); } else if (type.equalsIgnoreCase("RENTAL")) { rentalMap.put(date, val); } } }); int limit = 0; for (Map.Entry<Long, Integer> map : prsMap.entrySet()) { if (limit <= 6) { counts1.put(map.getValue()); limit++; } } for (Map.Entry<Long, Integer> map : prsMap.entrySet()) { if (limit <= 13) { counts11.put(map.getValue()); limit++; } } limit = 0; for (Map.Entry<Long, Integer> map : psmMap.entrySet()) { if (limit <= 6) { counts2.put(map.getValue()); limit++; } } for (Map.Entry<Long, Integer> map : psmMap.entrySet()) { if (limit <= 13) { counts22.put(map.getValue()); limit++; } } limit = 0; for (Map.Entry<Long, Integer> map : rentalMap.entrySet()) { if (limit <= 6) { counts3.put(map.getValue()); limit++; } } for (Map.Entry<Long, Integer> map : rentalMap.entrySet()) { if (limit <= 13) { counts33.put(map.getValue()); limit++; } } //-------------------------------------------------------- try { counts.put("countsPRS_LL", counts1); counts.put("countsPRS_L", counts11); counts.put("countsPSM_LL", counts2); counts.put("countsPSM_L", counts22); counts.put("countsRENTAL_LL", counts3); counts.put("countsRENTAL_L", counts33); counts.put("labels", labels); } catch (Exception e) { } response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(counts.toString()); } }