.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());
}
}
// fills in data from cached view of original actor
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
{
// this is to prevent JSON serializer from dying on a nulled out StreamEntityDTO.
activity.setOriginalActor(null);
// log this out so we don't just swallow problem.
logger.warn("Nulled out originalActor value for activity " + activity.getId()
+ ". Could not find values for uniqueId: " + originalActor.getUniqueIdentifier()
+ " type: " + originalActor.getType());
}
}
loadCommentInfo(activity); // set the first/last comment and comment count.
}