Example usage for java.math BigDecimal toString

List of usage examples for java.math BigDecimal toString

Introduction

In this page you can find the example usage for java.math BigDecimal toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.

Usage

From source file:org.egov.works.web.controller.letterofacceptance.UpdateLetterOfAcceptanceController.java

@RequestMapping(value = "/modify/{id}", method = RequestMethod.POST)
public String modify(@ModelAttribute("workOrder") final WorkOrder workOrder, final Model model,
        final BindingResult resultBinder, final HttpServletRequest request) throws ApplicationException {
    final List<String> workOrderNumbers = letterOfAcceptanceService
            .getApprovedWorkOrdersForCreateContractorBill(workOrder.getWorkOrderNumber());
    if (workOrderNumbers.isEmpty()) {
        resultBinder.rejectValue("", "error.modify.loa.finalbill.exists");
    }//  w  w w. ja v a2  s .  c  o m

    final LineEstimateDetails lineEstimateDetails = lineEstimateService
            .findByEstimateNumber(workOrder.getEstimateNumber());

    final Double revisedWorkOrderAmount = Double.valueOf(request.getParameter("revisedWorkOrderAmount"));
    final Double revisedValue = Double.valueOf(request.getParameter("revisedValue"));
    Double balanceAmount = 0.0;
    Double grossBillAmount = 0.0;
    final DecimalFormat df = new DecimalFormat("0.00");
    grossBillAmount = letterOfAcceptanceService.getGrossBillAmountOfBillsCreated(workOrder.getWorkOrderNumber(),
            WorksConstants.APPROVED, ContractorBillRegister.BillStatus.CANCELLED.toString());
    if (grossBillAmount == null)
        grossBillAmount = 0.0;
    final BigDecimal ledGrossBillAmount = lineEstimateDetails.getGrossAmountBilled();
    if (revisedWorkOrderAmount >= 0 && "-".equals(workOrder.getPercentageSign())) {
        if (lineEstimateDetails.getLineEstimate().isSpillOverFlag())
            balanceAmount = ledGrossBillAmount != null
                    ? workOrder.getWorkOrderAmount() - grossBillAmount - revisedValue
                            - ledGrossBillAmount.doubleValue()
                    : workOrder.getWorkOrderAmount() - grossBillAmount - revisedValue;

        else
            balanceAmount = workOrder.getWorkOrderAmount() - grossBillAmount - revisedValue;
        if (balanceAmount < 0) {
            if (lineEstimateDetails.getLineEstimate().isSpillOverFlag())
                grossBillAmount += lineEstimateDetails.getGrossAmountBilled().doubleValue();

            resultBinder.rejectValue("", "error.modify.loa.appropriation.amount",
                    new String[] { df.format(grossBillAmount), df.format(revisedWorkOrderAmount) }, null);
        }
    } else if (revisedWorkOrderAmount >= 0 && "+".equals(workOrder.getPercentageSign()))
        balanceAmount = revisedWorkOrderAmount - workOrder.getWorkOrderAmount();

    if (revisedWorkOrderAmount == 0)
        resultBinder.rejectValue(StringUtils.EMPTY, "error.modify.loa.agreement.amount");

    if (resultBinder.hasErrors()) {
        model.addAttribute("lineEstimateDetails", lineEstimateDetails);
        model.addAttribute("mode", "modify");
        model.addAttribute("lineEstimateDetails", lineEstimateDetails);
        model.addAttribute("revisedValue", request.getParameter("revisedValue"));
        return "letterOfAcceptance-modify";
    } else {
        WorkOrder savedWorkOrder = null;
        try {
            savedWorkOrder = letterOfAcceptanceService.update(workOrder, lineEstimateDetails, revisedValue,
                    revisedWorkOrderAmount);
        } catch (final ValidationException e) {
            final List<Long> budgetheadid = new ArrayList<>();
            budgetheadid.add(lineEstimateDetails.getLineEstimate().getBudgetHead().getId());

            try {
                final BigDecimal budgetAvailable = budgetDetailsDAO.getPlanningBudgetAvailable(
                        lineEstimateService.getCurrentFinancialYear(new Date()).getId(),
                        Integer.parseInt(lineEstimateDetails
                                .getLineEstimate().getExecutingDepartment().getId().toString()),
                        lineEstimateDetails.getLineEstimate().getFunction().getId(), null,
                        lineEstimateDetails.getLineEstimate().getScheme() == null ? null
                                : Integer.parseInt(
                                        lineEstimateDetails.getLineEstimate().getScheme().getId().toString()),
                        lineEstimateDetails.getLineEstimate().getSubScheme() == null ? null
                                : Integer.parseInt(lineEstimateDetails.getLineEstimate().getSubScheme().getId()
                                        .toString()),
                        null, budgetheadid,
                        Integer.parseInt(lineEstimateDetails.getLineEstimate().getFund().getId().toString()));
                final String errorMessage = messageSource.getMessage("error.budgetappropriation.amount",
                        new String[] { budgetAvailable.toString(), df.format(balanceAmount) }, null);
                model.addAttribute("message", errorMessage);
            } catch (final ValidationException v) {
                model.addAttribute("errorMessage", v.getErrors().get(0).getMessage());
            }

            return "lineestimate-success";
        }
        return "redirect:/letterofacceptance/loa-success?loaNumber=" + savedWorkOrder.getWorkOrderNumber()
                + "&isModify=true";
    }
}

From source file:org.openbravo.advpaymentmngt.ad_actionbutton.Reconciliation.java

