protected SocialEquityActionMapping getMergedEquityActionMapping(
      long groupId, SocialEquityActionMapping equityActionMapping) throws Exception {

    SocialEquityActionMapping mergedEquityActionMapping = equityActionMapping.clone();

    List<SocialEquitySetting> equitySettings =
        SocialEquitySettingLocalServiceUtil.getEquitySettings(
            groupId, equityActionMapping.getClassName(), equityActionMapping.getActionId());

    for (SocialEquitySetting equitySetting : equitySettings) {
      if (equitySetting.getType() == SocialEquitySettingConstants.TYPE_INFORMATION) {

        mergedEquityActionMapping.setInformationDailyLimit(equitySetting.getDailyLimit());
        mergedEquityActionMapping.setInformationLifespan(equitySetting.getLifespan());
        mergedEquityActionMapping.setInformationValue(equitySetting.getValue());
      } else {
        mergedEquityActionMapping.setParticipationDailyLimit(equitySetting.getDailyLimit());
        mergedEquityActionMapping.setParticipationLifespan(equitySetting.getLifespan());
        mergedEquityActionMapping.setParticipationValue(equitySetting.getValue());
      }

      mergedEquityActionMapping.setUnique(equitySetting.isUniqueEntry());
    }

    return mergedEquityActionMapping;
  }
  protected void addEquityLog(
      User user, AssetEntry assetEntry, User assetEntryUser, SocialEquitySetting equitySetting)
      throws PortalException, SystemException {

    if (!isAddEquityLog(user.getUserId(), assetEntry.getEntryId(), equitySetting)) {

      return;
    }

    int actionDate = getEquityDate();

    double k = calculateK(equitySetting.getValue(), equitySetting.getLifespan());
    double b = calculateB(actionDate, equitySetting.getValue(), equitySetting.getLifespan());

    SocialEquityValue socialEquity = new SocialEquityValue(k, b);

    if (equitySetting.getType() == SocialEquitySettingConstants.TYPE_INFORMATION) {

      socialEquityLogLocalService.incrementSocialEquityAssetEntry_IQ(
          assetEntry.getEntryId(), socialEquity);

      if ((assetEntryUser != null) && !assetEntryUser.isDefaultUser()) {
        socialEquityLogLocalService.incrementSocialEquityUser_CQ(
            assetEntry.getGroupId(), assetEntryUser.getUserId(), socialEquity);
      }
    } else if (equitySetting.getType() == SocialEquitySettingConstants.TYPE_PARTICIPATION) {

      if (!user.isDefaultUser()) {
        socialEquityLogLocalService.incrementSocialEquityUser_PQ(
            assetEntry.getGroupId(), user.getUserId(), socialEquity);
      }
    }

    long equityLogId = counterLocalService.increment();

    SocialEquityLog equityLog = socialEquityLogPersistence.create(equityLogId);

    equityLog.setGroupId(assetEntry.getGroupId());
    equityLog.setCompanyId(user.getCompanyId());
    equityLog.setUserId(user.getUserId());
    equityLog.setAssetEntryId(assetEntry.getEntryId());
    equityLog.setActionId(equitySetting.getActionId());
    equityLog.setActionDate(actionDate);
    equityLog.setType(equitySetting.getType());
    equityLog.setValue(equitySetting.getValue());
    equityLog.setExpiration(actionDate + equitySetting.getLifespan());
    equityLog.setActive(true);

    socialEquityLogPersistence.update(equityLog, false);
  }