/** * This method gets all responsible people for the given project ID. If none found, returns an * empty list. * * <p>Updates in version 1.1 - removes the reference to DataProvider and * DirectProjectMetadataService. Use native hibernate query to get the copilots and managers. * * @param projectId the ID of the direct project * @return the responsible people * @throws ProjectMilestoneManagementException If there are any errors during the execution of * this method */ @Transactional(readOnly = true) public List<ResponsiblePerson> getAllResponsiblePeople(long projectId) throws ProjectMilestoneManagementException { final String signature = CLASS_NAME + ".getAllResponsiblePeople(long projectId)"; final Date entranceTimestamp = new Date(); // Log entrance LoggingWrapperUtility.logEntrance( logger, signature, new String[] {"projectId"}, new Object[] {projectId}, true, Level.DEBUG); try { // Create list for responsible people: List<ResponsiblePerson> people = new ArrayList<ResponsiblePerson>(); Set<Long> duplicationChecking = new HashSet<Long>(); List copilotList = getSession() .getNamedQuery(GET_COPILOTS_FOR_PROJECT) .setParameter(DIRECT_PROJECT_ID_PARAM, projectId) .list(); for (Object o : copilotList) { ResponsiblePerson p = (ResponsiblePerson) o; if (!duplicationChecking.contains(p.getUserId())) { people.add(p); duplicationChecking.add(p.getUserId()); } } List managersList = sessionFactory .getCurrentSession() .getNamedQuery(GET_MANAGERS_FOR_PROJECT) .setParameter(DIRECT_PROJECT_ID_PARAM, projectId) .list(); for (Object o : managersList) { ResponsiblePerson p = (ResponsiblePerson) o; if (!duplicationChecking.contains(p.getUserId())) { people.add(p); duplicationChecking.add(p.getUserId()); } } // update all the responsible person id to 0, because they are using for looking up for (ResponsiblePerson p : people) { p.setId(0); } // Log exit LoggingWrapperUtility.logExit(logger, signature, new Object[] {people}, entranceTimestamp); // Return people return people; } catch (NumberFormatException e) { throw LoggingWrapperUtility.logException( logger, signature, new ProjectMilestoneManagementException( "NumberFormatException occurs while parsing long to string", e), true, Level.ERROR); } catch (Exception e) { throw LoggingWrapperUtility.logException( logger, signature, new ProjectMilestoneManagementException( "Exception occurs while getting all ResponsiblePeople", e), true, Level.ERROR); } }