Example usage for org.hibernate Query setBigDecimal

List of usage examples for org.hibernate Query setBigDecimal

Introduction

In this page you can find the example usage for org.hibernate Query setBigDecimal.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBigDecimal(String name, BigDecimal val) 

Source Link

Document

Bind a named BigDecimal-valued parameter.

Usage

From source file:openones.oopms.daocommon.BaseDao.java

License:Apache License

/**
 * Get roles of user with given id./*from  www  .j a  v a 2s  .c  o  m*/
 * Query template
 * SELECT A.RIGHTGROUPID, A.WORKUNITID, B.TYPE, B.WORKUNITNAME,B.TABLEID 
 *   FROM RIGHTGROUPOFUSERBYWORKUNIT A, WORKUNIT B 
 *   WHERE DEVELOPERID = ? AND B.WORKUNITID = A.WORKUNITID ORDER BY B.WORKUNITNAME
 * 
 * Explanation:
 * WORKUNITNAME: Code of Project if TYPE = 2
 * RIGHTGROUPID: Role of give account id for WorkUnit
 *   PD: Project Manager
 *   PL: Project Leader
 *   Tester: Tester
 *   TeamMember: Developer
 * 
 * @param developerId Identifier of user (For sysadmin, id = 1)
 * @return List of instances of RoleRight
 * @author Open-Ones team
 * @see http://open-ones.googlecode.com/svn/trunk/ProjectList/iPMS/SourceCode/FsoftInsight/src/com/fms1/common/Roles.java
 * , method Vector getRightOfUser(final long developerID)
 */
public List<Right> getRights(BigDecimal developerId) {
    try {
        SessionFactory sessionfactory = HibernateUtil.getSessionFactory();
        session = sessionfactory.openSession();
        session.beginTransaction();
        String sql = "SELECT A.RIGHTGROUPID, A.WORKUNITID, B.TYPE, B.WORKUNITNAME,B.TABLEID"
                + " FROM RIGHTGROUPOFUSERBYWORKUNIT A, WORKUNIT B WHERE DEVELOPERID = ?"
                + " AND B.WORKUNITID = A.WORKUNITID ORDER BY B.WORKUNITNAME";

        Query query = session.createSQLQuery(sql).addScalar("RIGHTGROUPID", Hibernate.STRING)
                .addScalar("WORKUNITID", Hibernate.BIG_DECIMAL).addScalar("TYPE", Hibernate.BIG_DECIMAL)
                .addScalar("WORKUNITNAME", Hibernate.STRING).addScalar("TABLEID", Hibernate.BIG_DECIMAL)
                .setResultTransformer(Transformers.aliasToBean(Right.class));
        query.setBigDecimal(0, developerId);
        List<Right> roleList = query.list();

        Right roleRight;
        for (int i = 0; i < roleList.size(); i++) {
            roleRight = roleList.get(i);
            roleRight.setRIGHTGROUPID(roleRight.getRIGHTGROUPID().trim());
            roleList.set(i, roleRight);
            // System.out.println("'" + roleList.get(i).getRIGHTGROUPID().trim() + "'");
        }

        return roleList;
    } finally {
        session.getTransaction().commit();
        session.close();
    }
}

From source file:org.egov.commons.dao.FunctionaryHibernateDAO.java

License:Open Source License

public Functionary getFunctionaryByCode(final BigDecimal functionaryCode) {
    final Query qry = getCurrentSession().createQuery("from Functionary where code=:code");
    qry.setBigDecimal("code", functionaryCode);
    return (Functionary) qry.uniqueResult();
}

From source file:org.egov.dao.recoveries.EgDeductionDetailsHibernateDAO.java

License:Open Source License