private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strOrgId,
        String strWindowId, String strTabId, String strFinancialAccountId, String strStatementDate,
        String strEndBalance) throws IOException, ServletException {

    log4j.debug("Output: Reconcile button pressed on Financial Account || Transaction tab");

    dao = new AdvPaymentMngtDao();
    String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties()
            .getProperty("dateFormat.java");
    SimpleDateFormat dateFormater = new SimpleDateFormat(dateFormat);

    FIN_Reconciliation currentReconciliation = null;
    OBContext.setAdminMode();//  ww w  .ja  va 2s  . c  o m
    try {
        FIN_FinancialAccount account = OBDal.getInstance().get(FIN_FinancialAccount.class,
                strFinancialAccountId);

        FIN_Reconciliation lastProcessedReconciliation = TransactionsDao.getLastReconciliation(account, "Y");
        currentReconciliation = TransactionsDao.getLastReconciliation(account, "N");
        if (isAutomaticReconciliation(currentReconciliation)) {
            OBDal.getInstance().rollbackAndClose();
            OBError message = Utility.translateError(this, vars, vars.getLanguage(),
                    Utility.parseTranslation(this, vars, vars.getLanguage(), "@APRM_ReconciliationMixed@"));
            vars.setMessage(strTabId, message);
            printPageClosePopUp(response, vars, Utility.getTabURL(strTabId, "R", true));
            return;
        }

        XmlDocument xmlDocument = xmlEngine
                .readXmlTemplate("org/openbravo/advpaymentmngt/ad_actionbutton/Reconciliation")
                .createXmlDocument();

        xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
        xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
        xmlDocument.setParameter("theme", vars.getTheme());

        xmlDocument.setParameter("dateDisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
        xmlDocument.setParameter("mainDate", DateTimeData.today(this));
        xmlDocument.setParameter("windowId", strWindowId);
        xmlDocument.setParameter("tabId", strTabId);
        xmlDocument.setParameter("orgId", strOrgId);
        xmlDocument.setParameter("finFinancialAccountId", strFinancialAccountId);

        BigDecimal currentEndBalance = BigDecimal.ZERO;
        if (vars.commandIn("PROCESS")) {
            xmlDocument.setParameter("statementDate", strStatementDate);
            xmlDocument.setParameter("endBalance", strEndBalance);
            xmlDocument.setParameter("calcEndingBalance", strEndBalance);

        } else {
            String currentStatementDate = DateTimeData.today(this);
            if (currentReconciliation != null) {
                currentStatementDate = dateFormater.format(currentReconciliation.getTransactionDate());
                currentEndBalance = currentReconciliation.getEndingBalance();
            }
            xmlDocument.setParameter("statementDate", currentStatementDate);
            xmlDocument.setParameter("endBalance", currentEndBalance.toString());
            xmlDocument.setParameter("calcEndingBalance", currentEndBalance.toString());
        }

        BigDecimal beginBalance = (lastProcessedReconciliation == null) ? account.getInitialBalance()
                : lastProcessedReconciliation.getEndingBalance();

        xmlDocument.setParameter("account", account.getName());
        xmlDocument.setParameter("beginBalance", beginBalance.toString());

        // Hidden inputs
        xmlDocument.setParameter("calcBeginningBalance", beginBalance.toString());
        xmlDocument.setParameter("calcTotalPayment", BigDecimal.ZERO.toString());
        xmlDocument.setParameter("calcTotalDeposit", BigDecimal.ZERO.toString());
        xmlDocument.setParameter("calcDifferenceToClear", currentEndBalance.subtract(beginBalance).toString());
        xmlDocument.setParameter("calcCurrentlyCleared",
                TransactionsDao.getCurrentlyClearedAmt(account.getId()).toString());
        xmlDocument.setParameter("calcDifference",
                currentEndBalance
                        .subtract(beginBalance.add(TransactionsDao.getCurrentlyClearedAmt(account.getId())))
                        .toString());

        OBContext.setAdminMode();
        try {
            xmlDocument.setParameter("precision", account.getCurrency().getStandardPrecision().toString());

            if (currentReconciliation == null) {
                DocumentType docType = FIN_Utility.getDocumentType(account.getOrganization(), "REC");
                if (docType == null) {
                    OBError msg = new OBError();
                    String strMessage = "@APRM_DocumentTypeNotFound@";
                    msg.setType("Error");
                    msg.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
                    msg.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(), strMessage));
                    vars.setMessage(strTabId, msg);
                    msg = null;
                    printPageClosePopUpAndRefreshParent(response, vars);
                    return;
                }
                String docNumber = FIN_Utility.getDocumentNo(account.getOrganization(), "REC",
                        "DocumentNo_FIN_Reconciliation");

                dao.getNewReconciliation(account.getOrganization(), account, docNumber, docType, new Date(),
                        new Date(), beginBalance, BigDecimal.ZERO, "DR");
            }
        } finally {
            OBContext.restorePreviousMode();
        }

        OBError myMessage = vars.getMessage(strWindowId);
        vars.removeMessage(strWindowId);
        if (myMessage != null) {
            xmlDocument.setParameter("messageType", myMessage.getType());
            xmlDocument.setParameter("messageTitle", myMessage.getTitle());
            xmlDocument.setParameter("messageMessage", myMessage.getMessage());
        }

        response.setContentType("text/html; charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println(xmlDocument.print());
        out.close();
    } catch (Exception e) {
        throw new OBException(e);
    } finally {
        OBContext.restorePreviousMode();
    }
}

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

/**
 * Returns list of Registration Info for the person: CO, AO, Schedules, etc.
 *
 * @throws OperationFailedException/*from   w w  w. ja  v  a  2s.  c o  m*/
 */
