@Test public void testExecute() { List<Long> list = new ArrayList<Long>(); list.add(new Long(ACTIVITY_ID)); List<ActivityDTO> results = mapper.execute(list); assertEquals(1, results.size()); verifyActivity6789(results.get(0)); results = mapper.execute(list); assertEquals(1, results.size()); verifyActivity6789(results.get(0)); }
@Override @SuppressWarnings("unchecked") public List<ActivityDTO> execute(final List<Long> activityIds) { Criteria criteria = getHibernateSession().createCriteria(Activity.class); ProjectionList fields = Projections.projectionList(); fields.add(getColumn("id")); fields.add(getColumn("verb")); fields.add(getColumn("baseObjectType")); fields.add(Projections.property("baseObject").as("baseObjectProperties")); fields.add(Projections.property("recipStreamScope.destinationEntityId").as("destinationStreamEntityId")); fields.add(Projections.property("recipStreamScope.id").as("destinationStreamScopeId")); fields.add(Projections.property("recipStreamScope.scopeType").as("destinationStreamScopeType")); fields.add(Projections.property("recipStreamScope.uniqueKey").as("destinationStreamUniqueKey")); fields.add(getColumn("isDestinationStreamPublic")); fields.add(getColumn("actorType")); fields.add(getColumn("originalActorType")); fields.add(Projections.property("actorId").as("actorUniqueIdentifier")); fields.add(Projections.property("originalActorId").as("originalActorUniqueIdentifier")); fields.add(getColumn("postedTime")); fields.add(getColumn("mood")); fields.add(getColumn("location")); fields.add(getColumn("annotation")); fields.add(getColumn("appId")); fields.add(getColumn("appSource")); fields.add(getColumn("appName")); fields.add(getColumn("showInStream")); criteria.createAlias("recipientStreamScope", "recipStreamScope"); criteria.setProjection(fields); criteria.add(Restrictions.in("this.id", activityIds)); final Map<Long, ActivityDTO> activityMap = new HashMap<Long, ActivityDTO>(); ModelViewResultTransformer<ActivityDTO> resultTransformer = new ModelViewResultTransformer<ActivityDTO>( new ActivityDTOFactory()); criteria.setResultTransformer(resultTransformer); List<ActivityDTO> results = criteria.list(); for (ActivityDTO activity : results) { activityMap.put(activity.getId(), activity); List<Long> streamIds = new ArrayList<Long>(); streamIds.add(activity.getDestinationStream().getId()); if (activity.getDestinationStream().getUniqueIdentifier() != null) { if (activity.getDestinationStream().getType() == EntityType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity .getDestinationStream().getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(person.getDisplayName()); } else if (activity.getDestinationStream().getType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream() .getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(group.getName()); } } final StreamEntityDTO actor = activity.getActor(); if (actor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(actor.getUniqueIdentifier())); if (!people.isEmpty()) { final PersonModelView person = people.get(0); actor.setId(person.getEntityId()); actor.setDestinationEntityId(person.getEntityId()); actor.setDisplayName(person.getDisplayName()); actor.setAvatarId(person.getAvatarId()); } } else if (actor.getType() == EntityType.GROUP) { List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor .getUniqueIdentifier())); if (!groups.isEmpty()) { final DomainGroupModelView group = groups.get(0); actor.setId(group.getEntityId()); actor.setDestinationEntityId(group.getEntityId()); actor.setDisplayName(group.getName()); actor.setAvatarId(group.getAvatarId()); } } final StreamEntityDTO originalActor = activity.getOriginalActor(); if (originalActor != null) { StreamDTO originalActorStreamDTO = null; if (originalActor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(originalActor.getUniqueIdentifier())); if (!people.isEmpty()) { originalActorStreamDTO = people.get(0); } } if (originalActor.getType() == EntityType.GROUP) { List<DomainGroupModelView> oagroups = groupMapper.execute(Collections.singletonList(originalActor .getUniqueIdentifier())); if (!oagroups.isEmpty()) { originalActorStreamDTO = oagroups.get(0); } } if (originalActorStreamDTO != null) { originalActor.setId(originalActorStreamDTO.getEntityId()); originalActor.setDestinationEntityId(originalActorStreamDTO.getEntityId()); originalActor.setDisplayName(originalActorStreamDTO.getDisplayName()); originalActor.setAvatarId(originalActorStreamDTO.getAvatarId()); } else { activity.setOriginalActor(null); logger.warn("Nulled out originalActor value for activity " + activity.getId() + ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier() + " type: " + originalActor.getType()); } } loadCommentInfo(activity); } final List<ActivityDTO> orderedResults = new LinkedList<ActivityDTO>(); for (int i = 0; i < activityIds.size(); i++) { if (activityMap.containsKey(activityIds.get(i))) { orderedResults.add(activityMap.get(activityIds.get(i))); } } return orderedResults; }
BulkActivitiesDbMapper extends BaseArgDomainMapper<List<Long>, List<ActivityDTO>> implements
        DomainMapper<List<Long>, List<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public List<ActivityDTO> execute(final List<Long> activityIds) { Criteria criteria = getHibernateSession().createCriteria(Activity.class); ProjectionList fields = Projections.projectionList(); fields.add(getColumn("id")); fields.add(getColumn("verb")); fields.add(getColumn("baseObjectType")); fields.add(Projections.property("baseObject").as("baseObjectProperties")); fields.add(Projections.property("recipStreamScope.destinationEntityId").as("destinationStreamEntityId")); fields.add(Projections.property("recipStreamScope.id").as("destinationStreamScopeId")); fields.add(Projections.property("recipStreamScope.scopeType").as("destinationStreamScopeType")); fields.add(Projections.property("recipStreamScope.uniqueKey").as("destinationStreamUniqueKey")); fields.add(getColumn("isDestinationStreamPublic")); fields.add(getColumn("actorType")); fields.add(getColumn("originalActorType")); fields.add(Projections.property("actorId").as("actorUniqueIdentifier")); fields.add(Projections.property("originalActorId").as("originalActorUniqueIdentifier")); fields.add(getColumn("postedTime")); fields.add(getColumn("mood")); fields.add(getColumn("location")); fields.add(getColumn("annotation")); fields.add(getColumn("appId")); fields.add(getColumn("appSource")); fields.add(getColumn("appName")); fields.add(getColumn("showInStream")); criteria.createAlias("recipientStreamScope", "recipStreamScope"); criteria.setProjection(fields); criteria.add(Restrictions.in("this.id", activityIds)); final Map<Long, ActivityDTO> activityMap = new HashMap<Long, ActivityDTO>(); ModelViewResultTransformer<ActivityDTO> resultTransformer = new ModelViewResultTransformer<ActivityDTO>( new ActivityDTOFactory()); criteria.setResultTransformer(resultTransformer); List<ActivityDTO> results = criteria.list(); for (ActivityDTO activity : results) { activityMap.put(activity.getId(), activity); List<Long> streamIds = new ArrayList<Long>(); streamIds.add(activity.getDestinationStream().getId()); if (activity.getDestinationStream().getUniqueIdentifier() != null) { if (activity.getDestinationStream().getType() == EntityType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity .getDestinationStream().getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(person.getDisplayName()); } else if (activity.getDestinationStream().getType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream() .getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(group.getName()); } } final StreamEntityDTO actor = activity.getActor(); if (actor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(actor.getUniqueIdentifier())); if (!people.isEmpty()) { final PersonModelView person = people.get(0); actor.setId(person.getEntityId()); actor.setDestinationEntityId(person.getEntityId()); actor.setDisplayName(person.getDisplayName()); actor.setAvatarId(person.getAvatarId()); } } else if (actor.getType() == EntityType.GROUP) { List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor .getUniqueIdentifier())); if (!groups.isEmpty()) { final DomainGroupModelView group = groups.get(0); actor.setId(group.getEntityId()); actor.setDestinationEntityId(group.getEntityId()); actor.setDisplayName(group.getName()); actor.setAvatarId(group.getAvatarId()); } } final StreamEntityDTO originalActor = activity.getOriginalActor(); if (originalActor != null) { StreamDTO originalActorStreamDTO = null; if (originalActor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(originalActor.getUniqueIdentifier())); if (!people.isEmpty()) { originalActorStreamDTO = people.get(0); } } if (originalActor.getType() == EntityType.GROUP) { List<DomainGroupModelView> oagroups = groupMapper.execute(Collections.singletonList(originalActor .getUniqueIdentifier())); if (!oagroups.isEmpty()) { originalActorStreamDTO = oagroups.get(0); } } if (originalActorStreamDTO != null) { originalActor.setId(originalActorStreamDTO.getEntityId()); originalActor.setDestinationEntityId(originalActorStreamDTO.getEntityId()); originalActor.setDisplayName(originalActorStreamDTO.getDisplayName()); originalActor.setAvatarId(originalActorStreamDTO.getAvatarId()); } else { activity.setOriginalActor(null); logger.warn("Nulled out originalActor value for activity " + activity.getId() + ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier() + " type: " + originalActor.getType()); } } loadCommentInfo(activity); } final List<ActivityDTO> orderedResults = new LinkedList<ActivityDTO>(); for (int i = 0; i < activityIds.size(); i++) { if (activityMap.containsKey(activityIds.get(i))) { orderedResults.add(activityMap.get(activityIds.get(i))); } } return orderedResults; } }