public List<EgDeductionDetails> getEgDeductionDetailsFilterBy(final Recovery tds, final BigDecimal amount,
        final String date, final EgwTypeOfWork egwTypeOfWork, final EgwTypeOfWork egwSubTypeOfWork) {
    session = getCurrentSession();//from ww w.  j a  v a 2s .c o  m
    Query qry;
    final StringBuffer qryStr = new StringBuffer();
    List<EgDeductionDetails> egDeductionDetailsList = null;
    qryStr.append("from EgDeductionDetails ed where ed.recovery=:tds ");
    qry = session.createQuery(qryStr.toString());

    if (amount != null) {
        qryStr.append(
                " and ((ed.lowlimit<=:amount and ed.highlimit>=:amount and ed.highlimit is not null) or (ed.lowlimit<=:amount and ed.highlimit is null)) ");
        qry = session.createQuery(qryStr.toString());
    }
    if (date != null && !date.equals("")) {
        qryStr.append(
                " and ((ed.datefrom<=:date and ed.dateto>=:date and ed.dateto is not null) or(ed.datefrom<=:date and ed.dateto is null))");
        qry = session.createQuery(qryStr.toString());
    }
    if (egwTypeOfWork != null) {
        qryStr.append(" and ed.workDocType =:egwTypeOfWork");
        qry = session.createQuery(qryStr.toString());
    }
    if (egwSubTypeOfWork != null) {
        qryStr.append("  and ed.workDocSubType =:egwSubTypeOfWork");
        qry = session.createQuery(qryStr.toString());
    }
    qryStr.append(" order by id");
    qry = session.createQuery(qryStr.toString());
    if (tds != null)
        qry.setEntity("tds", tds);
    if (date != null && !date.equals(""))
        qry.setString("date", date);
    if (amount != null)
        qry.setBigDecimal("amount", amount);
    if (egwTypeOfWork != null)
        qry.setEntity("egwTypeOfWork", egwTypeOfWork);
    if (egwSubTypeOfWork != null)
        qry.setEntity("egwSubTypeOfWork", egwSubTypeOfWork);

    egDeductionDetailsList = qry.list();
    return egDeductionDetailsList;
}

From source file:org.egov.dao.recoveries.TdsHibernateDAO.java

License:Open Source License

public List<Recovery> getActiveTdsFilterBy(final String estimateDate, final BigDecimal estCost,
        final EgPartytype egPartytype, final EgwTypeOfWork egwTypeOfWork,
        final EgwTypeOfWork egwSubTypeOfWork) {
    Query qry;
    session = getCurrentSession();/*from ww  w .  jav  a2s  . c  o  m*/
    final StringBuffer qryStr = new StringBuffer();
    List<Recovery> tdsList = null;
    qryStr.append("from Recovery tds where tds.isactive=true ");
    qry = session.createQuery(qryStr.toString());

    if (egPartytype != null) {
        qryStr.append(" and tds.egPartytype=:egPartytype");
        qry = session.createQuery(qryStr.toString());
    }

    if (estCost != null) {
        qryStr.append(
                " and tds.id in (select ed.recovery.id from EgDeductionDetails ed where (ed.lowlimit<=:estCost and ed.highlimit>=:estCost and ed.highlimit is not null) or (ed.lowlimit<=:estCost and ed.highlimit is null)) ");
        qry = session.createQuery(qryStr.toString());
    }

    if (estimateDate != null && !estimateDate.equals("")) {
        qryStr.append(
                " and tds.id in (select ed.recovery.id from EgDeductionDetails ed where (ed.datefrom<=:estimateDate and ed.dateto>=:estimateDate and ed.dateto is not null) or(ed.datefrom<=:estimateDate and ed.dateto is null))");
        qry = session.createQuery(qryStr.toString());
    }

    if (egwTypeOfWork != null) {
        qryStr.append(
                " and tds.id in (select ed.recovery.id from EgDeductionDetails ed where ed.workDocType =:egwTypeOfWork)");
        qry = session.createQuery(qryStr.toString());
    }
    if (egwSubTypeOfWork != null) {
        qryStr.append(
                "  and tds.id in (select ed.recovery.id from EgDeductionDetails ed where ed.workDocSubType =:egwSubTypeOfWork)");
        qry = session.createQuery(qryStr.toString());
    }

    qryStr.append(" order by upper(type)");
    qry = session.createQuery(qryStr.toString());

    if (estimateDate != null && !estimateDate.equals(""))
        qry.setString("estimateDate", estimateDate);
    if (estCost != null)
        qry.setBigDecimal("estCost", estCost);
    if (egPartytype != null)
        qry.setEntity("egPartytype", egPartytype);
    if (egwTypeOfWork != null)
        qry.setEntity("egwTypeOfWork", egwTypeOfWork);
    if (egwSubTypeOfWork != null)
        qry.setEntity("egwSubTypeOfWork", egwSubTypeOfWork);

    tdsList = qry.list();
    return tdsList;
}

From source file:org.egov.ptis.actions.search.GisSearchPropertyAction.java

License:Open Source License