private SearchResultInfo searchForAOSchedulesAndCOCreditAndGradingOptionsByIds(
        SearchRequestInfo searchRequestInfo) throws OperationFailedException {
    SearchResultInfo resultInfo = new SearchResultInfo();
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    List<String> luiIdsList = requestHelper.getParamAsList(SearchParameters.LUI_IDS);
    String luiIds = commaString(luiIdsList);

    String queryStr = "SELECT lui.ID, lui.NAME, luiId.LNG_NAME, luiRes.RESULT_VAL_GRP_ID, "
            + "room.ROOM_CD, rBldg.BUILDING_CD, "
            + "schedTmslt.WEEKDAYS, schedTmslt.START_TIME_MS, schedTmslt.END_TIME_MS "
            + "FROM KSEN_LUI_IDENT luiId, KSEN_LUI lui " + "LEFT OUTER JOIN KSEN_LUI_RESULT_VAL_GRP luiRes "
            + "ON luiRes.LUI_ID = lui.ID " + "AND (luiRes.RESULT_VAL_GRP_ID in (:rvgIds)"
            + "       OR luiRes.RESULT_VAL_GRP_ID like '"
            + LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + "%') "
            + "LEFT OUTER JOIN KSEN_LUI_SCHEDULE aoSched " + "ON aoSched.LUI_ID = lui.ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP schedCmp " + "ON schedCmp.SCHED_ID = aoSched.SCHED_ID "
            + "LEFT OUTER JOIN KSEN_ROOM room " + "ON room.ID = schedCmp.ROOM_ID "
            + "LEFT OUTER JOIN KSEN_ROOM_BUILDING rBldg " + "ON rBldg.ID = room.BUILDING_ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP_TMSLOT schedCmpTmslt "
            + "ON schedCmpTmslt.SCHED_CMP_ID = schedCmp.ID " + "LEFT OUTER JOIN KSEN_SCHED_TMSLOT schedTmslt "
            + "ON schedTmslt.ID = schedCmpTmslt.TM_SLOT_ID " + "WHERE lui.ID IN (:luiIds) "
            + "  AND luiId.LUI_ID = lui.ID";

    Query query = entityManager.createNativeQuery(queryStr);
    query.setParameter(SearchParameters.LUI_IDS, luiIds);
    query.setParameter(SearchParameters.RVG_IDS,
            Arrays.asList(CourseOfferingServiceConstants.ALL_STUDENT_REGISTRATION_OPTION_TYPE_KEYS));

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.LUI_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LONG_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RES_VAL_GROUP_KEY, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ROOM_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.BUILDING_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.WEEKDAYS, (String) resultRow[i++]);
        BigDecimal startTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.START_TIME_MS, (startTimeMs == null) ? "" : startTimeMs.toString());
        BigDecimal endTimeMs = (BigDecimal) resultRow[i];
        row.addCell(SearchResultColumns.END_TIME_MS, (endTimeMs == null) ? "" : endTimeMs.toString());
        resultInfo.getRows().add(row);
    }

    return resultInfo;
}

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

/**
 * Returns list of Registration Info for the person: CO, AO, Schedules, etc.
 *
 * @throws OperationFailedException/*  ww w  .jav  a 2  s  .com*/
 */
private SearchResultInfo searchForCourseRegistrationByPersonAndTerm(SearchRequestInfo searchRequestInfo)
        throws OperationFailedException {
    SearchResultInfo resultInfo = new SearchResultInfo();
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    String atpId = requestHelper.getParamAsString(SearchParameters.ATP_ID);
    String personId = requestHelper.getParamAsString(SearchParameters.PERSON_ID);
    List<String> lprTypes = requestHelper.getParamAsList(SearchParameters.LPR_TYPE);

    StringBuilder queryBuilder = new StringBuilder("");

    queryBuilder.append("SELECT atp.ID, atp.ATP_CD, atp.NAME as atp_name, "
            + "lpr.LUI_ID, lpr.MASTER_LPR_ID, lpr.LPR_TYPE, lpr.LPR_STATE, lpr.CREDITS, lpr.GRADING_OPT_ID, lpr.CROSSLIST, lpr.CREATETIME, "
            + "luiId.LUI_CD, lui.NAME as lui_name, lui.DESCR_FORMATTED, lui.LUI_TYPE, luiId.LNG_NAME, "
            + "luiRes.RESULT_VAL_GRP_ID, schedCmp.TBA_IND, " + "room.ROOM_CD, rBldg.BUILDING_CD, "
            + "schedTmslt.WEEKDAYS, schedTmslt.START_TIME_MS, schedTmslt.END_TIME_MS " + "FROM KSEN_ATP atp, "
            + "     KSEN_LPR lpr, " + "     KSEN_LUI lui, " + "     KSEN_LUI_IDENT luiId "
            + "LEFT OUTER JOIN KSEN_LUI_RESULT_VAL_GRP luiRes " + "ON luiRes.LUI_ID = luiId.LUI_ID "
            + "LEFT OUTER JOIN KSEN_LUI_SCHEDULE aoSched " + "ON aoSched.LUI_ID = luiId.LUI_ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP schedCmp " + "ON schedCmp.SCHED_ID = aoSched.SCHED_ID "
            + "LEFT OUTER JOIN KSEN_ROOM room " + "ON room.ID = schedCmp.ROOM_ID "
            + "LEFT OUTER JOIN KSEN_ROOM_BUILDING rBldg " + "ON rBldg.ID = room.BUILDING_ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP_TMSLOT schedCmpTmslt "
            + "ON schedCmpTmslt.SCHED_CMP_ID = schedCmp.ID " + "LEFT OUTER JOIN KSEN_SCHED_TMSLOT schedTmslt "
            + "ON schedTmslt.ID = schedCmpTmslt.TM_SLOT_ID " + "WHERE lpr.PERS_ID = :personId "
            + "  AND atp.ID = lpr.ATP_ID " + "  AND lui.ID = lpr.LUI_ID " + "  AND luiId.LUI_ID = lui.ID "
            + "  AND lpr.LPR_STATE = '" + LprServiceConstants.ACTIVE_STATE_KEY + "' ");

    if (!StringUtils.isEmpty(atpId)) {
        queryBuilder.append(" AND lpr.ATP_ID = :atpId ");
    }
    if (!CollectionUtils.isEmpty(lprTypes)) {
        queryBuilder.append(" AND lpr.LPR_TYPE in (:lprType) ");
    }

    Query query = entityManager.createNativeQuery(queryBuilder.toString());
    query.setParameter(SearchParameters.PERSON_ID, personId);
    if (!StringUtils.isEmpty(atpId)) {
        query.setParameter(SearchParameters.ATP_ID, atpId);
    }
    if (!CollectionUtils.isEmpty(lprTypes)) {
        query.setParameter(SearchParameters.LPR_TYPE, lprTypes);
    }

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.ATP_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_CD, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.MASTER_LPR_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.PERSON_LUI_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LPR_STATE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CREDITS, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.GRADING_OPTION_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CROSSLIST, (String) resultRow[i++]);
        Date lprCreateTime = (Date) resultRow[i++];
        row.addCell(SearchResultColumns.LPR_CREATETIME, lprCreateTime.toString());
        row.addCell(SearchResultColumns.LUI_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_DESC, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LONG_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RES_VAL_GROUP_KEY, (String) resultRow[i++]);
        BigDecimal tbaInd = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.TBA_IND, (tbaInd == null) ? "" : tbaInd.toString());
        row.addCell(SearchResultColumns.ROOM_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.BUILDING_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.WEEKDAYS, (String) resultRow[i++]);
        BigDecimal startTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.START_TIME_MS, (startTimeMs == null) ? "" : startTimeMs.toString());
        BigDecimal endTimeMs = (BigDecimal) resultRow[i];
        row.addCell(SearchResultColumns.END_TIME_MS, (endTimeMs == null) ? "" : endTimeMs.toString());
        resultInfo.getRows().add(row);
    }

    return resultInfo;
}

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