BulkActivitiesDbMapper extends BaseArgDomainMapper<List<Long>, List<ActivityDTO>> implements
        DomainMapper<List<Long>, List<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public List<ActivityDTO> execute(final List<Long> activityIds) { Criteria criteria = getHibernateSession().createCriteria(Activity.class); ProjectionList fields = Projections.projectionList(); fields.add(getColumn("id")); fields.add(getColumn("verb")); fields.add(getColumn("baseObjectType")); fields.add(Projections.property("baseObject").as("baseObjectProperties")); fields.add(Projections.property("recipStreamScope.destinationEntityId").as("destinationStreamEntityId")); fields.add(Projections.property("recipStreamScope.id").as("destinationStreamScopeId")); fields.add(Projections.property("recipStreamScope.scopeType").as("destinationStreamScopeType")); fields.add(Projections.property("recipStreamScope.uniqueKey").as("destinationStreamUniqueKey")); fields.add(getColumn("isDestinationStreamPublic")); fields.add(getColumn("actorType")); fields.add(getColumn("originalActorType")); fields.add(Projections.property("actorId").as("actorUniqueIdentifier")); fields.add(Projections.property("originalActorId").as("originalActorUniqueIdentifier")); fields.add(getColumn("postedTime")); fields.add(getColumn("mood")); fields.add(getColumn("location")); fields.add(getColumn("annotation")); fields.add(getColumn("appId")); fields.add(getColumn("appSource")); fields.add(getColumn("appName")); fields.add(getColumn("showInStream")); criteria.createAlias("recipientStreamScope", "recipStreamScope"); criteria.setProjection(fields); criteria.add(Restrictions.in("this.id", activityIds)); final Map<Long, ActivityDTO> activityMap = new HashMap<Long, ActivityDTO>(); ModelViewResultTransformer<ActivityDTO> resultTransformer = new ModelViewResultTransformer<ActivityDTO>( new ActivityDTOFactory()); criteria.setResultTransformer(resultTransformer); List<ActivityDTO> results = criteria.list(); for (ActivityDTO activity : results) { activityMap.put(activity.getId(), activity); List<Long> streamIds = new ArrayList<Long>(); streamIds.add(activity.getDestinationStream().getId()); if (activity.getDestinationStream().getUniqueIdentifier() != null) { if (activity.getDestinationStream().getType() == EntityType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity .getDestinationStream().getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(person.getDisplayName()); } else if (activity.getDestinationStream().getType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream() .getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(group.getName()); } } final StreamEntityDTO actor = activity.getActor(); if (actor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(actor.getUniqueIdentifier())); if (!people.isEmpty()) { final PersonModelView person = people.get(0); actor.setId(person.getEntityId()); actor.setDestinationEntityId(person.getEntityId()); actor.setDisplayName(person.getDisplayName()); actor.setAvatarId(person.getAvatarId()); } } else if (actor.getType() == EntityType.GROUP) { List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor .getUniqueIdentifier())); if (!groups.isEmpty()) { final DomainGroupModelView group = groups.get(0); actor.setId(group.getEntityId()); actor.setDestinationEntityId(group.getEntityId()); actor.setDisplayName(group.getName()); actor.setAvatarId(group.getAvatarId()); } } final StreamEntityDTO originalActor = activity.getOriginalActor(); if (originalActor != null) { StreamDTO originalActorStreamDTO = null; if (originalActor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(originalActor.getUniqueIdentifier())); if (!people.isEmpty()) { originalActorStreamDTO = people.get(0); } } if (originalActor.getType() == EntityType.GROUP) { List<DomainGroupModelView> oagroups = groupMapper.execute(Collections.singletonList(originalActor .getUniqueIdentifier())); if (!oagroups.isEmpty()) { originalActorStreamDTO = oagroups.get(0); } } if (originalActorStreamDTO != null) { originalActor.setId(originalActorStreamDTO.getEntityId()); originalActor.setDestinationEntityId(originalActorStreamDTO.getEntityId()); originalActor.setDisplayName(originalActorStreamDTO.getDisplayName()); originalActor.setAvatarId(originalActorStreamDTO.getAvatarId()); } else { activity.setOriginalActor(null); logger.warn("Nulled out originalActor value for activity " + activity.getId() + ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier() + " type: " + originalActor.getType()); } } loadCommentInfo(activity); } final List<ActivityDTO> orderedResults = new LinkedList<ActivityDTO>(); for (int i = 0; i < activityIds.size(); i++) { if (activityMap.containsKey(activityIds.get(i))) { orderedResults.add(activityMap.get(activityIds.get(i))); } } return orderedResults; } BulkActivitiesDbMapper(final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper, final DomainMapper<Long, List<Long>> inCommentIdListDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO); }