@ValidationErrorPage(value = "demand")
public String srchByDemand() {
    LOGGER.debug("Entered into srchByDemand method");
    LOGGER.debug("Zone Id : " + zoneId + ", " + "ward Id : " + wardId + ", " + "Property Type : " + propTypeId
            + ", " + "Demand from amt : " + demandFromAmt + ", " + "Demand To amt : " + demandToAmt);
    final String strZoneNum = boundaryService.getBoundaryById(zoneId).getName();
    final String strWardNum = "";
    String target = null;//  ww  w.j av a  2  s.  c o m
    String propTypeName = "";
    if (propTypeId != null && propTypeId != -1)
        propTypeName = propertyTypeMasterDAO.findById(propTypeId, false).getType();
    if (zoneId != null && zoneId != -1)
        try {
            final StringBuilder queryStr = new StringBuilder();
            queryStr.append("from PropertyMaterlizeView pmv where pmv.zone.id=:ZoneID and pmv.isActive = true");
            if (wardId != null && wardId != -1)
                queryStr.append(" and pmv.ward.id=:WardID");
            if (areaId != null && areaId != -1)
                queryStr.append(" and pmv.street.id=:AreaID");

            if (propTypeId != null && propTypeId != -1)
                queryStr.append(" and pmv.propTypeMstrID.id =:propType ");

            if (demandFromAmt != null && demandToAmt != null)
                queryStr.append(" and pmv.aggrCurrDmd BETWEEN :dmdFrmAmt and :dmdToAmt ");

            final Query query = getPersistenceService().getSession().createQuery(queryStr.toString());
            if (zoneId != null && zoneId != -1)
                query.setLong("ZoneID", zoneId);
            if (wardId != null && wardId != -1)
                query.setInteger("WardID", wardId);
            if (areaId != null && areaId != -1)
                query.setInteger("AreaID", areaId);
            if (propTypeId != null && propTypeId != -1)
                query.setInteger("propType", propTypeId);
            if (demandFromAmt != null && demandToAmt != null) {
                query.setBigDecimal("dmdFrmAmt", demandFromAmt);
                query.setBigDecimal("dmdToAmt", demandToAmt);
            }
            final List<PropertyMaterlizeView> propertyList = query.list();
            if (propertyList.size() < 0) {
                setSESSION(getSESSION());
                setMode("demand");
                target = "nodtls";
            }
            int count = 0;
            for (final PropertyMaterlizeView propMatview : propertyList) {
                LOGGER.debug("srchByBndry : Property : " + propMatview);
                if (count <= 6)
                    setSearchResultList(getResultsFromMv(propMatview));
                else
                    break;
                count++;
            }
            if (searchResultList != null)
                setSearchResultString(getSearchResultsString(searchResultList));
            setSearchUri("../search/searchProperty!srchByDemand.action");
            setSearchCreteria("Search By Zone, Ward,Area,Property Type,Demand");
            setSearchValue("Zone Num: " + strZoneNum + ", Ward Num: " + strWardNum + ", Property Type: "
                    + propTypeName);
            LOGGER.debug("Search Criteria : " + getSearchCreteria());
            LOGGER.debug("Search Value : " + getSearchValue());
            setSESSION(getSESSION());
            setGisCity(GISCITY);
            setGisVersion(GISVERSION);
            setMode("demand");
            target = "result";
        } catch (final Exception e) {
            LOGGER.error("Exception in Search Property By Demand ", e);
            throw new ApplicationRuntimeException("Exception : " + e);
        }
    LOGGER.debug("Exit from srchByDemand method");
    return target;

}

From source file:org.egov.ptis.actions.search.GisSearchPropertyAction.java

License:Open Source License