private SearchResultInfo searchForCourseRegistrationAndWaitlistByStudentAndTerm(
        SearchRequestInfo searchRequestInfo) throws OperationFailedException {
    SearchResultInfo resultInfo = new SearchResultInfo();
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    String atpId = requestHelper.getParamAsString(SearchParameters.ATP_ID);
    String personId = requestHelper.getParamAsString(SearchParameters.PERSON_ID);

    String queryStr = "SELECT " + "    lpr.LPR_TYPE              lprType, "
            + "    lpr.id                    lprId, " + "    lpr.ATP_ID                atpId, "
            + "    atp.ATP_CD                atpCode, " + "    atp.NAME                  atpName, "
            + "    coId.LUI_CD               courseCode, " + "    co.ID                     courseId, "
            + "    rg.NAME                   rgName, " + "    ao.NAME                   aoName, "
            + "    ao.LUI_TYPE               luiType, " + "    coId.LNG_NAME             coTitle, "
            + "    co.DESCR_FORMATTED        coDescription, " + "    schedCmp.TBA_IND          isTBA, "
            + "    room.ROOM_CD              room, " + "    room2bldg.BUILDING_CD     building, "
            + "    schedTmslt.WEEKDAYS       weekdays, " + "    schedTmslt.START_TIME_MS  startTime, "
            + "    schedTmslt.END_TIME_MS    endTime, " + "    credits.RESULT_VAL_GRP_ID credits, "
            + "    grading.RESULT_VAL_GRP_ID grading " + "FROM " + "    KSEN_LUI co, " + "    KSEN_LUI rg, "
            + "    KSEN_LUI_IDENT coId, " + "    KSEN_LUILUI_RELTN fo2rg, " + "    KSEN_LUILUI_RELTN co2fo, "
            + "    KSEN_LUILUI_RELTN rg2ao, " + "    KSEN_LUI ao " + "LEFT OUTER JOIN "
            + "    KSEN_LUI_SCHEDULE sched " + "ON " + "    sched.LUI_ID = ao.ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_CMP schedCmp " + "ON " + "    schedCmp.SCHED_ID = sched.SCHED_ID "
            + "LEFT OUTER JOIN " + "    KSEN_ROOM room " + "ON " + "    room.ID = schedCmp.ROOM_ID "
            + "LEFT OUTER JOIN " + "    KSEN_ROOM_BUILDING room2bldg " + "ON "
            + "    room2bldg.ID = room.BUILDING_ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_CMP_TMSLOT schedCmpTmslt " + "ON "
            + "    schedCmpTmslt.SCHED_CMP_ID = schedCmp.ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_TMSLOT schedTmslt " + "ON " + "    schedTmslt.ID = schedCmpTmslt.TM_SLOT_ID, "
            + "    KSEN_LPR lpr " + "LEFT OUTER JOIN " + "    KSEN_LPR_RESULT_VAL_GRP credits " + "ON "
            + "    credits.LPR_ID = lpr.id " + "AND credits.RESULT_VAL_GRP_ID LIKE '"
            + LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + "%' " + "LEFT OUTER JOIN "
            + "    KSEN_LPR_RESULT_VAL_GRP grading " + "ON " + "    grading.LPR_ID = lpr.id "
            + "AND grading.RESULT_VAL_GRP_ID LIKE '" + LrcServiceConstants.RESULT_GROUP_KEY_GRADE_BASE + ".%' "
            + "LEFT OUTER JOIN " + "    KSEN_ATP atp " + "ON " + "   atp.id = lpr.atp_id " + "WHERE "
            + "    lpr.PERS_ID = :personId " + "AND lpr.LPR_STATE = '" + LprServiceConstants.ACTIVE_STATE_KEY
            + "' " + "AND lpr.LPR_TYPE IN('" + LprServiceConstants.REGISTRANT_RG_LPR_TYPE_KEY + "', "
            + "                    '" + LprServiceConstants.WAITLIST_RG_LPR_TYPE_KEY + "') "
            + (!StringUtils.isEmpty(atpId) ? " AND lpr.ATP_ID = :atpId " : "") + "AND rg2ao.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_REGISTERED_FOR_VIA_RG_TO_AO_TYPE_KEY + "' "
            + "AND fo2rg.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_FO_TO_RG_TYPE_KEY + "' "
            + "AND co2fo.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_CO_TO_FO_TYPE_KEY + "' "
            + "AND rg2ao.LUI_ID=lpr.LUI_ID " + "AND fo2rg.RELATED_LUI_ID = lpr.LUI_ID "
            + "AND co2fo.RELATED_LUI_ID = fo2rg.LUI_ID " + "AND ao.id = rg2ao.RELATED_LUI_ID "
            + "AND co.id = co2fo.LUI_ID " + "AND rg.id = lpr.LUI_ID " + "AND coId.LUI_ID = co.id "
            + "ORDER BY lpr.ATP_ID, lpr.LPR_TYPE, lpr.id, ao.LUI_TYPE";

    Query query = entityManager.createNativeQuery(queryStr);
    query.setParameter(SearchParameters.PERSON_ID, personId);
    if (!StringUtils.isEmpty(atpId)) {
        query.setParameter(SearchParameters.ATP_ID, atpId);
    }/*from   www  . j  a  v  a 2  s. co  m*/

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.LPR_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.MASTER_LPR_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_CD, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RG_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LONG_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_DESC, (String) resultRow[i++]);
        BigDecimal tbaInd = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.TBA_IND, (tbaInd == null) ? "" : tbaInd.toString());
        row.addCell(SearchResultColumns.ROOM_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.BUILDING_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.WEEKDAYS, (String) resultRow[i++]);
        BigDecimal startTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.START_TIME_MS, (startTimeMs == null) ? "" : startTimeMs.toString());
        BigDecimal endTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.END_TIME_MS, (endTimeMs == null) ? "" : endTimeMs.toString());
        row.addCell(SearchResultColumns.CREDITS, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.GRADING_OPTION_ID, (String) resultRow[i]);

        resultInfo.getRows().add(row);
    }

    return resultInfo;
}

