Example usage for java.sql Date toString

List of usage examples for java.sql Date toString

Introduction

In this page you can find the example usage for java.sql Date toString.

Prototype

@SuppressWarnings("deprecation")
public String toString() 

Source Link

Document

Formats a date in the date escape format yyyy-mm-dd.

Usage

From source file:org.kuali.coeus.common.committee.impl.rules.CommitteeScheduleDateConflictRule.java

/**
 * Helper method to identify potential conflicts and adds error message to map.
 * @param committeeSchedules/* w w w. ja  v a 2  s.c  om*/
 * @param conflictDates
 */
private void identifyPotentialConflicts(List<CommitteeScheduleBase> committeeSchedules,
        List<Date> conflictDates) {
    Date scheduleDate = null;
    int count = 0;
    for (Date date : conflictDates) {
        count = 0;
        for (CommitteeScheduleBase committeeSchedule : committeeSchedules) {
            scheduleDate = committeeSchedule.getScheduledDate();
            if (DateUtils.isSameDay(date, scheduleDate)) {
                reportError(String.format(ID, count), KeyConstants.ERROR_COMMITTEESCHEDULE_DATE_CONFLICT,
                        scheduleDate.toString());
            }
            count++;
        }
    }
}

From source file:org.kuali.coeus.common.budget.impl.print.IndustrialBudgetXmlStream.java

private void setIndustrialBudgetLASalaryForBudgetRateAndBase(List<ReportType> reportTypeList) {
    List<ReportTypeVO> reportTypeVOList = new ArrayList<ReportTypeVO>();
    for (BudgetLineItem budgetLineItem : budgetPeriod.getBudgetLineItems()) {
        Map<String, BudgetRateAndBase> laRateBaseMap = new HashMap<String, BudgetRateAndBase>();
        for (BudgetRateAndBase budgetRateAndBase : budgetLineItem.getBudgetRateAndBaseList()) {
            if (isRateAndBaseOfRateClassTypeLAwithEBVA(budgetRateAndBase)) {
                Date startDate = budgetRateAndBase.getStartDate();
                Date endDate = budgetRateAndBase.getEndDate();
                String key = new StringBuilder(startDate.toString()).append(endDate.toString()).toString();
                if (laRateBaseMap.containsKey(key)) {
                    continue;
                }/*from w w  w  .j  ava 2  s . c om*/
                ReportTypeVO reportTypeVO = getReportTypeVOForIndustrialBudgetLASalaryForRateBase(
                        budgetLineItem, budgetRateAndBase);
                reportTypeVOList.add(reportTypeVO);
                laRateBaseMap.put(key, budgetRateAndBase);
            }
        }
    }
    setReportTypeBudgetLASalary(reportTypeList, reportTypeVOList);
}

From source file:de.tuttas.restful.AnwesenheitsManager.java

/**
 * Heutige Anwesenheit einer Klasse Adresse /api/v1/anwesenheit/{Name der
 * Klasse}/*from   w w w . ja  v a2  s .  c  o m*/
 *
 * @param kl Name der Klasse
 * @return Liste von AnwesenheitsObjekten
 */
@GET
@Path("/{klasse}")
public List<AnwesenheitObjekt> getAnwesenheit(@PathParam("klasse") String kl) {
    em.getEntityManagerFactory().getCache().evictAll();

    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Date d1 = new Date(cal.getTimeInMillis());
    Date d2 = new Date(cal.getTimeInMillis() + (1000 * 60 * 60 * 24));

    Log.d("Webservice Anwesenheit GET from Date=" + d1.toString() + " To " + d2.toString() + " klasse=" + kl);
    TypedQuery<AnwesenheitEintrag> query = em.createNamedQuery("findAnwesenheitbyKlasse",
            AnwesenheitEintrag.class);
    query.setParameter("paramKName", kl);
    query.setParameter("paramFromDate", d1);
    query.setParameter("paramToDate", d2);
    List<AnwesenheitEintrag> anwesenheit = query.getResultList();

    Query qb = em.createNamedQuery("findBemerkungbyDate");
    qb.setParameter("paramFromDate", d1);
    qb.setParameter("paramToDate", d2);

    List<String> ids = new ArrayList<>();
    for (AnwesenheitEintrag ae : anwesenheit) {
        ids.add("" + ae.getID_SCHUELER());
    }
    List<Bemerkung> bemerkungen = null;
    qb.setParameter("idList", ids);
    if (ids.size() > 0) {
        bemerkungen = qb.getResultList();
        Log.d("Result List Bemerkunken:" + bemerkungen);
    }
    return getData(anwesenheit, bemerkungen);
}