@ValidationErrorPage(value = "defaulter")
public String srchByDefaulter() {
    LOGGER.debug("Entered into srchByDefaulter method");
    LOGGER.debug("Zone Id : " + zoneId + ", " + "ward Id : " + wardId + ", " + "Property Type : " + propTypeId
            + ", " + "Defaulter from amt : " + defaulterFromAmt + ", " + "Defaulter To amt : "
            + defaulterToAmt);/*from w w  w.ja va  2 s.  c o m*/
    final String strZoneNum = boundaryService.getBoundaryById(zoneId).getName();
    final String strWardNum = "";
    String target = null;
    String propTypeName = "";
    if (propTypeId != null && propTypeId != -1)
        propTypeName = propertyTypeMasterDAO.findById(propTypeId, false).getType();
    if (zoneId != null && zoneId != -1)
        try {
            final StringBuilder queryStr = new StringBuilder();
            queryStr.append("from PropertyMaterlizeView pmv where pmv.zone.id=:ZoneID and pmv.isActive = true");
            if (wardId != null && wardId != -1)
                queryStr.append(" and pmv.ward.id=:WardID");
            if (areaId != null && areaId != -1)
                queryStr.append(" and pmv.street.id=:AreaID");

            if (propTypeId != null && propTypeId != -1)
                queryStr.append(" and pmv.propTypeMstrID.id =:propType ");

            if (defaulterFromAmt != null && defaulterToAmt != null)
                queryStr.append(
                        " and pmv.aggrCurrDmd - pmv.aggrCurrColl between :defaultFrmAmt and :defaultToAmt ");

            final Query query = getPersistenceService().getSession().createQuery(queryStr.toString());
            if (zoneId != null && zoneId != -1)
                query.setLong("ZoneID", zoneId);
            if (wardId != null && wardId != -1)
                query.setInteger("WardID", wardId);
            if (areaId != null && areaId != -1)
                query.setInteger("AreaID", areaId);
            if (propTypeId != null && propTypeId != -1)
                query.setInteger("propType", propTypeId);
            if (defaulterFromAmt != null && defaulterToAmt != null) {
                query.setBigDecimal("defaultFrmAmt", defaulterFromAmt);
                query.setBigDecimal("defaultToAmt", defaulterToAmt);
            }
            final List<PropertyMaterlizeView> propertyList = query.list();
            if (propertyList.size() < 0) {
                setSESSION(getSESSION());
                setMode("defaulter");
                target = "nodtls";
            }
            int count = 0;
            for (final PropertyMaterlizeView propMatview : propertyList) {
                LOGGER.debug("srchByBndry : Property : " + propMatview);
                if (count <= 6)
                    setSearchResultList(getResultsFromMv(propMatview));
                else
                    break;
                count++;
            }
            if (searchResultList != null)
                setSearchResultString(getSearchResultsString(searchResultList));
            setSearchUri("../search/searchProperty!srchByDefaulter.action");
            setSearchCreteria("Search By Zone, Ward,Area,Property Type,Defaulter");
            setSearchValue("Zone Num: " + strZoneNum + ", Ward Num: " + strWardNum + ", Property Type: "
                    + propTypeName);
            LOGGER.debug("Search Criteria : " + getSearchCreteria());
            LOGGER.debug("Search Value : " + getSearchValue());
            setSESSION(getSESSION());
            setGisCity(GISCITY);
            setGisVersion(GISVERSION);
            setMode("defaulter");
            target = "result";
        } catch (final Exception e) {
            LOGGER.error("Exception in Search Property By Defaulter ", e);
            throw new ApplicationRuntimeException("Exception : " + e);
        }
    LOGGER.debug("Exit from srchByDefaulter method");
    return target;

}

From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java

License:Open Source License