From source file:org.finra.herd.dao.impl.EmrDaoImpl.java

/**
 * Creates an instance group configuration.
 *
 * @param roleType role type for the instance group (MASTER/CORE/TASK)
 * @param instanceType EC2 instance type for the instance group
 * @param instanceCount number of instances for the instance group
 * @param bidPrice bid price in case of SPOT instance request
 * @param emrClusterDefinitionEbsConfiguration the instance of {@link EmrClusterDefinitionEbsConfiguration} that contains EBS configurations that will be
 * attached to each EC2 instance in this instance group
 *
 * @return the instance group config object
 *///from   w  w w.  j  a va 2s  . c  om
protected InstanceGroupConfig getInstanceGroupConfig(InstanceRoleType roleType, String instanceType,
        Integer instanceCount, BigDecimal bidPrice,
        EmrClusterDefinitionEbsConfiguration emrClusterDefinitionEbsConfiguration) {
    // Create an instance group configuration with an optional EBS configuration.
    InstanceGroupConfig instanceGroup = new InstanceGroupConfig(roleType, instanceType, instanceCount)
            .withEbsConfiguration(getEbsConfiguration(emrClusterDefinitionEbsConfiguration));

    // Consider spot price, if specified.
    if (bidPrice != null) {
        instanceGroup.setMarket(MarketType.SPOT);
        instanceGroup.setBidPrice(bidPrice.toString());
    }

    return instanceGroup;
}

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