From source file:org.rti.zcore.dar.report.StockUsageReport.java

@Override
public void getPatientRegister(Date beginDate, Date endDate, int siteId) {
    Connection conn = null;/* w w w . j  ava  2  s .  c  o  m*/
    try {
        conn = DatabaseUtils.getZEPRSConnection(org.rti.zcore.Constants.DATABASE_ADMIN_USERNAME);

        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFCellStyle boldStyle = wb.createCellStyle();
        HSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        boldStyle.setFont(font);

        HSSFCellStyle headerStyle = wb.createCellStyle();
        headerStyle.setWrapText(true);
        headerStyle.setFont(font);
        //log.debug("Before getPatientStockMap:" + DateUtils.getTime());
        HashMap<Long, List<StockControl>> stockMap = InventoryDAO.getPatientStockMap(conn, siteId, beginDate,
                endDate);
        //log.debug("Before EncountersDAO.getAll:" + DateUtils.getTime());
        // loop through all of the items
        //List<Item> items = EncountersDAO.getAll(conn, Long.valueOf(131), "SQL_RETRIEVE_ALL_ADMIN131", Item.class);
        List<Item> items = null;
        Map queries = QueryLoader.instance().load("/" + Constants.SQL_GENERATED_PROPERTIES);
        String sql = (String) queries.get("SQL_RETRIEVE_ALL_ADMIN131") + " ORDER BY item.name";
        ArrayList values = new ArrayList();
        items = DatabaseUtils.getList(conn, Item.class, sql, values);
        //log.debug("Before looping through items:" + DateUtils.getTime());
        //int j = 0;
        boolean generateReport = false;
        for (Item item : items) {
            Boolean useInReport = item.getUse_in_report();
            Long itemId = item.getId();
            useInReport = Boolean.TRUE;
            if ((useInReport != null) && (useInReport.booleanValue() == Boolean.TRUE)) {
                List<StockControl> patientStockChanges = stockMap.get(itemId);
                if (patientStockChanges == null) {
                    patientStockChanges = new ArrayList<StockControl>();
                }
                List<StockControl> stockChanges = InventoryDAO.getStockEncounterChanges(conn, itemId, siteId,
                        beginDate, endDate, null, patientStockChanges);
                int stockChangesSize = stockChanges.size();
                //if ((stockChangesSize > 0) ||  ((stockChangesSize == 0 && (item.getUse_in_report() != null)  && (!item.getUse_in_report().equals(Boolean.FALSE))))) {
                if ((stockChangesSize > 0)) {
                    generateReport = true;
                    StockReport stockReport = InventoryDAO.generateStockSummary(conn, itemId, beginDate,
                            stockChanges, false);
                    // populate the common fields
                    //HSSFSheet sheet  = wb.getSheetAt(j);
                    String fixedName = StringManipulation.escapeString(item.getName()).replace("/", " ")
                            .replace("\\", " ").replace(",", "_").replace("[", "").replace("(", "-")
                            .replace(")", "-");
                    int lenName = fixedName.length();
                    String itemIdString = String.valueOf(itemId);
                    int lenItemId = itemIdString.length();
                    String uniqueName = null;
                    if ((lenName + lenItemId) < 31) {
                        uniqueName = fixedName + "_" + itemId;
                        //log.debug(itemId + " size: " + uniqueName.length());
                    } else {
                        int offset = (30 - lenItemId) - 1;
                        if (lenName > offset) {
                            uniqueName = fixedName.substring(0, offset) + "_" + itemIdString;
                            //log.debug(itemId + " size: " + uniqueName.length());
                        } else {
                            uniqueName = fixedName + "_" + itemId;
                        }
                    }
                    HSSFSheet sheet = null;
                    try {
                        sheet = wb.createSheet(uniqueName);
                    } catch (IllegalArgumentException e) {
                        log.debug("Problem with name : " + uniqueName + " Error: " + e.getMessage());
                        //this.setType("error");
                        // e.printStackTrace();
                    }
                    String code = "";
                    if (item.getCode() != null) {
                        code = " (" + item.getCode() + ")";
                    }
                    if (sheet != null) {
                        //sheet.createRow(0).createCell(0).setCellValue(new HSSFRichTextString(item.getName() + code));
                        HSSFHeader header = sheet.getHeader();
                        header.setCenter(item.getName() + code);
                        /*HSSFCell titleCell = sheet.createRow(0).createCell(0);
                        titleCell.setCellStyle(boldStyle);
                        titleCell.setCellValue(new HSSFRichTextString(item.getName() + code));*/
                        //sheet.createRow(2).createCell(0).setCellValue(new HSSFRichTextString("Beginning Balance"));
                        HSSFRow row = sheet.createRow(0);
                        row.setHeightInPoints((3 * sheet.getDefaultRowHeightInPoints()));

                        HSSFCell cell = row.createCell(0);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Beginning \nBalance"));

                        //sheet.getRow(0).createCell(1).setCellValue(new HSSFRichTextString("Quantity Received this period"));
                        cell = row.createCell(1);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Quantity \nReceived \nthis period"));
                        //sheet.getRow(0).createCell(2).setCellValue(new HSSFRichTextString("Quantity dispensed this period"));
                        cell = row.createCell(2);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Quantity \ndispensed \nthis period"));
                        //sheet.getRow(0).createCell(3).setCellValue(new HSSFRichTextString("Total Issued to Patients"));
                        cell = row.createCell(3);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Total Issued \nto Patients"));
                        //sheet.getRow(0).createCell(4).setCellValue(new HSSFRichTextString("Positive Adjustments"));
                        cell = row.createCell(4);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Positive \nAdjustments"));
                        //sheet.getRow(0).createCell(5).setCellValue(new HSSFRichTextString("Negative Adjustments"));
                        cell = row.createCell(5);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Negative \nAdjustments"));
                        //sheet.getRow(0).createCell(6).setCellValue(new HSSFRichTextString("Ending Balance / Physical Count"));
                        cell = row.createCell(6);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Ending Balance \nPhysical Count"));

                        sheet.autoSizeColumn((short) 0);
                        sheet.autoSizeColumn((short) 1);
                        sheet.autoSizeColumn((short) 2);
                        sheet.autoSizeColumn((short) 3);
                        sheet.autoSizeColumn((short) 4);
                        sheet.autoSizeColumn((short) 5);
                        sheet.autoSizeColumn((short) 6);

                        sheet.createRow(1).createCell(0).setCellValue(stockReport.getBalanceBF());
                        sheet.getRow(1).createCell(1).setCellValue(stockReport.getAdditionsTotal());
                        sheet.getRow(1).createCell(2).setCellValue(stockReport.getDeletionsTotal());
                        sheet.getRow(1).createCell(3).setCellValue(stockReport.getTotalDispensed());
                        sheet.getRow(1).createCell(4).setCellValue(stockReport.getPosAdjustments());
                        sheet.getRow(1).createCell(5).setCellValue(stockReport.getNegAdjustments());
                        sheet.getRow(1).createCell(6).setCellValue(stockReport.getOnHand());

                        row = sheet.createRow(4);
                        row.setHeightInPoints((3 * sheet.getDefaultRowHeightInPoints()));

                        //sheet.createRow(4).createCell(0).setCellValue(new HSSFRichTextString("Date"));
                        cell = row.createCell(0);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Date"));
                        //sheet.getRow(4).createCell(1).setCellValue(new HSSFRichTextString("Type of Stock Change"));
                        cell = row.createCell(1);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Type of \nStock \nChange"));
                        //sheet.getRow(4).createCell(2).setCellValue(new HSSFRichTextString("Expiry Date"));
                        cell = row.createCell(2);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Expiry \nDate"));
                        //sheet.getRow(4).createCell(3).setCellValue(new HSSFRichTextString("Reference / Notes"));
                        cell = row.createCell(3);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Reference/ \n Notes"));
                        //sheet.getRow(4).createCell(4).setCellValue(new HSSFRichTextString("Additions"));
                        cell = row.createCell(4);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Additions"));
                        //sheet.getRow(4).createCell(5).setCellValue(new HSSFRichTextString("Subtractions"));
                        cell = row.createCell(5);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Subtractions"));
                        //sheet.getRow(4).createCell(6).setCellValue(new HSSFRichTextString("Recorded Balance"));
                        cell = row.createCell(6);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Recorded \nBalance"));
                        //sheet.getRow(4).createCell(7).setCellValue(new HSSFRichTextString("Calculated Balance"));
                        cell = row.createCell(7);
                        cell.setCellStyle(headerStyle);
                        cell.setCellValue(new HSSFRichTextString("Calculated \nBalance"));

                        sheet.autoSizeColumn((short) 7);

                        int k = 4;

                        for (StockControl stockControl : stockChanges) {
                            if (stockControl.getDate_of_record() != null) {
                                k++;
                                String stockChangeTypeString = null;
                                Integer posAdjust = null;
                                Integer negAdjust = null;
                                if (stockControl.getType_of_change() != null) {
                                    int stockChangeType = stockControl.getType_of_change();
                                    switch (stockChangeType) {
                                    case 3263:
                                        stockChangeTypeString = "Received";
                                        posAdjust = stockControl.getChange_value();
                                        break;
                                    case 3264:
                                        stockChangeTypeString = "Issued";
                                        negAdjust = stockControl.getChange_value();
                                        break;
                                    case 3265:
                                        stockChangeTypeString = "Losses";
                                        negAdjust = stockControl.getChange_value();
                                        break;
                                    case 3266:
                                        stockChangeTypeString = "Pos. Adjust.";
                                        posAdjust = stockControl.getChange_value();
                                        break;
                                    case 3267:
                                        stockChangeTypeString = "Neg. Adjust.";
                                        negAdjust = stockControl.getChange_value();
                                        break;
                                    case 3279:
                                        stockChangeTypeString = "Out-of-stock";
                                        break;

                                    default:
                                        break;
                                    }
                                }

                                row = sheet.createRow(k);

                                if (stockControl.getDate_of_record() != null) {
                                    Date dateRecord = stockControl.getDate_of_record();
                                    row.createCell(0)
                                            .setCellValue(new HSSFRichTextString(dateRecord.toString()));
                                } else {
                                    row.createCell(0).setCellValue(new HSSFRichTextString(""));
                                }
                                row.createCell(1).setCellValue(new HSSFRichTextString(stockChangeTypeString));
                                if (stockControl.getExpiry_date() != null) {
                                    Date expiryDate = stockControl.getExpiry_date();
                                    row.createCell(2)
                                            .setCellValue(new HSSFRichTextString(expiryDate.toString()));
                                } else {
                                    row.createCell(2).setCellValue(new HSSFRichTextString(""));
                                }
                                row.createCell(3).setCellValue(new HSSFRichTextString(stockControl.getNotes()));
                                if (posAdjust != null) {
                                    row.createCell(4).setCellValue(posAdjust);
                                }
                                if (negAdjust != null) {
                                    row.createCell(5).setCellValue(negAdjust);
                                }
                                if (stockControl.getBalance() != null) {
                                    row.createCell(6).setCellValue(stockControl.getBalance());
                                }
                                if (stockControl.getComputedBalance() != null) {
                                    row.createCell(7).setCellValue(stockControl.getComputedBalance());
                                }
                            }
                        }
                    }
                }
            }
            //j++;
        }
        if (generateReport) {
            FileOutputStream stream = new FileOutputStream(this.getReportPath());
            wb.write(stream);
            stream.close();
        } else {
            this.setType("empty");
        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            conn.close();
        } catch (SQLException e) {
            log.error(e);
        }
    }
}

