List of usage examples for org.joda.time DateTime minusDays
public DateTime minusDays(int days)
From source file:org.egov.pgr.dashboard.service.DashboardService.java
License:Open Source License
public Collection<Integer> getComplaintResolutionTrend() { DateTime currentDate = new DateTime(); Map<String, Integer> currentYearTillDays = constructDatePlaceHolder(currentDate.minusDays(6), currentDate, "MM-dd"); for (Object[] compDtl : dashboardRepository.fetchComplaintResolutionTrendBetween( startOfGivenDate(currentDate.minusDays(6)).toDate(), endOfGivenDate(currentDate).toDate())) currentYearTillDays.put(String.valueOf(compDtl[1]), Integer.valueOf(String.valueOf(compDtl[0]))); return currentYearTillDays.values(); }
From source file:org.egov.pgr.dashboard.service.DashboardService.java
License:Open Source License
private List<Map<String, Object>> performanceAnalysis(List<Object[]> wardwisePerformanceData, DateTime currentDate) { List<Map<String, Object>> compAggrData = new ArrayList<>(); String formattedFrm = endOfGivenDate(currentDate.minusDays(14)).toString(defaultDateFormatter()); String formattedDayAfterFrm = startOfGivenDate(currentDate.minusDays(13)).toString(defaultDateFormatter()); String formattedTo = currentDate.toString(defaultDateFormatter()); DecimalFormat df = new DecimalFormat("####0.00"); for (Object[] compData : wardwisePerformanceData) { Map<String, Object> complaintData = new HashMap<>(); complaintData.put("zone", compData[0]); BigInteger compData1 = (BigInteger) compData[1]; BigInteger compData3 = (BigInteger) compData[3]; BigInteger compData4 = (BigInteger) compData[4]; double noOfCompAsOnDate = compData1.doubleValue(); double noOfCompReceivedBtw = compData3.doubleValue(); double noOfCompPenAsonDate = compData4.doubleValue(); complaintData.put("dateAsOn2WeekBack", formattedFrm); complaintData.put("noOfCompAsOnDate", noOfCompAsOnDate); complaintData.put("dateAsOnDayAfter", formattedDayAfterFrm); complaintData.put("noOfCompReceivedBtw", noOfCompReceivedBtw); complaintData.put("dateAsOn", formattedTo); complaintData.put("noOfCompPenAsonDate", noOfCompPenAsonDate); Double disposalPerc = 100 * (noOfCompAsOnDate + noOfCompReceivedBtw - noOfCompPenAsonDate) / (noOfCompAsOnDate + noOfCompReceivedBtw); if (disposalPerc.isNaN() || disposalPerc.isInfinite()) complaintData.put(DISPOSALPERC, "0.00"); else/*from w w w .jav a2 s.co m*/ complaintData.put(DISPOSALPERC, df.format(disposalPerc)); complaintData.put("lat", compData[6]); complaintData.put("lng", compData[7]); complaintData.put("zoneId", compData[8]); compAggrData.add(complaintData); } // SORT ZONEWISE PERFORMANCE BY REDRESSAL % sortData(compAggrData, DISPOSALPERC); Collections.reverse(compAggrData); // ASSIGN A RANK BASED ON ORDER assignRank(compAggrData, "rank"); return compAggrData; }
From source file:org.egov.pgr.elasticsearch.entity.contract.ComplaintSearchRequest.java
License:Open Source License
public void setComplaintDate(String complaintDate) { if (complaintDate != null) { DateTime currentDate = new DateTime(); this.toDate = endOfGivenDate(currentDate).toString(ES_DATE_FORMAT); if ("today".equalsIgnoreCase(complaintDate)) { this.fromDate = currentDate.withTimeAtStartOfDay().toString(ES_DATE_FORMAT); } else if ("lastsevendays".equalsIgnoreCase(complaintDate)) { this.fromDate = currentDate.minusDays(7).toString(ES_DATE_FORMAT); } else if ("lastthirtydays".equalsIgnoreCase(complaintDate)) { this.fromDate = currentDate.minusDays(30).toString(ES_DATE_FORMAT); } else if ("lastninetydays".equalsIgnoreCase(complaintDate)) { this.fromDate = currentDate.minusDays(90).toString(ES_DATE_FORMAT); } else {/*from w w w.j a v a2 s . c om*/ this.fromDate = null; this.toDate = null; } } }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
License:Open Source License
public Collection<Integer> getComplaintRegistrationTrend() { final DateTime currentDate = new DateTime(); final Map<String, Integer> currentYearTillDays = constructDatePlaceHolder(currentDate.minusDays(6), currentDate, "MM-dd"); for (final Object[] compDtl : dashboardRepository.fetchComplaintRegistrationTrendBetween( startOfGivenDate(currentDate.minusDays(6)).toDate(), endOfGivenDate(currentDate).toDate())) currentYearTillDays.put(String.valueOf(compDtl[0]), Integer.valueOf(String.valueOf(compDtl[1]))); return currentYearTillDays.values(); }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
License:Open Source License
public Collection<Integer> getComplaintResolutionTrend() { final DateTime currentDate = new DateTime(); final Map<String, Integer> currentYearTillDays = constructDatePlaceHolder(currentDate.minusDays(6), currentDate, "MM-dd"); for (final Object[] compDtl : dashboardRepository.fetchComplaintResolutionTrendBetween( startOfGivenDate(currentDate.minusDays(6)).toDate(), endOfGivenDate(currentDate).toDate())) currentYearTillDays.put(String.valueOf(compDtl[1]), Integer.valueOf(String.valueOf(compDtl[0]))); return currentYearTillDays.values(); }
From source file:org.egov.pgr.service.dashboard.DashboardService.java
License:Open Source License
private List<Map<String, Object>> performanceAnalysis(final List<Object[]> wardwisePerformanceData, final DateTime currentDate) { final List<Map<String, Object>> compAggrData = new ArrayList<Map<String, Object>>(); final String formattedFrm = endOfGivenDate(currentDate.minusDays(14)).toString(DFLT_DATE_FRMTR); final String formattedDayAfterFrm = startOfGivenDate(currentDate.minusDays(13)).toString(DFLT_DATE_FRMTR); final String formattedTo = currentDate.toString(DFLT_DATE_FRMTR); final DecimalFormat df = new DecimalFormat("####0.00"); for (final Object[] compData : wardwisePerformanceData) { final Map<String, Object> complaintData = new HashMap<String, Object>(); complaintData.put("zone", compData[0]); final BigInteger compData1 = (BigInteger) compData[1]; final BigInteger compData3 = (BigInteger) compData[3]; final BigInteger compData4 = (BigInteger) compData[4]; final double noOfCompAsOnDate = compData1.doubleValue(); final double noOfCompReceivedBtw = compData3.doubleValue(); final double noOfCompPenAsonDate = compData4.doubleValue(); complaintData.put("dateAsOn2WeekBack", formattedFrm); complaintData.put("noOfCompAsOnDate", noOfCompAsOnDate); complaintData.put("dateAsOnDayAfter", formattedDayAfterFrm); complaintData.put("noOfCompReceivedBtw", noOfCompReceivedBtw); complaintData.put("dateAsOn", formattedTo); complaintData.put("noOfCompPenAsonDate", noOfCompPenAsonDate); final Double disposalPerc = 100 * (noOfCompAsOnDate + noOfCompReceivedBtw - noOfCompPenAsonDate) / (noOfCompAsOnDate + noOfCompReceivedBtw); if (disposalPerc.isNaN() || disposalPerc.isInfinite()) complaintData.put("disposalPerc", "0.00"); else/*from w w w.j av a 2 s .c o m*/ complaintData.put("disposalPerc", df.format(disposalPerc)); complaintData.put("lat", compData[6]); complaintData.put("lng", compData[7]); complaintData.put("zoneId", compData[8]); compAggrData.add(complaintData); } // SORT ZONEWISE PERFORMANCE BY REDRESSAL % sortData(compAggrData, "disposalPerc"); Collections.reverse(compAggrData); // ASSIGN A RANK BASED ON ORDER assignRank(compAggrData, "rank"); return compAggrData; }
From source file:org.egov.pgr.web.contract.ComplaintSearchRequest.java
License:Open Source License
public void setComplaintDate(final String complaintDate) { if (null != complaintDate) { DateTime currentDate = new DateTime(); complaintDateTo = endOfGivenDate(currentDate).toString(SEARCH_DATE_FORMAT); if (complaintDate.equalsIgnoreCase("today")) { complaintDateFrom = currentDate.withTimeAtStartOfDay().toString(SEARCH_DATE_FORMAT); } else if (complaintDate.equalsIgnoreCase("all")) { complaintDateFrom = null;//ww w . j a v a2s. c om complaintDateTo = null; } else if (complaintDate.equalsIgnoreCase("lastsevendays")) { complaintDateFrom = currentDate.minusDays(7).toString(SEARCH_DATE_FORMAT); } else if (complaintDate.equalsIgnoreCase("lastthirtydays")) { complaintDateFrom = currentDate.minusDays(30).toString(SEARCH_DATE_FORMAT); } else if (complaintDate.equalsIgnoreCase("lastninetydays")) { complaintDateFrom = currentDate.minusDays(90).toString(SEARCH_DATE_FORMAT); } else { complaintDateFrom = null; complaintDateTo = null; } } }
From source file:org.egov.ptis.repository.dashboard.RevenueDashboardRepository.java
License:Open Source License
public List<Map<String, Object>> revenueTrendForTheWeek() { final Query qry = getQuery("revenue.ptis.collectiontrend"); final DateTime currentDate = new DateTime(); qry.setParameter("fromDate", startOfGivenDate(currentDate.minusDays(6)).toDate()); qry.setParameter("toDate", endOfGivenDate(currentDate).toDate()); final List<Object[]> revenueData = qry.list(); final List<Map<String, Object>> currentYearTillDays = constructDayPlaceHolder(currentDate.minusDays(6), currentDate, "E-dd", "EEEE, dd MMM yyyy"); for (final Object[] revnueObj : revenueData) for (final Map<String, Object> mapdata : currentYearTillDays) if (mapdata.containsValue( org.apache.commons.lang.StringUtils.capitalize(String.valueOf(revnueObj[0]).toLowerCase()))) mapdata.put("y", Double.valueOf(String.valueOf(revnueObj[1]))); return currentYearTillDays; }
From source file:org.elasticsearch.indices.DateMathIndexExpressionsIntegrationIT.java
License:Apache License
public void testIndexNameDateMathExpressions() { DateTime now = new DateTime(DateTimeZone.UTC); String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now); String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1)); String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2)); createIndex(index1, index2, index3); String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; String dateMathExp3 = "<.marvel-{now/d-2d}>"; client().prepareIndex(dateMathExp1, "type", "1").setSource("{}").get(); client().prepareIndex(dateMathExp2, "type", "2").setSource("{}").get(); client().prepareIndex(dateMathExp3, "type", "3").setSource("{}").get(); refresh();/*from ww w . j a va2 s.co m*/ SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get(); assertHitCount(searchResponse, 3); assertSearchHits(searchResponse, "1", "2", "3"); GetResponse getResponse = client().prepareGet(dateMathExp1, "type", "1").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("1")); getResponse = client().prepareGet(dateMathExp2, "type", "2").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("2")); getResponse = client().prepareGet(dateMathExp3, "type", "3").get(); assertThat(getResponse.isExists(), is(true)); assertThat(getResponse.getId(), equalTo("3")); MultiGetResponse mgetResponse = client().prepareMultiGet().add(dateMathExp1, "type", "1") .add(dateMathExp2, "type", "2").add(dateMathExp3, "type", "3").get(); assertThat(mgetResponse.getResponses()[0].getResponse().isExists(), is(true)); assertThat(mgetResponse.getResponses()[0].getResponse().getId(), equalTo("1")); assertThat(mgetResponse.getResponses()[1].getResponse().isExists(), is(true)); assertThat(mgetResponse.getResponses()[1].getResponse().getId(), equalTo("2")); assertThat(mgetResponse.getResponses()[2].getResponse().isExists(), is(true)); assertThat(mgetResponse.getResponses()[2].getResponse().getId(), equalTo("3")); IndicesStatsResponse indicesStatsResponse = client().admin().indices() .prepareStats(dateMathExp1, dateMathExp2, dateMathExp3).get(); assertThat(indicesStatsResponse.getIndex(index1), notNullValue()); assertThat(indicesStatsResponse.getIndex(index2), notNullValue()); assertThat(indicesStatsResponse.getIndex(index3), notNullValue()); DeleteResponse deleteResponse = client().prepareDelete(dateMathExp1, "type", "1").get(); assertThat(deleteResponse.isFound(), equalTo(true)); assertThat(deleteResponse.getId(), equalTo("1")); deleteResponse = client().prepareDelete(dateMathExp2, "type", "2").get(); assertThat(deleteResponse.isFound(), equalTo(true)); assertThat(deleteResponse.getId(), equalTo("2")); deleteResponse = client().prepareDelete(dateMathExp3, "type", "3").get(); assertThat(deleteResponse.isFound(), equalTo(true)); assertThat(deleteResponse.getId(), equalTo("3")); }
From source file:org.elasticsearch.indices.DateMathIndexExpressionsIntegrationIT.java
License:Apache License
public void testAutoCreateIndexWithDateMathExpression() throws Exception { DateTime now = new DateTime(DateTimeZone.UTC); String index1 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now); String index2 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(1)); String index3 = ".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.minusDays(2)); String dateMathExp1 = "<.marvel-{now/d}>"; String dateMathExp2 = "<.marvel-{now/d-1d}>"; String dateMathExp3 = "<.marvel-{now/d-2d}>"; client().prepareIndex(dateMathExp1, "type", "1").setSource("{}").get(); client().prepareIndex(dateMathExp2, "type", "2").setSource("{}").get(); client().prepareIndex(dateMathExp3, "type", "3").setSource("{}").get(); refresh();/*from w w w. j av a 2 s .c o m*/ SearchResponse searchResponse = client().prepareSearch(dateMathExp1, dateMathExp2, dateMathExp3).get(); assertHitCount(searchResponse, 3); assertSearchHits(searchResponse, "1", "2", "3"); IndicesStatsResponse indicesStatsResponse = client().admin().indices() .prepareStats(dateMathExp1, dateMathExp2, dateMathExp3).get(); assertThat(indicesStatsResponse.getIndex(index1), notNullValue()); assertThat(indicesStatsResponse.getIndex(index2), notNullValue()); assertThat(indicesStatsResponse.getIndex(index3), notNullValue()); }