private SearchResultInfo searchForCourseRegistrationCartByPersonAndTerm(SearchRequestInfo searchRequestInfo)
        throws OperationFailedException {
    SearchResultInfo resultInfo = new SearchResultInfo();
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    String atpId = requestHelper.getParamAsString(SearchParameters.ATP_ID);
    String personId = requestHelper.getParamAsString(SearchParameters.PERSON_ID);
    String cartId = requestHelper.getParamAsString(SearchParameters.CART_ID);
    String cartItemId = requestHelper.getParamAsString(SearchParameters.CART_ITEM_ID);
    String lprtType = requestHelper.getParamAsString(SearchParameters.LPRT_TYPE);
    if (StringUtils.isEmpty(lprtType)) {
        lprtType = LprServiceConstants.LPRTRANS_REG_CART_TYPE_KEY;
    }/*www  . ja va  2  s .co m*/

    String queryStr = "SELECT " + "    lprt.id                   cartId, "
            + "    lprti.ID                  cartItemId, " + "    lprt.LPR_TRANS_STATE       cartState, "
            + "    lprt.LPR_TRANS_TYPE       cartType, " + "    lprti.LPR_TRANS_ITEM_STATE cartItemState, "
            + "    lprti.CROSSLIST           crossList, " + "    coId.LUI_CD               courseCode, "
            + "    co.ID                     courseId, " + "    rg.NAME                   rgName, "
            + "    rg.ID                     rgId, " + "    ao.ID                     aoId, "
            + "    ao.NAME                   aoName, " + "    ao.LUI_TYPE               luiType, "
            + "    coId.LNG_NAME             coTitle, " + "    schedCmp.TBA_IND          isTBA, "
            + "    room.ROOM_CD              room, " + "    room2bldg.BUILDING_CD     building, "
            + "    schedTmslt.WEEKDAYS       weekdays, " + "    schedTmslt.START_TIME_MS  startTime, "
            + "    schedTmslt.END_TIME_MS    endTime, " + "    credits.RESULT_VAL_GRP_ID credits, "
            + "    grading.RESULT_VAL_GRP_ID grading " + "FROM " + "    KSEN_LPR_TRANS lprt, "
            + "    KSEN_LUI co, " + "    KSEN_LUI rg, " + "    KSEN_LUI_IDENT coId, "
            + "    KSEN_LUILUI_RELTN fo2rg, " + "    KSEN_LUILUI_RELTN co2fo, "
            + "    KSEN_LUILUI_RELTN rg2ao, " + "    KSEN_LUI ao " + "LEFT OUTER JOIN "
            + "    KSEN_LUI_SCHEDULE sched " + "ON " + "    sched.LUI_ID = ao.ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_CMP schedCmp " + "ON " + "    schedCmp.SCHED_ID = sched.SCHED_ID "
            + "LEFT OUTER JOIN " + "    KSEN_ROOM room " + "ON " + "    room.ID = schedCmp.ROOM_ID "
            + "LEFT OUTER JOIN " + "    KSEN_ROOM_BUILDING room2bldg " + "ON "
            + "    room2bldg.ID = room.BUILDING_ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_CMP_TMSLOT schedCmpTmslt " + "ON "
            + "    schedCmpTmslt.SCHED_CMP_ID = schedCmp.ID " + "LEFT OUTER JOIN "
            + "    KSEN_SCHED_TMSLOT schedTmslt " + "ON " + "    schedTmslt.ID = schedCmpTmslt.TM_SLOT_ID, "
            + "    KSEN_LPR_TRANS_ITEM lprti " + "LEFT OUTER JOIN " + "    KSEN_LPR_TRANS_ITEM_RVG credits "
            + "ON " + "    credits.LPR_TRANS_ITEM_ID = lprti.id " + "AND credits.RESULT_VAL_GRP_ID LIKE '"
            + LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + "%' " + "LEFT OUTER JOIN "
            + "    KSEN_LPR_TRANS_ITEM_RVG grading " + "ON " + "    grading.LPR_TRANS_ITEM_ID = lprti.id "
            + "AND grading.RESULT_VAL_GRP_ID LIKE '" + LrcServiceConstants.RESULT_GROUP_KEY_GRADE_BASE + ".%' "
            + "WHERE " + "    lprt.REQUESTING_PERS_ID = :personId " + "AND ( lprt.LPR_TRANS_TYPE= :lprtType "
            + "      OR " + "     lprti.LPR_TRANS_ITEM_STATE = :lprtiProcessingState ) " + // shows processing items
            "AND lprt.ATP_ID = :atpId " + "AND lprti.LPR_TRANS_ID=lprt.ID " + "AND rg2ao.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_REGISTERED_FOR_VIA_RG_TO_AO_TYPE_KEY + "' "
            + "AND fo2rg.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_FO_TO_RG_TYPE_KEY + "' "
            + "AND co2fo.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_CO_TO_FO_TYPE_KEY + "' "
            + "AND rg2ao.LUI_ID=lprti.NEW_LUI_ID " + "AND fo2rg.RELATED_LUI_ID = lprti.NEW_LUI_ID "
            + "AND co2fo.RELATED_LUI_ID = fo2rg.LUI_ID " + "AND ao.id = rg2ao.RELATED_LUI_ID "
            + "AND co.id = co2fo.LUI_ID " + "AND rg.id = lprti.NEW_LUI_ID " + "AND coId.LUI_ID = co.id "
            + "AND coId.LUI_ID_TYPE = '" + LuiServiceConstants.LUI_IDENTIFIER_OFFICIAL_TYPE_KEY + "' "
            + "AND coId.LUI_ID_STATE = '" + LuiServiceConstants.LUI_IDENTIFIER_ACTIVE_STATE_KEY + "' "
            + (StringUtils.isEmpty(cartItemId) ? " " : "AND lprti.ID = :cartItemId ")
            + (StringUtils.isEmpty(cartId) ? " " : "AND lprt.ID = :cartId ") + "ORDER BY "
            + "    lprti.CREATETIME desc";

    Query query = entityManager.createNativeQuery(queryStr);
    query.setParameter(SearchParameters.PERSON_ID, personId);
    query.setParameter(SearchParameters.ATP_ID, atpId);
    query.setParameter(SearchParameters.LPRT_TYPE, lprtType);
    query.setParameter("lprtiProcessingState", LprServiceConstants.LPRTRANS_ITEM_PROCESSING_STATE_KEY);

    if (!StringUtils.isEmpty(cartItemId)) {
        query.setParameter(SearchParameters.CART_ITEM_ID, cartItemId);
    }
    if (!StringUtils.isEmpty(cartId)) {
        query.setParameter(SearchParameters.CART_ID, cartId);
    }

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.CART_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CART_ITEM_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CART_STATE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CART_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CART_ITEM_STATE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CROSSLIST, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RG_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RG_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LONG_NAME, (String) resultRow[i++]);
        BigDecimal tbaInd = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.TBA_IND, (tbaInd == null) ? "" : tbaInd.toString());
        row.addCell(SearchResultColumns.ROOM_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.BUILDING_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.WEEKDAYS, (String) resultRow[i++]);
        BigDecimal startTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.START_TIME_MS, (startTimeMs == null) ? "" : startTimeMs.toString());
        BigDecimal endTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.END_TIME_MS, (endTimeMs == null) ? "" : endTimeMs.toString());
        row.addCell(SearchResultColumns.CREDITS, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.GRADING, (String) resultRow[i]);

        resultInfo.getRows().add(row);
    }

    return resultInfo;

}

From source file:com.app.jdy.ui.CashAdvanceActivity.java