From source file:org.droidpres.activity.TransferActivity.java

private void deleteOldRecords() {
    Calendar cl = Calendar.getInstance();
    cl.add(Calendar.DAY_OF_MONTH, -30);
    Date sqlDate = new Date(cl.getTime().getTime());

    mDataBase.execSQL("delete from document where docstate = ? and docdate < ?",
            new Object[] { Const.DOCSTATE_SEND, sqlDate.toString() });
}

From source file:org.rti.zcore.dar.utils.TestPatientUtils.java

/**
* Creates a test patient//w ww . j  av a2s  .com
* @param conn
* @param siteId
* @param patientType - basic: Patient up to prob/labour visit
* @param username
* @return
* @throws Exception
* @throws SQLException
*/
public static EncounterData populate(Connection conn, Long siteId, String patientType, String username)
        throws Exception, SQLException {
    Long patientId = null;
    Long eventId = null;
    Long flowId = null;
    Long encounterId = null;
    SessionSubject sessionPatient = null;

    //DynaActionForm dynaForm = null;
    String firstName = null;
    //Site site = SessionUtil.getInstance(site).getClientSettings().getSite();
    //Long siteId = siteId.getId();
    boolean longEGA = false;
    boolean noPrevs = false;
    /*if (patientType.equals("partograph")) {
       firstName = "Parto";
    } else if (patientType.equals("labour")) {
       firstName = "Labour";*/
    // } else {
    firstName = "Basic";
    longEGA = false; // change to true of you want a long ega to test system-generated problems.
    //}
    ArrayList<String> recordTypes = new ArrayList<String>();
    if (Constants.RECORD_EXPORT_FORMAT.equals("openmrs")) {
        //recordTypes.add("initialvisit");

    } else {
        if (patientType.equals("AF1B")) {
            firstName = "AF1B";
            recordTypes.add("RegimenAF1B");
        } else if (patientType.equals("AF1C")) {
            firstName = "AF1C";
            recordTypes.add("RegimenAF1C");
        } else if (patientType.equals("AF2A")) {
            firstName = "AF2A";
            recordTypes.add("RegimenAF2A");
        } else if (patientType.equals("AF2B")) {
            firstName = "AF2B";
            recordTypes.add("RegimenAF2B");
        } else if (patientType.equals("AF2C")) {
            firstName = "AF2C";
            recordTypes.add("RegimenAF2C");
        } else if (patientType.equals("AF1A")) {
            firstName = "AF1A";
            recordTypes.add("RegimenAF1A");
        } else if (patientType.equals("child")) {
            firstName = "CF1A";
            recordTypes.add("RegimenCF1A");
        } else {
            firstName = "AF1A";
            recordTypes.add("RegimenAF1A");
        }
    }
    // create new patient
    //dynaForm = createPatient(cfg, firstName, siteId);
    Map formData = null;
    formData = TestPatientUtils.createPatient(conn, firstName, siteId, false);
    /*if (patientType.equals("child")) {
      firstName = "CF1A";
      formData = TestPatientUtils.createPatient(conn, firstName, siteId, true);
      recordTypes.add("RegimenCF1A");
    } else {
      //firstName = "AF1A";
      formData = TestPatientUtils.createPatient(conn, firstName, siteId, false);
      //recordTypes.add("RegimenAF1A");
    }*/
    // Create initial dateVisit field to store the earliest dateVisit value.
    Date dateVisit = (Date) formData.get("date_visit");

    Long formId = new Long("1");
    Form formDef = (Form) DynaSiteObjects.getForms().get(formId);
    EncounterData patReg = null;
    try {
        patReg = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId, formData,
                encounterId, siteId, username, sessionPatient);
    } catch (Exception e) {
        log.error(e);
        e.printStackTrace();
    }
    patientId = patReg.getPatientId();
    sessionPatient = (SessionSubject) SessionPatientDAO.getSessionPatient(conn, patientId,
            patReg.getEventUuid(), null);

    if (recordTypes.contains("RegimenAF1A")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "6");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenCF1A")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "48");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenAF1B")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "5");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenAF1C")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "389");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenAF2A")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "390");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenAF2B")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "225");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    if (recordTypes.contains("RegimenAF2C")) {
        // create case report request
        formId = new Long("137");
        formData = TestPatientUtils.fillFormData(formId);
        formData.put("date_started", dateVisit.toString());
        formData.put("regimen_1", "391");
        formDef = (Form) DynaSiteObjects.getForms().get(formId);
        try {
            EncounterData record = PopulatePatientRecord.saveForm(conn, formDef, formId.toString(), patientId,
                    formData, encounterId, siteId, username, sessionPatient);
        } catch (Exception e) {
            log.error(e);
        }
    }
    return patReg;
}

