List of usage examples for java.sql Date valueOf
@SuppressWarnings("deprecation") public static Date valueOf(LocalDate date)
From source file:org.openlmis.core.view.fragment.VIARequisitionFragmentTest.java
@Before public void setup() throws Exception { presenter = mock(VIARequisitionPresenter.class); RoboGuice.overrideApplicationInjector(RuntimeEnvironment.application, new Module() { @Override//from w ww . ja va 2s . c o m public void configure(Binder binder) { binder.bind(VIARequisitionPresenter.class).toInstance(presenter); } }); program = new Program(); program.setProgramCode("ESS_MEDS"); program.setProgramName("ESS_MEDS"); form = RnRForm.init(program, DateUtil.today()); form.setPeriodBegin(Date.valueOf("2015-04-21")); form.setPeriodEnd(Date.valueOf("2015-05-20")); formItemList = new ArrayList<>(); formItemList.add(RequisitionBuilder.buildFakeRequisitionViewModel()); when(presenter.getRequisitionFormItemViewModels()).thenReturn(formItemList); when(presenter.getViaKitsViewModel()).thenReturn(new ViaKitsViewModel()); when(presenter.getRnRForm()).thenReturn(form); when(presenter.getRnrFormStatus()).thenReturn(RnRForm.STATUS.DRAFT); VIARequisitionFragment = getVIARequisitionFragmentFromActivityWithIntent(); }
From source file:nu.yona.server.batch.jobs.ActivityAggregationBatchJob.java
@Bean(name = "activityAggregationJobDayActivityReader", destroyMethod = "") @StepScope/*from w ww . j a v a 2s . c om*/ public ItemReader<Long> dayActivityReader() { return intervalActivityIdReader(Date.valueOf(TimeUtil .getStartOfDay(DEFAULT_TIME_ZONE, ZonedDateTime.now(DEFAULT_TIME_ZONE)).minusDays(1).toLocalDate()), DayActivity.class, DAY_ACTIVITY_CHUNK_SIZE); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.AuthorManagerImpl.java
@Override @Transactional(readOnly = false)/* w ww. j ava 2s. c o m*/ public void updateAuthor(Author author) { validate(author); if (author.getId() == null) { throw new IllegalArgumentException("author id is null"); } int updated = jdbcTemplate.update( "UPDATE author SET firstname = ?, surname = ?, description = ?, nationality = ?, dateofbirth = ? WHERE id = ?", author.getFirstname(), author.getSurname(), author.getDescription(), author.getNationality(), Date.valueOf(author.getDateOfBirth()), author.getId()); DBUtils.checkUpdatesCount(updated, author, false); }
From source file:org.apache.hadoop.hive.accumulo.AccumuloTestSetup.java
protected void createAccumuloTable(Connector conn) throws TableExistsException, TableNotFoundException, AccumuloException, AccumuloSecurityException { TableOperations tops = conn.tableOperations(); if (tops.exists(TABLE_NAME)) { tops.delete(TABLE_NAME);/*from w ww . j a v a 2s. com*/ } tops.create(TABLE_NAME); boolean[] booleans = new boolean[] { true, false, true }; byte[] bytes = new byte[] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE }; short[] shorts = new short[] { Short.MIN_VALUE, -1, Short.MAX_VALUE }; int[] ints = new int[] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE }; long[] longs = new long[] { Long.MIN_VALUE, -1, Long.MAX_VALUE }; String[] strings = new String[] { "Hadoop, Accumulo", "Hive", "Test Strings" }; float[] floats = new float[] { Float.MIN_VALUE, -1.0F, Float.MAX_VALUE }; double[] doubles = new double[] { Double.MIN_VALUE, -1.0, Double.MAX_VALUE }; HiveDecimal[] decimals = new HiveDecimal[] { HiveDecimal.create("3.14159"), HiveDecimal.create("2.71828"), HiveDecimal.create("0.57721") }; Date[] dates = new Date[] { Date.valueOf("2014-01-01"), Date.valueOf("2014-03-01"), Date.valueOf("2014-05-01") }; Timestamp[] timestamps = new Timestamp[] { new Timestamp(50), new Timestamp(100), new Timestamp(150) }; BatchWriter bw = conn.createBatchWriter(TABLE_NAME, new BatchWriterConfig()); final String cf = "cf"; try { for (int i = 0; i < 3; i++) { Mutation m = new Mutation("key-" + i); m.put(cf, "cq-boolean", Boolean.toString(booleans[i])); m.put(cf.getBytes(), "cq-byte".getBytes(), new byte[] { bytes[i] }); m.put(cf, "cq-short", Short.toString(shorts[i])); m.put(cf, "cq-int", Integer.toString(ints[i])); m.put(cf, "cq-long", Long.toString(longs[i])); m.put(cf, "cq-string", strings[i]); m.put(cf, "cq-float", Float.toString(floats[i])); m.put(cf, "cq-double", Double.toString(doubles[i])); m.put(cf, "cq-decimal", decimals[i].toString()); m.put(cf, "cq-date", dates[i].toString()); m.put(cf, "cq-timestamp", timestamps[i].toString()); bw.addMutation(m); } } finally { bw.close(); } }
From source file:com.selfsoft.baseinformation.service.impl.TbCarInfoServiceImpl.java
public List<TbCarInfo> findByTbCarInfo(TbCarInfo tbCarInfo) { DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TbCarInfo.class); if (null != tbCarInfo) { if (null != tbCarInfo.getId()) { detachedCriteria.add(Restrictions.eq("id", tbCarInfo.getId())); }//from w w w . j a va 2 s . co m if (null != tbCarInfo.getLicenseCode() && !"".equals(tbCarInfo.getLicenseCode())) { //? detachedCriteria.add(Restrictions.like("licenseCode", "%" + tbCarInfo.getLicenseCode() + "%")); } if (null != tbCarInfo.getInsureCardCode() && !"".equals(tbCarInfo.getInsureCardCode())) { detachedCriteria .add(Restrictions.like("insureCardCode", "%" + tbCarInfo.getInsureCardCode() + "%")); } if (null != tbCarInfo.getTmCarModelType()) { detachedCriteria.createAlias("tmCarModelType", "tmCarModelType"); if (null != tbCarInfo.getTmCarModelType().getId()) { detachedCriteria .add(Restrictions.eq("tmCarModelType.id", tbCarInfo.getTmCarModelType().getId())); } } if (null != tbCarInfo.getTbCustomer()) { detachedCriteria.createAlias("tbCustomer", "tbCustomer"); if (null != tbCarInfo.getTbCustomer().getId()) { detachedCriteria.add(Restrictions.eq("tbCustomer.id", tbCarInfo.getTbCustomer().getId())); } if (null != tbCarInfo.getTbCustomer().getCustomerCode()) { detachedCriteria.add(Restrictions.like("tbCustomer.customerCode", "%" + tbCarInfo.getTbCustomer().getCustomerCode() + "%")); } if (null != tbCarInfo.getTbCustomer().getCustomerName()) { detachedCriteria.add(Restrictions.like("tbCustomer.customerName", "%" + tbCarInfo.getTbCustomer().getCustomerName() + "%")); } if (null != tbCarInfo.getTbCustomer().getTelephone()) { detachedCriteria.add(Restrictions.like("tbCustomer.telephone", "%" + tbCarInfo.getTbCustomer().getTelephone() + "%")); } } if (StringUtils.isNotBlank(tbCarInfo.getBeginLicenseDate())) { detachedCriteria.add(Restrictions.ge("licenseDate", Date.valueOf(tbCarInfo.getBeginLicenseDate()))); } if (StringUtils.isNotBlank(tbCarInfo.getEndLicenseDate())) { detachedCriteria.add(Restrictions.le("licenseDate", Date.valueOf(tbCarInfo.getEndLicenseDate()))); } if (StringUtils.isNotBlank(tbCarInfo.getBeginPurchaseDate())) { detachedCriteria .add(Restrictions.ge("purchaseDate", Date.valueOf(tbCarInfo.getBeginPurchaseDate()))); } if (StringUtils.isNotBlank(tbCarInfo.getEndPurchaseDate())) { detachedCriteria.add(Restrictions.le("purchaseDate", Date.valueOf(tbCarInfo.getEndPurchaseDate()))); } if (StringUtils.isNotBlank(tbCarInfo.getChassisCode())) { detachedCriteria.add(Restrictions.like("chassisCode", "%" + tbCarInfo.getChassisCode() + "%")); } if (tbCarInfo.getCarProperty() != null) { detachedCriteria.add(Restrictions.eq("carProperty", tbCarInfo.getCarProperty())); } if (StringUtils.isNotBlank(tbCarInfo.getLicenseMonth())) { detachedCriteria .add(Restrictions.sqlRestriction("month(LICENSE_DATE)=" + tbCarInfo.getLicenseMonth())); } if (tbCarInfo.getMaxKilo() != null && tbCarInfo.getMinKilo() != null) { detachedCriteria.add(Restrictions.between("kilo", tbCarInfo.getMinKilo(), tbCarInfo.getMaxKilo())); } } return tbCarInfoDao.findByCriteria(detachedCriteria, tbCarInfo); }
From source file:org.rti.zcore.dar.report.ChooseReportAction.java
protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //log.debug("Starting Report:" + DateUtils.getTime()); HttpSession session = request.getSession(); SessionUtil zeprs_session = null;/*from w w w .j a va 2 s . c o m*/ try { zeprs_session = (SessionUtil) session.getAttribute("zeprs_session"); } catch (Exception e) { // unit testing - it's ok... } String task = ""; if (request.getParameter("task") != null) { task = request.getParameter("task"); } boolean isXml = false; if (request.getParameter("isXml") != null) { isXml = true; } boolean isCombinedReport = false; // For combined Monthly Reports for ARV and OI boolean isFacilityReport = false; // For combined Monthly Reports for ARV and OI boolean dynamicReport = false; // For combined Monthly Reports for ARV and OI if (request.getParameter("isCombinedReport") != null) { isCombinedReport = true; request.setAttribute("isCombinedReport", "1"); } if (request.getParameter("dynamicReport") != null) { dynamicReport = true; request.setAttribute("dynamicReport", "1"); } if (request.getParameter("isFacilityReport") != null) { isFacilityReport = true; request.setAttribute("isFacilityReport", "1"); } Report report = null; Register register = null; int reportID = 0; //int reportID = Integer.parseInt(((chooseReportForm) form).getReport()); if (request.getParameter("report") != null) { reportID = (Integer.valueOf(request.getParameter("report").toString())); } else { return mapping.findForward("reports"); } Date beginDate = null; Date endDate = null; if (request.getParameter("bdate") != null) { beginDate = Date.valueOf(String.valueOf(request.getParameter("bdate"))); } if (request.getParameter("edate") != null) { endDate = Date.valueOf(String.valueOf(request.getParameter("edate"))); } if (reportID == 10) { isCombinedReport = true; reportID = 5; } else if (reportID == 14) { dynamicReport = true; isCombinedReport = true; reportID = 5; } else if (reportID == 15) { dynamicReport = true; reportID = 5; } else if (reportID == 16) { dynamicReport = true; reportID = 6; } else if (reportID == 17) { dynamicReport = true; reportID = 7; } else if (reportID == 20) { isFacilityReport = false; isCombinedReport = true; reportID = 5; } /*if (isCombinedReport == true) { Calendar gc = new GregorianCalendar(); gc.setTime(endDate); int maxDate = gc.getActualMaximum(Calendar.DAY_OF_MONTH); int month = gc.get(Calendar.MONTH); int year = gc.get(Calendar.YEAR); gc.set(year, month, 0, 0, 0, 0); gc.add(Calendar.DAY_OF_MONTH, 1); Calendar monthEndCal = new GregorianCalendar(); monthEndCal.set(year, month, maxDate, 0, 0, 0); // re-assign values for begin/endDate beginDate = new Date(gc.getTime().getTime()); endDate = new Date(monthEndCal.getTime().getTime()); }*/ java.util.Calendar c = java.util.Calendar.getInstance(); c.add(java.util.Calendar.MONTH, -1); java.util.Date date1monthpast = c.getTime(); String DATE_FORMAT = "yyyy-MM-dd"; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT); sdf.setTimeZone(TimeZone.getDefault()); String date1monthpastStr = sdf.format(date1monthpast); java.sql.Date date1monthpastSql = java.sql.Date.valueOf(date1monthpastStr); // week behind - for defaulters report java.util.Calendar c2 = java.util.Calendar.getInstance(); c2.add(java.util.Calendar.WEEK_OF_YEAR, -1); java.util.Date date1weekpast = c2.getTime(); sdf.setTimeZone(TimeZone.getDefault()); String date1weekpastStr = sdf.format(date1weekpast); java.sql.Date date1weekpastSql = java.sql.Date.valueOf(date1weekpastStr); // week ahead java.util.Calendar c4 = java.util.Calendar.getInstance(); c4.add(java.util.Calendar.WEEK_OF_YEAR, +1); java.util.Date date1weekahead = c4.getTime(); java.text.SimpleDateFormat sdf2 = new java.text.SimpleDateFormat(DATE_FORMAT); sdf2.setTimeZone(TimeZone.getDefault()); String date1weekaheadStr = sdf2.format(date1weekahead); java.sql.Date date1weekaheadSql = java.sql.Date.valueOf(date1weekaheadStr); // Name of the forward to use - see ChooseReportAction in struts-config // Most of the reports have thier own jsp page. Name sets the name of this file. String name = "none"; // int siteId = ((chooseReportForm) form).getSiteId(); int siteId = 0; if (request.getParameter("siteId") != null) { siteId = (Integer.valueOf(request.getParameter("siteId").toString())); } // boolean isXml= ((chooseReportForm) form).isXml(); String siteName; if (siteId == 0) { siteName = "All sites"; } else { Site site = (Site) DynaSiteObjects.getClinicMap().get((long) siteId); siteName = site.getName(); } request.setAttribute("siteId", siteId); request.setAttribute("siteName", siteName); List records = new ArrayList(); String abbrev = "enc"; Class clazz = EncounterData.class; java.sql.Date dateNow = DateUtils.getNow(); request.setAttribute("dateNow", dateNow); request.setAttribute("bdate", beginDate); request.setAttribute("edate", endDate); Principal user = request.getUserPrincipal(); String username = user.getName(); ReportCreator reportCreator = new ReportCreator(); reportCreator.setUsernameR(username); System.out.println("Report Id " + reportID); switch (reportID) { /**/ case 1: System.out.println("OIDailyActivityReport"); register = new DailyActivityReport(); register.setType("OIDailyActivityReport"); register.setSiteName(siteName); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); request.setAttribute("register", register); name = "OIDailyActivityReport"; abbrev = "OIDAR"; clazz = DailyActivityReport.class; break; case 2: System.out.println("ARTAdultDailyActivityReport"); register = new DailyActivityReport(); register.setType("ARTAdultDailyActivityReport"); register.setSiteName(siteName); register.getPatientRegister(beginDate, endDate, siteId); System.out.println("BAck from Database"); register.setBeginDate(beginDate); register.setEndDate(endDate); request.setAttribute("register", register); name = "ARTAdultDailyActivityReport"; abbrev = "ARTADAR"; clazz = DailyActivityReport.class; break; case 3: System.out.println("OIDailyActivityReport"); register = new DailyActivityReport(); register.setType("ARTChildDailyActivityReport"); register.setSiteName(siteName); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); request.setAttribute("register", register); name = "ARTChildDailyActivityReport"; abbrev = "ARTCDAR"; clazz = DailyActivityReport.class; break; /* case 4: register = new OIARTAdultDailyActivityReport(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); request.setAttribute("register", register); name = "OIARTAdultDailyActivityReport"; abbrev = "OIARTADAR"; clazz = OIARTAdultDailyActivityReport.class; break;*/ case 5: System.out.println("CDRRArtReport"); //register = new CDRRArtReport(); register = new DailyActivityReport(); /*if (dynamicReport == true) { request.setAttribute("dynamicReport", "1"); register.setDynamicReport(true); }*/ register.setType("CDRRArtReport"); register.setSiteName(siteName); register.setReportCreator(reportCreator); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); ClientSettings clientSettings = zeprs_session.getClientSettings(); Site site = clientSettings.getSite(); String siteAbbrev = site.getAbbreviation(); int i = 1; String reportFileName = "CDRRArtReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; String path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; // check if file exists File f = new File(path); while (f.exists()) { i++; reportFileName = "CDRRArtReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; f = new File(path); } register.setReportFileName(reportFileName); register.setReportPath(path); request.setAttribute("register", register); if (isCombinedReport == true) { request.setAttribute("isCombinedReport", "1"); } if (isFacilityReport == true) { request.setAttribute("isFacilityReport", "1"); } name = "CDRRArtReport"; abbrev = "CDRRArt"; //clazz = CDRRArtReport.class; SessionUtil.getInstance(session).getReports().put(name, register); break; case 6: System.out.println("print"); register = new MonthlyArtReport(); /*if (dynamicReport == true) { request.setAttribute("dynamicReport", "1"); register.setDynamicReport(true); }*/ register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); clientSettings = zeprs_session.getClientSettings(); site = clientSettings.getSite(); siteAbbrev = site.getAbbreviation(); i = 1; reportFileName = "MonthlyArtReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; // check if file exists f = new File(path); while (f.exists()) { i++; reportFileName = "MonthlyArtReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; f = new File(path); } register.setReportFileName(reportFileName); register.setReportPath(path); request.setAttribute("register", register); name = "MonthlyArtReport"; abbrev = "MART"; clazz = MonthlyArtReport.class; SessionUtil.getInstance(session).getReports().put(name, register); break; case 7: //register = new CDRROIReport(); System.out.println("CDRROIReport"); register = new DailyActivityReport(); register.setType("CDRROIReport"); /*if (dynamicReport == true) { request.setAttribute("dynamicReport", "1"); register.setDynamicReport(true); }*/ register.setSiteName(siteName); register.setReportCreator(reportCreator); register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); clientSettings = zeprs_session.getClientSettings(); site = clientSettings.getSite(); siteAbbrev = site.getAbbreviation(); i = 1; reportFileName = "CDRROIReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; // check if file exists f = new File(path); while (f.exists()) { i++; reportFileName = "CDRROIReport" + "-" + siteAbbrev + "-" + username + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; f = new File(path); } register.setReportFileName(reportFileName); register.setReportPath(path); request.setAttribute("register", register); name = "CDRROIReport"; abbrev = "CDRROI"; clazz = CDRROIReport.class; SessionUtil.getInstance(session).getReports().put(name, register); break; case 8: System.out.println("8 AppointmentRegister"); register = new AppointmentRegister(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); if (beginDate == null) { beginDate = dateNow; } if (endDate == null) { endDate = date1weekaheadSql; } register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); request.setAttribute("register", register); name = "AppointmentRegister"; abbrev = "APPREG"; clazz = AppointmentRegister.class; break; case 9: System.out.println("9+ DefaultersRegister"); System.out.println("9+ DefaultersRegister"); register = new DefaultersRegister(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); if (beginDate == null) { beginDate = date1weekpastSql; } if (endDate == null) { endDate = dateNow; } register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); request.setAttribute("register", register); name = "DefaultersRegister"; abbrev = "DEFREG"; clazz = DefaultersRegister.class; break; case 11: System.out.println("9+SiteStatisticsReport"); register = new SiteStatisticsReport(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); if (beginDate == null) { beginDate = date1monthpastSql; } if (endDate == null) { endDate = dateNow; } register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); request.setAttribute("register", register); name = "SiteStatisticsReport"; abbrev = "SSR"; clazz = SiteStatisticsReport.class; break; case 12: System.out.println("12+StockUsageReport"); register = new StockUsageReport(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); clientSettings = zeprs_session.getClientSettings(); site = clientSettings.getSite(); siteAbbrev = site.getAbbreviation(); i = 1; reportFileName = "Monthly Drug Usage Report" + "-" + siteName.trim() + "-" + username.trim() + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; // check if file exists f = new File(path); while (f.exists()) { i++; reportFileName = "Monthly Drug Usage Report" + "-" + siteName.trim() + "-" + username.trim() + "-" + DateUtils.getNowPretty() + "-" + i; path = Constants.ARCHIVE_PATH + site.getAbbreviation() + Constants.pathSep + "reports" + Constants.pathSep + reportFileName + ".xls"; f = new File(path); } beginDate = Date.valueOf("1900-01-01"); endDate = DateUtils.getNow(); register.setReportFileName(reportFileName); register.setReportPath(path); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); try { register.getPatientRegister(beginDate, endDate, siteId); } catch (Exception e) { e.printStackTrace(); request.setAttribute("exception", e); return mapping.findForward("error"); } request.setAttribute("register", register); name = "StockUsageReport"; if ((!register.getType().equals("error")) && (!register.getType().equals("empty"))) { /* response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=" + path);*/ //return(null); request.setAttribute("message", "Report saved at "); request.setAttribute("path", path); } else if (register.getType().equals("empty")) { request.setAttribute("exception", "There was were not any stock transactions to generate this report."); return mapping.findForward("error"); } else { request.setAttribute("exception", "There was an error generating this report."); return mapping.findForward("error"); } break; case 13: System.out.println("RegimenChangeReport"); register = new RegimenChangeReport(); register.setType("print"); // not (longer) view version register.setSiteName(siteName); register.setReportCreator(reportCreator); if (beginDate == null) { beginDate = date1monthpastSql; } if (endDate == null) { endDate = dateNow; } register.getPatientRegister(beginDate, endDate, siteId); register.setBeginDate(beginDate); register.setEndDate(endDate); register.setReportDate(dateNow); register.setSiteId(siteId); request.setAttribute("register", register); name = "RegimenChangeReport"; abbrev = "RCR"; clazz = RegimenChangeReport.class; break; /**/ default: break; } // end switch /* if ((reportID == 12) && (!register.getType().equals("error"))) { return(null); }*/ if (isXml) { String reportType = null; if (records.size() > 0) { reportType = "records"; } else if (register != null) { reportType = "register"; } if (reportType != null) { XStream xstream = new XStream(); xstream.alias(abbrev, clazz); xstream.alias("log", org.apache.commons.logging.impl.Log4JLogger.class); // response.setContentType("text/html"); response.setContentType("text/xml"); response.setContentType("application/vnd.ms-excel"); PrintWriter writer = response.getWriter(); writer.write("<?xml version=\"1.0\"?>\n"); if (reportType.equals("records")) { xstream.toXML(records, writer); } else { xstream.toXML(register, writer); } //writer.write(xml); writer.flush(); writer.close(); // use writer to render text return (null); // log.info("saved register " + path + name + "Register.xml"); } } if (task.equals("generate")) { if (report != null) { XStream xstream = new XStream(); String path = Constants.REPORTS_XML_PATH; Writer writer = new BufferedWriter(new FileWriter(path + name + "Report.xml")); writer.write("<?xml version=\"1.0\"?>\n"); xstream.toXML(report, writer); //writer.write(xml); writer.flush(); writer.close(); log.info("saved report " + path + name + "Report.xml"); } else if (register != null) { XStream xstream = new XStream(); String path = Constants.REPORTS_XML_PATH; Writer writer = new BufferedWriter(new FileWriter(path + name + "Report.xml")); writer.write("<?xml version=\"1.0\"?>\n"); xstream.toXML(register, writer); //writer.write(xml); writer.flush(); writer.close(); log.info("saved register " + path + name + "Report.xml"); } } return mapping.findForward(name); }
From source file:cz.muni.fi.sport.club.sport.club.rest.AgeGroupsResource.java
@PUT @Path("{id}") public void update(@PathParam("id") String id, @FormParam("eldest") String eldest, @FormParam("youngest") String youngest, @FormParam("groupLevel") String groupLevel) throws WebApplicationException { try {//from ww w. jav a 2 s . c o m AgeGroupDTO agDTO = ageGroupService.getAgeGroupById(Long.parseLong(id)); if (agDTO == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } agDTO.setEldest(Date.valueOf(eldest)); agDTO.setYoungest(Date.valueOf(youngest)); agDTO.setGroupLevel(AgeGroupLevel.valueOf(groupLevel)); ageGroupService.updateAgeGroup(agDTO); } catch (NumberFormatException ex) { throw new WebApplicationException(new Throwable("You put wrong request"), Response.Status.BAD_REQUEST); } catch (WebApplicationException ex) { throw ex; } catch (Exception ex) { throw new WebApplicationException(new Throwable("We apologize for internal server error"), Response.Status.INTERNAL_SERVER_ERROR); } }
From source file:org.apache.kylin.jdbc.KylinClient.java
public static Object wrapObject(String value, int sqlType) { if (null == value) { return null; }/*from ww w . j av a 2 s .c om*/ switch (sqlType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return value; case Types.NUMERIC: case Types.DECIMAL: return new BigDecimal(value); case Types.BIT: return Boolean.parseBoolean(value); case Types.TINYINT: return Byte.valueOf(value); case Types.SMALLINT: return Short.valueOf(value); case Types.INTEGER: return Integer.parseInt(value); case Types.BIGINT: return Long.parseLong(value); case Types.FLOAT: return Float.parseFloat(value); case Types.REAL: case Types.DOUBLE: return Double.parseDouble(value); case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: return value.getBytes(); case Types.DATE: return Date.valueOf(value); case Types.TIME: return Time.valueOf(value); case Types.TIMESTAMP: return Timestamp.valueOf(value); default: //do nothing break; } return value; }
From source file:org.apache.drill.exec.physical.impl.limit.TestEarlyLimit0Optimization.java
@Test public void simpleSelect() throws Exception { testBuilder().sqlQuery(String.format("SELECT * FROM %s", viewName)).ordered() .baselineColumns("employee_id", "full_name", "position_id", "department_id", "birth_date", "hire_date", "salary", "fsalary", "single", "education_level", "gender") .baselineValues(1, "Sheri Nowmer", 1, 1L, new DateTime(Date.valueOf("1961-08-26").getTime()), new DateTime(Date.valueOf("1994-12-01").getTime()), 80000.0D, 80000.0F, true, "Graduate Degree", "F") .go();//from www . j a v a2 s . com }
From source file:org.geoserver.wms.dimension.RasterTimeDimensionDefaultValueTest.java
@Test public void testExplicitMinTimeCoverageSelector() throws Exception { // Use explicit default value strategy: DimensionDefaultValueSetting defaultValueSetting = new DimensionDefaultValueSetting(); defaultValueSetting.setStrategyType(Strategy.MINIMUM); setupCoverageTimeDimension(WATTEMP_FUTURE, defaultValueSetting); //From src/test/resources/org/geoserver/wms/watertemp.zip: Date expected = Date.valueOf("2008-10-31"); CoverageInfo coverage = getCatalog().getCoverageByName(WATTEMP_FUTURE.getLocalPart()); java.util.Date d = wms.getDefaultTime(coverage); assertTrue("Returns a valid Default time", d != null); assertTrue("Default time should be the smallest one", d.getTime() == expected.getTime()); }