List of usage examples for javax.persistence TemporalType DATE
TemporalType DATE
To view the source code for javax.persistence TemporalType DATE.
Click Source Link
java.sql.Date
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public List<RawMaterialPayRoll> findAllPayRollesByGAB(Date startDate, Date endDate, ProductiveZone productiveZone) { List<RawMaterialPayRoll> rawMaterialPayRolls; if (productiveZone != null) { rawMaterialPayRolls = getEntityManager().createNamedQuery("RawMaterialPayRoll.getPayRollInDatesAndGAB") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE) .setParameter("productiveZone", productiveZone).getResultList(); } else {/*from www .j a v a 2 s. co m*/ rawMaterialPayRolls = getEntityManager().createNamedQuery("RawMaterialPayRoll.getPayRollInDates") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).getResultList(); } return rawMaterialPayRolls; }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void approvedNoteRejection(Calendar startDate, Calendar endDate) { getEntityManager().createQuery(// ww w .j a v a 2 s. c o m "update RawMaterialRejectionNote rawMaterialRejectionNote set rawMaterialRejectionNote.state = 'APPROVED'" + " where rawMaterialRejectionNote.date between :startDate and :endDate ") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); }
From source file:gov.opm.scrd.batchprocessing.jobs.BatchProcessingJob.java
/** * Creates the General Ledger file given the database data. * <p/>// w ww. j a v a 2 s. com * This method does not throw any exception. * * @param glFileDirectory The directory to create GL file. * @param procMessage The process message. Used to build the mail message. * @param now The current date. * @return true if execution is successful; false otherwise. */ private boolean makeGLFile(File glFileDirectory, StringBuilder procMessage, Date now) { if (!glFileDirectory.exists() || !glFileDirectory.isDirectory() || !glFileDirectory.canRead() || !glFileDirectory.canWrite()) { logger.warn("Can not make GL file in directory:" + glFileDirectory); procMessage.append(CRLF).append(CRLF).append("Can not make GL file in directory:" + glFileDirectory) .append(CRLF); return false; } File outputGLFile = new File(glFileDirectory, "SCGL" + new SimpleDateFormat("yyMMdd").format(now) + ".txt"); PrintWriter output = null; try { startTransaction(); StoredProcedureQuery sp = entityManager.createNamedStoredProcedureQuery("BatchDailyGLFile"); sp.setParameter("pDayToProcess", now, TemporalType.DATE); sp.execute(); @SuppressWarnings("unchecked") List<GLFileRecord> records = sp.getResultList(); commitTransaction(); Calendar cal = Calendar.getInstance(); cal.setTime(now); String dayOfYear = String.format("%03d", cal.get(Calendar.DAY_OF_YEAR)); for (GLFileRecord record : records) { StringBuilder line = new StringBuilder(""); line.append(record.getFeederSystemId()); line.append(record.getJulianDate()); line.append(dayOfYear); line.append(record.getGlFiller()); line.append(record.getGlCode()); int fiscalYear = record.getFiscalYear() == null ? 0 : record.getFiscalYear(); if (fiscalYear < 1000) { line.append(StringUtils.rightPad(record.getGlAccountingCode(), 20)); } else { line.append(fiscalYear % 100); line.append(" "); line.append(StringUtils.rightPad(record.getGlAccountingCode(), 16)); } line.append(String.format("%015d", record.getRecipientAmount().multiply(BatchProcessHelper.HUNDRED).longValue())); line.append(record.getRevenueSourceCode()); // Pad 28 spaces for (int i = 0; i < 28; i++) { line.append(" "); } if (output == null) { // Lazily create output file only when there is line to write output = new PrintWriter(outputGLFile); } output.println(line.toString()); } if (output != null) { output.flush(); logger.info("General Ledger file created."); procMessage.append(CRLF).append(CRLF).append("General Ledger file created.").append(CRLF); } else { String info = "There are no GL entries for " + DateFormat.getDateInstance(DateFormat.LONG, Locale.US).format(now) + " so no GL file was created. "; logger.info(info); procMessage.append(CRLF).append(CRLF).append(info).append(CRLF); } return true; } catch (PersistenceException pe) { logger.error("Database error creating the GL file.", pe); procMessage.append(CRLF).append(CRLF).append("Database error creating the GL file.").append(CRLF); return false; } catch (IOException e) { logger.error("IO error creating the GL file.", e); procMessage.append(CRLF).append(CRLF).append("IO error creating the GL file.").append(CRLF); return false; } finally { if (output != null) { output.close(); } } }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void approvedDiscounts(Calendar startDate, Calendar endDate, ProductiveZone productiveZone) { if (productiveZone != null) { getEntityManager().createQuery(/* www .j a v a2 s.c o m*/ "update SalaryMovementProducer salaryMovementProducer set salaryMovementProducer.state = 'APPROVED'" + " where salaryMovementProducer.date between :startDate and :endDate " + " and salaryMovementProducer.productiveZone = :productiveZone") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE) .setParameter("productiveZone", productiveZone).executeUpdate(); } else { getEntityManager().createQuery( "update SalaryMovementProducer salaryMovementProducer set salaryMovementProducer.state = 'APPROVED'" + " where salaryMovementProducer.date between :startDate and :endDate ") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); } }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void approvedReservProductor(Calendar startDate, Calendar endDate) { getEntityManager()/* w w w . jav a 2 s. co m*/ .createQuery("update DiscountProducer discountProducer set discountProducer.state = 'APPROVED'" + " where discountProducer.startDate = :startDate" + " and discountProducer.endDate = :endDate ") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void approvedDiscountsGAB(Calendar startDate, Calendar endDate, ProductiveZone productiveZone) { if (productiveZone != null) { getEntityManager()//from w w w .j a v a 2 s. c o m .createQuery( "update SalaryMovementGAB salaryMovementGAB set salaryMovementGAB.state = 'APPROVED'" + " where salaryMovementGAB.date between :startDate and :endDate " + " and salaryMovementGAB.productiveZone = :productiveZone") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE) .setParameter("productiveZone", productiveZone).executeUpdate(); } else { getEntityManager() .createQuery( "update SalaryMovementGAB salaryMovementGAB set salaryMovementGAB.state = 'APPROVED'" + " where salaryMovementGAB.date between :startDate and :endDate ") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); } }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void approvedRawMaterialPayRoll(Calendar startDate, Calendar endDate, ProductiveZone productiveZone) { if (productiveZone != null) { getEntityManager()/* w w w .j a v a 2 s .c om*/ .createQuery( "update RawMaterialPayRoll rawMaterialPayRoll set rawMaterialPayRoll.state = 'APPROVED'" + " where rawMaterialPayRoll.startDate = :startDate " + " and rawMaterialPayRoll.endDate = :endDate " + " and rawMaterialPayRoll.productiveZone = :productiveZone") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE) .setParameter("productiveZone", productiveZone).executeUpdate(); } else { getEntityManager() .createQuery( "update RawMaterialPayRoll rawMaterialPayRoll set rawMaterialPayRoll.state = 'APPROVED'" + " where rawMaterialPayRoll.startDate = :startDate " + " and rawMaterialPayRoll.endDate = :endDate ") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); } }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public Double getReservProducer(Date startDate, Date endDate) { BigDecimal result = (BigDecimal) getEntityManager() .createNativeQuery("select IFNULL(sum(monto),0.0) from DESCUENTORESERVA\n" + "where FECHAINI = :startDate\n " + "and FECHAFIN = :endDate") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).getSingleResult(); return result.doubleValue(); }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public void deleteReserveDiscount(Date startDate, Date endDate) { getEntityManager()/*from w w w . j a va 2s. co m*/ .createNativeQuery( "delete from descuentoreserva where fechaini = :startDate\n" + "and fechafin = :endDate") .setParameter("startDate", startDate, TemporalType.DATE) .setParameter("endDate", endDate, TemporalType.DATE).executeUpdate(); }
From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@Override public boolean verifDayColected(Calendar date_aux, ProductiveZone zone) { List<Object> list = getEntityManager() .createQuery("SELECT rawMaterialCollectionSession " + "from RawMaterialCollectionSession rawMaterialCollectionSession" + " where rawMaterialCollectionSession.date = :date_aux" + " and rawMaterialCollectionSession.productiveZone = :zone ") .setParameter("date_aux", date_aux.getTime(), TemporalType.DATE).setParameter("zone", zone) .getResultList();/*from w ww . ja va2 s . c om*/ return (list.size() == 0) ? false : true; }