private void addEvents() {
    button.setOnClickListener(new OnClickListener() {

        @Override/*from  w w w. jav a 2  s  . co m*/
        public void onClick(View v) {

            // ????
            if (HttpUtils.isNetworkConnected(CashAdvanceActivity.this)) {

                if (editText.getText().toString().length() == 0) {
                    Toast.makeText(CashAdvanceActivity.this, "?", Toast.LENGTH_SHORT).show();
                } else {

                    // ?
                    int count = 0, start = 0;
                    while ((start = editText.getText().toString().indexOf(".", start)) >= 0) {
                        start += ".".length();
                        count++;
                    }
                    if (count > 1 || editText.getText().toString().indexOf(".") == 0) {
                        Toast.makeText(CashAdvanceActivity.this, "", Toast.LENGTH_SHORT)
                                .show();
                    } else {

                        // ?????
                        BigDecimal judgemoney = null;
                        try {
                            judgemoney = new BigDecimal(editText.getText().toString());
                        } catch (NumberFormatException e) {
                            Toast.makeText(CashAdvanceActivity.this, "",
                                    Toast.LENGTH_SHORT).show();
                            return;
                        }
                        judgemoney = judgemoney.setScale(2, BigDecimal.ROUND_HALF_UP);

                        // ?????
                        String judgecanWithdCash = textView2.getText().toString();

                        if (textView4.getText().toString().equals("?")
                                || textView4.getText().toString().length() == 0
                                || textView3.getText().toString().length() == 0) {
                            Toast.makeText(CashAdvanceActivity.this, "?", Toast.LENGTH_SHORT)
                                    .show();
                        } else if (judgemoney.toString() == "0.00") {
                            Toast.makeText(CashAdvanceActivity.this, "?0?",
                                    Toast.LENGTH_SHORT).show();
                        } else if (judgemoney
                                .compareTo(BigDecimal.valueOf(Double.valueOf(judgecanWithdCash))) == 1) {
                            // BigDecimalcompareTo-1 ? 0
                            // 1
                            Toast.makeText(CashAdvanceActivity.this, "??????",
                                    Toast.LENGTH_LONG).show();
                        } else {
                            editText.setText(judgemoney.toString());

                            withdrawCashDialog = new WithdrawCashDialog(CashAdvanceActivity.this,
                                    R.style.ForwardDialog, judgemoney.toString());
                            withdrawCashDialog.show();
                        }

                    }

                }
            } else {
                // ??
                Toast.makeText(CashAdvanceActivity.this, Constants.NO_INTENT_TIPS, Toast.LENGTH_LONG).show();
            }

        }
    });

    // ??????
    findViewById(R.id.cash_textView5).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(CashAdvanceActivity.this, BankCardActivity.class);

            Bundle bundle = new Bundle();
            bundle.putBoolean("isOk", true);
            intent.putExtras(bundle);
            startActivity(intent);
            finish();
        }
    });

}

From source file:is.idega.idegaweb.egov.gumbo.webservice.client.business.DOFWSClientRealWebservice.java

