List of usage examples for java.util Calendar getActualMaximum
public int getActualMaximum(int field)
Calendar
. From source file:com.gnizr.core.util.GnizrDaoUtil.java
public static Date[] getTimeRangeDate(int timeRange) { Date[] dates = new Date[2]; Date now = GnizrDaoUtil.getNow(); dates[0] = GnizrDaoUtil.toDayBegins(now); dates[1] = GnizrDaoUtil.toDayEnds(now); if (TimeRange.TODAY == timeRange) { return dates; } else if (TimeRange.YESTERDAY == timeRange) { Calendar cal = Calendar.getInstance(); cal.setTime(dates[0]);/* ww w. j a v a 2 s . c o m*/ cal.add(Calendar.DAY_OF_MONTH, -1); dates[0] = cal.getTime(); cal.setTime(dates[1]); cal.add(Calendar.DAY_OF_MONTH, -1); dates[1] = cal.getTime(); } else if (TimeRange.LAST_7_DAYS == timeRange) { Calendar cal = Calendar.getInstance(); cal.setTime(dates[0]); cal.add(Calendar.DAY_OF_MONTH, -6); dates[0] = cal.getTime(); } else if (TimeRange.THIS_MONTH == timeRange) { Calendar cal = Calendar.getInstance(); cal.setTime(dates[0]); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); dates[0] = cal.getTime(); } else if (TimeRange.LAST_MONTH == timeRange) { Calendar cal = Calendar.getInstance(); cal.setTime(dates[0]); cal.add(Calendar.MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); dates[0] = cal.getTime(); cal.setTime(dates[1]); cal.add(Calendar.MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); dates[1] = cal.getTime(); } else { return null; } return dates; }
From source file:org.projectforge.business.fibu.AuftragDao.java
private List<AuftragDO> getList(final BaseSearchFilter filter, final boolean checkAccess) { final AuftragFilter myFilter; if (filter instanceof AuftragFilter) { myFilter = (AuftragFilter) filter; } else {/*w ww .j a v a 2s .co m*/ myFilter = new AuftragFilter(filter); } final QueryFilter queryFilter = new QueryFilter(myFilter); Boolean vollstaendigFakturiert = null; if (myFilter.isShowBeauftragtNochNichtVollstaendigFakturiert() == true) { queryFilter.add(Restrictions.not(Restrictions.in("auftragsStatus", new AuftragsStatus[] { AuftragsStatus.ABGELEHNT, AuftragsStatus.ERSETZT, AuftragsStatus.GELEGT, AuftragsStatus.GROB_KALKULATION, AuftragsStatus.IN_ERSTELLUNG }))); vollstaendigFakturiert = false; } else if (myFilter.isShowNochNichtVollstaendigFakturiert() == true) { queryFilter.add(Restrictions.not(Restrictions.in("auftragsStatus", new AuftragsStatus[] { AuftragsStatus.ABGELEHNT, AuftragsStatus.ERSETZT }))); vollstaendigFakturiert = false; } else if (myFilter.isShowVollstaendigFakturiert() == true) { vollstaendigFakturiert = true; } else if (myFilter.isShowAbgelehnt() == true) { queryFilter.add(Restrictions.eq("auftragsStatus", AuftragsStatus.ABGELEHNT)); } else if (myFilter.isShowAbgeschlossenNichtFakturiert() == true) { queryFilter.createAlias("positionen", "position") .createAlias("paymentSchedules", "paymentSchedule", Criteria.FULL_JOIN).add( Restrictions.or( Restrictions.or(Restrictions.eq("auftragsStatus", AuftragsStatus.ABGESCHLOSSEN), Restrictions.eq("position.status", AuftragsPositionsStatus.ABGESCHLOSSEN)), Restrictions.eq("paymentSchedule.reached", true))); vollstaendigFakturiert = false; } else if (myFilter.isShowAkquise() == true) { queryFilter.add(Restrictions.in("auftragsStatus", new AuftragsStatus[] { AuftragsStatus.GELEGT, AuftragsStatus.IN_ERSTELLUNG, AuftragsStatus.GROB_KALKULATION })); } else if (myFilter.isShowBeauftragt() == true) { queryFilter.add(Restrictions.in("auftragsStatus", new AuftragsStatus[] { AuftragsStatus.BEAUFTRAGT, AuftragsStatus.LOI, AuftragsStatus.ESKALATION })); } else if (myFilter.isShowErsetzt() == true) { queryFilter.add(Restrictions.eq("auftragsStatus", AuftragsStatus.ERSETZT)); } if (myFilter.getYear() > 1900) { final Calendar cal = DateHelper.getUTCCalendar(); cal.set(Calendar.YEAR, myFilter.getYear()); java.sql.Date lo = null; java.sql.Date hi = null; cal.set(Calendar.DAY_OF_YEAR, 1); lo = new java.sql.Date(cal.getTimeInMillis()); final int lastDayOfYear = cal.getActualMaximum(Calendar.DAY_OF_YEAR); cal.set(Calendar.DAY_OF_YEAR, lastDayOfYear); hi = new java.sql.Date(cal.getTimeInMillis()); queryFilter.add(Restrictions.between("angebotsDatum", lo, hi)); } queryFilter.addOrder(Order.desc("nummer")); final List<AuftragDO> list; if (checkAccess == true) { list = getList(queryFilter); } else { list = internalGetList(queryFilter); } if (vollstaendigFakturiert != null) { final Boolean invoiced = vollstaendigFakturiert; CollectionUtils.filter(list, new Predicate() { @Override public boolean evaluate(final Object object) { final AuftragDO auftrag = (AuftragDO) object; final boolean orderIsCompletelyInvoiced = auftrag.isVollstaendigFakturiert(); if (HibernateUtils.getDialect() != DatabaseDialect.HSQL && myFilter.isShowAbgeschlossenNichtFakturiert() == true) { // if order is completed and not all positions are completely invoiced if (auftrag.getAuftragsStatus() == AuftragsStatus.ABGESCHLOSSEN && orderIsCompletelyInvoiced == false) { return true; } // if order is completed and not completely invoiced if (auftrag.getPositionen() != null) { for (final AuftragsPositionDO pos : auftrag.getPositionen()) { if (pos.isAbgeschlossenUndNichtVollstaendigFakturiert() == true) { return true; } } } if (auftrag.getPaymentSchedules() != null) { for (final PaymentScheduleDO schedule : auftrag.getPaymentSchedules()) { if (schedule.isReached() == true && schedule.isVollstaendigFakturiert() == false) { return true; } } } return false; } return orderIsCompletelyInvoiced == invoiced; } }); } if (myFilter.getAuftragsPositionsArt() != null) { final AuftragFilter fil = myFilter; CollectionUtils.filter(list, new Predicate() { @Override public boolean evaluate(final Object object) { final AuftragDO auftrag = (AuftragDO) object; boolean match = false; if (fil.getAuftragsPositionsArt() != null) { if (CollectionUtils.isNotEmpty(auftrag.getPositionen()) == true) { for (final AuftragsPositionDO position : auftrag.getPositionen()) { if (fil.getAuftragsPositionsArt() == position.getArt()) { match = true; break; } } } } return match; } }); } return list; }
From source file:nl.tricode.magnolia.blogs.templates.BlogRenderableDefinition.java
protected String getDateCreatedPredicate() { if (filter.containsKey(PARAM_YEAR)) { final int year = Integer.parseInt(filter.get(PARAM_YEAR)); final Calendar start = Calendar.getInstance(); start.set(year, Calendar.JANUARY, 1, 0, 0, 0); start.set(Calendar.MILLISECOND, 0); final Calendar end = Calendar.getInstance(); end.set(year, Calendar.DECEMBER, 1, 23, 59, 59); end.set(Calendar.MILLISECOND, 999); if (filter.containsKey(PARAM_MONTH)) { final int month = Integer.parseInt(filter.get(PARAM_MONTH)) - 1; start.set(Calendar.MONTH, month); end.set(Calendar.MONTH, month); }/*from w w w.j av a 2 s.c o m*/ // Determine last day of the end month end.set(Calendar.DAY_OF_MONTH, end.getActualMaximum(Calendar.DAY_OF_MONTH)); final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); // Format start date and end data for use in jcr sql predicate return "AND p.[mgnl:created] >= CAST('" + dateFormat.format(start.getTime()) + "' AS DATE) " + "AND p.[mgnl:created] <= CAST('" + dateFormat.format(end.getTime()) + "' AS DATE) "; } return StringUtils.EMPTY; }
From source file:cn.com.sinosoft.util.time.DurationFormatUtils.java
/** * <p>Formats the time gap as a string, using the specified format. * Padding the left hand side of numbers with zeroes is optional and * the timezone may be specified. </p> * * <p>When calculating the difference between months/days, it chooses to * calculate months first. So when working out the number of months and * days between January 15th and March 10th, it choose 1 month and * 23 days gained by choosing January->February = 1 month and then * calculating days forwards, and not the 1 month and 26 days gained by * choosing March -> February = 1 month and then calculating days * backwards. </p>//w w w.ja v a2 s.c o m * * <p>For more control, the <a href="http://joda-time.sf.net/">Joda-Time</a> * library is recommended.</p> * * @param startMillis the start of the duration * @param endMillis the end of the duration * @param format the way in which to format the duration * @param padWithZeros whether to pad the left hand side of numbers with 0's * @param timezone the millis are defined in * @return the time as a String */ public static String formatPeriod(long startMillis, long endMillis, String format, boolean padWithZeros, TimeZone timezone) { // Used to optimise for differences under 28 days and // called formatDuration(millis, format); however this did not work // over leap years. // TODO: Compare performance to see if anything was lost by // losing this optimisation. Token[] tokens = lexx(format); // timezones get funky around 0, so normalizing everything to GMT // stops the hours being off Calendar start = Calendar.getInstance(timezone); start.setTime(new Date(startMillis)); Calendar end = Calendar.getInstance(timezone); end.setTime(new Date(endMillis)); // initial estimates int milliseconds = end.get(Calendar.MILLISECOND) - start.get(Calendar.MILLISECOND); int seconds = end.get(Calendar.SECOND) - start.get(Calendar.SECOND); int minutes = end.get(Calendar.MINUTE) - start.get(Calendar.MINUTE); int hours = end.get(Calendar.HOUR_OF_DAY) - start.get(Calendar.HOUR_OF_DAY); int days = end.get(Calendar.DAY_OF_MONTH) - start.get(Calendar.DAY_OF_MONTH); int months = end.get(Calendar.MONTH) - start.get(Calendar.MONTH); int years = end.get(Calendar.YEAR) - start.get(Calendar.YEAR); // each initial estimate is adjusted in case it is under 0 while (milliseconds < 0) { milliseconds += 1000; seconds -= 1; } while (seconds < 0) { seconds += 60; minutes -= 1; } while (minutes < 0) { minutes += 60; hours -= 1; } while (hours < 0) { hours += 24; days -= 1; } if (Token.containsTokenWithValue(tokens, M)) { while (days < 0) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); months -= 1; start.add(Calendar.MONTH, 1); } while (months < 0) { months += 12; years -= 1; } if (!Token.containsTokenWithValue(tokens, y) && years != 0) { while (years != 0) { months += 12 * years; years = 0; } } } else { // there are no M's in the format string if (!Token.containsTokenWithValue(tokens, y)) { int target = end.get(Calendar.YEAR); if (months < 0) { // target is end-year -1 target -= 1; } while ((start.get(Calendar.YEAR) != target)) { days += start.getActualMaximum(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR); // Not sure I grok why this is needed, but the brutal tests show it is if (start instanceof GregorianCalendar) { if ((start.get(Calendar.MONTH) == Calendar.FEBRUARY) && (start.get(Calendar.DAY_OF_MONTH) == 29)) { days += 1; } } start.add(Calendar.YEAR, 1); days += start.get(Calendar.DAY_OF_YEAR); } years = 0; } while (start.get(Calendar.MONTH) != end.get(Calendar.MONTH)) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); start.add(Calendar.MONTH, 1); } months = 0; while (days < 0) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); months -= 1; start.add(Calendar.MONTH, 1); } } // The rest of this code adds in values that // aren't requested. This allows the user to ask for the // number of months and get the real count and not just 0->11. if (!Token.containsTokenWithValue(tokens, d)) { hours += 24 * days; days = 0; } if (!Token.containsTokenWithValue(tokens, H)) { minutes += 60 * hours; hours = 0; } if (!Token.containsTokenWithValue(tokens, m)) { seconds += 60 * minutes; minutes = 0; } if (!Token.containsTokenWithValue(tokens, s)) { milliseconds += 1000 * seconds; seconds = 0; } return format(tokens, years, months, days, hours, minutes, seconds, milliseconds, padWithZeros); }
From source file:org.openmrs.module.clinicalsummary.rule.pediatric.AgeWithUnitRule.java
/** * @see org.openmrs.logic.Rule#eval(org.openmrs.logic.LogicContext, Integer, java.util.Map) *///from w w w .ja v a 2 s .c o m @Override protected Result evaluate(final LogicContext context, final Integer patientId, final Map<String, Object> parameters) throws LogicException { // just make sure that this is the patient from the database Patient patient = Context.getPatientService().getPatient(patientId); Date birthdate = patient.getBirthdate(); if (log.isDebugEnabled()) log.debug("Patient: " + patient.getPatientId() + ", birthdate: " + birthdate); Result ageResult = new Result(); if (birthdate != null) { Calendar todayCalendar = Calendar.getInstance(); Date referenceDate = (Date) parameters.get(REFERENCE_DATE); if (referenceDate != null) todayCalendar.setTime(referenceDate); Calendar birthCalendar = Calendar.getInstance(); birthCalendar.setTime(birthdate); int birthYear = birthCalendar.get(Calendar.YEAR); int todayYear = todayCalendar.get(Calendar.YEAR); int ageInYear = todayYear - birthYear; int birthMonth = birthCalendar.get(Calendar.MONTH); int todayMonth = todayCalendar.get(Calendar.MONTH); int ageInMonth = todayMonth - birthMonth; if (ageInMonth < 0) { // birth month is bigger, the decrease the year ageInYear--; ageInMonth = 12 - birthMonth + todayMonth; } int birthDay = birthCalendar.get(Calendar.DATE); int todayDay = todayCalendar.get(Calendar.DATE); int ageInDay = todayDay - birthDay; if (ageInDay < 0) { ageInMonth--; birthCalendar.add(Calendar.MONTH, -1); ageInDay = birthCalendar.getActualMaximum(Calendar.DATE) - birthDay + todayDay; if (ageInDay > birthCalendar.getActualMaximum(Calendar.DATE) / 2) ageInMonth++; } if (ageInYear != 0) ageResult.add(new Result(ageInYear + " Years")); if (ageInMonth != 0) ageResult.add(new Result(ageInMonth + " Months")); } return ageResult; }
From source file:com.customdatepicker.date.DatePickerDialog.java
private Calendar adjustDayInMonthIfNeeded(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_MONTH); int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); if (day > daysInMonth) { calendar.set(Calendar.DAY_OF_MONTH, daysInMonth); }/* ww w. java2s. c o m*/ return mDateRangeLimiter.setToNearestDate(calendar); }
From source file:com.silverpeas.scheduler.simple.SchedulerJob.java
/** * The constructor has proteceted access, because the generation of jobs should be done in a * central way by the class 'SimpleScheduler' * @param aController The controller, that controls all job executions * @param aOwner The owner of the job/* w ww.j a va 2s . co m*/ * @param aJobName The name of the job * @param aLogBaseFile The log file for the job */ protected SchedulerJob(SimpleScheduler aController, SchedulerEventListener aOwner, String aJobName) throws SchedulerException { if (aController == null) { throw new SchedulerException("SchedulerJob.SchedulerJob: Parameter 'aController' is null"); } if (aOwner == null) { throw new SchedulerException("SchedulerJob.SchedulerJob: Parameter 'aOwner' is null"); } if (aJobName == null) { throw new SchedulerException("SchedulerJob.SchedulerJob: Parameter 'aJobName' is null"); } theOwner = aOwner; sJobName = aJobName; vMinutes = new ArrayList<Integer>(); vHours = new ArrayList<Integer>(); vDaysOfMonth = new ArrayList<Integer>(); vMonths = new ArrayList<Integer>(); vDaysOfWeek = new ArrayList<Integer>(); // Instead Calendar calInit = Calendar.getInstance(); currentMinute = 0; currentHour = 0; if (calInit.getActualMinimum(Calendar.DAY_OF_MONTH) == calInit.get(Calendar.DAY_OF_MONTH)) { currentDayOfMonth = calInit.getActualMaximum(Calendar.DAY_OF_MONTH); if (calInit.getActualMinimum(Calendar.MONTH) == calInit.get(Calendar.MONTH)) { currentMonth = calInit.getActualMaximum(Calendar.MONTH); currentYear = calInit.get(Calendar.YEAR) - 1; } else { currentMonth = calInit.get(Calendar.MONTH) - 1; currentYear = calInit.get(Calendar.YEAR); } } else { currentDayOfMonth = calInit.get(Calendar.DAY_OF_MONTH) - 1; currentMonth = calInit.get(Calendar.MONTH); currentYear = calInit.get(Calendar.YEAR); } if (calInit.getActualMinimum(Calendar.MONTH) == currentMonth) { currentMonth = calInit.getActualMaximum(Calendar.MONTH); currentYear = currentYear - 1; } else { currentMonth = currentMonth - 1; } nextTimeStamp = 0; bRunnable = true; }
From source file:com.marcohc.robotocalendar.RobotoCalendarView.java
private void setDaysInCalendar() { Calendar auxCalendar = Calendar.getInstance(locale); auxCalendar.setTime(currentCalendar.getTime()); auxCalendar.set(Calendar.DAY_OF_MONTH, 1); int firstDayOfMonth = auxCalendar.get(Calendar.DAY_OF_WEEK); TextView dayOfMonthText;// w ww.j a v a 2s . co m ViewGroup dayOfMonthContainer; // Calculate dayOfMonthIndex int dayOfMonthIndex = getWeekIndex(firstDayOfMonth, auxCalendar); for (int i = 1; i <= auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++, dayOfMonthIndex++) { dayOfMonthContainer = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_CONTAINER + dayOfMonthIndex); dayOfMonthText = (TextView) view.findViewWithTag(DAY_OF_MONTH_TEXT + dayOfMonthIndex); if (dayOfMonthText == null) { break; } dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener); dayOfMonthText.setVisibility(View.VISIBLE); dayOfMonthText.setText(String.valueOf(i)); dayOfMonthText.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_month)); dayOfMonthContainer.setBackgroundResource(0); } // If the last week row has no visible days, hide it or show it in case ViewGroup weekRow = (ViewGroup) view.findViewWithTag("weekRow6"); dayOfMonthText = (TextView) view.findViewWithTag("dayOfMonthText36"); if (dayOfMonthText.getVisibility() == INVISIBLE) { weekRow.setVisibility(GONE); } else { weekRow.setVisibility(VISIBLE); } updateBackgroundSelectDays(); }
From source file:org.apache.oozie.coord.CoordELFunctions.java
/** * Calculate number of days in one month for n-th dataset instance. <p> It depends on: <p> 1. Data set frequency . * <p> 2. Data set Time unit (day, month, minute) <p> 3. Data set Time zone/DST <p> 4. End Day/Month flag <p> 5. * Data set initial instance <p> 6. Action Creation Time * * @param n instance count. domain: n is integer * @return number of days in that month <p> returns -1 means n-th instance is earlier than Initial-Instance of DS * @throws Exception//from w ww .j a v a 2s . c o m */ public static int ph2_coord_daysInMonth(int n) throws Exception { int datasetFrequency = (int) getDSFrequency();// in minutes // Calendar nominalInstanceCal = // getCurrentInstance(getActionCreationtime()); Calendar nominalInstanceCal = getEffectiveNominalTime(); if (nominalInstanceCal == null) { return -1; } nominalInstanceCal.add(getDSTimeUnit().getCalendarUnit(), datasetFrequency * n); /* * if (nominalInstanceCal.getTime().compareTo(getInitialInstance()) < 0) * { return -1; } */ nominalInstanceCal.setTimeZone(getDatasetTZ());// Use Dataset TZ // DateUtils.moveToEnd(nominalInstanceCal, getDSEndOfFlag()); return nominalInstanceCal.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:org.hil.core.dao.hibernate.ChildrenDaoHibernate.java
public List<RegionVaccinationReportData> getChildrenVaccinationReport(String timeFrom, String timeTo, Commune commune, District district) { List<RegionVaccinationReportData> statistics = new ArrayList<RegionVaccinationReportData>(); String[] timeFromYM = timeFrom.split("/"); String strTimeFrom = timeFromYM[1] + "-" + timeFromYM[0] + "-01 00:00:00"; log.debug("From: " + strTimeFrom); Calendar calendar = Calendar.getInstance(); String[] timeToYM = timeTo.split("/"); int year = Integer.parseInt(timeToYM[1]); String strTimeFromY = year + "-01-01 00:00:00"; calendar.set(year, Integer.parseInt(timeToYM[0]), 1); int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); String strTimeTo = year + "-" + timeToYM[0] + "-" + maxDay + " 23:59:59"; log.debug("To: " + strTimeTo); String queryLocation = ""; if (commune != null) queryLocation = " AND cm.id = :communeId"; else if (district != null) queryLocation = " AND cm.id_district = :districtId GROUP BY cm.id ORDER BY cm.id ASC"; String sql = this.buidlSQLforReport("commune", queryLocation, "strTimeFrom"); log.debug(sql);//from ww w. j a v a2s . c om SQLQuery qry = getSession().createSQLQuery(sql); if (commune != null) qry.setParameter("communeId", commune.getId()); else if (district != null) qry.setParameter("districtId", district.getId()); qry.setParameter("timeYear", year); qry.setParameter("strTimeFrom", strTimeFrom); qry.setParameter("strTimeTo", strTimeTo); qry.addScalar("regionName", Hibernate.STRING); qry.addScalar("childrenUnder1", Hibernate.INTEGER); qry.addScalar("VGBL24", Hibernate.INTEGER); qry.addScalar("VGBG24", Hibernate.INTEGER); qry.addScalar("BCG", Hibernate.INTEGER); qry.addScalar("DPT_VGB_Hib1", Hibernate.INTEGER); qry.addScalar("OPV1", Hibernate.INTEGER); qry.addScalar("DPT_VGB_Hib2", Hibernate.INTEGER); qry.addScalar("OPV2", Hibernate.INTEGER); qry.addScalar("DPT_VGB_Hib3", Hibernate.INTEGER); qry.addScalar("OPV3", Hibernate.INTEGER); qry.addScalar("measles1", Hibernate.INTEGER); qry.addScalar("eVGBL24", Hibernate.INTEGER); qry.addScalar("eVGBG24", Hibernate.INTEGER); qry.addScalar("eBCG", Hibernate.INTEGER); qry.addScalar("eDPT_VGB_Hib1", Hibernate.INTEGER); qry.addScalar("eOPV1", Hibernate.INTEGER); qry.addScalar("eDPT_VGB_Hib2", Hibernate.INTEGER); qry.addScalar("eOPV2", Hibernate.INTEGER); qry.addScalar("eDPT_VGB_Hib3", Hibernate.INTEGER); qry.addScalar("eOPV3", Hibernate.INTEGER); qry.addScalar("eMeasles1", Hibernate.INTEGER); qry.addScalar("protectedTetanusCases", Hibernate.INTEGER); qry.addScalar("reactionNormalCases", Hibernate.INTEGER); qry.addScalar("reactionSeriousCases", Hibernate.INTEGER); qry.addScalar("amountOfFinish", Hibernate.INTEGER); qry.setResultTransformer(Transformers.aliasToBean(RegionVaccinationReportData.class)); statistics = qry.list(); if (commune != null && statistics.size() > 0) { RegionVaccinationReportData same = new RegionVaccinationReportData(); same.setAmountOfFinish(statistics.get(0).getAmountOfFinish()); same.setAmountOfFinish(statistics.get(0).getAmountOfFinish()); same.setBCG(statistics.get(0).getBCG()); same.setChildrenUnder1(statistics.get(0).getChildrenUnder1()); same.setDPT_VGB_Hib1(statistics.get(0).getDPT_VGB_Hib1()); same.setDPT_VGB_Hib2(statistics.get(0).getDPT_VGB_Hib2()); same.setDPT_VGB_Hib3(statistics.get(0).getDPT_VGB_Hib3()); same.setMeasles1(statistics.get(0).getMeasles1()); same.setOPV1(statistics.get(0).getOPV1()); same.setOPV2(statistics.get(0).getOPV2()); same.setOPV3(statistics.get(0).getOPV3()); same.setVGBG24(statistics.get(0).getVGBG24()); same.setVGBL24(statistics.get(0).getVGBL24()); same.setProtectedTetanusCases(statistics.get(0).getProtectedTetanusCases()); same.setReactionNormalCases(statistics.get(0).getReactionNormalCases()); same.setReactionSeriousCases(statistics.get(0).getReactionSeriousCases()); same.seteBCG(statistics.get(0).geteBCG()); same.seteDPT_VGB_Hib1(statistics.get(0).geteDPT_VGB_Hib1()); same.seteDPT_VGB_Hib2(statistics.get(0).geteDPT_VGB_Hib2()); same.seteDPT_VGB_Hib3(statistics.get(0).geteDPT_VGB_Hib3()); same.seteMeasles1(statistics.get(0).geteMeasles1()); same.seteOPV1(statistics.get(0).geteOPV1()); same.seteOPV2(statistics.get(0).geteOPV2()); same.seteOPV3(statistics.get(0).geteOPV3()); same.seteVGBG24(statistics.get(0).geteVGBG24()); same.seteVGBL24(statistics.get(0).geteVGBL24()); statistics.add(same); String sql2 = this.buidlSQLforReport("commune", queryLocation, "strTimeFromY"); SQLQuery qry2 = getSession().createSQLQuery(sql2); qry2.setParameter("communeId", commune.getId()); qry2.setParameter("timeYear", year); qry2.setParameter("strTimeTo", strTimeTo); qry2.setParameter("strTimeFromY", strTimeFromY); qry2.addScalar("regionName", Hibernate.STRING); qry2.addScalar("childrenUnder1", Hibernate.INTEGER); qry2.addScalar("VGBL24", Hibernate.INTEGER); qry2.addScalar("VGBG24", Hibernate.INTEGER); qry2.addScalar("BCG", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib1", Hibernate.INTEGER); qry2.addScalar("OPV1", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib2", Hibernate.INTEGER); qry2.addScalar("OPV2", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib3", Hibernate.INTEGER); qry2.addScalar("OPV3", Hibernate.INTEGER); qry2.addScalar("measles1", Hibernate.INTEGER); qry2.addScalar("eVGBL24", Hibernate.INTEGER); qry2.addScalar("eVGBG24", Hibernate.INTEGER); qry2.addScalar("eBCG", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib1", Hibernate.INTEGER); qry2.addScalar("eOPV1", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib2", Hibernate.INTEGER); qry2.addScalar("eOPV2", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib3", Hibernate.INTEGER); qry2.addScalar("eOPV3", Hibernate.INTEGER); qry2.addScalar("eMeasles1", Hibernate.INTEGER); qry2.addScalar("protectedTetanusCases", Hibernate.INTEGER); qry2.addScalar("reactionNormalCases", Hibernate.INTEGER); qry2.addScalar("reactionSeriousCases", Hibernate.INTEGER); qry2.addScalar("amountOfFinish", Hibernate.INTEGER); qry2.setResultTransformer(Transformers.aliasToBean(RegionVaccinationReportData.class)); statistics.add((RegionVaccinationReportData) qry2.list().get(0)); } else if (district != null && statistics.size() > 0) { String sql2 = this.buidlSQLforReport("district", queryLocation, "strTimeFrom"); //log.debug(sql2); SQLQuery qry2 = getSession().createSQLQuery(sql2); qry2.setParameter("districtId", district.getId()); qry2.setParameter("timeYear", year); qry2.setParameter("strTimeFrom", strTimeFrom); qry2.setParameter("strTimeTo", strTimeTo); qry2.addScalar("regionName", Hibernate.STRING); qry2.addScalar("childrenUnder1", Hibernate.INTEGER); qry2.addScalar("VGBL24", Hibernate.INTEGER); qry2.addScalar("VGBG24", Hibernate.INTEGER); qry2.addScalar("BCG", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib1", Hibernate.INTEGER); qry2.addScalar("OPV1", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib2", Hibernate.INTEGER); qry2.addScalar("OPV2", Hibernate.INTEGER); qry2.addScalar("DPT_VGB_Hib3", Hibernate.INTEGER); qry2.addScalar("OPV3", Hibernate.INTEGER); qry2.addScalar("measles1", Hibernate.INTEGER); qry2.addScalar("eVGBL24", Hibernate.INTEGER); qry2.addScalar("eVGBG24", Hibernate.INTEGER); qry2.addScalar("eBCG", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib1", Hibernate.INTEGER); qry2.addScalar("eOPV1", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib2", Hibernate.INTEGER); qry2.addScalar("eOPV2", Hibernate.INTEGER); qry2.addScalar("eDPT_VGB_Hib3", Hibernate.INTEGER); qry2.addScalar("eOPV3", Hibernate.INTEGER); qry2.addScalar("eMeasles1", Hibernate.INTEGER); qry2.addScalar("protectedTetanusCases", Hibernate.INTEGER); qry2.addScalar("reactionNormalCases", Hibernate.INTEGER); qry2.addScalar("reactionSeriousCases", Hibernate.INTEGER); qry2.addScalar("amountOfFinish", Hibernate.INTEGER); qry2.setResultTransformer(Transformers.aliasToBean(RegionVaccinationReportData.class)); statistics.add((RegionVaccinationReportData) qry2.list().get(0)); String sql3 = this.buidlSQLforReport("district", queryLocation, "strTimeFromY"); //log.debug(sql3); SQLQuery qry3 = getSession().createSQLQuery(sql3); qry3.setParameter("districtId", district.getId()); qry3.setParameter("timeYear", year); qry3.setParameter("strTimeTo", strTimeTo); qry3.setParameter("strTimeFromY", strTimeFromY); qry3.addScalar("regionName", Hibernate.STRING); qry3.addScalar("childrenUnder1", Hibernate.INTEGER); qry3.addScalar("VGBL24", Hibernate.INTEGER); qry3.addScalar("VGBG24", Hibernate.INTEGER); qry3.addScalar("BCG", Hibernate.INTEGER); qry3.addScalar("DPT_VGB_Hib1", Hibernate.INTEGER); qry3.addScalar("OPV1", Hibernate.INTEGER); qry3.addScalar("DPT_VGB_Hib2", Hibernate.INTEGER); qry3.addScalar("OPV2", Hibernate.INTEGER); qry3.addScalar("DPT_VGB_Hib3", Hibernate.INTEGER); qry3.addScalar("OPV3", Hibernate.INTEGER); qry3.addScalar("measles1", Hibernate.INTEGER); qry3.addScalar("eVGBL24", Hibernate.INTEGER); qry3.addScalar("eVGBG24", Hibernate.INTEGER); qry3.addScalar("eBCG", Hibernate.INTEGER); qry3.addScalar("eDPT_VGB_Hib1", Hibernate.INTEGER); qry3.addScalar("eOPV1", Hibernate.INTEGER); qry3.addScalar("eDPT_VGB_Hib2", Hibernate.INTEGER); qry3.addScalar("eOPV2", Hibernate.INTEGER); qry3.addScalar("eDPT_VGB_Hib3", Hibernate.INTEGER); qry3.addScalar("eOPV3", Hibernate.INTEGER); qry3.addScalar("eMeasles1", Hibernate.INTEGER); qry3.addScalar("protectedTetanusCases", Hibernate.INTEGER); qry3.addScalar("reactionNormalCases", Hibernate.INTEGER); qry3.addScalar("reactionSeriousCases", Hibernate.INTEGER); qry3.addScalar("amountOfFinish", Hibernate.INTEGER); qry3.setResultTransformer(Transformers.aliasToBean(RegionVaccinationReportData.class)); statistics.add((RegionVaccinationReportData) qry3.list().get(0)); } log.debug("Report: " + statistics.size()); return statistics; }