@Override
public List getPropertyByRvAmout(Integer boundaryID, Character RvSel, String lowVal, String HighVal)
        throws PropertyNotFoundException {
    LOGGER.info(">>>>>>>>>>inside getPropertyByRvAmout>>>>>>>>>>>>>>");
    if (RvSel == null || RvSel.equals("")) {
        throw new ApplicationRuntimeException(
                "RV amout selection was not Set during PropertySearch based on Boundry!!");
    }/* w ww.  ja v a2s . c o  m*/
    LOGGER.info("after query execution--------------RvSel--" + RvSel.charValue() + "---------lowVal----------"
            + lowVal + "--------HighVal--------" + HighVal);

    Query qry;
    try {
        LOGGER.info("Executing testChequeQry query...............");

        Boundary boundary = boundaryService.getBoundaryById(boundaryID.longValue());
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
        String finEndDate = sdf.format(new Date());//TODO WHEN REQUIRED removing getFinancialYear sdf.format(DateUtils.getFinancialYear().getEndOnOnDate());
        StringBuffer qryStr = new StringBuffer(2000);
        qryStr.append("select distinct pi From PropertyImpl pi inner join pi.basicProperty bp inner join "
                + "pi.ptDemandARVSet rv where rv.toDate = to_date('" + finEndDate + "','dd/mm/yyyy') and "
                + "pi.status='A' and bp.active='Y' ");
        boolean rvLess = false;
        boolean rvGreater = false;
        boolean rvBetween = false;
        boolean rvEqual = false;
        boolean seatFound = false;
        if (boundaryID != null && boundaryID.intValue() != 0) {
            seatFound = true;
            qryStr.append(" and bp.boundary = :boundary");
            LOGGER.info(
                    ">>>>>>>>>>>>>>Search by seat no>>>>>>>>>>>>> " + qryStr.toString() + "....." + boundaryID);
        }
        if (RvSel.charValue() == '1') {
            rvLess = true;
            qryStr.append(" and rv.arv <= :highVal ");
            LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 1");
        }
        if (RvSel.charValue() == '2') {
            rvGreater = true;
            qryStr.append(" and rv.arv >= :lowVal ");
            LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 2");
        }
        if (RvSel.charValue() == '3') {
            rvBetween = true;
            qryStr.append(" and rv.arv >= :lowVal and rv.arv <= :highVal ");
            LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 3");
        }
        if (RvSel.charValue() == '4') {
            rvEqual = true;
            qryStr.append(" and rv.arv = :lowVal ");
            LOGGER.info(">>>>>>>>>>>>>>Search by arv amount rvsel--- 2");
        }
        LOGGER.info("query string final--------------" + qryStr.toString());

        qry = getCurrentSession().createQuery(qryStr.toString());
        if (seatFound) {
            qry.setEntity("boundary", boundary);
        }
        if (rvLess) {
            qry.setBigDecimal("highVal", new BigDecimal(HighVal));
        }
        if (rvGreater) {
            qry.setBigDecimal("lowVal", new BigDecimal(lowVal));
        }
        if (rvBetween) {
            qry.setBigDecimal("lowVal", new BigDecimal(lowVal));
            qry.setBigDecimal("highVal", new BigDecimal(HighVal));
        }
        if (rvEqual) {
            qry.setBigDecimal("lowVal", new BigDecimal(lowVal));
        }
        LOGGER.info("before query execution");
        List propertyList = qry.list();
        if (propertyList == null) {
            throw new PropertyNotFoundException(
                    "No Properties Found with the matching Criteria: lowval:" + lowVal + ",highval:" + HighVal);
        } else {
            if (propertyList.size() > 200) {
                List errorList = new ArrayList();
                errorList.add(0, "more props");
                return errorList;
            }
            return getSearchResultList(propertyList);
        }
    } catch (Exception e) {
        LOGGER.info("Excetion in getPropertyByRvAmout----------------" + e);
        throw new ApplicationRuntimeException("Error in getPropertyByRvAmout", e);
    }
}

From source file:org.egov.ptis.domain.dao.property.SearchPropertyHibernateDAO.java

License:Open Source License

/**
 * //from w ww .j ava2 s.  c  o  m
 */