public List<Item> getGrasleppaVesselsForUser(String companyPersonalID) {
    // get all open cases for user
    List<String> alreadyAppliedShips = new ArrayList<String>();
    try {/* w  ww.j av  a2  s.  c  om*/
        User user = getUserBusiness().getUser(companyPersonalID);
        // INPR,PEND,UBEH,OMPR,WFPA,WAIT
        List<String> statusesToShow = new ArrayList<String>();
        statusesToShow.add("INPR");
        statusesToShow.add("PEND");
        statusesToShow.add("UBEH");
        statusesToShow.add("OMPR");
        statusesToShow.add("WFPA");
        statusesToShow.add("WAIT");

        List<String> names = new ArrayList<String>();
        names.add("string_vesselRegistryNr");

        List<Integer> ids = getCaseManagersProvider().getCaseManager().getCaseIds(user,
                CasesRetrievalManager.CASE_LIST_TYPE_OPEN, null, null, statusesToShow, false, false);
        if (ids != null) {
            List<CaseProcInstBind> binds = getCasesBPMDAO().getCasesProcInstBindsByCasesIds(ids);
            for (CaseProcInstBind caseProcInstBind : binds) {
                ProcessInstanceW inst = getBPMFactory().getProcessInstanceW(caseProcInstBind.getProcInstId());
                if ("Grasleppa".equals(inst.getProcessDefinitionW().getProcessDefinition().getName())) {
                    List<Long> procIds = new ArrayList<Long>();
                    procIds.add(inst.getProcessInstanceId());
                    Collection<VariableInstanceInfo> info = getVariablesQuerier()
                            .getVariablesByProcessInstanceIdAndVariablesNames(procIds, names);
                    if (info != null) {
                        for (VariableInstanceInfo variableInstanceInfo : info) {
                            alreadyAppliedShips.add((String) variableInstanceInfo.getValue());
                        }
                    }
                }
            }
        }
    } catch (IBOLookupException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (FinderException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    List<Item> items = null;
    BigDecimal shipNr[] = getGrasleppuShipNrByCompanySSN(companyPersonalID);
    if (shipNr != null && shipNr.length > 0) {
        items = new ArrayList<Item>(shipNr.length);
        for (BigDecimal nr : shipNr) {
            if (!alreadyAppliedShips.contains(nr.toString())) {
                SkipInfoTypeUser vessel = getShipInfo(nr.toString());
                items.add(new Item(vessel.getSkipNr().toString(),
                        "(" + vessel.getSkipNr().toString() + ") " + vessel.getNafn()));
            }
        }
    }
    return items;
}

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

/**
 * Grabs a view of Course Offering information that is the basis for the registration course search
 * Optional search parameters of term ids and lui ids can be passed in to limit the search.
 *
 * @param searchRequestInfo search request
 * @return search results//from w w w. j  a va2 s.  c  o  m
 */
private SearchResultInfo searchForCOSearchInfo(SearchRequestInfo searchRequestInfo) {
    SearchResultInfo resultInfo = new SearchResultInfo();
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    List<String> luiIds = requestHelper.getParamAsList(SearchParameters.LUI_IDS);
    List<String> atpIds = requestHelper.getParamAsList(SearchParameters.ATP_ID);
    String queryStr = "SELECT\n" + "    luii.LUI_ID_TYPE          coIdentType,\n"
            + "    lui.LUI_STATE             coState,\n" + "    lui.CLU_ID                cluid,\n"
            + "    lui.id                    luiid,\n" + "    lui.ATP_ID                atpid,\n"
            + "    lui.DESCR_FORMATTED       description,\n" + "    luii.LNG_NAME             title,\n"
            + "    luii.LUI_CD               code,\n" + "    clui.LVL                  crsLevel,\n"
            + "    clui.DIVISION             division,\n" + "    clui.SUFX_CD              suffix,\n"
            + "    credits.RESULT_VAL_GRP_ID credits,\n" + "    freeseats.sumao -\n" + "    (\n"
            + "        SELECT\n" + "            COUNT(*)\n" + "        FROM\n" + "            KSEN_LPR lpr\n"
            + "        WHERE\n" + "            lpr.LUI_ID=lui.id\n" + "        AND lpr.LPR_STATE='"
            + LprServiceConstants.ACTIVE_STATE_KEY + "'\n" + "        AND lpr.LPR_TYPE='"
            + LprServiceConstants.REGISTRANT_CO_LPR_TYPE_KEY + "') seatsAvailable,\n"
            + "    honorsCd.value            honorsFlag\n" + "FROM\n" + "    KSEN_LUI lui\n"
            + "    INNER JOIN KSLU_CLU clu ON clu.id = lui.CLU_ID\n"
            + "    INNER JOIN KSLU_CLU_IDENT clui on clui.id = clu.OFFIC_CLU_ID\n"
            + "    INNER JOIN KSEN_LUI_IDENT luii ON luii.LUI_ID = lui.ID\n" + "    INNER JOIN (\n"
            + "        SELECT\n" + "            luiid      luiid,\n" + "            SUM(aomax) sumao\n"
            + "        FROM\n" + "            (\n" + "                SELECT\n"
            + "                    co2fo.LUI_ID      luiid,\n" + "                    rg2ao.LUI_ID      rgid,\n"
            + "                    MIN(ao.MAX_SEATS) aomax\n" + "                FROM\n"
            + "                    KSEN_LUI ao,\n" + "                    KSEN_LUILUI_RELTN co2fo,\n"
            + "                    KSEN_LUILUI_RELTN fo2rg,\n" + "                    KSEN_LUILUI_RELTN rg2ao\n"
            + "                WHERE\n" + "                    co2fo.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_CO_TO_FO_TYPE_KEY + "'\n"
            + "                AND co2fo.LUILUI_RELTN_STATE='"
            + LuiServiceConstants.LUI_LUI_RELATION_ACTIVE_STATE_KEY + "'\n"
            + "                AND fo2rg.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_FO_TO_RG_TYPE_KEY + "'\n"
            + "                AND fo2rg.LUILUI_RELTN_STATE='"
            + LuiServiceConstants.LUI_LUI_RELATION_ACTIVE_STATE_KEY + "'\n"
            + "                AND rg2ao.LUILUI_RELTN_TYPE='"
            + LuiServiceConstants.LUI_LUI_RELATION_REGISTERED_FOR_VIA_RG_TO_AO_TYPE_KEY + "'\n"
            + "                AND rg2ao.LUILUI_RELTN_STATE='"
            + LuiServiceConstants.LUI_LUI_RELATION_ACTIVE_STATE_KEY + "'\n"
            + "                AND co2fo.RELATED_LUI_ID=fo2rg.LUI_ID\n"
            + "                AND fo2rg.RELATED_LUI_ID=rg2ao.LUI_ID\n"
            + "                AND rg2ao.RELATED_LUI_ID=ao.id\n" + "                GROUP BY\n"
            + "                    co2fo.LUI_ID,\n" + "                    rg2ao.LUI_ID )\n"
            + "        GROUP BY\n" + "            luiid) freeseats on freeseats.luiid=lui.id\n"
            + "    INNER JOIN KSEN_LUI_RESULT_VAL_GRP credits on credits.LUI_ID = lui.id\n"
            + "    LEFT OUTER JOIN KSEN_LUI_LU_CD honorsCd on honorsCd.lui_id = luiId and honorsCd.lui_lucd_type = '"
            + LuiServiceConstants.HONORS_LU_CODE + "'\n" + "WHERE\n" + "    lui.LUI_TYPE='"
            + LuiServiceConstants.COURSE_OFFERING_TYPE_KEY + "'\n" + "AND credits.RESULT_VAL_GRP_ID LIKE '"
            + LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + "%'\n"
            + (atpIds == null || atpIds.isEmpty() ? "" : "AND lui.ATP_ID IN(:atpIds)\n") + //Optional parameter to filter by luiids
            (luiIds == null || luiIds.isEmpty() ? "" : "AND lui.ID IN(:luiIds)\n"); //Optional parameter to filter by term

    Query query = entityManager.createNativeQuery(queryStr);

    if (atpIds != null) {
        query.setParameter(SearchParameters.ATP_IDS, atpIds);
    }
    if (luiIds != null) {
        query.setParameter(SearchParameters.LUI_IDS, luiIds);
    }

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.CO_IDENT_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_STATE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CLU_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.ATP_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_DESC, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LONG_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.LUI_LEVEL, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_DIVISION, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.COURSE_NUMBER, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CREDITS, (String) resultRow[i++]);
        BigDecimal seatsAvailable = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.SEATS_AVAILABLE,
                (seatsAvailable == null) ? "" : seatsAvailable.toString());
        row.addCell(SearchResultColumns.HONORS_FLAG, (String) resultRow[i]);
        resultInfo.getRows().add(row);
    }

    return resultInfo;

}