1 Reply Latest reply on Oct 3, 2016 8:16 AM by vanontherun

    How to filter activity under /people/admin/activity by a space and its subspace

    vanontherun

      Hi,

       

      I'm trying to filter the activity stream under /people/admin/activity by a space (and it's subspaces).

       

      The current activity is served up by ViewProfileActivity. I was thinking to do this by customizing the class vs REST API for activity.  Has anybody ever customized this to filter by space.

      I thought some likely lines could be:

       

      Changing the defaultstream and keeping the first param as a user object :

       Iterator<ActivityContainer> activity = activityManager.getActivity(targetUser, streamSource, defaultStream,
                      Sets.newHashSet(new StreamFilter(filter, null)), null).iterator();
      

       

       

      Or doing a check for the content space container before adding :

      List<ActivityContainer> activityList = Lists.newArrayList();
              for (int i=1; activity.hasNext(); i++) {
                  activityList.add(activity.next());
                  if (i > numResults) {
                      moreResultsAvailable = true;
                      break;
                  }
              }
      

       

      Anybody ever done this and can provide pointers?

       

      Thanks,
      Van

        • Re: How to filter activity under /people/admin/activity by a space and its subspace
          vanontherun

          In case it helps anyone, I went with checkingthe content space container prior to adding.

           

          I got the subspaces as a set of Longs.

           

           

          private Set<Long> getSubspaces(Community community, String depthValue) {

           

            Set<Long> subspaces = new HashSet<Long>();

            subspaces.addAll(getEntityDescriptors(communityManager.getRecursiveCommunities(community)));

           

            return subspaces;

           

          }

           

          private Set<Long> getEntityDescriptors(Iterable<Community> communities) {

            Set<Long> subspaces = new HashSet<Long>();

             for (Community community : communities) {

            subspaces.add(community.getID());

             }

             return subspaces;

          }

           

          Then within the getViewBean(), I get the containerId of the object and check for it in the subspaces object.

          if(subspaces.contains(ActivityBeanContainerID)){

            System.out.println("VRH: ActivityBeanContainerID is in subspace : " + ActivityBeanContainerID);

            activityList.add(theActivity);

            iResultBean++;

           

          } else {

           

          Thanks,
          Van