List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:org.egov.pims.commons.service.EisCommonsServiceImpl.java
License:Open Source License
public User getUserForPosition(Integer posId, Date date) { User user = null;// w w w . j a va 2s.com try { String mainStr = ""; mainStr = " select USER_ID from EG_EIS_EMPLOYEEINFO ev where ev.pos_id = :posId and ((ev.to_Date is null and ev.from_Date <= :thisDate ) OR (ev.from_Date <= :thisDate AND ev.to_Date > :thisDate))"; Query qry = getCurrentSession().createSQLQuery(mainStr).addScalar("USER_ID", IntegerType.INSTANCE); qry.setInteger("posId", posId); qry.setDate("thisDate", date); List retList = qry.list(); if (retList != null && !retList.isEmpty()) { Long userId = null; for (Iterator iter = retList.iterator(); iter.hasNext();) { userId = (Long) iter.next(); } if (userId != null) { user = userService.getUserById(userId); } } } catch (HibernateException he) { throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } catch (Exception he) { throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } return user; }
From source file:org.egov.pims.dao.AssignmentHibernateDAO.java
License:Open Source License
public List getListOfEmployeeWithoutAssignment(Date fromdate) { List employeeAssignList = null; try {/* ww w . j a v a 2 s. c o m*/ StringBuffer query = new StringBuffer( " select distinct ev.id from EmployeeView ev where ev.isActive=1 and " + "(ev.fromDate > :fromdate OR ev.toDate < :fromdate) AND (ev.dateOfFirstAppointment <= :fromdate) and " + "(ev.id not in (select ev.id from ev where (ev.fromDate <= :fromdate and ev.toDate >=:fromdate)))"); Query qry = getCurrentSession().createQuery(query.toString()); // qry.setString("date", formatter.format(todate.getTime())); qry.setDate("fromdate", fromdate); employeeAssignList = qry.list(); } catch (HibernateException he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } catch (Exception he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } return employeeAssignList; }
From source file:org.egov.pims.dao.AssignmentHibernateDAO.java
License:Open Source License
public Assignment getLatestAssignmentForEmployeeByToDate(Integer empId, Date todate) throws Exception { Assignment assignment = null;/*from ww w . j a v a2s . c o m*/ try { StringBuffer query = new StringBuffer( " select ev.assignment from EmployeeView ev where ev.assignment.isPrimary = 'Y' and " + "ev.id = :empid and ev.fromDate <= :todate and rownum=1 order by ev.toDate desc "); Query qry = getCurrentSession().createQuery(query.toString()); // qry.setString("date", formatter.format(todate.getTime())); qry.setDate("todate", todate); qry.setInteger("empid", empId); assignment = (Assignment) qry.uniqueResult(); } catch (HibernateException he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } catch (Exception he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } return assignment; }
From source file:org.egov.pims.dao.AssignmentHibernateDAO.java
License:Open Source License
/** * Api to get Employee Report with Temporary Assignemt * @param Date/*from w w w . j a v a 2 s .c o m*/ * @param Position Id * @return employeeView */ public List<EmployeeView> getEmployeeWithTempAssignment(Date givenDate, Integer posId) { List<EmployeeView> employeeAssignList = null; try { StringBuffer query = null; query = new StringBuffer("from EmployeeView ev where ev.isActive=1 and ev.assignment.isPrimary='N'"); if (givenDate != null) { query.append(" and ev.fromDate <= :givenDate and ev.toDate >=:givenDate"); } if (posId != null && posId != 0) { query.append(" and ev.position.id =:posId "); } Query qry = getCurrentSession().createQuery(query.toString()); if (givenDate != null) { qry.setDate("givenDate", givenDate); } if (posId != null && posId != 0) { qry.setInteger("posId", posId); } employeeAssignList = (List) qry.list(); } catch (HibernateException he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } catch (Exception he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } return employeeAssignList; }
From source file:org.egov.pims.dao.AssignmentHibernateDAO.java
License:Open Source License
/** * Api to get Employee Report with Temporary Assignemt. New Api Added based on Story enhancement * @param Date/*from w w w . j a va 2 s .c o m*/ * @param Position Id * @param employee code * @return employeeView */ public List<EmployeeView> getEmployeeWithTempAssignment(String code, Date givenDate, Integer posId) { List<EmployeeView> employeeAssignList = null; try { StringBuffer query = null; query = new StringBuffer("from EmployeeView ev where ev.isActive=true and ev.assignment.isPrimary='N'"); if (code != null && !code.equals("")) { query.append(" and upper(trim(ev.employeeCode)) = :code"); } if (givenDate == null && posId == 0) { query.append(" and ((ev.toDate IS NULL AND ev.fromDate <= SYSDATE) " + "OR (ev.fromDate <= SYSDATE AND ev.toDate > SYSDATE)OR " + "(ev.fromDate IN (SELECT MAX (evn.fromDate) FROM EmployeeView evn WHERE evn.id = ev.id and evn.assignment.isPrimary='N'))) "); } else { if (givenDate != null) { query.append(" and ev.fromDate <= :givenDate and ev.toDate >=:givenDate"); } if (posId != null && posId != 0) { query.append(" and ev.position.id =:posId "); } } Query qry = getCurrentSession().createQuery(query.toString()); if (givenDate != null) { qry.setDate("givenDate", givenDate); } if (posId != null && posId != 0) { qry.setInteger("posId", posId); } if (code != null && !code.equals("")) { qry.setString("code", code); } employeeAssignList = (List) qry.list(); } catch (HibernateException he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } catch (Exception he) { LOGGER.error(he.getMessage()); throw new ApplicationRuntimeException(STR_EXCEPTION + he.getMessage(), he); } return employeeAssignList; }
From source file:org.egov.pims.dao.PersonalInformationHibernateDAO.java
License:Open Source License
public List getListOfUsersByBoundaryId(Long boundaryId) throws NoSuchObjectException { List userObjList = new ArrayList(); List bndryObjList = boundaryService.getParentBoundariesByBoundaryId(boundaryId); Date currDate = new Date(); if (!bndryObjList.isEmpty()) { Query qry = getCurrentSession() .createQuery("select J FROM JurisdictionValues JurVal, Jurisdiction J where " + "JurVal.boundary in (:bndryObjList) and JurVal.userJurLevel.id=J.id and JurVal.isHistory='N' and J.user.active=true and " + "(" + "(JurVal.toDate IS NULL and JurVal.fromDate <= :currDate) " + "OR " + "(JurVal.fromDate <= :currDate and JurVal.toDate >= :currDate)) "); qry.setParameterList("bndryObjList", bndryObjList); qry.setDate(STR_CURRDATE, currDate); for (Iterator iter = qry.iterate(); iter.hasNext();) { Jurisdiction jurObj = (Jurisdiction) iter.next(); //userObjList.add(jurObj.getUser()); }//from ww w . j av a 2 s . co m } return userObjList; }
From source file:org.egov.pims.dao.PersonalInformationHibernateDAO.java
License:Open Source License
/** * To get list of users which belong to given boundary. If give boundary is Zone, then it will get all the wards * under that zone and search for users for that Zone and wards within that zone. * @param boundaryId/*w w w . j av a 2s .co m*/ * @return * @throws NoSuchObjectException */ public List getListOfUsersForGivenBoundaryId(Long boundaryId) throws NoSuchObjectException { List userObjList = new ArrayList(); List bndryObjList = new ArrayList(); //get All Children of given boundary bndryObjList = boundaryService.getChildBoundariesByBoundaryId(boundaryId); //Add parent boundary Boundary bnd = boundaryService.getBoundaryById(boundaryId); if (bnd != null) bndryObjList.add(bnd); Date currDate = new Date(); if (!bndryObjList.isEmpty()) { Query qry = getCurrentSession() .createQuery("select J FROM JurisdictionValues JurVal, Jurisdiction J where " + "JurVal.boundary in (:bndryObjList) and JurVal.userJurLevel.id=J.id and JurVal.isHistory='N' and J.user.active=true and " + "(" + "(JurVal.toDate IS NULL and JurVal.fromDate <= :currDate) " + "OR " + "(JurVal.fromDate <= :currDate and JurVal.toDate >= :currDate)) "); qry.setParameterList("bndryObjList", bndryObjList); qry.setDate(STR_CURRDATE, currDate); for (Iterator iter = qry.iterate(); iter.hasNext();) { Jurisdiction jurObj = (Jurisdiction) iter.next(); //userObjList.add(jurObj.getUser()); } } return userObjList; }
From source file:org.egov.pims.dao.PersonalInformationHibernateDAO.java
License:Open Source License
/** * This is used for workflow/*from ww w . j av a2 s . com*/ * Getting employee by passing dept,desig,boundary * @param deptId * @param designationId * @param Boundaryid * @return temAssigned employee if temp Assignement is present otherwise primary assigned employee * @throws TooManyValuesException * @throws NoSuchObjectException */ public PersonalInformation getEmployee(Integer deptId, Integer designationId, Long boundaryId) throws TooManyValuesException, NoSuchObjectException { PersonalInformation personalInformation = null; Query qry1 = null; try { List userList = new ArrayList(); List<PersonalInformation> empList; Date currDate = new Date(); if (boundaryId != null && boundaryId != 0) { //FIXME: should take actual instance of boundary //fixed userList = getListOfUsersByBoundaryId(boundaryId); } if (userList.isEmpty()) { throw new NoSuchObjectException("user.Obj.null"); } else { qry1 = getCurrentSession().createQuery("select P from PersonalInformation P, Assignment A where" + " P.idPersonalInformation=A.employee.idPersonalInformation and " + " A.deptId.id=:deptId and" + " A.desigId.designationId=:designationId and " + " A.isPrimary = 'N' and " + " P.userMaster in (:userObjList) and (" + "(A.toDate IS NULL and A.fromDate <= :currDate) " + "OR " + "(A.fromDate <= :currDate and A.toDate >= :currDate))"); qry1.setInteger("deptId", deptId); qry1.setInteger("designationId", designationId); qry1.setParameterList("userObjList", userList); qry1.setDate(STR_CURRDATE, currDate); empList = qry1.list(); if (empList.size() == 0) { qry1 = getCurrentSession().createQuery("select P from PersonalInformation P, Assignment A where" + " P.idPersonalInformation=A.employee.idPersonalInformation and " + " A.deptId.id=:deptId and" + " A.desigId.designationId=:designationId and " + " A.isPrimary = 'Y' and " + " P.userMaster in (:userObjList) and (" + "(A.toDate IS NULL and A.fromDate <= :currDate) " + "OR " + "(A.fromDate <= :currDate and A.toDate >= :currDate))"); qry1.setInteger("deptId", deptId); qry1.setInteger("designationId", designationId); qry1.setParameterList("userObjList", userList); qry1.setDate(STR_CURRDATE, currDate); empList = qry1.list(); if (empList.isEmpty()) { throw new NoSuchObjectException("personalinformation.object.notFound"); } if (empList.size() > 1) { throw new TooManyValuesException("personalinformation.object.Foundmorethanone"); } if (empList.size() == 1) { personalInformation = empList.get(0); } } else if (empList.size() > 1) { throw new TooManyValuesException("tempAssigned.personalinformation.object.Foundmorethanone"); } else if (empList.size() == 1) { personalInformation = empList.get(0); } } return (personalInformation); } catch (Exception e) { throw new ApplicationRuntimeException(e.getMessage(), e); } }
From source file:org.egov.pims.dao.PersonalInformationHibernateDAO.java
License:Open Source License
/** * This is used for workflow/*ww w.j a v a 2 s.com*/ * Getting employee by passing deptId,desigId,boundaryId,functionaryId * @param deptId * @param designationId * @param Boundaryid * @return temAssigned employee if tempAssignement is present otherwise primary assigned employee * @throws TooManyValuesException * @throws NoSuchObjectException */ public PersonalInformation getEmployeeByFunctionary(Long deptId, Long designationId, Long boundaryId, Integer functionaryId) throws TooManyValuesException, NoSuchObjectException { PersonalInformation personalInformation = null; Query qry1 = null; try { List userList = new ArrayList(); List<PersonalInformation> empList; Date currDate = new Date(); if (boundaryId != null && boundaryId != 0) { //FIXME: should take actual instance of boundary //fixed userList = getListOfUsersByBoundaryId(boundaryId); } if (userList.isEmpty()) { throw new NoSuchObjectException("user.Obj.null"); } else { qry1 = getCurrentSession().createQuery("select P from PersonalInformation P, Assignment A where" + " P.idPersonalInformation=A.employee.idPersonalInformation and " + " A.deptId.id=:deptId and" + " A.desigId.designationId=:designationId and " + "A.functionary.id=:functionaryId and " + " A.isPrimary = 'N' and " + " P.userMaster in (:userObjList) and (" + "(A.toDate IS NULL and A.fromDate <= :currDate) " + "OR " + "(A.fromDate <= :currDate and A.toDate >= :currDate))"); qry1.setLong("deptId", deptId); qry1.setLong("designationId", designationId); qry1.setInteger("functionaryId", functionaryId); qry1.setParameterList("userObjList", userList); qry1.setDate(STR_CURRDATE, currDate); empList = qry1.list(); if (empList.size() == 0) { qry1 = getCurrentSession().createQuery("select P from PersonalInformation P, Assignment A where" + " P.idPersonalInformation=A.employee.idPersonalInformation and " + " A.deptId.id=:deptId and" + " A.desigId.designationId=:designationId and " + "A.functionary.id=:functionaryId and " + " A.isPrimary = 'Y' and " + " P.userMaster in (:userObjList) and (" + "(A.toDate IS NULL and A.fromDate <= :currDate) " + "OR " + "(A.fromDate <= :currDate and A.toDate >= :currDate))"); qry1.setLong("deptId", deptId); qry1.setLong("designationId", designationId); qry1.setInteger("functionaryId", functionaryId); qry1.setParameterList("userObjList", userList); qry1.setDate(STR_CURRDATE, currDate); empList = qry1.list(); if (empList.size() == 0) { throw new NoSuchObjectException("personalinformation.object.notFound"); } if (empList.size() > 1) { throw new TooManyValuesException("personalinformation.object.Foundmorethanone"); } if (empList.size() == 1) { personalInformation = empList.get(0); } } else if (empList.size() > 1) { throw new TooManyValuesException("personalinformation.object.Foundmorethanone"); } else if (empList.size() == 1) { personalInformation = empList.get(0); } } return (personalInformation); } catch (Exception e) { throw new ApplicationRuntimeException(e.getMessage(), e); } }
From source file:org.egov.pims.dao.PersonalInformationHibernateDAO.java
License:Open Source License
/** * Returning temporary assigned employee object by pepartment,designation,functionary,date * @param deptId/*from w w w .j a v a 2 s .c o m*/ * @param DesigId * @param functionaryId * @param onDate * @return Employee * @throws Exception */ public PersonalInformation getTempAssignedEmployeeByDeptDesigFunctionaryDate(Integer deptId, Integer desigId, Integer functionaryId, Date onDate) throws Exception { PersonalInformation tempAssignedEemployee = null; LOGGER.info("Inside temp assigned emp API-----------"); List<PersonalInformation> listEmployee = null; Query qry = getCurrentSession() .createQuery("select A.employee from Assignment A where " + "A.deptId.id=:deptId and " + "A.desigId.designationId=:desigId and " + "A.functionary.id=:functionaryId and " + "A.isPrimary = 'N' and " + "((A.toDate IS NULL and A.fromDate <= :onDate) OR " + "(A.fromDate <= :onDate and A.toDate >= :onDate))"); qry.setInteger("deptId", deptId); qry.setInteger("desigId", desigId); qry.setInteger("functionaryId", functionaryId); qry.setDate("onDate", onDate); LOGGER.info("Inside temp assigned emp API query-----------" + qry.getQueryString()); listEmployee = qry.list(); if (listEmployee.size() == 0) { throw new NoSuchObjectException("tempAssigned.personalinformation.object.notFound"); } if (listEmployee.size() > 1) { throw new TooManyValuesException("tempAssigned.personalinformation.object.Foundmorethanone"); } if (listEmployee.size() == 1) { tempAssignedEemployee = listEmployee.get(0); } return tempAssignedEemployee; }