public List getPropertyByBoundryAndQueryParamMap(Map<String, Object> queryParamMap)
        throws PropertyNotFoundException {

    String ownerName = null;
    String newHouseNo = null;
    String oldHouseNo = null;
    Integer propTypeId = null;
    ;
    BigDecimal dmdFrmAmt = null;
    BigDecimal dmdToAmt = null;
    BigDecimal defaultFrmamt = null;
    BigDecimal defaultToAmt = null;
    Query qry;
    List propertyList = new ArrayList();
    try {
        if (queryParamMap.get(SRCH_BOUNDARY_ID) != null) {
            Integer boundryID = (Integer) queryParamMap.get(SRCH_BOUNDARY_ID);
            if (boundryID != null && !boundryID.equals("")) {
                Boundary boundary = boundaryService.getBoundaryById(boundryID.longValue());
                LOGGER.info("boundary.obj................" + boundary);
                if (boundary != null) {
                    String boundryType = boundary.getBoundaryType().getName();
                    LOGGER.info("testQry executed.......boundryType................." + boundryType);
                    StringBuffer qryStr = new StringBuffer(2000);
                    qryStr.append(
                            "select EGPTP.ID_PROPERTY from egpt_property egptp left outer join egpt_basic_property egptb")
                            .append(" on EGPTP.ID_BASIC_PROPERTY=EGPTB.ID_BASIC_PROPERTY")
                            .append(" left outer join egpt_propertyid egptpid on EGPTB.ID_PROPERTYID=EGPTPID.ID")
                            .append(" left outer join egpt_property_detail egptpd on EGPTP.ID_PROPERTY=EGPTPD.ID_PROPERTY")
                            .append(" left outer join egpt_ptdemand egptde on EGPTP.ID_PROPERTY=EGPTDE.ID_PROPERTY")
                            .append(" left outer join EG_DEMAND_DETAILS egdet on EGPTDE.ID_DEMAND=EGDET.ID_DEMAND")
                            .append(" left outer join eg_demand_reason egdr on EGDET.ID_DEMAND_REASON=egdr.id")
                            .append(" left outer join eg_address egadd on EGPTB.ADDRESSID=EGADD.ADDRESSID")
                            .append(" left outer join EGPT_PROPERTY_OWNER egptprown on EGPTP.ID_PROPERTY=EGPTPROWN.ID_PROPERTY")
                            .append(" left outer join eg_citizen egciti on EGPTPROWN.OWNERID=EGCITI.CITIZENID")
                            .append(" where EGPTP.STATUS='A' and EGPTP.IS_DEFAULT_PROPERTY='Y' and EGPTB.IS_ACTIVE='Y'");

                    LOGGER.debug("searching for boundary " + qryStr.toString() + "boundaryId" + boundryID);
                    boolean zoneBndryFound = false;
                    boolean bndryFound = false;
                    boolean wardBndryFound = false;
                    boolean areaBndryFound = false;
                    boolean ownerFound = false;
                    boolean houseFound = false;
                    boolean propTypeFound = false;
                    boolean demandFound = false;
                    boolean defaulterFound = false;
                    if (boundryType != null && boundryType.endsWith("Revenue Zone")) {
                        zoneBndryFound = true;
                        qryStr.append(" and EGPTPID.ZONE_NUM= :boundryID");
                    } else if (boundryType != null && boundryType.endsWith("Revenue Ward")) {
                        wardBndryFound = true;
                        qryStr.append(" and EGPTPID.WARD_ADM_ID = :boundryID");
                    } else if (boundryType != null && boundryType.endsWith("Revenue Area")) {
                        areaBndryFound = true;
                        qryStr.append(" and EGPTPID.ADM1 = :boundryID");
                    } else if (boundryType != null && boundryType.endsWith("Revenue Locality")) {
                        bndryFound = true;
                        qryStr.append(" and EGPTPID.ADM2 = :boundryID");
                    } else if (boundryType != null && boundryType.endsWith("Revenue Street")) {
                        bndryFound = true;
                        qryStr.append(" and EGPTPID.ADM3 = :boundryID");
                    }

                    if (queryParamMap.get(SRCH_OWNER_NAME) != null) {
                        ownerName = queryParamMap.get(SRCH_OWNER_NAME).toString();
                        if (!ownerName.equals("")) {
                            ownerFound = true;
                            qryStr.append(" and upper(EGCITI.FIRSTNAME) like :firstName "); // :lastName
                        }
                    }
                    if (queryParamMap.get(SRCH_NEW_HOUSE_NO) != null) {
                        newHouseNo = queryParamMap.get(SRCH_NEW_HOUSE_NO).toString();
                        if (!newHouseNo.equals("")) {
                            houseFound = true;
                            qryStr.append(" and upper(EGADD.HOUSENO) like :houseno ");
                        }
                    }
                    if (queryParamMap.get(SRCH_PROPERTY_TYPE) != null) {
                        propTypeId = (Integer) queryParamMap.get(SRCH_PROPERTY_TYPE);
                        if (propTypeId != -1) {
                            propTypeFound = true;
                            qryStr.append(" and EGPTPD.ID_PROPERTYTYPEMASTER =:propType ");
                        }
                    }

                    qryStr.append(
                            " and EGDR.ID_INSTALLMENT = (select id_installment from eg_installment_master where start_date<=sysdate and end_date>=sysdate")
                            .append(" and id_module=(select id_module from eg_module where module_name='Property Tax')) ")
                            .append(" group by EGDR.ID_INSTALLMENT,EGPTP.ID_PROPERTY");
                    if (queryParamMap.get(SRCH_DEMAND_FROM_AMOUNT) != null
                            || queryParamMap.get(SRCH_DEMAND_TO_AMOUNT) != null) {
                        dmdFrmAmt = (BigDecimal) queryParamMap.get(SRCH_DEMAND_FROM_AMOUNT);
                        dmdToAmt = (BigDecimal) queryParamMap.get(SRCH_DEMAND_TO_AMOUNT);
                        demandFound = true;
                        qryStr.append(" having sum( EGDET.AMOUNT) BETWEEN :dmdFrmAmt and :dmdToAmt ");
                    }
                    if (queryParamMap.get(SRCH_DEFAULTER_FROM_AMOUNT) != null
                            || queryParamMap.get(SRCH_DEFAULTER_TO_AMOUNT) != null) {
                        defaultFrmamt = (BigDecimal) queryParamMap.get(SRCH_DEFAULTER_FROM_AMOUNT);
                        defaultToAmt = (BigDecimal) queryParamMap.get(SRCH_DEFAULTER_TO_AMOUNT);
                        defaulterFound = true;
                        qryStr.append(
                                " having sum(EGDET.AMOUNT)- sum(EGDET.AMT_COLLECTED) between :defaultFrmAmt and :defaultToAmt ");
                    }
                    LOGGER.info("query string final--------------" + qryStr.toString());
                    qry = getCurrentSession().createSQLQuery(qryStr.toString());
                    if (zoneBndryFound) {
                        qry.setInteger("boundryID", boundryID);
                    }
                    if (wardBndryFound) {
                        qry.setInteger("boundryID", boundryID);
                    }
                    if (areaBndryFound) {
                        qry.setInteger("boundryID", boundryID);
                    }
                    if (bndryFound) {
                        qry.setInteger("boundryID", boundryID);
                    }
                    if (ownerFound) {
                        qry.setString("firstName", "%" + ownerName.toUpperCase() + "%");
                    }
                    if (houseFound) {
                        qry.setString("houseno", newHouseNo.toUpperCase() + "%");
                    }

                    if (propTypeFound) {
                        qry.setInteger("propType", propTypeId);
                    }
                    if (demandFound) {
                        qry.setBigDecimal("dmdFrmAmt", dmdFrmAmt);
                        qry.setBigDecimal("dmdToAmt", dmdToAmt);
                    }
                    if (defaulterFound) {
                        qry.setBigDecimal("defaultFrmAmt", defaultFrmamt);
                        qry.setBigDecimal("defaultToAmt", defaultToAmt);
                    }
                    propertyList = qry.list();
                }
            }
        }
        return propertyList;
    } catch (Exception e) {
        throw new ApplicationRuntimeException("Error in getPropertyByBoundryAndOwnerNameAndHouseNo", e);
    }

}

