* This execute method retrieves the ActivityDTO objects for the parameters passed in.
*/
@Override
public LinkedList<ActivityDTO> execute(final PrincipalActionContext inActionContext) throws ExecutionException
{
GetUserActivitiesRequest currentRequest = (GetUserActivitiesRequest) inActionContext.getParams();
LinkedList<ActivityDTO> currentActivityDTOs = new LinkedList<ActivityDTO>();
if (currentRequest.getOpenSocialIds() != null && currentRequest.getOpenSocialIds().size() > 0)
{
List<PersonModelView> users = getPeopleByOpenSocialIds.execute(new ArrayList<String>(currentRequest
.getOpenSocialIds()));
if (users.size() > 0)
{
final JSONObject json = new JSONObject();
json.put("count", maxActivitiesToReturnByOpenSocialId);
JSONArray recipients = new JSONArray();
for (PersonModelView user : users)
{
JSONObject recipient = new JSONObject();
recipient.put("type", "PERSON");
recipient.put("name", user.getAccountId());
recipients.add(recipient);
}
JSONObject query = new JSONObject();
query.put("recipient", recipients);
json.put("query", query);
PrincipalActionContext context = new PrincipalActionContext()
{
@Override
public Principal getPrincipal()
{
return inActionContext.getPrincipal();
}
@Override
public String getActionId()
{
return null;
}
@Override
public Serializable getParams()
{
return json.toString();
}
@Override
public Map<String, Object> getState()
{
return null;
}
@Override
public void setActionId(final String inActionId)
{
}
};
PagedSet<ActivityDTO> activities = (PagedSet<ActivityDTO>) getActivitiesByRequestExecution
.execute(context);
currentActivityDTOs.addAll(activities.getPagedSet());
}
}
// if the user has provided activities to retrieve in the parameters, retrieve the corresponding
// ActivityDTO objects.
if (currentRequest.getActivityIds() != null && currentRequest.getActivityIds().size() > 0)
{
List<Long> activityIds = new ArrayList<Long>(currentRequest.getActivityIds());
// only look for IDs that aren't yet in the list
for (ActivityDTO act : currentActivityDTOs)
{
if (activityIds.contains(act.getId()))