@Test public void testFilterEmpty() { sut.filter(Collections.EMPTY_LIST, null); context.assertIsSatisfied(); }
@Override public void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount) { if (inActivities.isEmpty()) { return; } Set<Long> ids = new HashSet<Long>(); for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { ids.add(activity.getActor().getId()); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { ids.add(activity.getOriginalActor().getId()); } } List<PersonModelView> peopleList = getPeopleMapper.execute(new ArrayList<Long>(ids)); HashMap<Long, Boolean> peopleIndex = new HashMap<Long, Boolean>(); for (PersonModelView person : peopleList) { peopleIndex.put(person.getId(), person.isAccountLocked()); } for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { activity.getActor().setActive(!peopleIndex.get(activity.getActor().getId())); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { activity.getOriginalActor().setActive(!peopleIndex.get(activity.getOriginalActor().getId())); } } }
IsAuthorLockedFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount) { if (inActivities.isEmpty()) { return; } Set<Long> ids = new HashSet<Long>(); for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { ids.add(activity.getActor().getId()); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { ids.add(activity.getOriginalActor().getId()); } } List<PersonModelView> peopleList = getPeopleMapper.execute(new ArrayList<Long>(ids)); HashMap<Long, Boolean> peopleIndex = new HashMap<Long, Boolean>(); for (PersonModelView person : peopleList) { peopleIndex.put(person.getId(), person.isAccountLocked()); } for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { activity.getActor().setActive(!peopleIndex.get(activity.getActor().getId())); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { activity.getOriginalActor().setActive(!peopleIndex.get(activity.getOriginalActor().getId())); } } } }
IsAuthorLockedFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount) { if (inActivities.isEmpty()) { return; } Set<Long> ids = new HashSet<Long>(); for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { ids.add(activity.getActor().getId()); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { ids.add(activity.getOriginalActor().getId()); } } List<PersonModelView> peopleList = getPeopleMapper.execute(new ArrayList<Long>(ids)); HashMap<Long, Boolean> peopleIndex = new HashMap<Long, Boolean>(); for (PersonModelView person : peopleList) { peopleIndex.put(person.getId(), person.isAccountLocked()); } for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { activity.getActor().setActive(!peopleIndex.get(activity.getActor().getId())); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { activity.getOriginalActor().setActive(!peopleIndex.get(activity.getOriginalActor().getId())); } } } IsAuthorLockedFilter(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleMapper); }
IsAuthorLockedFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount) { if (inActivities.isEmpty()) { return; } Set<Long> ids = new HashSet<Long>(); for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { ids.add(activity.getActor().getId()); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { ids.add(activity.getOriginalActor().getId()); } } List<PersonModelView> peopleList = getPeopleMapper.execute(new ArrayList<Long>(ids)); HashMap<Long, Boolean> peopleIndex = new HashMap<Long, Boolean>(); for (PersonModelView person : peopleList) { peopleIndex.put(person.getId(), person.isAccountLocked()); } for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { activity.getActor().setActive(!peopleIndex.get(activity.getActor().getId())); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { activity.getOriginalActor().setActive(!peopleIndex.get(activity.getOriginalActor().getId())); } } } IsAuthorLockedFilter(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleMapper); @Override void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount); }
IsAuthorLockedFilter implements ActivityFilter { @Override public void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount) { if (inActivities.isEmpty()) { return; } Set<Long> ids = new HashSet<Long>(); for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { ids.add(activity.getActor().getId()); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { ids.add(activity.getOriginalActor().getId()); } } List<PersonModelView> peopleList = getPeopleMapper.execute(new ArrayList<Long>(ids)); HashMap<Long, Boolean> peopleIndex = new HashMap<Long, Boolean>(); for (PersonModelView person : peopleList) { peopleIndex.put(person.getId(), person.isAccountLocked()); } for (ActivityDTO activity : inActivities) { if (activity.getActor().getType() == EntityType.PERSON) { activity.getActor().setActive(!peopleIndex.get(activity.getActor().getId())); } if (activity.getOriginalActor() != null && activity.getOriginalActor().getType() == EntityType.PERSON) { activity.getOriginalActor().setActive(!peopleIndex.get(activity.getOriginalActor().getId())); } } } IsAuthorLockedFilter(final DomainMapper<List<Long>, List<PersonModelView>> inGetPeopleMapper); @Override void filter(final List<ActivityDTO> inActivities, final PersonModelView inCurrentUserAccount);  }