From source file:org.egov.ptis.domain.service.property.PropertyService.java

License:Open Source License

/**
 * @param fromDemand/*  w w w  .j  av  a 2 s.c  o  m*/
 * @param toDemand
 * @return List of property having demand between fromDemand and toDemand
 */
@ReadOnly
@SuppressWarnings("unchecked")
public List<PropertyMaterlizeView> getPropertyByDemand(final String fromDemand, final String toDemand) {
    final StringBuilder queryStr = new StringBuilder();
    queryStr.append(
            "select distinct pmv from PropertyMaterlizeView pmv where pmv.aggrCurrFirstHalfDmd is not null and pmv.aggrCurrFirstHalfDmd>=:fromDemand ")
            .append("and pmv.aggrCurrFirstHalfDmd<=:toDemand and pmv.isActive = true ");
    final Query query = propPerServ.getSession().createQuery(queryStr.toString());
    query.setBigDecimal("fromDemand", new BigDecimal(fromDemand));
    query.setBigDecimal("toDemand", new BigDecimal(toDemand));

    return (List<PropertyMaterlizeView>) query.list();
}

From source file:org.jasig.ssp.dao.PersonSearchDao.java

License:Apache License

private void addBindParams(PersonSearchRequest personSearchRequest, Query query, Term currentTerm) {
    if (hasStudentId(personSearchRequest)) {
        final String wildcardedStudentIdOrNameTerm = new StringBuilder("%")
                .append(personSearchRequest.getSchoolId().toUpperCase()).append("%").toString();
        query.setString("studentIdOrName", wildcardedStudentIdOrNameTerm);
    }//from www.ja  va 2s  .  co m

    if (hasPlanExists(personSearchRequest)) {
        if (PersonSearchRequest.PLAN_EXISTS_ACTIVE.equals(personSearchRequest.getPlanExists())) {
            query.setInteger("planObjectStatus", ObjectStatus.ACTIVE.ordinal());
        } else if (PersonSearchRequest.PLAN_EXISTS_INACTIVE.equals(personSearchRequest.getPlanExists())) {
            query.setInteger("planObjectStatus", ObjectStatus.INACTIVE.ordinal());
        } else if (PersonSearchRequest.PLAN_EXISTS_NONE.equals(personSearchRequest.getPlanExists())) {
            // this is handled structurally (exists test)
        } else {
            query.setParameter("planObjectStatus", null);
        }
    }
    if (hasPlanStatus(personSearchRequest)) {
        PlanStatus param = null;
        if (PersonSearchRequest.PLAN_STATUS_ON_PLAN.equals(personSearchRequest.getPlanStatus())) {
            param = PlanStatus.ON;
        }
        if (PersonSearchRequest.PLAN_STATUS_OFF_PLAN.equals(personSearchRequest.getPlanStatus())) {
            param = PlanStatus.OFF;
        }
        if (PersonSearchRequest.PLAN_STATUS_ON_TRACK_SEQUENCE.equals(personSearchRequest.getPlanStatus())) {
            param = PlanStatus.ON_TRACK_SEQUENCE;
        }
        if (PersonSearchRequest.PLAN_STATUS_ON_TRACK_SUBSTITUTION.equals(personSearchRequest.getPlanStatus())) {
            param = PlanStatus.ON_TRACK_SUBSTITUTION;
        }
        query.setString("planStatus", param == null ? null : param.name());
    }

    if (hasGpaCriteria(personSearchRequest)) {
        if (personSearchRequest.getGpaEarnedMin() != null) {
            query.setBigDecimal("gpaEarnedMin", personSearchRequest.getGpaEarnedMin());
        }
        if (personSearchRequest.getGpaEarnedMax() != null) {
            query.setBigDecimal("gpaEarnedMax", personSearchRequest.getGpaEarnedMax());
        }
    }

    if (hasCoach(personSearchRequest) || hasMyCaseload(personSearchRequest)) {
        Person me = null;
        Person coach = null;
        if (hasMyCaseload(personSearchRequest)) {
            me = securityService.currentlyAuthenticatedUser().getPerson();
        }
        if (hasCoach(personSearchRequest)) {
            coach = personSearchRequest.getCoach();
        }

        UUID queryPersonId = null;
        Person compareTo = null;
        if (me != null) {
            queryPersonId = me.getId();
            compareTo = coach;
        } else if (coach != null) {
            queryPersonId = coach.getId();
            compareTo = me;
        }
        // If me and coach aren't the same, the query is non-sensical, so set the 'queryPerson' to null which
        // will effectively force the query to return no results.
        if (queryPersonId != null && compareTo != null) {
            queryPersonId = queryPersonId.equals(compareTo.getId()) ? queryPersonId : null;
        }
        query.setParameter("coachId", queryPersonId);
    }

    if (hasAnyWatchCriteria(personSearchRequest)) {
        Person me = null;
        Person watcher = null;
        if (hasMyWatchList(personSearchRequest)) {
            me = securityService.currentlyAuthenticatedUser().getPerson();
        }
        if (hasWatcher(personSearchRequest)) {
            watcher = personSearchRequest.getWatcher();
        }

        UUID queryPersonId = null;
        Person compareTo = null;
        if (me != null) {
            queryPersonId = me.getId();
            compareTo = watcher;
        } else if (watcher != null) {
            queryPersonId = watcher.getId();
            compareTo = me;
        }
        // If me and watcher aren't the same, the query is non-sensical, so set the 'queryPerson' to null which
        // will effectively force the query to return no results.
        if (queryPersonId != null && compareTo != null) {
            queryPersonId = queryPersonId.equals(compareTo.getId()) ? queryPersonId : null;
        }
        query.setParameter("watcherId", queryPersonId);
    }

    if (hasDeclaredMajor(personSearchRequest)) {
        query.setString("programCode", personSearchRequest.getDeclaredMajor());
    }

    if (hasHoursEarnedCriteria(personSearchRequest)) {
        if (personSearchRequest.getHoursEarnedMin() != null) {
            query.setBigDecimal("hoursEarnedMin", personSearchRequest.getHoursEarnedMin());
        }
        if (personSearchRequest.getHoursEarnedMax() != null) {
            query.setBigDecimal("hoursEarnedMax", personSearchRequest.getHoursEarnedMax());
        }
    }

    if (hasProgramStatus(personSearchRequest)) {
        query.setEntity("programStatus", personSearchRequest.getProgramStatus());
    }

    if (hasSpecialServiceGroup(personSearchRequest)) {
        query.setEntity("specialServiceGroup", personSearchRequest.getSpecialServiceGroup());
    }

    if (hasFinancialAidStatus(personSearchRequest)) {
        query.setString("sapStatusCode", personSearchRequest.getSapStatusCode());
    }

    if (hasCurrentlyRegistered(personSearchRequest)) {
        query.setString("currentTerm", currentTerm.getCode());
    }

    if (hasMyPlans(personSearchRequest)) {
        query.setEntity("owner", securityService.currentlyAuthenticatedUser().getPerson());
    }

    if (hasBirthDate(personSearchRequest)) {
        query.setDate("birthDate", personSearchRequest.getBirthDate());
    }

    query.setInteger("activeObjectStatus", ObjectStatus.ACTIVE.ordinal());
}