@Override
  protected long getActivitySetId(long activityId) {
    try {
      SocialActivitySet activitySet = null;

      SocialActivity activity = SocialActivityLocalServiceUtil.getActivity(activityId);

      if (activity.getType() == SocialActivityKeyConstants.DL_ADD_FILE_ENTRY) {

        activitySet =
            SocialActivitySetLocalServiceUtil.getUserActivitySet(
                activity.getGroupId(), activity.getUserId(),
                activity.getClassNameId(), activity.getType());
      } else if (activity.getType() == SocialActivityKeyConstants.DL_UPDATE_FILE_ENTRY) {

        activitySet =
            SocialActivitySetLocalServiceUtil.getClassActivitySet(
                activity.getUserId(), activity.getClassNameId(),
                activity.getClassPK(), activity.getType());
      }

      if ((activitySet != null) && !isExpired(activitySet, false)) {
        return activitySet.getActivitySetId();
      }
    } catch (Exception e) {
    }

    return 0;
  }
Ejemplo n.º 2
0
  @Override
  public void updateActivitySet(long activityId) throws PortalException, SystemException {

    SocialActivity activity = SocialActivityUtil.fetchByPrimaryKey(activityId);

    if ((activity == null) || (activity.getActivitySetId() > 0)) {
      return;
    }

    long activitySetId = getActivitySetId(activityId);

    if (activitySetId > 0) {
      SocialActivitySetLocalServiceUtil.incrementActivityCount(activitySetId, activityId);
    } else {
      SocialActivitySetLocalServiceUtil.addActivitySet(activityId);
    }
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        SocialActivitySetLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            SocialActivitySet socialActivitySet = (SocialActivitySet) object;

            Assert.assertNotNull(socialActivitySet);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }