@Test public void testExecuteWithMultipleIds() { List<Long> list = new ArrayList<Long>(Arrays.asList(PERSON_ID, PERSON_ID2)); List<PersonModelView> results = mapper.execute(list); assertEquals(2, results.size()); results = mapper.execute(list); assertEquals(2, results.size()); }
@SuppressWarnings("unchecked") @Override public List<PersonModelView> execute(final Collection<Long> inPeopleIds) { if (inPeopleIds == null || inPeopleIds.size() == 0) { return new ArrayList<PersonModelView>(); } Criteria criteria = personQueryStrategy.getCriteria(getHibernateSession()); criteria.add(Restrictions.in("this.id", inPeopleIds)); List<PersonModelView> results = criteria.list(); Map<Long, List<String>> skillsForPeople = getSkillsForPeopleByPeopleIdsMapper.execute(inPeopleIds); for (PersonModelView result : results) { if (skillsForPeople.containsKey(result.getEntityId())) { List<String> interests = skillsForPeople.get(result.getEntityId()); log.debug("Found " + interests.size() + " interests for " + result.getAccountId() + ": " + interests.toString()); result.setInterests(interests); } else { log.debug("Found 0 interests for " + result.getAccountId()); result.setInterests(new ArrayList<String>()); } } return results; }
GetPersonsByIds extends BaseArgDomainMapper<Collection<Long>, List<PersonModelView>> { @SuppressWarnings("unchecked") @Override public List<PersonModelView> execute(final Collection<Long> inPeopleIds) { if (inPeopleIds == null || inPeopleIds.size() == 0) { return new ArrayList<PersonModelView>(); } Criteria criteria = personQueryStrategy.getCriteria(getHibernateSession()); criteria.add(Restrictions.in("this.id", inPeopleIds)); List<PersonModelView> results = criteria.list(); Map<Long, List<String>> skillsForPeople = getSkillsForPeopleByPeopleIdsMapper.execute(inPeopleIds); for (PersonModelView result : results) { if (skillsForPeople.containsKey(result.getEntityId())) { List<String> interests = skillsForPeople.get(result.getEntityId()); log.debug("Found " + interests.size() + " interests for " + result.getAccountId() + ": " + interests.toString()); result.setInterests(interests); } else { log.debug("Found 0 interests for " + result.getAccountId()); result.setInterests(new ArrayList<String>()); } } return results; } }
GetPersonsByIds extends BaseArgDomainMapper<Collection<Long>, List<PersonModelView>> { @SuppressWarnings("unchecked") @Override public List<PersonModelView> execute(final Collection<Long> inPeopleIds) { if (inPeopleIds == null || inPeopleIds.size() == 0) { return new ArrayList<PersonModelView>(); } Criteria criteria = personQueryStrategy.getCriteria(getHibernateSession()); criteria.add(Restrictions.in("this.id", inPeopleIds)); List<PersonModelView> results = criteria.list(); Map<Long, List<String>> skillsForPeople = getSkillsForPeopleByPeopleIdsMapper.execute(inPeopleIds); for (PersonModelView result : results) { if (skillsForPeople.containsKey(result.getEntityId())) { List<String> interests = skillsForPeople.get(result.getEntityId()); log.debug("Found " + interests.size() + " interests for " + result.getAccountId() + ": " + interests.toString()); result.setInterests(interests); } else { log.debug("Found 0 interests for " + result.getAccountId()); result.setInterests(new ArrayList<String>()); } } return results; } GetPersonsByIds(final PersonQueryStrategy inPersonQueryStrategy,
            final DomainMapper<Collection<Long>, Map<Long, List<String>>> inGetSkillsForPeopleByPeopleIdsMapper); }
GetPersonsByIds extends BaseArgDomainMapper<Collection<Long>, List<PersonModelView>> { @SuppressWarnings("unchecked") @Override public List<PersonModelView> execute(final Collection<Long> inPeopleIds) { if (inPeopleIds == null || inPeopleIds.size() == 0) { return new ArrayList<PersonModelView>(); } Criteria criteria = personQueryStrategy.getCriteria(getHibernateSession()); criteria.add(Restrictions.in("this.id", inPeopleIds)); List<PersonModelView> results = criteria.list(); Map<Long, List<String>> skillsForPeople = getSkillsForPeopleByPeopleIdsMapper.execute(inPeopleIds); for (PersonModelView result : results) { if (skillsForPeople.containsKey(result.getEntityId())) { List<String> interests = skillsForPeople.get(result.getEntityId()); log.debug("Found " + interests.size() + " interests for " + result.getAccountId() + ": " + interests.toString()); result.setInterests(interests); } else { log.debug("Found 0 interests for " + result.getAccountId()); result.setInterests(new ArrayList<String>()); } } return results; } GetPersonsByIds(final PersonQueryStrategy inPersonQueryStrategy,
            final DomainMapper<Collection<Long>, Map<Long, List<String>>> inGetSkillsForPeopleByPeopleIdsMapper); @SuppressWarnings("unchecked") @Override List<PersonModelView> execute(final Collection<Long> inPeopleIds); }
GetPersonsByIds extends BaseArgDomainMapper<Collection<Long>, List<PersonModelView>> { @SuppressWarnings("unchecked") @Override public List<PersonModelView> execute(final Collection<Long> inPeopleIds) { if (inPeopleIds == null || inPeopleIds.size() == 0) { return new ArrayList<PersonModelView>(); } Criteria criteria = personQueryStrategy.getCriteria(getHibernateSession()); criteria.add(Restrictions.in("this.id", inPeopleIds)); List<PersonModelView> results = criteria.list(); Map<Long, List<String>> skillsForPeople = getSkillsForPeopleByPeopleIdsMapper.execute(inPeopleIds); for (PersonModelView result : results) { if (skillsForPeople.containsKey(result.getEntityId())) { List<String> interests = skillsForPeople.get(result.getEntityId()); log.debug("Found " + interests.size() + " interests for " + result.getAccountId() + ": " + interests.toString()); result.setInterests(interests); } else { log.debug("Found 0 interests for " + result.getAccountId()); result.setInterests(new ArrayList<String>()); } } return results; } GetPersonsByIds(final PersonQueryStrategy inPersonQueryStrategy,
            final DomainMapper<Collection<Long>, Map<Long, List<String>>> inGetSkillsForPeopleByPeopleIdsMapper); @SuppressWarnings("unchecked") @Override List<PersonModelView> execute(final Collection<Long> inPeopleIds);  }