public SocialActivitySet addActivitySet(long activityId) throws PortalException, SystemException {

    // Activity set

    SocialActivity activity = socialActivityPersistence.findByPrimaryKey(activityId);

    long activitySetId = counterLocalService.increment();

    SocialActivitySet activitySet = socialActivitySetPersistence.create(activitySetId);

    activitySet.setGroupId(activity.getGroupId());
    activitySet.setCompanyId(activity.getCompanyId());
    activitySet.setUserId(activity.getUserId());
    activitySet.setCreateDate(activity.getCreateDate());
    activitySet.setModifiedDate(activity.getCreateDate());
    activitySet.setClassName(activity.getClassName());
    activitySet.setClassPK(activity.getClassPK());
    activitySet.setType(activity.getType());
    activitySet.setActivityCount(1);

    socialActivitySetPersistence.update(activitySet);

    // Activity

    activity.setActivitySetId(activitySetId);

    socialActivityPersistence.update(activity);

    return activitySet;
  }
  @Override
  public int compareTo(SocialActivity socialActivity) {
    int value = 0;

    if (getCreateDate() < socialActivity.getCreateDate()) {
      value = -1;
    } else if (getCreateDate() > socialActivity.getCreateDate()) {
      value = 1;
    } else {
      value = 0;
    }

    value = value * -1;

    if (value != 0) {
      return value;
    }

    return 0;
  }
  protected void importSocialActivity(SocialActivity socialActivity, long calendarBookingId)
      throws SystemException {

    addSocialActivity(
        counterLocalService.increment(SocialActivity.class.getName()),
        socialActivity.getGroupId(),
        socialActivity.getCompanyId(),
        socialActivity.getUserId(),
        socialActivity.getCreateDate(),
        socialActivity.getMirrorActivityId(),
        classNameLocalService.getClassNameId(CalendarBooking.class),
        calendarBookingId,
        socialActivity.getType(),
        socialActivity.getExtraData(),
        socialActivity.getReceiverUserId());
  }
  public void incrementActivityCount(long activitySetId, long activityId)
      throws PortalException, SystemException {

    // Activity set

    SocialActivitySet activitySet = socialActivitySetPersistence.findByPrimaryKey(activitySetId);

    SocialActivity activity = socialActivityPersistence.findByPrimaryKey(activityId);

    activitySet.setModifiedDate(activity.getCreateDate());

    activitySet.setActivityCount(activitySet.getActivityCount() + 1);

    socialActivitySetPersistence.update(activitySet);

    // Activity

    activity.setActivitySetId(activitySetId);

    socialActivityPersistence.update(activity);
  }