BulkActivitiesDbMapper extends BaseArgDomainMapper<List<Long>, List<ActivityDTO>> implements
        DomainMapper<List<Long>, List<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public List<ActivityDTO> execute(final List<Long> activityIds) { Criteria criteria = getHibernateSession().createCriteria(Activity.class); ProjectionList fields = Projections.projectionList(); fields.add(getColumn("id")); fields.add(getColumn("verb")); fields.add(getColumn("baseObjectType")); fields.add(Projections.property("baseObject").as("baseObjectProperties")); fields.add(Projections.property("recipStreamScope.destinationEntityId").as("destinationStreamEntityId")); fields.add(Projections.property("recipStreamScope.id").as("destinationStreamScopeId")); fields.add(Projections.property("recipStreamScope.scopeType").as("destinationStreamScopeType")); fields.add(Projections.property("recipStreamScope.uniqueKey").as("destinationStreamUniqueKey")); fields.add(getColumn("isDestinationStreamPublic")); fields.add(getColumn("actorType")); fields.add(getColumn("originalActorType")); fields.add(Projections.property("actorId").as("actorUniqueIdentifier")); fields.add(Projections.property("originalActorId").as("originalActorUniqueIdentifier")); fields.add(getColumn("postedTime")); fields.add(getColumn("mood")); fields.add(getColumn("location")); fields.add(getColumn("annotation")); fields.add(getColumn("appId")); fields.add(getColumn("appSource")); fields.add(getColumn("appName")); fields.add(getColumn("showInStream")); criteria.createAlias("recipientStreamScope", "recipStreamScope"); criteria.setProjection(fields); criteria.add(Restrictions.in("this.id", activityIds)); final Map<Long, ActivityDTO> activityMap = new HashMap<Long, ActivityDTO>(); ModelViewResultTransformer<ActivityDTO> resultTransformer = new ModelViewResultTransformer<ActivityDTO>( new ActivityDTOFactory()); criteria.setResultTransformer(resultTransformer); List<ActivityDTO> results = criteria.list(); for (ActivityDTO activity : results) { activityMap.put(activity.getId(), activity); List<Long> streamIds = new ArrayList<Long>(); streamIds.add(activity.getDestinationStream().getId()); if (activity.getDestinationStream().getUniqueIdentifier() != null) { if (activity.getDestinationStream().getType() == EntityType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity .getDestinationStream().getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(person.getDisplayName()); } else if (activity.getDestinationStream().getType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream() .getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(group.getName()); } } final StreamEntityDTO actor = activity.getActor(); if (actor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(actor.getUniqueIdentifier())); if (!people.isEmpty()) { final PersonModelView person = people.get(0); actor.setId(person.getEntityId()); actor.setDestinationEntityId(person.getEntityId()); actor.setDisplayName(person.getDisplayName()); actor.setAvatarId(person.getAvatarId()); } } else if (actor.getType() == EntityType.GROUP) { List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor .getUniqueIdentifier())); if (!groups.isEmpty()) { final DomainGroupModelView group = groups.get(0); actor.setId(group.getEntityId()); actor.setDestinationEntityId(group.getEntityId()); actor.setDisplayName(group.getName()); actor.setAvatarId(group.getAvatarId()); } } final StreamEntityDTO originalActor = activity.getOriginalActor(); if (originalActor != null) { StreamDTO originalActorStreamDTO = null; if (originalActor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(originalActor.getUniqueIdentifier())); if (!people.isEmpty()) { originalActorStreamDTO = people.get(0); } } if (originalActor.getType() == EntityType.GROUP) { List<DomainGroupModelView> oagroups = groupMapper.execute(Collections.singletonList(originalActor .getUniqueIdentifier())); if (!oagroups.isEmpty()) { originalActorStreamDTO = oagroups.get(0); } } if (originalActorStreamDTO != null) { originalActor.setId(originalActorStreamDTO.getEntityId()); originalActor.setDestinationEntityId(originalActorStreamDTO.getEntityId()); originalActor.setDisplayName(originalActorStreamDTO.getDisplayName()); originalActor.setAvatarId(originalActorStreamDTO.getAvatarId()); } else { activity.setOriginalActor(null); logger.warn("Nulled out originalActor value for activity " + activity.getId() + ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier() + " type: " + originalActor.getType()); } } loadCommentInfo(activity); } final List<ActivityDTO> orderedResults = new LinkedList<ActivityDTO>(); for (int i = 0; i < activityIds.size(); i++) { if (activityMap.containsKey(activityIds.get(i))) { orderedResults.add(activityMap.get(activityIds.get(i))); } } return orderedResults; } BulkActivitiesDbMapper(final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper, final DomainMapper<Long, List<Long>> inCommentIdListDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO); @Override @SuppressWarnings("unchecked") List<ActivityDTO> execute(final List<Long> activityIds); }