From source file:org.kuali.kfs.module.ar.document.validation.impl.CustomerRule.java

public boolean validateEndDateForExistingCustomerAddress(Date newEndDate, int ind) {
    boolean isValid = checkEndDateIsValid(newEndDate, true);

    // valid end date for an existing customer address;
    // 1. blank <=> no date entered
    // 2. todays date -> makes address inactive
    // 3. future date
    // 4. if end date is a passed date AND it hasn't been updated <=> oldEndDate = newEndDate
    ///*  w w  w  .  j  av  a2s .  c om*/
    // invalid end date for an existing customer address
    // 1. if end date is a passed date AND it has been updated <=> oldEndDate != newEndDate
    if (!isValid) {
        Date oldEndDate = oldCustomer.getCustomerAddresses().get(ind).getCustomerAddressEndDate();
        // passed end date has been entered
        if (ObjectUtils.isNull(oldEndDate)
                || ObjectUtils.isNotNull(oldEndDate) && !oldEndDate.toString().equals(newEndDate.toString())) {
            String propertyName = ArPropertyConstants.CustomerFields.CUSTOMER_TAB_ADDRESSES + "[" + ind + "]."
                    + ArPropertyConstants.CustomerFields.CUSTOMER_ADDRESS_END_DATE;
            putFieldError(propertyName,
                    ArKeyConstants.CustomerConstants.ERROR_CUSTOMER_ADDRESS_END_DATE_MUST_BE_CURRENT_OR_FUTURE_DATE);
        } else {
            isValid = true;
        }
    }
    return isValid;
}

