@Test public void testExecute() { final long fordId = 42L; final long montyBurnsId = 99L; List<Long> peopleIds = new ArrayList<Long>(); peopleIds.add(fordId); peopleIds.add(montyBurnsId); Map<Long, List<String>> data = sut.execute(peopleIds); assertEquals(2, data.keySet().size()); assertEquals(2, data.get(fordId).size()); assertEquals("skill_1", data.get(fordId).get(0)); assertEquals("skill_2", data.get(fordId).get(1)); assertEquals(2, data.get(montyBurnsId).size()); assertEquals("skill_2", data.get(montyBurnsId).get(0)); assertEquals("skill_3", data.get(montyBurnsId).get(1)); }
@Override public Map<Long, List<String>> execute(final Collection<Long> inPersonIds) { Map<Long, List<String>> map = new HashMap<Long, List<String>>(); Query q = getEntityManager().createQuery( "SELECT p.id, bgi.name FROM BackgroundItem bgi, Person p, PersonBackgroundItemSkill skill " + "WHERE bgi MEMBER OF p.background.skills AND p.id IN (:personIds) " + "and skill.pk.backgroundItemId = bgi.id and skill.pk.backgroundId = p.background.id " + "ORDER BY skill.pk.sortIndex").setParameter("personIds", inPersonIds); List<Object[]> results = q.getResultList(); for (Object[] interestData : results) { Long personId = (Long) interestData[0]; String interest = (String) interestData[1]; List<String> interests; if (map.containsKey(personId)) { interests = map.get(personId); } else { interests = new ArrayList<String>(); map.put(personId, interests); } interests.add(interest); } return map; }
GetSkillsAndInterestsByEmployeeIdsDbMapper extends
        BaseArgDomainMapper<Collection<Long>, Map<Long, List<String>>> { @Override public Map<Long, List<String>> execute(final Collection<Long> inPersonIds) { Map<Long, List<String>> map = new HashMap<Long, List<String>>(); Query q = getEntityManager().createQuery( "SELECT p.id, bgi.name FROM BackgroundItem bgi, Person p, PersonBackgroundItemSkill skill " + "WHERE bgi MEMBER OF p.background.skills AND p.id IN (:personIds) " + "and skill.pk.backgroundItemId = bgi.id and skill.pk.backgroundId = p.background.id " + "ORDER BY skill.pk.sortIndex").setParameter("personIds", inPersonIds); List<Object[]> results = q.getResultList(); for (Object[] interestData : results) { Long personId = (Long) interestData[0]; String interest = (String) interestData[1]; List<String> interests; if (map.containsKey(personId)) { interests = map.get(personId); } else { interests = new ArrayList<String>(); map.put(personId, interests); } interests.add(interest); } return map; } }
GetSkillsAndInterestsByEmployeeIdsDbMapper extends
        BaseArgDomainMapper<Collection<Long>, Map<Long, List<String>>> { @Override public Map<Long, List<String>> execute(final Collection<Long> inPersonIds) { Map<Long, List<String>> map = new HashMap<Long, List<String>>(); Query q = getEntityManager().createQuery( "SELECT p.id, bgi.name FROM BackgroundItem bgi, Person p, PersonBackgroundItemSkill skill " + "WHERE bgi MEMBER OF p.background.skills AND p.id IN (:personIds) " + "and skill.pk.backgroundItemId = bgi.id and skill.pk.backgroundId = p.background.id " + "ORDER BY skill.pk.sortIndex").setParameter("personIds", inPersonIds); List<Object[]> results = q.getResultList(); for (Object[] interestData : results) { Long personId = (Long) interestData[0]; String interest = (String) interestData[1]; List<String> interests; if (map.containsKey(personId)) { interests = map.get(personId); } else { interests = new ArrayList<String>(); map.put(personId, interests); } interests.add(interest); } return map; }  }
GetSkillsAndInterestsByEmployeeIdsDbMapper extends
        BaseArgDomainMapper<Collection<Long>, Map<Long, List<String>>> { @Override public Map<Long, List<String>> execute(final Collection<Long> inPersonIds) { Map<Long, List<String>> map = new HashMap<Long, List<String>>(); Query q = getEntityManager().createQuery( "SELECT p.id, bgi.name FROM BackgroundItem bgi, Person p, PersonBackgroundItemSkill skill " + "WHERE bgi MEMBER OF p.background.skills AND p.id IN (:personIds) " + "and skill.pk.backgroundItemId = bgi.id and skill.pk.backgroundId = p.background.id " + "ORDER BY skill.pk.sortIndex").setParameter("personIds", inPersonIds); List<Object[]> results = q.getResultList(); for (Object[] interestData : results) { Long personId = (Long) interestData[0]; String interest = (String) interestData[1]; List<String> interests; if (map.containsKey(personId)) { interests = map.get(personId); } else { interests = new ArrayList<String>(); map.put(personId, interests); } interests.add(interest); } return map; }  @Override Map<Long, List<String>> execute(final Collection<Long> inPersonIds); }
GetSkillsAndInterestsByEmployeeIdsDbMapper extends
        BaseArgDomainMapper<Collection<Long>, Map<Long, List<String>>> { @Override public Map<Long, List<String>> execute(final Collection<Long> inPersonIds) { Map<Long, List<String>> map = new HashMap<Long, List<String>>(); Query q = getEntityManager().createQuery( "SELECT p.id, bgi.name FROM BackgroundItem bgi, Person p, PersonBackgroundItemSkill skill " + "WHERE bgi MEMBER OF p.background.skills AND p.id IN (:personIds) " + "and skill.pk.backgroundItemId = bgi.id and skill.pk.backgroundId = p.background.id " + "ORDER BY skill.pk.sortIndex").setParameter("personIds", inPersonIds); List<Object[]> results = q.getResultList(); for (Object[] interestData : results) { Long personId = (Long) interestData[0]; String interest = (String) interestData[1]; List<String> interests; if (map.containsKey(personId)) { interests = map.get(personId); } else { interests = new ArrayList<String>(); map.put(personId, interests); } interests.add(interest); } return map; }  @Override Map<Long, List<String>> execute(final Collection<Long> inPersonIds);  }