BulkActivitiesDbMapper extends BaseArgDomainMapper<List<Long>, List<ActivityDTO>> implements
        DomainMapper<List<Long>, List<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public List<ActivityDTO> execute(final List<Long> activityIds) { Criteria criteria = getHibernateSession().createCriteria(Activity.class); ProjectionList fields = Projections.projectionList(); fields.add(getColumn("id")); fields.add(getColumn("verb")); fields.add(getColumn("baseObjectType")); fields.add(Projections.property("baseObject").as("baseObjectProperties")); fields.add(Projections.property("recipStreamScope.destinationEntityId").as("destinationStreamEntityId")); fields.add(Projections.property("recipStreamScope.id").as("destinationStreamScopeId")); fields.add(Projections.property("recipStreamScope.scopeType").as("destinationStreamScopeType")); fields.add(Projections.property("recipStreamScope.uniqueKey").as("destinationStreamUniqueKey")); fields.add(getColumn("isDestinationStreamPublic")); fields.add(getColumn("actorType")); fields.add(getColumn("originalActorType")); fields.add(Projections.property("actorId").as("actorUniqueIdentifier")); fields.add(Projections.property("originalActorId").as("originalActorUniqueIdentifier")); fields.add(getColumn("postedTime")); fields.add(getColumn("mood")); fields.add(getColumn("location")); fields.add(getColumn("annotation")); fields.add(getColumn("appId")); fields.add(getColumn("appSource")); fields.add(getColumn("appName")); fields.add(getColumn("showInStream")); criteria.createAlias("recipientStreamScope", "recipStreamScope"); criteria.setProjection(fields); criteria.add(Restrictions.in("this.id", activityIds)); final Map<Long, ActivityDTO> activityMap = new HashMap<Long, ActivityDTO>(); ModelViewResultTransformer<ActivityDTO> resultTransformer = new ModelViewResultTransformer<ActivityDTO>( new ActivityDTOFactory()); criteria.setResultTransformer(resultTransformer); List<ActivityDTO> results = criteria.list(); for (ActivityDTO activity : results) { activityMap.put(activity.getId(), activity); List<Long> streamIds = new ArrayList<Long>(); streamIds.add(activity.getDestinationStream().getId()); if (activity.getDestinationStream().getUniqueIdentifier() != null) { if (activity.getDestinationStream().getType() == EntityType.PERSON) { PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity .getDestinationStream().getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(person.getDisplayName()); } else if (activity.getDestinationStream().getType() == EntityType.GROUP) { DomainGroupModelView group = groupMapper.fetchUniqueResult(activity.getDestinationStream() .getUniqueIdentifier()); activity.getDestinationStream().setDisplayName(group.getName()); } } final StreamEntityDTO actor = activity.getActor(); if (actor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(actor.getUniqueIdentifier())); if (!people.isEmpty()) { final PersonModelView person = people.get(0); actor.setId(person.getEntityId()); actor.setDestinationEntityId(person.getEntityId()); actor.setDisplayName(person.getDisplayName()); actor.setAvatarId(person.getAvatarId()); } } else if (actor.getType() == EntityType.GROUP) { List<DomainGroupModelView> groups = groupMapper.execute(Collections.singletonList(actor .getUniqueIdentifier())); if (!groups.isEmpty()) { final DomainGroupModelView group = groups.get(0); actor.setId(group.getEntityId()); actor.setDestinationEntityId(group.getEntityId()); actor.setDisplayName(group.getName()); actor.setAvatarId(group.getAvatarId()); } } final StreamEntityDTO originalActor = activity.getOriginalActor(); if (originalActor != null) { StreamDTO originalActorStreamDTO = null; if (originalActor.getType() == EntityType.PERSON) { List<PersonModelView> people = getPersonModelViewsByAccountIdsMapper.execute(Collections .singletonList(originalActor.getUniqueIdentifier())); if (!people.isEmpty()) { originalActorStreamDTO = people.get(0); } } if (originalActor.getType() == EntityType.GROUP) { List<DomainGroupModelView> oagroups = groupMapper.execute(Collections.singletonList(originalActor .getUniqueIdentifier())); if (!oagroups.isEmpty()) { originalActorStreamDTO = oagroups.get(0); } } if (originalActorStreamDTO != null) { originalActor.setId(originalActorStreamDTO.getEntityId()); originalActor.setDestinationEntityId(originalActorStreamDTO.getEntityId()); originalActor.setDisplayName(originalActorStreamDTO.getDisplayName()); originalActor.setAvatarId(originalActorStreamDTO.getAvatarId()); } else { activity.setOriginalActor(null); logger.warn("Nulled out originalActor value for activity " + activity.getId() + ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier() + " type: " + originalActor.getType()); } } loadCommentInfo(activity); } final List<ActivityDTO> orderedResults = new LinkedList<ActivityDTO>(); for (int i = 0; i < activityIds.size(); i++) { if (activityMap.containsKey(activityIds.get(i))) { orderedResults.add(activityMap.get(activityIds.get(i))); } } return orderedResults; } BulkActivitiesDbMapper(final DomainMapper<String, PersonModelView> inGetPersonModelViewByAccountIdMapper,
            final DomainMapper<List<String>, List<PersonModelView>> inGetPersonModelViewsByAccountIdsMapper,
            final GetDomainGroupsByShortNames inGroupMapper, final DomainMapper<Long, List<Long>> inCommentIdListDAO,
            final DomainMapper<List<Long>, List<CommentDTO>> inCommentsByIdDAO); @Override @SuppressWarnings("unchecked") List<ActivityDTO> execute(final List<Long> activityIds);  }