From source file:org.apache.phoenix.end2end.CursorWithRowValueConstructorIT.java

@Test
/**/* w w  w. j ava 2  s  . co m*/
 * Test for the precision of Date datatype when used as part of a filter within the internal Select statement.
 */
public void testCursorsWithDateDatatypeFilter() throws Exception {
    long ts = nextTimestamp();
    String tenantId = getOrganizationId();
    long currentTime = System.currentTimeMillis();
    java.sql.Date date = new java.sql.Date(currentTime);
    String strCurrentDate = date.toString();

    //Sets date to <yesterday's date> 23:59:59.999
    while (date.toString().equals(strCurrentDate)) {
        currentTime -= 1;
        date = new Date(currentTime);
    }
    //Sets date to <today's date> 00:00:00.001
    date = new Date(currentTime + 2);
    java.sql.Date midnight = new Date(currentTime + 1);

    initEntityHistoryTableValues(tenantId, getDefaultSplits(tenantId), date, ts);
    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
    props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2));
    Connection conn = DriverManager.getConnection(getUrl(), props);

    String query = "select parent_id from " + ENTITY_HISTORY_TABLE_NAME
            + " WHERE (organization_id, parent_id, created_date, entity_history_id) IN ((?,?,?,?),(?,?,?,?))";

    query = query.replaceFirst("\\?", "'" + tenantId + "'");
    query = query.replaceFirst("\\?", "'" + PARENTID3 + "'");
    query = query.replaceFirst("\\?",
            "TO_DATE('" + DateUtil.getDateFormatter(DateUtil.DEFAULT_DATE_FORMAT).format(date) + "')");
    query = query.replaceFirst("\\?", "'" + ENTITYHISTID3 + "'");
    query = query.replaceFirst("\\?", "'" + tenantId + "'");
    query = query.replaceFirst("\\?", "'" + PARENTID7 + "'");
    query = query.replaceFirst("\\?",
            "TO_DATE('" + DateUtil.getDateFormatter(DateUtil.DEFAULT_DATE_FORMAT).format(date) + "')");
    query = query.replaceFirst("\\?", "'" + ENTITYHISTID7 + "'");
    String cursor = "DECLARE testCursor CURSOR FOR " + query;

    conn.prepareStatement(cursor).execute();
    cursor = "OPEN testCursor";
    conn.prepareStatement(cursor).execute();
    cursor = "FETCH NEXT FROM testCursor";

    ResultSet rs = conn.prepareStatement(cursor).executeQuery();
    assertTrue(rs.next());
    assertEquals(PARENTID3, rs.getString(1));
    rs = conn.prepareStatement(cursor).executeQuery();
    assertTrue(rs.next());
    assertEquals(PARENTID7, rs.getString(1));
    assertFalse(rs.next());

    //Test against the same table for the same records, but this time use the 'midnight' java.sql.Date instance.
    //'midnight' is identical to 'date' to the tens of millisecond precision.
    query = "select parent_id from " + ENTITY_HISTORY_TABLE_NAME
            + " WHERE (organization_id, parent_id, created_date, entity_history_id) IN ((?,?,?,?),(?,?,?,?))";
    query = query.replaceFirst("\\?", "'" + tenantId + "'");
    query = query.replaceFirst("\\?", "'" + PARENTID3 + "'");
    query = query.replaceFirst("\\?",
            "TO_DATE('" + DateUtil.getDateFormatter(DateUtil.DEFAULT_DATE_FORMAT).format(midnight) + "')");
    query = query.replaceFirst("\\?", "'" + ENTITYHISTID3 + "'");
    query = query.replaceFirst("\\?", "'" + tenantId + "'");
    query = query.replaceFirst("\\?", "'" + PARENTID7 + "'");
    query = query.replaceFirst("\\?",
            "TO_DATE('" + DateUtil.getDateFormatter(DateUtil.DEFAULT_DATE_FORMAT).format(midnight) + "')");
    query = query.replaceFirst("\\?", "'" + ENTITYHISTID7 + "'");
    cursor = "DECLARE testCursor2 CURSOR FOR " + query;

    conn.prepareStatement(cursor).execute();
    cursor = "OPEN testCursor2";
    conn.prepareStatement(cursor).execute();
    cursor = "FETCH NEXT FROM testCursor2";

    rs = conn.prepareStatement(cursor).executeQuery();
    assertTrue(!rs.next());
    String sql = "CLOSE testCursor";
    conn.prepareStatement(sql).execute();
    sql = "CLOSE testCursor2";
    conn.prepareStatement(sql).execute();
}

