List of usage examples for java.sql Date getTime
public long getTime()
From source file:com.ichi2.anki.SyncClient.java
/** * Anki Desktop -> libanki/anki/sync.py, SyncTools - needFullSync * //from ww w.j av a 2 s. co m * @param sums * @return */ @SuppressWarnings("unchecked") public boolean needFullSync(JSONArray sums) { Log.i(AnkiDroidApp.TAG, "needFullSync - lastSync = " + mDeck.getLastSync()); if (mDeck.getLastSync() <= 0) { Log.i(AnkiDroidApp.TAG, "deck.lastSync <= 0"); return true; } int len = sums.length(); for (int i = 0; i < len; i++) { try { JSONObject summary = sums.getJSONObject(i); Iterator keys = summary.keys(); while (keys.hasNext()) { String key = (String) keys.next(); JSONArray l = (JSONArray) summary.get(key); Log.i(AnkiDroidApp.TAG, "Key " + key + ", length = " + l.length()); if (l.length() > 500) { Log.i(AnkiDroidApp.TAG, "Length of key > 500"); return true; } } } catch (JSONException e) { Log.i(AnkiDroidApp.TAG, "JSONException = " + e.getMessage()); } } AnkiDb ankiDB = AnkiDatabaseManager.getDatabase(mDeck.getDeckPath()); if (ankiDB.queryScalar("SELECT count() FROM reviewHistory WHERE time > " + mDeck.getLastSync()) > 500) { Log.i(AnkiDroidApp.TAG, "reviewHistory since lastSync > 500"); return true; } Date lastDay = new Date(java.lang.Math.max(0, (long) (mDeck.getLastSync() - 60 * 60 * 24) * 1000)); Log.i(AnkiDroidApp.TAG, "lastDay = " + lastDay.toString() + ", lastDayInMillis = " + lastDay.getTime()); Log.i(AnkiDroidApp.TAG, "Count stats = " + ankiDB.queryScalar("SELECT count() FROM stats WHERE day >= \"" + lastDay.toString() + "\"")); if (ankiDB.queryScalar("SELECT count() FROM stats WHERE day >= \"" + lastDay.toString() + "\"") > 100) { Log.i(AnkiDroidApp.TAG, "stats since lastDay > 100"); return true; } return false; }
From source file:org.kuali.ole.module.purap.document.service.impl.PaymentRequestServiceImpl.java
/** * @see org.kuali.ole.module.purap.document.service.PaymentRequestService#markPaid(org.kuali.ole.module.purap.document.PaymentRequestDocument, * java.sql.Date)/*from w w w .j a v a 2s .c o m*/ */ @Override public void markPaid(PaymentRequestDocument pr, Date processDate) { LOG.debug("markPaid() started"); pr.setPaymentPaidTimestamp(new Timestamp(processDate.getTime())); purapService.saveDocumentNoValidation(pr); }
From source file:org.kuali.ole.module.purap.document.service.impl.InvoiceServiceImpl.java
/** * @see org.kuali.ole.module.purap.document.service.InvoiceService#markPaid(org.kuali.ole.module.purap.document.InvoiceDocument, * java.sql.Date)//ww w. j av a 2 s. c o m */ @Override public void markPaid(InvoiceDocument pr, Date processDate) { LOG.debug("markPaid() started"); pr.setPaymentPaidTimestamp(new Timestamp(processDate.getTime())); purapService.saveDocumentNoValidation(pr); }
From source file:org.apache.phoenix.end2end.DateTimeIT.java
@Test public void testNowFunction() throws Exception { String tableName = generateUniqueName(); Date date = new Date(System.currentTimeMillis()); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (k1 INTEGER NOT NULL, timestamps TIMESTAMP CONSTRAINT pk PRIMARY KEY (k1))"; conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + tableName + " VALUES (?, ?)"; PreparedStatement stmt = conn.prepareStatement(dml); stmt.setInt(1, 1);//from w w w .j av a 2s . c om stmt.setDate(2, new Date(date.getTime() - 500)); stmt.execute(); stmt.setInt(1, 2); stmt.setDate(2, new Date(date.getTime() + 600000)); stmt.execute(); conn.commit(); ResultSet rs = conn.createStatement() .executeQuery("SELECT * from " + tableName + " where now() > timestamps"); assertTrue(rs.next()); assertEquals(1, rs.getInt(1)); assertEquals(new Date(date.getTime() - 500), rs.getDate(2)); assertFalse(rs.next()); }
From source file:org.kuali.kfs.module.purap.document.service.impl.PaymentRequestServiceImpl.java
/** * @see org.kuali.kfs.module.purap.document.service.PaymentRequestService#markPaid(org.kuali.kfs.module.purap.document.PaymentRequestDocument, * java.sql.Date)//from www . j a v a 2s .c o m */ @Override @NonTransactional public void markPaid(PaymentRequestDocument pr, Date processDate) { LOG.debug("markPaid() started"); pr.setPaymentPaidTimestamp(new Timestamp(processDate.getTime())); purapService.saveDocumentNoValidation(pr); }
From source file:org.rti.zcore.dar.report.CDRROIReport.java
/** * * @param beginDate// w w w.ja va 2 s . c om * @param endDate * @param siteId */ public void getPatientRegister(Date beginDate, Date endDate, int siteId) { PreparedStatement ps = null; ResultSet rs = null; String sql = null; Form encounterForm = ((Form) DynaSiteObjects.getForms().get(new Long(132))); String className = "org.rti.zcore.dar.gen." + StringManipulation.fixClassname(encounterForm.getName()); Class clazz = null; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection conn = null; try { conn = DatabaseUtils.getZEPRSConnection(org.rti.zcore.Constants.DATABASE_ADMIN_USERNAME); ReportCreator reportCreator = this.getReportCreator(); String username = reportCreator.getUsernameR(); UserInfoReport userInfo = (UserInfoReport) EncountersDAO.getOneReportById(conn, username, "SQL_RETRIEVE_REPORT_ID_ADMIN170", UserInfoReport.class); reportCreator.setEmailR(userInfo.getEmailR()); // email reportCreator.setFirstnameR(userInfo.getForenamesR()); // firstname reportCreator.setLastnameR(userInfo.getLastnameR()); // lastname reportCreator.setMobileR(userInfo.getMobileR()); // mobile reportCreator.setPhoneR(userInfo.getPhoneR()); // phone drugReportList = new ArrayList<DrugReport>(); HashMap<Long, DrugReport> map = new HashMap<Long, DrugReport>(); HashMap<Long, Item> itemMap = new HashMap<Long, Item>(); // Create a map with Item id, name ArrayList<Item> items = (ArrayList<Item>) EncountersDAO.getAll(conn, Long.valueOf(131), "SQL_RETRIEVE_ALL_ADMIN_PAGER131", Item.class); for (Item item : items) { itemMap.put(item.getId(), item); } // For each patient, load the report class and add this patient to the list // also increment the total dispensed values totalDispensed = new OIPatient(); totalDispensedMap = new HashMap(); try { rs = getEncounters(conn, siteId, beginDate, endDate); } catch (Exception e) { e.printStackTrace(); } try { while (rs.next()) { try { Long encounterId = rs.getLong("id"); Long patientId = rs.getLong("patient_id"); String districtPatientId = rs.getString("district_patient_id"); String firstName = rs.getString("first_name"); String surname = rs.getString("surname"); Date dateVisit = rs.getDate("date_visit"); Integer age = rs.getInt("age_at_first_visit"); int currentSiteId = rs.getInt("site_id"); String createdBy = rs.getString("created_by"); Timestamp created = rs.getTimestamp("created"); OIPatient patient = new OIPatient(); patient.setEncounterId(encounterId); patient.setPatientId(patientId); patient.setClientId(districtPatientId); patient.setFirstName(firstName); patient.setSurname(surname); patient.setDateVisit(dateVisit); patient.setSiteId(currentSiteId); patient.setPharmacist(createdBy); patient.setCreated(created); if (age <= 14) { patient.setChildOrAdult("C"); } else { patient.setChildOrAdult("A"); } EncounterData encounter = (EncounterData) PatientItemDAO.getEncounterRawValues(conn, encounterForm, "132", encounterId, clazz); Map encMap = encounter.getEncounterMap(); Set encSet = encMap.entrySet(); boolean isArtVisit = false; for (Iterator iterator = encSet.iterator(); iterator.hasNext();) { Map.Entry entry = (Map.Entry) iterator.next(); Long key = (Long) entry.getKey(); Integer value = (Integer) entry.getValue(); // Someone might have forgotten to enter the value if (value == null) { value = 0; } Item item = itemMap.get(key); int n = 0; if (key != null) { DrugReport drugReport = map.get(key); if (drugReport == null) { drugReport = new DrugReport(); drugReport.setId(item.getId()); drugReport.setName(item.getName()); drugReport.setGroup(item.getItem_group_id()); drugReport.setItem(item); map.put(key, drugReport); } int count = 0; if (drugReport.getTotalDispensed() != null) { count = drugReport.getTotalDispensed() + value; } else { count = value; } drugReport.setTotalDispensed(count); switch (key.intValue()) { case 51: patient.setAcyclovir200mg(value); isArtVisit = true; if (totalDispensed.getAcyclovir200mg() != null) { n = totalDispensed.getAcyclovir200mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setAcyclovir200mg(n); break; case 52: patient.setAcyclovirIVInfusion(value); isArtVisit = true; if (totalDispensed.getAcyclovirIVInfusion() != null) { n = totalDispensed.getAcyclovirIVInfusion() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setAcyclovirIVInfusion(n); break; case 50: patient.setAminosidineSulphate(value); isArtVisit = true; if (totalDispensed.getAminosidineSulphate() != null) { n = totalDispensed.getAminosidineSulphate() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setAminosidineSulphate(n); break; case 49: patient.setAminosidineSulphateliquid(value); isArtVisit = true; if (totalDispensed.getAminosidineSulphateliquid() != null) { n = totalDispensed.getAminosidineSulphateliquid() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setAminosidineSulphateliquid(n); break; case 44: patient.setAmphotericinBInjection(value); isArtVisit = true; if (totalDispensed.getAmphotericinBInjection() != null) { n = totalDispensed.getAmphotericinBInjection() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setAmphotericinBInjection(n); break; case 48: patient.setCeftriaxoneInj250mgIM(value); isArtVisit = true; if (totalDispensed.getCeftriaxoneInj250mgIM() != null) { n = totalDispensed.getCeftriaxoneInj250mgIM() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setCeftriaxoneInj250mgIM(n); break; case 47: patient.setCiprofloxacinTabs500mg(value); isArtVisit = true; if (totalDispensed.getCiprofloxacinTabs500mg() != null) { n = totalDispensed.getCiprofloxacinTabs500mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setCiprofloxacinTabs500mg(n); break; case 46: patient.setCotrimoxazoleDS960mg(value); isArtVisit = true; if (totalDispensed.getCotrimoxazoleDS960mg() != null) { n = totalDispensed.getCotrimoxazoleDS960mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setCotrimoxazoleDS960mg(n); break; case 174: patient.setCotrimoxazoleTabs480mg(value); isArtVisit = true; if (totalDispensed.getCotrimoxazoleTabs480mg() != null) { n = totalDispensed.getCotrimoxazoleTabs480mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setCotrimoxazoleTabs480mg(n); break; case 45: patient.setCotrimoxazolesusp240mg_5ml(value); isArtVisit = true; if (totalDispensed.getCotrimoxazolesusp240mg_5ml() != null) { n = totalDispensed.getCotrimoxazolesusp240mg_5ml() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setCotrimoxazolesusp240mg_5ml(n); break; case 35: patient.setDiflucan200mg(value); isArtVisit = true; if (totalDispensed.getDiflucan200mg() != null) { n = totalDispensed.getDiflucan200mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setDiflucan200mg(n); break; case 37: patient.setDiflucanInfusion(value); isArtVisit = true; if (totalDispensed.getDiflucanInfusion() != null) { n = totalDispensed.getDiflucanInfusion() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setDiflucanInfusion(n); break; case 36: patient.setDiflucansuspension(value); isArtVisit = true; if (totalDispensed.getDiflucansuspension() != null) { n = totalDispensed.getDiflucansuspension() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setDiflucansuspension(n); break; case 39: patient.setFluconazole150mg(value); isArtVisit = true; if (totalDispensed.getFluconazole150mg() != null) { n = totalDispensed.getFluconazole150mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setFluconazole150mg(n); break; case 38: patient.setFluconazole200mg(value); isArtVisit = true; if (totalDispensed.getFluconazole200mg() != null) { n = totalDispensed.getFluconazole200mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setFluconazole200mg(n); break; case 40: patient.setFluconazole50mg(value); isArtVisit = true; if (totalDispensed.getFluconazole50mg() != null) { n = totalDispensed.getFluconazole50mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setFluconazole50mg(n); break; case 41: patient.setKetaconazole200mg(value); isArtVisit = true; if (totalDispensed.getKetaconazole200mg() != null) { n = totalDispensed.getKetaconazole200mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setKetaconazole200mg(n); break; case 42: patient.setMiconazoleNitrate2OralGel(value); isArtVisit = true; if (totalDispensed.getMiconazoleNitrate2OralGel() != null) { n = totalDispensed.getMiconazoleNitrate2OralGel() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setMiconazoleNitrate2OralGel(n); break; case 43: patient.setNystatinOralSuspension100000Units(value); isArtVisit = true; if (totalDispensed.getNystatinOralSuspension100000Units() != null) { n = totalDispensed.getNystatinOralSuspension100000Units() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setNystatinOralSuspension100000Units(n); break; case 53: patient.setPyridoxine25mg(value); isArtVisit = true; if (totalDispensed.getPyridoxine25mg() != null) { n = totalDispensed.getPyridoxine25mg() + value; } else { n = value; } totalDispensedMap.put(key.intValue(), n); totalDispensed.setPyridoxine25mg(n); break; default: break; } } else { log.debug("Key is null: Patient ID: " + patientId + " EncounterId: " + encounterId + " in form 132"); } } // no need to do this query if it's not an art visit if (isArtVisit == true) { // check if this is the first visit - there might be multiples ones for this encounter Date firstVisit = EncountersDAO.getFirstVisit(conn, patientId); if (firstVisit.getTime() == dateVisit.getTime()) { patient.setRevisit(false); } else { patient.setRevisit(true); } } // don't add this patient if it's not an art visit if (isArtVisit == true) { patient.setEncounter(encounter); if (patient != null) { this.addPatient(patient); /*if (patientMap.get(patient.getPatientId()) != null) { ARTCombinedPatient encounter = (ARTCombinedPatient) patientMap.get(patient.getPatientId()); encounters.add(patient); } else { patientMap.put(patient.getPatientId(), patient); }*/ } } } catch (SQLException e) { log.error(e); } } } catch (SQLException e) { log.error(e); } // Get the stock onHand for each item try { balanceBF = new OIPatient(); received = new OIPatient(); onHand = new OIPatient(); losses = new OIPatient(); negAdjustments = new OIPatient(); posAdjustments = new OIPatient(); quantity6MonthsExpired = new OIPatient(); expiryDate = new OIExpiration(); daysOutOfStock = new OIPatient(); quantityRequiredResupply = new OIPatient(); quantityRequiredNewPatients = new OIPatient(); totalQuantityRequired = new OIPatient(); //HashMap<Long, List<StockControl>> stockMap = InventoryDAO.getPatientStockMap(conn, siteId, beginDate, endDate); HashMap<Long, StockReport> balanceMap = InventoryDAO.getBalanceMap(conn, siteId, null, endDate); HashMap<Long, StockReport> balanceBFMap = InventoryDAO.getBalanceMap(conn, null, beginDate, endDate); //https://ogembo@bitbucket.org/ogembo/zcore-dar.git java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat( org.rti.zcore.Constants.DATE_FORMAT_SHORT); sdf.setTimeZone(TimeZone.getDefault()); //https://github.com/boloogembo/chrisekelley.github.io.git //https://github.com/chrisekelley/dar //https://github.com/chrisekelley/dar.git //https://github.com/boloogembo/chrisekelley.github.io.git //https://github.com/boloogembo/dar.git Integer currentBalance = null; List<DropdownItem> list = WidgetUtils.getList(conn, "item", "id", " WHERE ITEM_GROUP_ID < 9 ", " ORDER BY id ", DropdownItem.class, null); for (DropdownItem dropdownItem : list) { Long itemId = Long.valueOf(dropdownItem.getDropdownId()); List<StockControl> stockChanges = (List<StockControl>) InventoryDAO.getStockChanges(conn, itemId, siteId, beginDate, endDate); StockReport stockReport = balanceMap.get(itemId); if (stockReport == null) { currentBalance = 0; } else { currentBalance = stockReport.getOnHand(); } Integer stockReceived = 0; Integer stockLoss = 0; Integer stockNegAdjust = 0; Integer stockPosAdjust = 0; Integer stock6monthExpiry = 0; Integer stockRemaining = 0; Integer outOfStockDays = 0; Integer stockResupply = 0; Integer stockNew = 0; Integer totalRequired = 0; String expiry = null; String expiryValue = null; //String expiryStr = null; Boolean isExpirySet = false; int i = 0; //Integer totalLosses = 0; //List<StockControl> stockChanges = (List<StockControl>) InventoryDAO.getStockChanges(conn, itemId, siteId, beginDate, endDate); Date expiryDateD = null; if (stockChanges.size() > 0) { for (Iterator iterator = stockChanges.iterator(); iterator.hasNext();) { StockControl stock = (StockControl) iterator.next(); i++; Integer changeType = stock.getType_of_change(); Integer quantity = stock.getChange_value(); //expiryValue = stock.getExpiry_date(); if (stock.getExpiry_date() != null) { expiryValue = sdf.format(stock.getExpiry_date().getTime()); } Timestamp created = stock.getCreated(); if (quantity != null) { if (expiryValue != null) { //Boolean sixMonthsExpiry = DateUtils.check6monthExpiry(endDate, expiryValue); if (stock.getExpiry_date() != null) { Boolean sixMonthsExpiry = InventoryUtils.checkExpiry(endDate, stock.getExpiry_date(), 6); // TODO: need to make sure that previous stock is not exhausted // currently you may use the remaining field in the form to tweak the results. if (sixMonthsExpiry == true) { //stock6monthExpiry++; stock6monthExpiry = currentBalance; /*if (remaining != null) { stockRemaining = stockRemaining + remaining; }*/ // do not display expiry unless stock6monthExpiry >0 if (stock6monthExpiry > 0) { if (isExpirySet == false) { expiry = expiryValue; isExpirySet = true; expiryDateD = stock.getExpiry_date(); } } } } else { //log.debug("stock.getExpiry_date() -- null for itemId: " + stock.getId()); } } switch (changeType.intValue()) { case 3263: // received stockReceived = stockReceived + quantity; break; case 3265: // loss stockLoss = stockLoss + quantity; break; case 3266: // Pos. Adjust. stockPosAdjust = stockPosAdjust + quantity; break; case 3267: // Neg. Adjust. stockNegAdjust = stockNegAdjust + quantity; break; case 3279: // Out-of-stock if (i == 1) { // calc how many days since this out-of-stock record was created long days = DateUtils.calculateDays(created, endDate); outOfStockDays = Long.valueOf(days).intValue(); if (outOfStockDays == 0) { outOfStockDays = 1; } } break; default: break; } } } } int totalDispensedInt = 0; if (totalDispensedMap.get(itemId.intValue()) != null) { try { totalDispensedInt = (Integer) totalDispensedMap.get(itemId.intValue()); } catch (Exception e) { log.debug("itemId: " + itemId.intValue() + " totalDispensedMap: " + totalDispensedMap.toString()); } } stockResupply = (3 * totalDispensedInt) - currentBalance; if (stockResupply < 0) { stockResupply = 0; } /*StockControl beginningStockControl = InventoryDAO.getBeginningStockBalance(conn, 161, itemId, beginDate); Integer beginningBalance = beginningStockControl.getBalance();*/ StockReport stockReportBbf = balanceBFMap.get(itemId); Integer beginningBalance = 0; if (stockReportBbf == null) { beginningBalance = 0; } else { beginningBalance = stockReportBbf.getOnHand(); } if (stockRemaining > 0) { stock6monthExpiry = stockRemaining; } if (currentBalance == 0) { expiry = null; } // keep the report easy-to-read - not a bunch of zeros. if (stockLoss == 0) { stockLoss = null; } if (stockReceived == 0) { stockReceived = null; } if (stockPosAdjust == 0) { stockPosAdjust = null; } if (stockNegAdjust == 0) { stockNegAdjust = null; } if (stock6monthExpiry == 0) { stock6monthExpiry = null; } if (outOfStockDays == 0) { //if (value > 0) { outOfStockDays = null; //} } if (stockResupply == 0) { stockResupply = null; } if (stockNew == 0) { stockNew = null; } if (totalRequired == 0) { totalRequired = null; } // You want to see if the stock balance is 0. /*if (value == 0) { value = null; }*/ Item item = itemMap.get(itemId); DrugReport drugReport = map.get(itemId); if (drugReport == null) { drugReport = new DrugReport(); drugReport.setId(item.getId()); drugReport.setName(item.getName()); drugReport.setGroup(item.getItem_group_id()); drugReport.setItem(item); } drugReport.setBalanceBF(beginningBalance); drugReport.setOnHand(currentBalance); drugReport.setLosses(stockLoss); drugReport.setReceived(stockReceived); drugReport.setPosAdjustments(stockPosAdjust); drugReport.setNegAdjustments(stockNegAdjust); drugReport.setQuantity6MonthsExpired(stock6monthExpiry); drugReport.setExpiryDate(expiryDateD); drugReport.setDaysOutOfStock(outOfStockDays); drugReport.setQuantityRequiredResupply(stockResupply); drugReport.setQuantityRequiredNewPatients(stockNew); drugReport.setTotalQuantityRequired(totalRequired); if ((drugReport.getTotalDispensed() != null) || (stockChanges.size() > 0) || ((currentBalance != 0) && (beginningBalance != 0))) { map.put(itemId, drugReport); } switch (itemId.intValue()) { case 51: balanceBF.setAcyclovir200mg(beginningBalance); onHand.setAcyclovir200mg(currentBalance); losses.setAcyclovir200mg(stockLoss); received.setAcyclovir200mg(stockReceived); posAdjustments.setAcyclovir200mg(stockPosAdjust); negAdjustments.setAcyclovir200mg(stockNegAdjust); quantity6MonthsExpired.setAcyclovir200mg(stock6monthExpiry); expiryDate.setAcyclovir200mg(expiry); daysOutOfStock.setAcyclovir200mg(outOfStockDays); quantityRequiredResupply.setAcyclovir200mg(stockResupply); quantityRequiredNewPatients.setAcyclovir200mg(stockNew); totalQuantityRequired.setAcyclovir200mg(totalRequired); break; case 52: balanceBF.setAcyclovirIVInfusion(beginningBalance); onHand.setAcyclovirIVInfusion(currentBalance); losses.setAcyclovirIVInfusion(stockLoss); received.setAcyclovirIVInfusion(stockReceived); posAdjustments.setAcyclovirIVInfusion(stockPosAdjust); negAdjustments.setAcyclovirIVInfusion(stockNegAdjust); quantity6MonthsExpired.setAcyclovirIVInfusion(stock6monthExpiry); expiryDate.setAcyclovirIVInfusion(expiry); daysOutOfStock.setAcyclovirIVInfusion(outOfStockDays); quantityRequiredResupply.setAcyclovirIVInfusion(stockResupply); quantityRequiredNewPatients.setAcyclovirIVInfusion(stockNew); totalQuantityRequired.setAcyclovirIVInfusion(totalRequired); break; case 50: balanceBF.setAminosidineSulphate(beginningBalance); onHand.setAminosidineSulphate(currentBalance); losses.setAminosidineSulphate(stockLoss); received.setAminosidineSulphate(stockReceived); posAdjustments.setAminosidineSulphate(stockPosAdjust); negAdjustments.setAminosidineSulphate(stockNegAdjust); quantity6MonthsExpired.setAminosidineSulphate(stock6monthExpiry); expiryDate.setAminosidineSulphate(expiry); daysOutOfStock.setAminosidineSulphate(outOfStockDays); quantityRequiredResupply.setAminosidineSulphate(stockResupply); quantityRequiredNewPatients.setAminosidineSulphate(stockNew); totalQuantityRequired.setAminosidineSulphate(totalRequired); break; case 49: balanceBF.setAminosidineSulphateliquid(beginningBalance); onHand.setAminosidineSulphateliquid(currentBalance); losses.setAminosidineSulphateliquid(stockLoss); received.setAminosidineSulphateliquid(stockReceived); posAdjustments.setAminosidineSulphateliquid(stockPosAdjust); negAdjustments.setAminosidineSulphateliquid(stockNegAdjust); quantity6MonthsExpired.setAminosidineSulphateliquid(stock6monthExpiry); expiryDate.setAminosidineSulphateliquid(expiry); daysOutOfStock.setAminosidineSulphateliquid(outOfStockDays); quantityRequiredResupply.setAminosidineSulphateliquid(stockResupply); quantityRequiredNewPatients.setAminosidineSulphateliquid(stockNew); totalQuantityRequired.setAminosidineSulphateliquid(totalRequired); break; case 44: balanceBF.setAmphotericinBInjection(beginningBalance); onHand.setAmphotericinBInjection(currentBalance); losses.setAmphotericinBInjection(stockLoss); received.setAmphotericinBInjection(stockReceived); posAdjustments.setAmphotericinBInjection(stockPosAdjust); negAdjustments.setAmphotericinBInjection(stockNegAdjust); quantity6MonthsExpired.setAmphotericinBInjection(stock6monthExpiry); expiryDate.setAmphotericinBInjection(expiry); daysOutOfStock.setAmphotericinBInjection(outOfStockDays); quantityRequiredResupply.setAmphotericinBInjection(stockResupply); quantityRequiredNewPatients.setAmphotericinBInjection(stockNew); totalQuantityRequired.setAmphotericinBInjection(totalRequired); break; case 48: balanceBF.setCeftriaxoneInj250mgIM(beginningBalance); onHand.setCeftriaxoneInj250mgIM(currentBalance); losses.setCeftriaxoneInj250mgIM(stockLoss); received.setCeftriaxoneInj250mgIM(stockReceived); posAdjustments.setCeftriaxoneInj250mgIM(stockPosAdjust); negAdjustments.setCeftriaxoneInj250mgIM(stockNegAdjust); quantity6MonthsExpired.setCeftriaxoneInj250mgIM(stock6monthExpiry); expiryDate.setCeftriaxoneInj250mgIM(expiry); daysOutOfStock.setCeftriaxoneInj250mgIM(outOfStockDays); quantityRequiredResupply.setCeftriaxoneInj250mgIM(stockResupply); quantityRequiredNewPatients.setCeftriaxoneInj250mgIM(stockNew); totalQuantityRequired.setCeftriaxoneInj250mgIM(totalRequired); break; case 47: balanceBF.setCiprofloxacinTabs500mg(beginningBalance); onHand.setCiprofloxacinTabs500mg(currentBalance); losses.setCiprofloxacinTabs500mg(stockLoss); received.setCiprofloxacinTabs500mg(stockReceived); posAdjustments.setCiprofloxacinTabs500mg(stockPosAdjust); negAdjustments.setCiprofloxacinTabs500mg(stockNegAdjust); quantity6MonthsExpired.setCiprofloxacinTabs500mg(stock6monthExpiry); expiryDate.setCiprofloxacinTabs500mg(expiry); daysOutOfStock.setCiprofloxacinTabs500mg(outOfStockDays); quantityRequiredResupply.setCiprofloxacinTabs500mg(stockResupply); quantityRequiredNewPatients.setCiprofloxacinTabs500mg(stockNew); totalQuantityRequired.setCiprofloxacinTabs500mg(totalRequired); break; case 46: balanceBF.setCotrimoxazoleDS960mg(beginningBalance); onHand.setCotrimoxazoleDS960mg(currentBalance); losses.setCotrimoxazoleDS960mg(stockLoss); negAdjustments.setCotrimoxazoleDS960mg(stockNegAdjust); posAdjustments.setCotrimoxazoleDS960mg(stockPosAdjust); received.setCotrimoxazoleDS960mg(stockReceived); quantity6MonthsExpired.setCotrimoxazoleDS960mg(stock6monthExpiry); expiryDate.setCotrimoxazoleDS960mg(expiry); daysOutOfStock.setCotrimoxazoleDS960mg(outOfStockDays); quantityRequiredResupply.setCotrimoxazoleDS960mg(stockResupply); quantityRequiredNewPatients.setCotrimoxazoleDS960mg(stockNew); totalQuantityRequired.setCotrimoxazoleDS960mg(totalRequired); break; case 174: balanceBF.setCotrimoxazoleTabs480mg(beginningBalance); onHand.setCotrimoxazoleTabs480mg(currentBalance); losses.setCotrimoxazoleTabs480mg(stockLoss); negAdjustments.setCotrimoxazoleTabs480mg(stockNegAdjust); posAdjustments.setCotrimoxazoleTabs480mg(stockPosAdjust); received.setCotrimoxazoleTabs480mg(stockReceived); quantity6MonthsExpired.setCotrimoxazoleTabs480mg(stock6monthExpiry); expiryDate.setCotrimoxazoleTabs480mg(expiry); daysOutOfStock.setCotrimoxazoleTabs480mg(outOfStockDays); quantityRequiredResupply.setCotrimoxazoleTabs480mg(stockResupply); quantityRequiredNewPatients.setCotrimoxazoleTabs480mg(stockNew); totalQuantityRequired.setCotrimoxazoleTabs480mg(totalRequired); break; case 45: balanceBF.setCotrimoxazolesusp240mg_5ml(beginningBalance); onHand.setCotrimoxazolesusp240mg_5ml(currentBalance); losses.setCotrimoxazolesusp240mg_5ml(stockLoss); negAdjustments.setCotrimoxazolesusp240mg_5ml(stockNegAdjust); posAdjustments.setCotrimoxazolesusp240mg_5ml(stockPosAdjust); received.setCotrimoxazolesusp240mg_5ml(stockReceived); quantity6MonthsExpired.setCotrimoxazolesusp240mg_5ml(stock6monthExpiry); expiryDate.setCotrimoxazolesusp240mg_5ml(expiry); daysOutOfStock.setCotrimoxazolesusp240mg_5ml(outOfStockDays); quantityRequiredResupply.setCotrimoxazolesusp240mg_5ml(stockResupply); quantityRequiredNewPatients.setCotrimoxazolesusp240mg_5ml(stockNew); totalQuantityRequired.setCotrimoxazolesusp240mg_5ml(totalRequired); break; case 35: balanceBF.setDiflucan200mg(beginningBalance); onHand.setDiflucan200mg(currentBalance); losses.setDiflucan200mg(stockLoss); received.setDiflucan200mg(stockReceived); posAdjustments.setDiflucan200mg(stockPosAdjust); negAdjustments.setDiflucan200mg(stockNegAdjust); quantity6MonthsExpired.setDiflucan200mg(stock6monthExpiry); expiryDate.setDiflucan200mg(expiry); daysOutOfStock.setDiflucan200mg(outOfStockDays); quantityRequiredResupply.setDiflucan200mg(stockResupply); quantityRequiredNewPatients.setDiflucan200mg(stockNew); totalQuantityRequired.setDiflucan200mg(totalRequired); break; case 37: balanceBF.setDiflucanInfusion(beginningBalance); onHand.setDiflucanInfusion(currentBalance); losses.setDiflucanInfusion(stockLoss); received.setDiflucanInfusion(stockReceived); posAdjustments.setDiflucanInfusion(stockPosAdjust); negAdjustments.setDiflucanInfusion(stockNegAdjust); quantity6MonthsExpired.setDiflucanInfusion(stock6monthExpiry); expiryDate.setDiflucanInfusion(expiry); daysOutOfStock.setDiflucanInfusion(outOfStockDays); quantityRequiredResupply.setDiflucanInfusion(stockResupply); quantityRequiredNewPatients.setDiflucanInfusion(stockNew); totalQuantityRequired.setDiflucanInfusion(totalRequired); break; case 36: balanceBF.setDiflucansuspension(beginningBalance); onHand.setDiflucansuspension(currentBalance); losses.setDiflucansuspension(stockLoss); received.setDiflucansuspension(stockReceived); posAdjustments.setDiflucansuspension(stockPosAdjust); negAdjustments.setDiflucansuspension(stockNegAdjust); quantity6MonthsExpired.setDiflucansuspension(stock6monthExpiry); expiryDate.setDiflucansuspension(expiry); daysOutOfStock.setDiflucansuspension(outOfStockDays); quantityRequiredResupply.setDiflucansuspension(stockResupply); quantityRequiredNewPatients.setDiflucansuspension(stockNew); totalQuantityRequired.setDiflucansuspension(totalRequired); break; case 39: balanceBF.setFluconazole150mg(beginningBalance); onHand.setFluconazole150mg(currentBalance); losses.setFluconazole150mg(stockLoss); received.setFluconazole150mg(stockReceived); posAdjustments.setFluconazole150mg(stockPosAdjust); negAdjustments.setFluconazole150mg(stockNegAdjust); quantity6MonthsExpired.setFluconazole150mg(stock6monthExpiry); expiryDate.setFluconazole150mg(expiry); daysOutOfStock.setFluconazole150mg(outOfStockDays); quantityRequiredResupply.setFluconazole150mg(stockResupply); quantityRequiredNewPatients.setFluconazole150mg(stockNew); totalQuantityRequired.setFluconazole150mg(totalRequired); break; case 38: balanceBF.setFluconazole200mg(beginningBalance); onHand.setFluconazole200mg(currentBalance); losses.setFluconazole200mg(stockLoss); received.setFluconazole200mg(stockReceived); posAdjustments.setFluconazole200mg(stockPosAdjust); negAdjustments.setFluconazole200mg(stockNegAdjust); quantity6MonthsExpired.setFluconazole200mg(stock6monthExpiry); expiryDate.setFluconazole200mg(expiry); daysOutOfStock.setFluconazole200mg(outOfStockDays); quantityRequiredResupply.setFluconazole200mg(stockResupply); quantityRequiredNewPatients.setFluconazole200mg(stockNew); totalQuantityRequired.setFluconazole200mg(totalRequired); break; case 40: balanceBF.setFluconazole50mg(beginningBalance); onHand.setFluconazole50mg(currentBalance); losses.setFluconazole50mg(stockLoss); received.setFluconazole50mg(stockReceived); posAdjustments.setFluconazole50mg(stockPosAdjust); negAdjustments.setFluconazole50mg(stockNegAdjust); quantity6MonthsExpired.setFluconazole50mg(stock6monthExpiry); expiryDate.setFluconazole50mg(expiry); daysOutOfStock.setFluconazole50mg(outOfStockDays); quantityRequiredResupply.setFluconazole50mg(stockResupply); quantityRequiredNewPatients.setFluconazole50mg(stockNew); totalQuantityRequired.setFluconazole50mg(totalRequired); break; case 41: balanceBF.setKetaconazole200mg(beginningBalance); onHand.setKetaconazole200mg(currentBalance); losses.setKetaconazole200mg(stockLoss); received.setKetaconazole200mg(stockReceived); posAdjustments.setKetaconazole200mg(stockPosAdjust); negAdjustments.setKetaconazole200mg(stockNegAdjust); quantity6MonthsExpired.setKetaconazole200mg(stock6monthExpiry); expiryDate.setKetaconazole200mg(expiry); daysOutOfStock.setKetaconazole200mg(outOfStockDays); quantityRequiredResupply.setKetaconazole200mg(stockResupply); quantityRequiredNewPatients.setKetaconazole200mg(stockNew); totalQuantityRequired.setKetaconazole200mg(totalRequired); break; case 42: balanceBF.setMiconazoleNitrate2OralGel(beginningBalance); onHand.setMiconazoleNitrate2OralGel(currentBalance); losses.setMiconazoleNitrate2OralGel(stockLoss); received.setMiconazoleNitrate2OralGel(stockReceived); posAdjustments.setMiconazoleNitrate2OralGel(stockPosAdjust); negAdjustments.setMiconazoleNitrate2OralGel(stockNegAdjust); quantity6MonthsExpired.setMiconazoleNitrate2OralGel(stock6monthExpiry); expiryDate.setMiconazoleNitrate2OralGel(expiry); daysOutOfStock.setMiconazoleNitrate2OralGel(outOfStockDays); quantityRequiredResupply.setMiconazoleNitrate2OralGel(stockResupply); quantityRequiredNewPatients.setMiconazoleNitrate2OralGel(stockNew); totalQuantityRequired.setMiconazoleNitrate2OralGel(totalRequired); break; case 43: balanceBF.setNystatinOralSuspension100000Units(beginningBalance); onHand.setNystatinOralSuspension100000Units(currentBalance); losses.setNystatinOralSuspension100000Units(stockLoss); received.setNystatinOralSuspension100000Units(stockReceived); posAdjustments.setNystatinOralSuspension100000Units(stockPosAdjust); negAdjustments.setNystatinOralSuspension100000Units(stockNegAdjust); quantity6MonthsExpired.setNystatinOralSuspension100000Units(stock6monthExpiry); expiryDate.setNystatinOralSuspension100000Units(expiry); daysOutOfStock.setNystatinOralSuspension100000Units(outOfStockDays); quantityRequiredResupply.setNystatinOralSuspension100000Units(stockResupply); quantityRequiredNewPatients.setNystatinOralSuspension100000Units(stockNew); totalQuantityRequired.setNystatinOralSuspension100000Units(totalRequired); break; case 53: balanceBF.setPyridoxine25mg(beginningBalance); onHand.setPyridoxine25mg(currentBalance); losses.setPyridoxine25mg(stockLoss); received.setPyridoxine25mg(stockReceived); posAdjustments.setPyridoxine25mg(stockPosAdjust); negAdjustments.setPyridoxine25mg(stockNegAdjust); quantity6MonthsExpired.setPyridoxine25mg(stock6monthExpiry); expiryDate.setPyridoxine25mg(expiry); daysOutOfStock.setPyridoxine25mg(outOfStockDays); quantityRequiredResupply.setPyridoxine25mg(stockResupply); quantityRequiredNewPatients.setPyridoxine25mg(stockNew); totalQuantityRequired.setPyridoxine25mg(totalRequired); break; default: break; } } Set<Entry<Long, DrugReport>> set = map.entrySet(); for (Entry<Long, DrugReport> entry : set) { DrugReport report = entry.getValue(); drugReportList.add(report); } //Collections.sort(drugReportList, new SiteStatisticsDAO().new CodeComparator()); Collections.sort(drugReportList, new DrugReportNameComparator()); } catch (SQLException e) { log.error(e); } // Now get stats for ART regimens artRegimenReport = new ARTReport(); try { rs = getArtRegimens(conn, siteId, beginDate, endDate); while (rs.next()) { Integer age = rs.getInt("age"); String code = rs.getString("code"); Long encounterId = rs.getLong("id"); Long patientId = rs.getLong("patient_id"); String districtPatientId = rs.getString("district_patient_id"); String firstName = rs.getString("first_name"); String surname = rs.getString("surname"); Date dateVisit = rs.getDate("date_visit"); int currentSiteId = rs.getInt("site_id"); String createdBy = rs.getString("created_by"); Timestamp created = rs.getTimestamp("created"); OIPatient patient = new OIPatient(); patient.setEncounterId(encounterId); patient.setPatientId(patientId); patient.setClientId(districtPatientId); patient.setFirstName(firstName); patient.setSurname(surname); patient.setDateVisit(dateVisit); patient.setSiteId(currentSiteId); patient.setPharmacist(createdBy); //patient.setArvRegimenCode(code); patient.setCreated(created); if (age <= 14) { patient.setChildOrAdult("C"); } else { patient.setChildOrAdult("A"); } // increment the totals if (age != null && age > 14) { int n = artRegimenReport.getTotalAdults(); n++; artRegimenReport.setTotalAdults(n); } if (age != null && age <= 14) { int n = artRegimenReport.getTotalChildren(); n++; artRegimenReport.setTotalChildren(n); } if (patient != null) { // check if this is the first visit - there might be multiples ones for this encounter Date firstVisit = EncountersDAO.getFirstVisit(conn, patientId); if (firstVisit.getTime() == dateVisit.getTime()) { patient.setRevisit(false); } else { patient.setRevisit(true); } this.addPatient(patient); /*if (patientMap.get(patient.getPatientId()) != null) { ARTCombinedPatient encounter = (ARTCombinedPatient) patientMap.get(patient.getPatientId()); encounters.add(patient); } else { patientMap.put(patient.getPatientId(), patient); }*/ } } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { try { conn.close(); } catch (SQLException e) { log.error(e); } } }
From source file:edu.harvard.i2b2.ontology.dao.ConceptDao.java
private ParameterizedRowMapper<ModifierType> getModMapper(final NodeType node, final boolean ofuscatedUserFlag, final String dbType) { ParameterizedRowMapper<ModifierType> mapper = new ParameterizedRowMapper<ModifierType>() { public ModifierType mapRow(ResultSet rs, int rowNum) throws SQLException { ModifierType child = new ModifierType(); if (node.getType().equals("limited")) { child.setName(rs.getString("c_name")); child.setAppliedPath(rs.getString("m_applied_path")); child.setBasecode(rs.getString("c_basecode")); child.setKey("\\\\" + node.getNode() + rs.getString("c_fullname")); child.setLevel(rs.getInt("c_hlevel")); child.setFullname(rs.getString("c_fullname")); child.setVisualattributes(rs.getString("c_visualattributes")); child.setSynonymCd(rs.getString("c_synonym_cd")); child.setTooltip(rs.getString("c_tooltip")); } else { child.setName(rs.getString("c_name")); child.setAppliedPath(rs.getString("m_applied_path")); child.setBasecode(rs.getString("c_basecode")); child.setKey("\\\\" + node.getNode() + rs.getString("c_fullname")); child.setLevel(rs.getInt("c_hlevel")); child.setFullname(rs.getString("c_fullname")); child.setVisualattributes(rs.getString("c_visualattributes")); child.setSynonymCd(rs.getString("c_synonym_cd")); child.setFacttablecolumn(rs.getString("c_facttablecolumn")); child.setTooltip(rs.getString("c_tooltip")); child.setTablename(rs.getString("c_tablename")); child.setColumnname(rs.getString("c_columnname")); child.setColumndatatype(rs.getString("c_columndatatype")); child.setOperator(rs.getString("c_operator")); child.setDimcode(rs.getString("c_dimcode")); }/*from w w w. j a v a 2 s. co m*/ if (node.isBlob() == true) { try { if (dbType.equals("POSTGRESQL")) { if (rs.getString("c_comment") == null) child.setComment(null); else child.setComment(rs.getString("c_comment")); } else { if (rs.getClob("c_comment") == null) child.setComment(null); else child.setComment(JDBCUtil.getClobString(rs.getClob("c_comment"))); } } catch (IOException e) { log.error(e.getMessage()); child.setComment(null); } String c_xml = null; try { if (dbType.equals("POSTGRESQL")) c_xml = rs.getString("c_metadataxml"); else if (rs.getClob("c_metadataxml") != null) c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml")); } catch (IOException e) { log.error(e.getMessage()); child.setMetadataxml(null); } if (c_xml == null) { child.setMetadataxml(null); } else { if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) { SAXBuilder parser = new SAXBuilder(); java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml); Element rootElement = null; try { org.jdom.Document metadataDoc = parser.build(xmlStringReader); org.jdom.output.DOMOutputter out = new DOMOutputter(); Document doc = out.output(metadataDoc); rootElement = doc.getDocumentElement(); } catch (JDOMException e) { log.error(e.getMessage()); child.setMetadataxml(null); } catch (IOException e1) { log.error(e1.getMessage()); child.setMetadataxml(null); } if (rootElement != null) { XmlValueType xml = new XmlValueType(); xml.getAny().add(rootElement); child.setMetadataxml(xml); } } else { child.setMetadataxml(null); } } } if ((node.getType().equals("all"))) { DTOFactory factory = new DTOFactory(); // make sure date isnt null before converting to XMLGregorianCalendar Date date = rs.getDate("update_date"); if (date == null) child.setUpdateDate(null); else child.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("download_date"); if (date == null) child.setDownloadDate(null); else child.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("import_date"); if (date == null) child.setImportDate(null); else child.setImportDate(factory.getXMLGregorianCalendar(date.getTime())); child.setSourcesystemCd(rs.getString("sourcesystem_cd")); } return child; } }; return mapper; }
From source file:edu.harvard.i2b2.ontology.dao.ConceptDao.java
private ParameterizedRowMapper<ConceptType> getMapper(final NodeType node, final boolean ofuscatedUserFlag, final String dbType) { ParameterizedRowMapper<ConceptType> mapper = new ParameterizedRowMapper<ConceptType>() { public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptType child = new ConceptType(); child.setName(rs.getString("c_name")); if (!(node.getType().equals("default"))) { child.setBasecode(rs.getString("c_basecode")); child.setLevel(rs.getInt("c_hlevel")); // cover get Code Info case where we dont know the vocabType.category apriori if (node.getNode() != null) child.setKey("\\\\" + node.getNode() + rs.getString("c_fullname")); else child.setKey("\\\\" + rs.getString("tableCd") + rs.getString("c_fullname")); child.setSynonymCd(rs.getString("c_synonym_cd")); child.setVisualattributes(rs.getString("c_visualattributes")); Integer totalNumValue = rs.getInt("c_totalnum"); boolean nullFlag = rs.wasNull(); /*// w w w. j av a 2s . c o m if (nullFlag) { ("null in totalnum flag "); } else { ("not null in totalnum flag "); } if (rs.getString("c_totalnum") == null) { ("null in totalnum flag using getString method"); } else { ("not null in totalnum flag using getString method [" + rs.getString("c_totalnum") + "]"); } */ if (ofuscatedUserFlag == false && nullFlag == false) { child.setTotalnum(totalNumValue); } child.setTooltip(rs.getString("c_tooltip")); child.setValuetypeCd(rs.getString("valuetype_cd")); if (!(node.getType().equals("limited"))) { child.setFacttablecolumn(rs.getString("c_facttablecolumn")); child.setTablename(rs.getString("c_tablename")); child.setColumnname(rs.getString("c_columnname")); child.setColumndatatype(rs.getString("c_columndatatype")); child.setOperator(rs.getString("c_operator")); child.setDimcode(rs.getString("c_dimcode")); } } if (node.isBlob() == true) { try { if (dbType.equals("POSTGRESQL")) { if (rs.getString("c_comment") == null) child.setComment(null); else child.setComment(rs.getString("c_comment")); } else { if (rs.getClob("c_comment") == null) child.setComment(null); else child.setComment(JDBCUtil.getClobString(rs.getClob("c_comment"))); } } catch (IOException e) { log.error(e.getMessage()); child.setComment(null); } String c_xml = null; try { if (dbType.equals("POSTGRESQL")) c_xml = rs.getString("c_metadataxml"); else if (rs.getClob("c_metadataxml") != null) c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml")); } catch (IOException e) { log.error(e.getMessage()); child.setMetadataxml(null); } if (c_xml == null) { child.setMetadataxml(null); } else { if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) { SAXBuilder parser = new SAXBuilder(); java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml); Element rootElement = null; try { org.jdom.Document metadataDoc = parser.build(xmlStringReader); org.jdom.output.DOMOutputter out = new DOMOutputter(); Document doc = out.output(metadataDoc); rootElement = doc.getDocumentElement(); } catch (JDOMException e) { log.error(e.getMessage()); child.setMetadataxml(null); } catch (IOException e1) { log.error(e1.getMessage()); child.setMetadataxml(null); } if (rootElement != null) { XmlValueType xml = new XmlValueType(); xml.getAny().add(rootElement); child.setMetadataxml(xml); } } else { child.setMetadataxml(null); } } } if ((node.getType().equals("all"))) { DTOFactory factory = new DTOFactory(); // make sure date isnt null before converting to XMLGregorianCalendar Date date = rs.getDate("update_date"); if (date == null) child.setUpdateDate(null); else child.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("download_date"); if (date == null) child.setDownloadDate(null); else child.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("import_date"); if (date == null) child.setImportDate(null); else child.setImportDate(factory.getXMLGregorianCalendar(date.getTime())); child.setSourcesystemCd(rs.getString("sourcesystem_cd")); } return child; } }; return mapper; }
From source file:org.kuali.kfs.gl.businessobject.Entry.java
public Entry(Transaction t, java.util.Date postDate) { super();//from w ww .j a va 2 s .c om this.dummyBusinessObject = new TransientBalanceInquiryAttributes(); setUniversityFiscalYear(t.getUniversityFiscalYear()); setChartOfAccountsCode(t.getChartOfAccountsCode()); setAccountNumber(t.getAccountNumber()); setSubAccountNumber(t.getSubAccountNumber()); setFinancialObjectCode(t.getFinancialObjectCode()); setFinancialSubObjectCode(t.getFinancialSubObjectCode()); setFinancialBalanceTypeCode(t.getFinancialBalanceTypeCode()); setFinancialObjectTypeCode(t.getFinancialObjectTypeCode()); setUniversityFiscalPeriodCode(t.getUniversityFiscalPeriodCode()); setFinancialDocumentTypeCode(t.getFinancialDocumentTypeCode()); setFinancialSystemOriginationCode(t.getFinancialSystemOriginationCode()); setDocumentNumber(t.getDocumentNumber()); setTransactionLedgerEntrySequenceNumber(t.getTransactionLedgerEntrySequenceNumber()); setTransactionLedgerEntryDescription(t.getTransactionLedgerEntryDescription()); setTransactionLedgerEntryAmount(t.getTransactionLedgerEntryAmount()); setTransactionDebitCreditCode(t.getTransactionDebitCreditCode()); setTransactionDate(t.getTransactionDate()); setOrganizationDocumentNumber(t.getOrganizationDocumentNumber()); setProjectCode(t.getProjectCode()); setOrganizationReferenceId(t.getOrganizationReferenceId()); setReferenceFinancialDocumentTypeCode(t.getReferenceFinancialDocumentTypeCode()); setReferenceFinancialSystemOriginationCode(t.getReferenceFinancialSystemOriginationCode()); setReferenceFinancialDocumentNumber(t.getReferenceFinancialDocumentNumber()); setFinancialDocumentReversalDate(t.getFinancialDocumentReversalDate()); setTransactionEncumbranceUpdateCode(t.getTransactionEncumbranceUpdateCode()); if (postDate != null) { setTransactionPostingDate(new Date(postDate.getTime())); } Timestamp now = SpringContext.getBean(DateTimeService.class).getCurrentTimestamp(); setTransactionDateTimeStamp(now); }
From source file:org.kuali.kra.coi.service.impl.CoiMessagesServiceImpl.java
/** * @ Check COI to see if annual disclosure is coming due *//* w ww .j a v a 2 s .c om*/ public List<String> getMessages() { List<String> results = new ArrayList<String>(); UserSession session = GlobalVariables.getUserSession(); if (session != null && StringUtils.isNotEmpty(GlobalVariables.getUserSession().getPrincipalId())) { String personId = GlobalVariables.getUserSession().getPrincipalId(); String renewalDateString = getParameterService().getParameterValueAsString( Constants.MODULE_NAMESPACE_COIDISCLOSURE, ParameterConstants.DOCUMENT_COMPONENT, "ANNUAL_DISCLOSURE_RENEWAL_DATE"); LOG.debug("renewalDateString=" + renewalDateString); if (StringUtils.isNotEmpty(renewalDateString)) { Date renewalDue = null; try { renewalDue = new Date(new SimpleDateFormat("MM/dd/yyyy").parse(renewalDateString).getTime()); } catch (Exception e) { LOG.error( "***** no valid Annual Disclosure Certification renewal date found. Defaulting to anniversary of last Annual"); } String advanceNoticeString = getParameterService().getParameterValueAsString( Constants.MODULE_NAMESPACE_COIDISCLOSURE, ParameterConstants.DOCUMENT_COMPONENT, "ANNUAL_DISCLOSURE_ADVANCE_NOTICE"); int advanceDays = -1; try { advanceDays = Integer.parseInt(advanceNoticeString); } catch (Exception e) { LOG.error( "***** no valid Annual Disclosure Certification advance notice parameter found. Defaulting to 30 days."); advanceDays = 30; } LOG.debug("advanceDays=" + advanceDays); // find latest existing annual review Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("personId", personId); fieldValues.put("eventTypeCode", CoiDisclosureEventType.ANNUAL); List<CoiDisclosure> annualDisclosures = (List<CoiDisclosure>) businessObjectService .findMatching(CoiDisclosure.class, fieldValues); Timestamp lastAnnualDate = null; for (CoiDisclosure disclosure : annualDisclosures) { final Timestamp disclosureCertificationTimestamp = disclosure.getCertificationTimestamp(); if (disclosureCertificationTimestamp != null) { if (lastAnnualDate == null || lastAnnualDate.before(disclosureCertificationTimestamp)) { lastAnnualDate = disclosureCertificationTimestamp; } } } Calendar lastAnnualCalendar = null; if (lastAnnualDate != null) { lastAnnualCalendar = Calendar.getInstance(); lastAnnualCalendar.setTimeInMillis(lastAnnualDate.getTime()); } final Calendar currentTime = Calendar.getInstance(); boolean sendErrorWithDate = false; boolean sendError = false; LOG.debug("renewalDue=" + renewalDue); if (renewalDue != null) { final Calendar reminderDate = Calendar.getInstance(); reminderDate.setTimeInMillis(renewalDue.getTime()); reminderDate.add(Calendar.DATE, -advanceDays); if (currentTime.after(reminderDate) && ((lastAnnualCalendar == null) || currentTime.after(lastAnnualCalendar))) { sendErrorWithDate = true; } } else { final Calendar dueCalendarDate = Calendar.getInstance(); if (lastAnnualDate == null) { sendError = true; } else { dueCalendarDate.setTimeInMillis(lastAnnualDate.getTime()); dueCalendarDate.add(Calendar.YEAR, 1); dueCalendarDate.add(Calendar.DATE, -1); renewalDue = new Date(dueCalendarDate.getTimeInMillis()); final Calendar reminderDate = Calendar.getInstance(); reminderDate.setTimeInMillis(renewalDue.getTime()); reminderDate.add(Calendar.DATE, -advanceDays); if (currentTime.after(reminderDate)) { sendErrorWithDate = true; } } } if (sendError) { String msg = getConfigurationService() .getPropertyValueAsString("annual.disclosure.due.message"); if (!StringUtils.isEmpty(msg)) { results.add(msg); } } if (sendErrorWithDate) { String msg = getConfigurationService() .getPropertyValueAsString("annual.disclosure.due.message.with.date"); if (!StringUtils.isEmpty(msg)) { results.add(msg.replace("{0}", new SimpleDateFormat("MM/dd/yyyy").format(renewalDue))); } } } } return results; }