@Override public List<Deal> getCoordinatorActiveDeals(User user) { DetachedCriteria criteria = DetachedCriteria.forClass(Deal.class); DealStateType dealCloseState = workflowDAO.getDealStateType(DealStates.CLOSED_ID); DealStateType dealNewState = workflowDAO.getDealStateType(DealStates.NEW_ID); criteria .add(Restrictions.eq("isEnabled", true)) .add(Restrictions.ne("dealStateType", dealCloseState)) .add(Restrictions.ne("dealStateType", dealNewState)) .add(Restrictions.eq("step", Deal.FINISHED)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); @SuppressWarnings("unchecked") List<Deal> deals = hibernateTemplate.findByCriteria(criteria); return deals; }
@Override public List<Deal> getOperatorActiveDeals(User user) { DetachedCriteria criteria = DetachedCriteria.forClass(Deal.class) .createAlias("user", "user", CriteriaSpecification.LEFT_JOIN); criteria.add(Restrictions.eq("user", user)).add(Restrictions.eq("isEnabled", true)); DealWorkflowSideType operatorWorkflowSideType = workflowDAO.getWorkflowSideType(DealWorkflowSideTypes.OPERATOR_SIDE_ID); DealStateType dealCloseState = workflowDAO.getDealStateType(DealStates.CLOSED_ID); criteria .add(Restrictions.eq("dealWorkflowSideType", operatorWorkflowSideType)) .add(Restrictions.ne("dealStateType", dealCloseState)) .add(Restrictions.eq("step", Deal.FINISHED)); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); @SuppressWarnings("unchecked") List<Deal> deals = hibernateTemplate.findByCriteria(criteria); return deals; }