From source file:org.kuali.coeus.common.budget.impl.print.BudgetCumilativeXmlStream.java

private void setBudgetLASalaryForBudgetRateAndBaseForCumulativeReport(List<ReportType> reportTypeList) {
    List<ReportTypeVO> reportTypeVOList = new ArrayList<ReportTypeVO>();
    for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
        for (BudgetLineItem budgetLineItem : budgetPeriod.getBudgetLineItems()) {
            Map<String, BudgetRateAndBase> laRateBaseMap = new HashMap<String, BudgetRateAndBase>();
            for (BudgetRateAndBase budgetRateAndBase : budgetLineItem.getBudgetRateAndBaseList()) {
                if (isRateAndBaseOfRateClassTypeLAwithEBVA(budgetRateAndBase)) {
                    Date startDate = budgetRateAndBase.getStartDate();
                    Date endDate = budgetRateAndBase.getEndDate();
                    String key = new StringBuilder(startDate.toString()).append(endDate.toString()).toString();
                    if (laRateBaseMap.containsKey(key)) {
                        continue;
                    }/*  w w  w.  ja  va2 s.  c  o m*/
                    ReportTypeVO reportTypeVO = getReportTypeVOForBudgetLASalaryForRateBase(budgetLineItem,
                            budgetRateAndBase);
                    reportTypeVOList.add(reportTypeVO);
                    laRateBaseMap.put(key, budgetRateAndBase);
                }
            }
        }
    }
    setReportTypeBudgetLASalary(reportTypeList, reportTypeVOList);
}

