List of usage examples for java.util Calendar clone
@Override
public Object clone()
From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java
private DefaultCategoryDataset getActivityMonthBarDataSet(String siteId, int width) { // LOG.info("Generating activityMonthBarDataSet"); SummaryActivityChartData sac = M_sm.getSummaryActivityChartData(siteId, StatsManager.VIEW_MONTH, StatsManager.CHARTTYPE_BAR); if (sac == null) return null; DefaultCategoryDataset activityMonthBarDataSet = new DefaultCategoryDataset(); String activity = msgs.getString("legend_activity"); Day day;/*from www . ja va 2s . c om*/ Calendar cal = Calendar.getInstance(); cal.setTime(sac.getFirstDay()); Calendar currDay = (Calendar) cal.clone(); long activityData[] = sac.getActivity(); for (int i = 0; i < activityData.length; i++) { int dayOfMonth = currDay.get(Calendar.DAY_OF_MONTH); //if(params.areAllDaysDrawable() || (i == 0 || i == 30 - 1 || i % 2 == 0)){ if (canUseNormalFontSize(width) || (i == 0 || i == 30 - 1 || i % 2 == 0)) { day = new Day(dayOfMonth, Integer.toString(dayOfMonth)); } else { day = new Day(dayOfMonth, ""); } activityMonthBarDataSet.addValue(activityData[i], activity, day); currDay.add(Calendar.DAY_OF_MONTH, 1); } return activityMonthBarDataSet; }
From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java
private DefaultCategoryDataset getVisitsMonthDataSet(String siteId, int width) { // LOG.info("Generating visitsMonthDataSet"); SummaryVisitsChartData svc = M_sm.getSummaryVisitsChartData(siteId, StatsManager.VIEW_MONTH); if (svc == null) return null; DefaultCategoryDataset visitsMonthDataSet = new DefaultCategoryDataset(); String visits = msgs.getString("legend_visits"); String uniqueVisits = msgs.getString("legend_unique_visitors"); Day day;/* w ww . j a v a 2 s . c om*/ Calendar cal = Calendar.getInstance(); cal.setTime(svc.getFirstDay()); Calendar currDay = (Calendar) cal.clone(); long visitsData[] = svc.getVisits(); long uniqueVisitsData[] = svc.getUniqueVisits(); for (int i = 0; i < visitsData.length; i++) { int dayOfMonth = currDay.get(Calendar.DAY_OF_MONTH); if (canUseNormalFontSize(width) || (i == 0 || i == 30 - 1 || i % 2 == 0)) { day = new Day(dayOfMonth, Integer.toString(dayOfMonth)); } else { day = new Day(dayOfMonth, ""); } visitsMonthDataSet.addValue(visitsData[i], visits, day); visitsMonthDataSet.addValue(uniqueVisitsData[i], uniqueVisits, day); currDay.add(Calendar.DAY_OF_MONTH, 1); } return visitsMonthDataSet; }
From source file:tw.edu.chit.struts.action.language.ReportPrintAction.java
/** * ?/*from ww w .java2 s. co m*/ * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") private void printDeptStdSkillList4(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); AdminManager am = (AdminManager) getBean(IConstants.ADMIN_MANAGER_BEAN_NAME); MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME); Member member = (Member) getUserCredential(session).getMember(); Empl empl = mm.findEmplByOid(member.getOid()); ServletContext context = request.getSession().getServletContext(); DateFormat df = new SimpleDateFormat("yyyy/MM/dd"); Calendar cal = Calendar.getInstance(); Calendar cal1 = (Calendar) cal.clone(); Calendar cal2 = (Calendar) cal.clone(); if (StringUtils.isNotBlank(form.getString("licenseValidDateStart")) || StringUtils.isNotBlank(form.getString("licenseValidDateEnd"))) { Date from = StringUtils.isBlank(form.getString("licenseValidDateStart")) ? null : Toolket.parseNativeDate(form.getString("licenseValidDateStart")); // ??? Date to = StringUtils.isBlank(form.getString("licenseValidDateEnd")) ? Calendar.getInstance().getTime() : Toolket.parseNativeDate(form.getString("licenseValidDateEnd")); cal1.setTime(from); cal1.set(Calendar.HOUR_OF_DAY, 0); cal1.set(Calendar.MINUTE, 0); cal1.set(Calendar.SECOND, 0); cal1.set(Calendar.MILLISECOND, 0); cal2.setTime(to); cal2.set(Calendar.HOUR_OF_DAY, 23); cal2.set(Calendar.MINUTE, 59); cal2.set(Calendar.SECOND, 59); cal2.set(Calendar.MILLISECOND, 999); } String hql = "SELECT COUNT(*), SUM(s.amount), s FROM StdSkill s WHERE s.deptNo = ? " + "AND s.amountDate IS NOT NULL AND s.licenseValidDate BETWEEN ? AND ? " + "GROUP BY s.licenseCode"; List<Object> ret = (List<Object>) am.find(hql, new Object[] { "0", cal1.getTime(), cal2.getTime() }); // HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("?"); sheet.setColumnWidth(0, 1500); sheet.setColumnWidth(1, 3000); sheet.setColumnWidth(2, 10000); sheet.setColumnWidth(3, 3000); sheet.setColumnWidth(4, 5000); sheet.setColumnWidth(5, 2400); sheet.setColumnWidth(6, 8000); sheet.setColumnWidth(7, 1800); sheet.setColumnWidth(8, 2200); sheet.setColumnWidth(9, 2400); sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9)); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFFont fontSize10 = workbook.createFont(); fontSize10.setFontHeightInPoints((short) 10); fontSize10.setFontName("Arial Unicode MS"); // Header Toolket.setCellValue(workbook, sheet, 0, 0, "?" + Toolket.getEmpUnit(empl.getUnit()) + "? (" + df.format(cal1.getTime()) + "~" + df.format(cal2.getTime()) + ")", fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null); // Column Header Toolket.setCellValue(workbook, sheet, 1, 0, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 1, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 2, "??", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 3, "/", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 4, "/", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 5, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 6, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 7, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 8, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 9, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); int index = 2, totals = 0, sum = 0; StdSkill skill = null; List<LicenseCode> codes = null; List<LicenseCode961> code961s = null; LicenseCode code = null; LicenseCode961 code961 = null; Object[] data = null; for (Object o : ret) { data = (Object[]) o; totals += (Integer) data[0]; sum += (Integer) data[1]; skill = (StdSkill) data[2]; Toolket.setCellValue(workbook, sheet, index, 0, String.valueOf(index - 1), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 7, ((Integer) data[0]).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 8, skill.getAmount().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 9, ((Integer) data[1]).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); codes = (List<LicenseCode>) am .findLicenseCodesBy(new LicenseCode(Integer.valueOf(skill.getLicenseCode()))); if (!codes.isEmpty()) { code = codes.get(0); Toolket.setCellValue(workbook, sheet, index, 1, code.getCode().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 2, code.getName(), fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); Toolket.setCellValue(workbook, sheet, index, 3, code.getLocale().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 4, code.getLevel(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 5, code.getType().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 6, code.getDeptName(), fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); } else { code961s = (List<LicenseCode961>) am .findLicenseCode961sBy(new LicenseCode961(Integer.valueOf(skill.getLicenseCode()))); if (!code961s.isEmpty()) { code961 = code961s.get(0); Toolket.setCellValue(workbook, sheet, index, 1, code961.getCode().toString(), fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); Toolket.setCellValue(workbook, sheet, index, 2, code961.getName(), fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); Toolket.setCellValue(workbook, sheet, index, 3, code961.getLocale().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 4, code961.getLevel(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 5, code961.getType().toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 6, code961.getDeptName(), fontSize10, HSSFCellStyle.ALIGN_LEFT, true, null); } } index++; } Toolket.setCellValue(workbook, sheet, index, 6, "?", fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null); Toolket.setCellValue(workbook, sheet, index, 7, String.valueOf(totals), fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null); Toolket.setCellValue(workbook, sheet, index, 9, String.valueOf(sum), fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null); File tempDir = new File( context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, "DeptStdSkillList4.xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); }
From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java
/** * Returns the specified amount of most current entries, starting from the current date.<p> * //from w w w . j a va 2 s. com * The result is sorted by the start date of the entries, ascending.<p> * * @param count the amount of entries to return * @return the most current entries */ public List getMostCurrentEntries(int count) { List result = new ArrayList(count); // determine start date Calendar startDay = new GregorianCalendar(getJsp().getRequestContext().getLocale()); startDay.setTimeInMillis(System.currentTimeMillis()); startDay = setDayTime(startDay, 0, 0, 0); // determine current view range Calendar endDay = (GregorianCalendar) startDay.clone(); endDay.add(Calendar.YEAR, 30); List viewDates = new ArrayList(1); CmsCalendarEntryDate viewDate = new CmsCalendarEntryDate(startDay, setDayTime(endDay, 23, 59, 59)); viewDates.add(viewDate); // create the simple view CmsCalendarViewSimple calendarView = new CmsCalendarViewSimple(viewDates); Iterator i = getEntries().iterator(); while (i.hasNext()) { CmsCalendarEntry entry = (CmsCalendarEntry) i.next(); if (entry.getEntryDate().isSerialDate()) { // serial date, create entry clones for every future occurance CmsCalendarEntryDateSerial serialDate = (CmsCalendarEntryDateSerial) entry.getEntryDate(); result.addAll(serialDate.matchCalendarView(entry, calendarView, count)); } else if (entry.getEntryDate().getStartDate().getTimeInMillis() > startDay.getTimeInMillis()) { // common entry that is in the future, add it to result result.add(entry); } } // sort the collected entries by date ascending calendarView.sort(result); if ((count > 0) && (result.size() > count)) { // cut off all items > count result = result.subList(0, count); } return result; }
From source file:com.espertech.esper.schedule.ScheduleComputeHelper.java
private static int determineDayOfMonth(ScheduleSpec spec, Calendar after, ScheduleCalendar result) { SortedSet<Integer> daysOfMonthSet = spec.getUnitValues().get(ScheduleUnit.DAYS_OF_MONTH); SortedSet<Integer> daysOfWeekSet = spec.getUnitValues().get(ScheduleUnit.DAYS_OF_WEEK); SortedSet<Integer> secondsSet = spec.getUnitValues().get(ScheduleUnit.SECONDS); SortedSet<Integer> minutesSet = spec.getUnitValues().get(ScheduleUnit.MINUTES); SortedSet<Integer> hoursSet = spec.getUnitValues().get(ScheduleUnit.HOURS); int dayOfMonth; // If days of week is a wildcard, just go by days of month if (spec.getOptionalDayOfMonthOperator() != null || spec.getOptionalDayOfWeekOperator() != null) { boolean isWeek = false; CronParameter op = spec.getOptionalDayOfMonthOperator(); if (spec.getOptionalDayOfMonthOperator() == null) { op = spec.getOptionalDayOfWeekOperator(); isWeek = true;//from www.j a va 2s .com } // may return the current day or a future day in the same month, // and may advance the "after" date to the next month int currentYYMMDD = getTimeYYYYMMDD(after); increaseAfterDayOfMonthSpecialOp(op.getOperator(), op.getDay(), op.getMonth(), isWeek, after); int rolledYYMMDD = getTimeYYYYMMDD(after); // if rolled then reset time portion if (rolledYYMMDD > currentYYMMDD) { result.setSecond(nextValue(secondsSet, 0)); result.setMinute(nextValue(minutesSet, 0)); result.setHour(nextValue(hoursSet, 0)); return after.get(Calendar.DAY_OF_MONTH); } // rolling backwards is not allowed else if (rolledYYMMDD < currentYYMMDD) { throw new IllegalStateException( "Failed to evaluate special date op, rolled date less then current date"); } else { Calendar work = (Calendar) after.clone(); work.set(Calendar.SECOND, result.getSecond()); work.set(Calendar.MINUTE, result.getMinute()); work.set(Calendar.HOUR_OF_DAY, result.getHour()); if (!work.after(after)) { // new date is not after current date, so bump after.add(Calendar.DAY_OF_MONTH, 1); result.setSecond(nextValue(secondsSet, 0)); result.setMinute(nextValue(minutesSet, 0)); result.setHour(nextValue(hoursSet, 0)); increaseAfterDayOfMonthSpecialOp(op.getOperator(), op.getDay(), op.getMonth(), isWeek, after); } return after.get(Calendar.DAY_OF_MONTH); } } else if (daysOfWeekSet == null) { dayOfMonth = nextValue(daysOfMonthSet, after.get(Calendar.DAY_OF_MONTH)); if (dayOfMonth != after.get(Calendar.DAY_OF_MONTH)) { result.setSecond(nextValue(secondsSet, 0)); result.setMinute(nextValue(minutesSet, 0)); result.setHour(nextValue(hoursSet, 0)); } if (dayOfMonth == -1) { dayOfMonth = nextValue(daysOfMonthSet, 0); after.add(Calendar.MONTH, 1); } } // If days of weeks is not a wildcard and days of month is a wildcard, go by days of week only else if (daysOfMonthSet == null) { // Loop to find the next day of month that works for the specified day of week values while (true) { dayOfMonth = after.get(Calendar.DAY_OF_MONTH); int dayOfWeek = after.get(Calendar.DAY_OF_WEEK) - 1; // If the day matches neither the day of month nor the day of week if (!daysOfWeekSet.contains(dayOfWeek)) { result.setSecond(nextValue(secondsSet, 0)); result.setMinute(nextValue(minutesSet, 0)); result.setHour(nextValue(hoursSet, 0)); after.add(Calendar.DAY_OF_MONTH, 1); } else { break; } } } // Both days of weeks and days of month are not a wildcard else { // Loop to find the next day of month that works for either day of month OR day of week while (true) { dayOfMonth = after.get(Calendar.DAY_OF_MONTH); int dayOfWeek = after.get(Calendar.DAY_OF_WEEK) - 1; // If the day matches neither the day of month nor the day of week if ((!daysOfWeekSet.contains(dayOfWeek)) && (!daysOfMonthSet.contains(dayOfMonth))) { result.setSecond(nextValue(secondsSet, 0)); result.setMinute(nextValue(minutesSet, 0)); result.setHour(nextValue(hoursSet, 0)); after.add(Calendar.DAY_OF_MONTH, 1); } else { break; } } } return dayOfMonth; }
From source file:org.tsaap.lti.tp.ResourceLink.java
/** * Set the date/time when the resource link was created. * * @param created date/time of creation/*from w w w .ja v a 2 s . c om*/ */ public void setCreated(Calendar created) { if (created != null) { this.created = (Calendar) created.clone(); } else { this.created = null; } }
From source file:org.tsaap.lti.tp.ResourceLink.java
/** * Set the date/time when the resource link was last updated. * * @param updated date/time of last update *//*from ww w. j av a2 s .c o m*/ public void setUpdated(Calendar updated) { if (updated != null) { this.updated = (Calendar) updated.clone(); } else { this.updated = null; } }
From source file:org.apache.stratos.usage.api.TenantUsageRetriever.java
public RequestStatistics[] getRequestStatistics(int tenantId, Calendar startDate, Calendar endDate, boolean currentMonth) throws Exception { RequestStatistics[] stats;//from w w w . j ava 2s. c om if (currentMonth) { //get from daily usage stats List<RequestStatistics> rsList = new ArrayList<RequestStatistics>(); rsList = dao.getDailyRequestStats(tenantId, startDate, endDate); //next we'll get from the houlry stats to get the stats which are not yet //summarized to the daily stats table Calendar startHour = Calendar.getInstance(); startHour.set(Calendar.HOUR, 0); startHour.set(Calendar.MINUTE, 0); startHour.set(Calendar.SECOND, 0); Calendar endHour = Calendar.getInstance(); rsList.addAll(dao.getHourlyRequestStats(tenantId, startHour, endHour)); stats = convertRSListToArray(rsList); } else { //get from monthly usage stats Calendar monthCal = (Calendar) endDate.clone(); monthCal.set(Calendar.DATE, 0); monthCal.set(Calendar.HOUR, 0); monthCal.set(Calendar.MINUTE, 0); monthCal.set(Calendar.SECOND, 0); stats = convertRSListToArray(dao.getMonthlyRequestStats(tenantId, monthCal)); } // store the statistics in a temporary map. This is because, we are getting the server name // from the URL and there might be two distinct URL gives same server name. // For example, http://esb.a.b/ and http://esb.c.d/ both will give the server name as "esb" // Hence, the value should be accumulated value HashMap<String, RequestStatistics> tempReqStatMap = new HashMap<String, RequestStatistics>(); if (stats != null) { for (RequestStatistics stat : stats) { //Proceed only if request count is not zero if (stat.getRequestCount() == 0) { continue; } String serverName = extractServiceNameFromUrl(stat.getKey()); //find whether the map already has this key; If not, insert a new one RequestStatistics reqStat = tempReqStatMap.get(serverName); if (reqStat == null) { reqStat = new RequestStatistics(serverName); tempReqStatMap.put(serverName, reqStat); } // Update the service specific statistics reqStat.setRequestCount(reqStat.getRequestCount() + stat.getRequestCount()); reqStat.setResponseCount(reqStat.getResponseCount() + stat.getResponseCount()); reqStat.setFaultCount(reqStat.getFaultCount() + stat.getFaultCount()); } } //Convert to array and return it Collection<RequestStatistics> values = tempReqStatMap.values(); return values.toArray(new RequestStatistics[values.size()]); }
From source file:com.frameworkset.platform.sanylog.action.CounterController.java
/** * ?//from w ww .j a va 2 s . co m * @param type week:7days:7month:30days:30 * @return String * @throws Exception */ @SuppressWarnings("rawtypes") public @ResponseBody String showBrowserCounterDayDistribute(int siteId, String type, String startTime, String endTime) throws Exception { String caption = "?"; String subCaption = ""; Calendar startDate = Calendar.getInstance(); Calendar endDate = Calendar.getInstance(); int addDay = 0; if ("week".equals(type)) { int offset = startDate.get(Calendar.DAY_OF_WEEK); startDate.add(Calendar.DAY_OF_MONTH, offset - (offset * 2 - 1)); endDate = (Calendar) startDate.clone(); endDate.add(Calendar.DAY_OF_MONTH, 6); addDay = 6; subCaption = ""; } else if ("7days".equals(type)) { startDate.add(Calendar.DAY_OF_MONTH, -6); addDay = 6; subCaption = "7"; } else if ("month".equals(type)) { int offset = startDate.get(Calendar.DAY_OF_MONTH); startDate.add(Calendar.DAY_OF_MONTH, offset - (offset * 2 - 1)); endDate = (Calendar) startDate.clone(); endDate.add(Calendar.MONTH, 1); endDate.add(Calendar.DAY_OF_MONTH, -1); addDay = startDate.getActualMaximum(Calendar.DAY_OF_MONTH) - startDate.getActualMinimum(Calendar.DAY_OF_MONTH); subCaption = ""; } else if ("30days".equals(type)) { startDate.add(Calendar.DAY_OF_MONTH, -29); addDay = 29; subCaption = "30"; } List<Calendar> calendarList = new ArrayList<Calendar>(); for (int i = 0; i <= addDay; i++) { Calendar tempStartDate = (Calendar) startDate.clone(); tempStartDate.add(Calendar.DAY_OF_MONTH, i); calendarList.add(tempStartDate); } if (StringUtil.isEmpty(startTime)) { startTime = DateUtils.format(startDate.getTime(), DateUtils.ISO8601_DATE_PATTERN); } if (StringUtil.isEmpty(endTime)) { endTime = DateUtils.format(endDate.getTime(), DateUtils.ISO8601_DATE_PATTERN); } List<HashMap> browserCounterDayDistribute = counterManager.getBrowserCounterDayDistribute(siteId, startTime, endTime); StringBuilder xml = new StringBuilder("<chart caption='").append(caption).append("' subCaption='") .append(subCaption) .append("' yMaxValue='100' bgColor='406181, 6DA5DB' bgAlpha='100' baseFontColor='FFFFFF' canvasBgAlpha='0' canvasBorderColor='FFFFFF' divLineColor='FFFFFF' divLineAlpha='100' numVDivlines='10' vDivLineisDashed='1' showAlternateVGridColor='1' lineColor='BBDA00' anchorRadius='4' anchorBgColor='BBDA00' anchorBorderColor='FFFFFF' anchorBorderThickness='2' showValues='0' toolTipBgColor='406181' toolTipBorderColor='406181' alternateHGridAlpha='5'>"); if (!CollectionUtils.isEmpty(browserCounterDayDistribute)) { for (Calendar calendar : calendarList) { int vday = calendar.get(Calendar.DAY_OF_MONTH); int vcount = 0; for (HashMap map : browserCounterDayDistribute) { if (vday == Integer.parseInt(map.get("VDAY").toString())) { vcount = Integer.parseInt(map.get("VCOUNT").toString()); break; } } xml.append("<set label='").append(vday).append("' value='").append(vcount).append("' />"); } xml.append( "<styles><definition><style name='LineShadow' type='shadow' color='333333' distance='6'/></definition><application><apply toObject='DATAPLOT' styles='LineShadow' /></application></styles></chart> "); } return xml.toString(); }
From source file:tw.edu.chit.struts.action.language.ReportPrintAction.java
/** * //w w w . ja v a 2 s. c o m * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") private void printDeptStdSkillList3(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); AdminManager am = (AdminManager) getBean(IConstants.ADMIN_MANAGER_BEAN_NAME); MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME); Member member = (Member) getUserCredential(session).getMember(); Empl empl = mm.findEmplByOid(member.getOid()); ServletContext context = request.getSession().getServletContext(); Calendar cal = Calendar.getInstance(); Calendar cal1 = (Calendar) cal.clone(); Calendar cal2 = (Calendar) cal.clone(); if (StringUtils.isNotBlank(form.getString("licenseValidDateStart")) || StringUtils.isNotBlank(form.getString("licenseValidDateEnd"))) { Date from = StringUtils.isBlank(form.getString("licenseValidDateStart")) ? null : Toolket.parseNativeDate(form.getString("licenseValidDateStart")); // ??? Date to = StringUtils.isBlank(form.getString("licenseValidDateEnd")) ? Calendar.getInstance().getTime() : Toolket.parseNativeDate(form.getString("licenseValidDateEnd")); cal1.setTime(from); cal1.set(Calendar.HOUR_OF_DAY, 0); cal1.set(Calendar.MINUTE, 0); cal1.set(Calendar.SECOND, 0); cal1.set(Calendar.MILLISECOND, 0); cal2.setTime(to); cal2.set(Calendar.HOUR_OF_DAY, 23); cal2.set(Calendar.MINUTE, 59); cal2.set(Calendar.SECOND, 59); cal2.set(Calendar.MILLISECOND, 999); } String hql = "SELECT COUNT(*) CT, ss.licenseValidDate LVD, ss.licenseCode LC, " + "s.depart_class DC1, s.sex S1, gs.depart_class DC2, gs.sex S2 " + "FROM StdSkill ss LEFT JOIN stmd s ON ss.studentNo = s.student_no " + "LEFT JOIN Gstmd gs ON ss.studentNo = gs.student_no " + "WHERE ss.deptNo = ? AND ss.licenseValidDate BETWEEN ? AND ? " + "GROUP BY ss.licenseValidDate, s.depart_class, s.sex, " + "gs.depart_class, gs.sex " + "ORDER BY ss.licenseValidDate, s.depart_class, " + "s.sex, gs.depart_class, gs.sex"; List<Map> ret = (List<Map>) am.findBySQL(hql, new Object[] { "0", cal1.getTime(), cal2.getTime() }); // DateFormat df = new SimpleDateFormat("yyyy/MM/dd"); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(""); sheet.setColumnWidth(0, 1800); sheet.setColumnWidth(1, 2000); sheet.setColumnWidth(2, 2000); sheet.setColumnWidth(3, 3000); sheet.setColumnWidth(4, 5000); sheet.setColumnWidth(5, 3000); sheet.setColumnWidth(6, 8000); sheet.setColumnWidth(7, 3000); sheet.setColumnWidth(8, 4000); sheet.setColumnWidth(9, 2200); sheet.setColumnWidth(10, 2200); sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 10)); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFFont fontSize10 = workbook.createFont(); fontSize10.setFontHeightInPoints((short) 10); fontSize10.setFontName("Arial Unicode MS"); // Header Toolket.setCellValue(workbook, sheet, 0, 0, "?" + Toolket.getEmpUnit(empl.getUnit()) + " (" + df.format(cal1.getTime()) + "~" + df.format(cal2.getTime()) + ")", fontSize12, HSSFCellStyle.ALIGN_CENTER, false, 35.0F, null); // Column Header Toolket.setCellValue(workbook, sheet, 1, 0, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 1, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 2, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 3, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 4, "?", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 5, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 6, "??", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 7, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 8, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 9, "()", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, 1, 10, "()", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); // Toolket.setCellValue(workbook, sheet, 1, 11, "?", fontSize10, // HSSFCellStyle.ALIGN_CENTER, true, null); int index = 2; boolean isGraduate = false; String departClass = null; List<LicenseCode> codes = null; List<LicenseCode961> code961s = null; List<DeptCode4Yun> yuns = null; LicenseCode code = null; LicenseCode961 code961 = null; DeptCode4Yun yun = null; Example example = null; for (Map data : ret) { Toolket.setCellValue(workbook, sheet, index, 0, String.valueOf(index - 1), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); if (data.get("DC1") != null) { departClass = (String) data.get("DC1"); isGraduate = false; } else { departClass = (String) data.get("DC2"); isGraduate = true; } yun = new DeptCode4Yun(); yun.setClassNo(StringUtils.substring(departClass, 0, 4)); example = Example.create(yun).ignoreCase().enableLike(MatchMode.START); yuns = (List<DeptCode4Yun>) am.findSQLWithCriteria(DeptCode4Yun.class, example, null, null); if (!yuns.isEmpty() && yuns.size() == 1) { yun = yuns.get(0); Toolket.setCellValue(workbook, sheet, index, 1, yun.getDeptCode(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 2, yun.getCampusCode(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 3, yun.getCampusName(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } Toolket.setCellValue(workbook, sheet, index, 4, Toolket.getClassFullName(departClass), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 5, (String) data.get("LC"), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); codes = (List<LicenseCode>) am .findLicenseCodesBy(new LicenseCode(Integer.valueOf((String) data.get("LC")))); if (!codes.isEmpty()) { code = codes.get(0); Toolket.setCellValue(workbook, sheet, index, 6, code.getName(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 7, code.getLevel(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } else { code961s = (List<LicenseCode961>) am .findLicenseCode961sBy(new LicenseCode961(Integer.valueOf((String) data.get("LC")))); if (!code961s.isEmpty()) { code961 = code961s.get(0); Toolket.setCellValue(workbook, sheet, index, 6, code961.getName(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 7, code961.getLevel(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } } Toolket.setCellValue(workbook, sheet, index, 8, df.format((Date) data.get("LVD")), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); if (!isGraduate) { if ("1".equals((String) data.get("S1"))) { Toolket.setCellValue(workbook, sheet, index, 9, ((Long) data.get("CT")).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 10, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } else if ("2".equals((String) data.get("S1"))) { Toolket.setCellValue(workbook, sheet, index, 9, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 10, ((Long) data.get("CT")).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } } else { if ("1".equals((String) data.get("S2"))) { Toolket.setCellValue(workbook, sheet, index, 9, ((Long) data.get("CT")).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 10, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } else if ("2".equals((String) data.get("S2"))) { Toolket.setCellValue(workbook, sheet, index, 9, "", fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); Toolket.setCellValue(workbook, sheet, index, 10, ((Long) data.get("CT")).toString(), fontSize10, HSSFCellStyle.ALIGN_CENTER, true, null); } } index++; // Toolket.setCellValue(workbook, sheet, index++, 11, ((Long) m // .get("CT")).toString(), fontSize10, // HSSFCellStyle.ALIGN_CENTER, true, null); } File tempDir = new File( context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, "DeptStdSkillList3.xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); }