List of usage examples for java.sql Date getTime
public long getTime()
From source file:org.kuali.kra.budget.calculator.AbstractBudgetCalculator.java
/** * Use the combined & sorted Prop & LA rates to create Boundary objects. Each Boundary will contain start date & end date. Check * whether any rate changes, and break at this point to create a new boundary. * //from w w w.j a v a2 s. co m * @return List of boundary objects */ public List<Boundary> createBreakupBoundaries(QueryList<AbstractBudgetRate> qlCombinedRates, Date liStartDate, Date liEndDate) { List<Boundary> boundaries = new ArrayList<Boundary>(); if (qlCombinedRates != null && qlCombinedRates.size() > 0) { Date tempStartDate = liStartDate; Date tempEndDate = liEndDate; Date rateChangeDate; GreaterThan greaterThan = new GreaterThan("startDate", liStartDate); qlCombinedRates = qlCombinedRates.filter(greaterThan); qlCombinedRates.sort("startDate", true); for (AbstractBudgetRate laRate : qlCombinedRates) { rateChangeDate = laRate.getStartDate(); if (rateChangeDate.after(tempStartDate)) { Calendar temEndCal = dateTimeService.getCalendar(rateChangeDate); temEndCal.add(Calendar.DAY_OF_MONTH, -1); try { tempEndDate = dateTimeService.convertToSqlDate(temEndCal.get(Calendar.YEAR) + "-" + (temEndCal.get(Calendar.MONTH) + 1) + "-" + temEndCal.get(Calendar.DAY_OF_MONTH)); } catch (ParseException e) { tempEndDate = new Date(rateChangeDate.getTime() - 86400000); } Boundary boundary = new Boundary(tempStartDate, tempEndDate); boundaries.add(boundary); tempStartDate = rateChangeDate; } } /** * add one more boundary if no rate change on endDate and atleast one boundary is present */ if (boundaries.size() > 0) { Boundary boundary = new Boundary(tempStartDate, liEndDate); boundaries.add(boundary); } /** * if no rate changes during the period create one boundary with startDate & endDate same as that for line item */ if (boundaries.size() == 0) { Boundary boundary = new Boundary(liStartDate, liEndDate); boundaries.add(boundary); } } return boundaries; }
From source file:org.jtotus.database.LocalJDBC.java
public HashMap<String, Double> fetchPeriodAsMap(String tableName, DateTime startDate, DateTime endDate) { HashMap<String, Double> retMap = new HashMap<String, Double>(); BigDecimal retValue = null;//ww w .j a va 2 s .c om PreparedStatement pstm = null; java.sql.Date retDate = null; ResultSet results = null; Connection connection = null; try { String query = "SELECT CLOSE, DATE FROM " + this.normTableName(tableName) + " WHERE DATE>=? AND DATE<=? ORDER BY DATE ASC"; // this.createTable(connection, this.normTableName(tableName)); connection = this.getConnection(); pstm = connection.prepareStatement(query); java.sql.Date startSqlDate = new java.sql.Date(startDate.getMillis()); pstm.setDate(1, startSqlDate); java.sql.Date endSqlDate = new java.sql.Date(endDate.getMillis()); pstm.setDate(2, endSqlDate); System.out.printf("fetchPeriod : %s : %s\n", startSqlDate, endSqlDate); DateIterator iter = new DateIterator(startDate, endDate); results = pstm.executeQuery(); DateTime dateCheck; while (results.next()) { retValue = results.getBigDecimal(1); retDate = results.getDate(2); if (retValue == null || retDate == null) { System.err.println("Database is corrupted!"); System.exit(-1); } if (iter.hasNext()) { dateCheck = iter.nextInCalendar(); DateTime compCal = new DateTime(retDate.getTime()); if (debug) { if (retValue != null) { System.out.printf("Fetched:\'%s\' from \'%s\' : value:%f date:%s\n", "Closing Price", tableName, retValue.doubleValue(), retDate.toString()); } else { System.out.printf("Fetched:\'%s\' from \'%s\' : value:%s date:%s\n", "Closing Price", tableName, "is null", retDate.toString()); } } if (compCal.getDayOfMonth() == dateCheck.getDayOfMonth() && compCal.getMonthOfYear() == dateCheck.getMonthOfYear() && compCal.getYear() == dateCheck.getYear()) { retMap.put(formatter.print(compCal), retValue.doubleValue()); continue; } while (((compCal.getDayOfMonth() != dateCheck.getDayOfMonth()) || (compCal.getMonthOfYear() != dateCheck.getMonthOfYear()) || (compCal.getYear() != dateCheck.getYear())) && dateCheck.isBefore(compCal)) { if (fetcher != null) { BigDecimal failOverValue = getFetcher().fetchData(tableName, dateCheck, "CLOSE"); if (failOverValue != null) { retMap.put(formatter.print(dateCheck), retValue.doubleValue()); } if (iter.hasNext()) { System.err.printf("Warning : Miss matching dates for: %s - %s\n", retDate.toString(), dateCheck.toString()); dateCheck = iter.nextInCalendar(); continue; } } else { System.err.printf("Fatal missing fetcher : Miss matching dates: %s - %s\n", retDate.toString(), dateCheck.toString()); return null; } } } } while (iter.hasNext()) { retValue = getFetcher().fetchData(tableName, iter.nextInCalendar(), "CLOSE"); if (retValue != null) { retMap.put(formatter.print(iter.getCurrentAsCalendar()), retValue.doubleValue()); } } } catch (SQLException ex) { System.err.printf("LocalJDBC Unable to find date for:'%s' from'%s' Time" + startDate.toDate() + "\n", "Cosing Price", tableName); // ex.printStackTrace(); // SQLException xp = null; // while((xp = ex.getNextException()) != null) { // xp.printStackTrace(); // } } finally { try { if (results != null) results.close(); if (pstm != null) pstm.close(); if (connection != null) connection.close(); // System.out.printf("Max connect:%d in use:%d\n",mainPool.getMaxConnections(), mainPool.getActiveConnections()); // mainPool.dispose(); } catch (SQLException ex) { Logger.getLogger(LocalJDBC.class.getName()).log(Level.SEVERE, null, ex); } } return retMap; }
From source file:org.openiam.idm.srvc.synch.srcadapter.RDBMSAdapter.java
@Override public SyncResponse startSynch(final SynchConfig config, SynchReviewEntity sourceReview, final SynchReviewEntity resultReview) { log.debug("RDBMS SYNCH STARTED ^^^^^^^^"); SyncResponse res = new SyncResponse(ResponseStatus.SUCCESS); SynchReview review = null;/*from w w w.ja v a2 s .c o m*/ if (sourceReview != null) { review = synchReviewDozerConverter.convertToDTO(sourceReview, false); } LineObject rowHeaderForReport = null; InputStream input = null; try { final ValidationScript validationScript = org.mule.util.StringUtils.isNotEmpty( config.getValidationRule()) ? SynchScriptFactory.createValidationScript(config, review) : null; final List<TransformScript> transformScripts = SynchScriptFactory.createTransformationScript(config, review); final MatchObjectRule matchRule = matchRuleFactory.create(config.getCustomMatchRule()); // check if matchRule exists if (validationScript == null || transformScripts == null || matchRule == null) { res = new SyncResponse(ResponseStatus.FAILURE); res.setErrorText("The problem in initialization of RDBMSAdapter, please check validationScript= " + validationScript + ", transformScripts=" + transformScripts + ", matchRule=" + matchRule + " all must be set!"); res.setErrorCode(ResponseCode.INVALID_ARGUMENTS); return res; } if (sourceReview != null && !sourceReview.isSourceRejected()) { return startSynchReview(config, sourceReview, resultReview, validationScript, transformScripts, matchRule); } if (!connect(config)) { SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.FAIL_SQL_ERROR); return resp; } java.util.Date lastExec = null; if (config.getLastExecTime() != null) { lastExec = config.getLastExecTime(); } final String changeLog = config.getQueryTimeField(); StringBuilder sql = new StringBuilder(config.getQuery()); // if its incremental synch, then add the change log parameter if (config.getSynchType().equalsIgnoreCase("INCREMENTAL")) { // execute the query if (StringUtils.isNotEmpty(sql.toString()) && (lastExec != null)) { String temp = sql.toString().toUpperCase(); // strip off any trailing semi-colons. Not needed for jbdc temp = StringUtils.removeEnd(temp, ";"); if (temp.contains("WHERE")) { sql.append(" AND "); } else { sql.append(" WHERE "); } sql.append(changeLog).append(" >= ?"); } } log.debug("-SYNCH SQL=" + sql.toString()); log.debug("-last processed record =" + lastExec); PreparedStatement ps = con.prepareStatement(sql.toString()); if (config.getSynchType().equalsIgnoreCase("INCREMENTAL") && (lastExec != null)) { ps.setTimestamp(1, new Timestamp(lastExec.getTime())); } ResultSet rs = ps.executeQuery(); // get the list of columns ResultSetMetaData rsMetadata = rs.getMetaData(); DatabaseUtil.populateTemplate(rsMetadata, rowHeader); //Read Resultset to List List<LineObject> results = new LinkedList<LineObject>(); while (rs.next()) { LineObject rowObj = rowHeader.copy(); DatabaseUtil.populateRowObject(rowObj, rs, changeLog); results.add(rowObj); } // test log.debug("Result set contains following number of columns : " + rowHeader.getColumnMap().size()); // Multithreading int allRowsCount = results.size(); if (allRowsCount > 0) { int threadCoount = THREAD_COUNT; int rowsInOneExecutors = allRowsCount / threadCoount; int remains = rowsInOneExecutors > 0 ? allRowsCount % (rowsInOneExecutors * threadCoount) : 0; if (remains != 0) { threadCoount++; } log.debug("Thread count = " + threadCoount + "; Rows in one thread = " + rowsInOneExecutors + "; Remains rows = " + remains); System.out.println("Thread count = " + threadCoount + "; Rows in one thread = " + rowsInOneExecutors + "; Remains rows = " + remains); List<Future> threadResults = new LinkedList<Future>(); // store the latest processed record by thread indx final Map<String, Timestamp> recentRecordByThreadInx = new HashMap<String, Timestamp>(); final ExecutorService service = Executors.newCachedThreadPool(); for (int i = 0; i < threadCoount; i++) { final int threadIndx = i; final int startIndex = i * rowsInOneExecutors; // Start index for current thread int shiftIndex = threadCoount > THREAD_COUNT && i == threadCoount - 1 ? remains : rowsInOneExecutors; // Part of the rowas that should be processing with this thread final List<LineObject> part = results.subList(startIndex, startIndex + shiftIndex); threadResults.add(service.submit(new Runnable() { @Override public void run() { try { Timestamp mostRecentRecord = proccess(config, resultReview, provService, part, validationScript, transformScripts, matchRule, resultReview, startIndex); recentRecordByThreadInx.put("Thread_" + threadIndx, mostRecentRecord); } catch (ClassNotFoundException e) { log.error(e); /* synchStartLog.updateSynchAttributes("FAIL", ResponseCode.CLASS_NOT_FOUND.toString(), e.toString()); auditHelper.logEvent(synchStartLog); */ } } })); //Give THREAD_DELAY_BEFORE_START seconds time for thread to be UP (load all cache and begin the work) Thread.sleep(THREAD_DELAY_BEFORE_START); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { service.shutdown(); try { if (!service.awaitTermination(SHUTDOWN_TIME, TimeUnit.MILLISECONDS)) { //optional * log.warn("Executor did not terminate in the specified time."); //optional * List<Runnable> droppedTasks = service.shutdownNow(); //optional ** log.warn("Executor was abruptly shut down. " + droppedTasks.size() + " tasks will not be executed."); //optional ** } } catch (InterruptedException e) { log.error(e); /* synchStartLog.updateSynchAttributes("FAIL", ResponseCode.INTERRUPTED_EXCEPTION.toString(), e.toString()); auditHelper.logEvent(synchStartLog); */ SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.INTERRUPTED_EXCEPTION); } } }); waitUntilWorkDone(threadResults); } } catch (ClassNotFoundException cnfe) { log.error(cnfe); res = new SyncResponse(ResponseStatus.FAILURE); res.setErrorCode(ResponseCode.CLASS_NOT_FOUND); return res; } catch (FileNotFoundException fe) { fe.printStackTrace(); log.error(fe); // auditBuilder.addAttribute(AuditAttributeName.DESCRIPTION, "FileNotFoundException: "+fe.getMessage()); // auditLogProvider.persist(auditBuilder); SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.FILE_EXCEPTION); log.debug("RDBMS SYNCHRONIZATION COMPLETE WITH ERRORS ^^^^^^^^"); return resp; } catch (IOException io) { io.printStackTrace(); /* synchStartLog.updateSynchAttributes("FAIL", ResponseCode.IO_EXCEPTION.toString(), io.toString()); auditHelper.logEvent(synchStartLog); */ SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.IO_EXCEPTION); log.debug("RDBMS SYNCHRONIZATION COMPLETE WITH ERRORS ^^^^^^^^"); return resp; } catch (SQLException se) { log.error(se); closeConnection(); /* synchStartLog.updateSynchAttributes("FAIL", ResponseCode.SQL_EXCEPTION.toString(), se.toString()); auditHelper.logEvent(synchStartLog); */ SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.SQL_EXCEPTION); resp.setErrorText(se.toString()); return resp; } catch (InterruptedException e) { log.error(e); SyncResponse resp = new SyncResponse(ResponseStatus.FAILURE); resp.setErrorCode(ResponseCode.INTERRUPTED_EXCEPTION); } finally { if (resultReview != null) { if (CollectionUtils.isNotEmpty(resultReview.getReviewRecords())) { // add header row resultReview.addRecord(generateSynchReviewRecord(rowHeader, true)); } } closeConnection(); } log.debug("RDBMS SYNCH COMPLETE.^^^^^^^^"); return new SyncResponse(ResponseStatus.SUCCESS); }
From source file:org.jtotus.database.LocalJDBC.java
public double[] fetchPeriod(String tableName, DateTime startDate, DateTime endDate, String type) { BigDecimal retValue = null;/*from w ww . j a v a 2s. c om*/ PreparedStatement pstm = null; java.sql.Date retDate = null; ResultSet results = null; ArrayList<Double> closingPrices = new ArrayList<Double>(600); Connection connection = null; try { String query = "SELECT " + type + ", DATE FROM " + this.normTableName(tableName) + " WHERE DATE>=? AND DATE<=? ORDER BY DATE ASC"; // this.createTable(connection, this.normTableName(tableName)); connection = this.getConnection(); pstm = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); java.sql.Date startSqlDate = new java.sql.Date(startDate.getMillis()); pstm.setDate(1, startSqlDate); java.sql.Date endSqlDate = new java.sql.Date(endDate.getMillis()); pstm.setDate(2, endSqlDate); DateIterator dateIter = new DateIterator(startDate, endDate); results = pstm.executeQuery(); DateTime dateCheck; if (debug) { System.out.printf("start data %s end date: %s\n", startSqlDate.toString(), endSqlDate.toString()); } while (dateIter.hasNext()) { dateCheck = dateIter.nextInCalendar(); if (results.next()) { retValue = results.getBigDecimal(1); retDate = results.getDate(2); DateTime compCal = new DateTime(retDate.getTime()); if (compCal.getDayOfMonth() == dateCheck.getDayOfMonth() && compCal.getMonthOfYear() == dateCheck.getMonthOfYear() && compCal.getYear() == dateCheck.getYear()) { closingPrices.add(retValue.doubleValue()); continue; } else { results.previous(); } } BigDecimal failOverValue = getFetcher().fetchData(tableName, dateCheck, type); if (failOverValue != null) { closingPrices.add(failOverValue.doubleValue()); } } } catch (SQLException ex) { System.err.printf("LocalJDBC Unable to find date for:'%s' from'%s' Time" + startDate.toDate() + "\n", "Cosing Price", tableName); ex.printStackTrace(); SQLException xp = null; while ((xp = ex.getNextException()) != null) { xp.printStackTrace(); } } finally { try { if (results != null) results.close(); if (pstm != null) pstm.close(); if (connection != null) connection.close(); // System.out.printf("Max connect:%d in use:%d\n",mainPool.getMaxConnections(), mainPool.getActiveConnections()); // mainPool.dispose(); } catch (SQLException ex) { Logger.getLogger(LocalJDBC.class.getName()).log(Level.SEVERE, null, ex); } } return ArrayUtils.toPrimitive(closingPrices.toArray(new Double[0])); }
From source file:org.kuali.kfs.fp.document.service.impl.DisbursementVoucherExtractionHelperServiceImpl.java
/** * This method builds a payment detail object from the disbursement voucher document provided and links that detail file to the * batch and process run date given.// www.j a v a 2 s . c o m * * @param document The disbursement voucher document to retrieve payment information from to populate the PaymentDetail. * @param batch The batch file associated with the payment. * @param processRunDate The date of the payment detail invoice. * @return A fully populated PaymentDetail instance. */ protected PaymentDetail buildPaymentDetail(DisbursementVoucherDocument document, Date processRunDate) { if (LOG.isDebugEnabled()) { LOG.debug("buildPaymentDetail() started"); } final String maxNoteLinesParam = getParameterService().getParameterValueAsString( KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES); int maxNoteLines; try { maxNoteLines = Integer.parseInt(maxNoteLinesParam); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: " + maxNoteLinesParam + " cannot be converted to an integer"); } PaymentDetail pd = new PaymentDetail(); if (StringUtils.isNotEmpty(document.getDocumentHeader().getOrganizationDocumentNumber())) { pd.setOrganizationDocNbr(document.getDocumentHeader().getOrganizationDocumentNumber()); } pd.setCustPaymentDocNbr(document.getDocumentNumber()); pd.setInvoiceDate(new java.sql.Date(processRunDate.getTime())); pd.setOrigInvoiceAmount(document.getDisbVchrCheckTotalAmount()); pd.setInvTotDiscountAmount(KualiDecimal.ZERO); pd.setInvTotOtherCreditAmount(KualiDecimal.ZERO); pd.setInvTotOtherDebitAmount(KualiDecimal.ZERO); pd.setInvTotShipAmount(KualiDecimal.ZERO); pd.setNetPaymentAmount(document.getDisbVchrCheckTotalAmount()); pd.setPrimaryCancelledPayment(Boolean.FALSE); pd.setFinancialDocumentTypeCode(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH); pd.setFinancialSystemOriginCode(KFSConstants.ORIGIN_CODE_KUALI); // Handle accounts for (SourceAccountingLine sal : (List<? extends SourceAccountingLine>) document .getSourceAccountingLines()) { PaymentAccountDetail pad = new PaymentAccountDetail(); pad.setFinChartCode(sal.getChartOfAccountsCode()); pad.setAccountNbr(sal.getAccountNumber()); if (StringUtils.isNotEmpty(sal.getSubAccountNumber())) { pad.setSubAccountNbr(sal.getSubAccountNumber()); } else { pad.setSubAccountNbr(KFSConstants.getDashSubAccountNumber()); } pad.setFinObjectCode(sal.getFinancialObjectCode()); if (StringUtils.isNotEmpty(sal.getFinancialSubObjectCode())) { pad.setFinSubObjectCode(sal.getFinancialSubObjectCode()); } else { pad.setFinSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } if (StringUtils.isNotEmpty(sal.getOrganizationReferenceId())) { pad.setOrgReferenceId(sal.getOrganizationReferenceId()); } if (StringUtils.isNotEmpty(sal.getProjectCode())) { pad.setProjectCode(sal.getProjectCode()); } else { pad.setProjectCode(KFSConstants.getDashProjectCode()); } pad.setAccountNetAmount(sal.getAmount()); pd.addAccountDetail(pad); } // Handle notes DisbursementVoucherPayeeDetail dvpd = document.getDvPayeeDetail(); int line = 0; PaymentNoteText pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("Info: " + document.getDisbVchrContactPersonName() + " " + document.getDisbVchrContactPhoneNumber()); pd.addNote(pnt); String dvSpecialHandlingPersonName = null; String dvSpecialHandlingLine1Address = null; String dvSpecialHandlingLine2Address = null; String dvSpecialHandlingCity = null; String dvSpecialHandlingState = null; String dvSpecialHandlingZip = null; dvSpecialHandlingPersonName = dvpd.getDisbVchrSpecialHandlingPersonName(); dvSpecialHandlingLine1Address = dvpd.getDisbVchrSpecialHandlingLine1Addr(); dvSpecialHandlingLine2Address = dvpd.getDisbVchrSpecialHandlingLine2Addr(); dvSpecialHandlingCity = dvpd.getDisbVchrSpecialHandlingCityName(); dvSpecialHandlingState = dvpd.getDisbVchrSpecialHandlingStateCode(); dvSpecialHandlingZip = dvpd.getDisbVchrSpecialHandlingZipCode(); if (StringUtils.isNotEmpty(dvSpecialHandlingPersonName)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("Send Check To: " + dvSpecialHandlingPersonName); if (LOG.isDebugEnabled()) { LOG.debug("Creating special handling person name note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } if (StringUtils.isNotEmpty(dvSpecialHandlingLine1Address)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText(dvSpecialHandlingLine1Address); if (LOG.isDebugEnabled()) { LOG.debug("Creating special handling address 1 note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } if (StringUtils.isNotEmpty(dvSpecialHandlingLine2Address)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText(dvSpecialHandlingLine2Address); if (LOG.isDebugEnabled()) { LOG.debug("Creating special handling address 2 note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } if (StringUtils.isNotEmpty(dvSpecialHandlingCity)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText( dvSpecialHandlingCity + ", " + dvSpecialHandlingState + " " + dvSpecialHandlingZip); if (LOG.isDebugEnabled()) { LOG.debug("Creating special handling city note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } if (document.isDisbVchrAttachmentCode()) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("Attachment Included"); if (LOG.isDebugEnabled()) { LOG.debug("create attachment note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } String paymentReasonCode = dvpd.getDisbVchrPaymentReasonCode(); if (/*REFACTORME*/getParameterEvaluatorService() .getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM, paymentReasonCode) .evaluationSucceeds()) { DisbursementVoucherNonEmployeeTravel dvnet = document.getDvNonEmployeeTravel(); pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("Reimbursement associated with " + dvnet.getDisbVchrServicePerformedDesc()); if (LOG.isDebugEnabled()) { LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("The total per diem amount for your daily expenses is " + dvnet.getDisbVchrPerdiemCalculatedAmt()); if (LOG.isDebugEnabled()) { LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); if (dvnet.getDisbVchrPersonalCarAmount() != null && dvnet.getDisbVchrPersonalCarAmount().compareTo(KualiDecimal.ZERO) != 0) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("The total dollar amount for your vehicle mileage is " + dvnet.getDisbVchrPersonalCarAmount()); if (LOG.isDebugEnabled()) { LOG.debug("Creating non employee travel vehicle note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); for (DisbursementVoucherNonEmployeeExpense exp : (List<DisbursementVoucherNonEmployeeExpense>) dvnet .getDvNonEmployeeExpenses()) { if (line < (maxNoteLines - 8)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText( exp.getDisbVchrExpenseCompanyName() + " " + exp.getDisbVchrExpenseAmount()); if (LOG.isDebugEnabled()) { LOG.debug("Creating non employee travel expense note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } } } } else if (/*REFACTORME*/getParameterEvaluatorService() .getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM, paymentReasonCode) .evaluationSucceeds()) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText("Payment is for the following individuals/charges:"); pd.addNote(pnt); if (LOG.isDebugEnabled()) { LOG.info("Creating prepaid travel note note: " + pnt.getCustomerNoteText()); } DisbursementVoucherPreConferenceDetail dvpcd = document.getDvPreConferenceDetail(); for (DisbursementVoucherPreConferenceRegistrant dvpcr : (List<DisbursementVoucherPreConferenceRegistrant>) dvpcd .getDvPreConferenceRegistrants()) { if (line < (maxNoteLines - 8)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(line++)); pnt.setCustomerNoteText( dvpcr.getDvConferenceRegistrantName() + " " + dvpcr.getDisbVchrExpenseAmount()); if (LOG.isDebugEnabled()) { LOG.debug("Creating pre-paid conference registrants note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } } } // Get the original, raw form, note text from the DV document. final String text = document.getDisbVchrCheckStubText(); if (!StringUtils.isBlank(text)) { pnt = this.getPaymentSourceHelperService().buildNoteForCheckStubText(text, line); // Logging... if (LOG.isDebugEnabled()) { LOG.debug("Creating check stub text note: " + pnt.getCustomerNoteText()); } pd.addNote(pnt); } return pd; }
From source file:org.apache.phoenix.query.BaseTest.java
protected static void populateMultiCFTestTable(String tableName, Date date) throws SQLException { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try {/* ww w . j a v a 2 s . c om*/ String upsert = "UPSERT INTO " + tableName + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); stmt.setString(1, "varchar1"); stmt.setString(2, "char1"); stmt.setInt(3, 1); stmt.setLong(4, 1L); stmt.setBigDecimal(5, new BigDecimal("1.1")); stmt.setString(6, "varchar_a"); stmt.setString(7, "chara"); stmt.setInt(8, 2); stmt.setLong(9, 2L); stmt.setBigDecimal(10, new BigDecimal("2.1")); stmt.setString(11, "varchar_b"); stmt.setString(12, "charb"); stmt.setInt(13, 3); stmt.setLong(14, 3L); stmt.setBigDecimal(15, new BigDecimal("3.1")); stmt.setDate(16, date == null ? null : new Date(date.getTime() + MILLIS_IN_DAY)); stmt.executeUpdate(); stmt.setString(1, "varchar2"); stmt.setString(2, "char2"); stmt.setInt(3, 2); stmt.setLong(4, 2L); stmt.setBigDecimal(5, new BigDecimal("2.2")); stmt.setString(6, "varchar_a"); stmt.setString(7, "chara"); stmt.setInt(8, 3); stmt.setLong(9, 3L); stmt.setBigDecimal(10, new BigDecimal("3.2")); stmt.setString(11, "varchar_b"); stmt.setString(12, "charb"); stmt.setInt(13, 4); stmt.setLong(14, 4L); stmt.setBigDecimal(15, new BigDecimal("4.2")); stmt.setDate(16, date); stmt.executeUpdate(); stmt.setString(1, "varchar3"); stmt.setString(2, "char3"); stmt.setInt(3, 3); stmt.setLong(4, 3L); stmt.setBigDecimal(5, new BigDecimal("3.3")); stmt.setString(6, "varchar_a"); stmt.setString(7, "chara"); stmt.setInt(8, 4); stmt.setLong(9, 4L); stmt.setBigDecimal(10, new BigDecimal("4.3")); stmt.setString(11, "varchar_b"); stmt.setString(12, "charb"); stmt.setInt(13, 5); stmt.setLong(14, 5L); stmt.setBigDecimal(15, new BigDecimal("5.3")); stmt.setDate(16, date == null ? null : new Date(date.getTime() + 2 * MILLIS_IN_DAY)); stmt.executeUpdate(); conn.commit(); } finally { conn.close(); } }
From source file:org.apache.phoenix.end2end.DateTimeIT.java
@Test public void testDateSubtractionCompareDate() throws Exception { String tablename = generateUniqueName(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM " + tablename + " WHERE organization_id = ? and date - 1 >= ?"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try {/* ww w . j av a 2s . co m*/ Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(startDate.getTime() + 9 * QueryConstants.MILLIS_IN_DAY); initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setDate(2, endDate); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("F", rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); } }
From source file:org.apache.phoenix.end2end.DateTimeIT.java
@Test public void testDateAddCompareDate() throws Exception { String tablename = generateUniqueName(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM " + tablename + " WHERE organization_id = ? and date + 1 >= ?"; Connection conn = DriverManager.getConnection(url); try {//w w w.ja va2 s . c om Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(startDate.getTime() + 8 * QueryConstants.MILLIS_IN_DAY); initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setDate(2, endDate); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("E", rs.getString(1)); assertTrue(rs.next()); assertEquals("F", rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); } }
From source file:org.apache.phoenix.end2end.DateTimeIT.java
@Test public void testDateSubtractionCompareNumber() throws Exception { String tablename = generateUniqueName(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM " + tablename + " WHERE organization_id = ? and ? - \"DATE\" > 3"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try {// www .java 2s .co m Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(startDate.getTime() + 6 * QueryConstants.MILLIS_IN_DAY); initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setDate(2, endDate); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("A", rs.getString(1)); assertTrue(rs.next()); assertEquals("B", rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); } }
From source file:org.apache.phoenix.end2end.DateTimeIT.java
@Test public void testDateSubtractionLongToDecimalCompareNumber() throws Exception { String tablename = generateUniqueName(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM " + tablename + " WHERE organization_id = ? and ? - \"DATE\" - 1.5 > 3"; Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try {//from www . ja v a 2 s . co m Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(startDate.getTime() + 9 * QueryConstants.MILLIS_IN_DAY); initDateTableValues(tablename, tenantId, getSplits(tenantId), startDate); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setDate(2, endDate); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("A", rs.getString(1)); assertTrue(rs.next()); assertEquals("B", rs.getString(1)); assertTrue(rs.next()); assertEquals("C", rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); } }