From source file:org.kuali.kfs.module.ld.batch.service.impl.LaborYearEndBalanceForwardServiceImpl.java

/**
 * Report out which significant parameters were used in this report.
 * @param runDate the date when this job was run
 * @param closingYear the fiscal year closed by this job
 * @param processedFundGroups the fund groups processed by this job
 * @param processedSubFundGroups the sub-fund groups processed by this job
 * @param originationCode the origination code of the posted entries
 * @param processedBalanceTypeCodes the balance type codes processed by this job
 * @param processedObjectTypeCodes the object type codes processed by this job
 * @param documentTypeCode the document type code of posted entries
 */// w ww.  j a v  a2s  .c om
protected void fillParametersReportWriter(Date runDate, Integer closingYear,
        Collection<String> processedFundGroups, Collection<String> processedSubFundGroups,
        String originationCode, Collection<String> processedBalanceTypeCodes,
        Collection<String> processedObjectTypeCodes, String documentTypeCode) {
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            GeneralLedgerConstants.ANNUAL_CLOSING_TRANSACTION_DATE_PARM, runDate.toString());
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborConstants.YearEnd.OLD_FISCAL_YEAR, closingYear);
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborConstants.YearEnd.FUND_GROUP_PROCESSED, StringUtils.join(processedFundGroups, ", "));
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborConstants.YearEnd.SUB_FUND_GROUP_PROCESSED, StringUtils.join(processedSubFundGroups, ", "));
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborConstants.YearEnd.ORIGINATION_CODE, originationCode);
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborYearEndBalanceForwardServiceImpl.PROCESSED_BALANCE_TYPES_LABEL,
            StringUtils.join(processedBalanceTypeCodes, ", "));
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            LaborYearEndBalanceForwardServiceImpl.PROCESSED_OBJECT_TYPES_LABEL,
            StringUtils.join(processedObjectTypeCodes, ", "));
    laborBalanceForwardReportWriterService.writeParameterLine("%32s %10s",
            GeneralLedgerConstants.ANNUAL_CLOSING_DOCUMENT_TYPE, documentTypeCode);
    laborBalanceForwardReportWriterService.pageBreak();
}