コード例 #1
0
  @BufferedIncrement(incrementClass = SocialEquityIncrement.class)
  public void incrementSocialEquityAssetEntry_IQ(
      long assetEntryId, SocialEquityValue socialEquityValue) throws SystemException {

    AssetEntry assetEntry = assetEntryPersistence.fetchByPrimaryKey(assetEntryId);

    assetEntry.updateSocialInformationEquity(socialEquityValue.getValue());

    int count = socialEquityAssetEntryPersistence.countByAssetEntryId(assetEntryId);

    if (count == 0) {
      addSocialEquityAssetEntry(assetEntry);
    }

    String sql = CustomSQLUtil.get(_UPDATE_SOCIAL_EQUITY_ASSET_ENTRY_IQ);

    sql =
        StringUtil.replace(
            sql,
            new String[] {"[$ASSET_ENTRY_ID$]", "[$INFORMATION_B$]", "[$INFORMATION_K$]"},
            new String[] {
              String.valueOf(assetEntryId),
              String.valueOf(socialEquityValue.getB()),
              String.valueOf(socialEquityValue.getK())
            });

    runSQL(sql);
  }
コード例 #2
0
  @BufferedIncrement(incrementClass = SocialEquityIncrement.class)
  public void incrementSocialEquityUser_PQ(
      long groupId, long userId, SocialEquityValue socialEquityValue)
      throws PortalException, SystemException {

    User user = userLocalService.getUser(userId);

    int count = socialEquityUserPersistence.countByG_U(groupId, userId);

    if (count == 0) {
      addSocialEquityUser(groupId, user);
    }

    user.updateSocialParticipationEquity(socialEquityValue.getValue());

    String sql = CustomSQLUtil.get(_UPDATE_SOCIAL_EQUITY_USER_PQ);

    sql =
        StringUtil.replace(
            sql,
            new String[] {
              "[$GROUP_ID$]", "[$PARTICIPATION_B$]", "[$PARTICIPATION_K$]", "[$USER_ID$]"
            },
            new String[] {
              String.valueOf(groupId),
              String.valueOf(socialEquityValue.getB()),
              String.valueOf(socialEquityValue.getK()),
              String.valueOf(userId)
            });

    runSQL(sql);
  }
コード例 #3
0
  public void deactivateEquityLogs(long userId, long assetEntryId, String actionId)
      throws PortalException, SystemException {

    if (!PropsValues.SOCIAL_EQUITY_EQUITY_LOG_ENABLED) {
      return;
    }

    User user = userPersistence.findByPrimaryKey(userId);

    AssetEntry assetEntry = assetEntryPersistence.findByPrimaryKey(assetEntryId);

    // Information Equity

    if (isSocialEquityEnabled(
        assetEntry.getGroupId(),
        assetEntry.getClassName(),
        SocialEquitySettingConstants.TYPE_INFORMATION)) {

      List<SocialEquityLog> equityLogs =
          socialEquityLogPersistence.findByAEI_AID_A_T(
              assetEntryId, actionId, true, SocialEquitySettingConstants.TYPE_INFORMATION);

      SocialEquityValue socialEquityValue = new SocialEquityValue(0, 0);

      for (SocialEquityLog equityLog : equityLogs) {
        double k = calculateK(equityLog.getValue(), equityLog.getLifespan());
        double b =
            calculateB(equityLog.getActionDate(), equityLog.getValue(), equityLog.getLifespan());

        socialEquityValue.subtract(new SocialEquityValue(k, b));

        socialEquityLogPersistence.remove(equityLog);
      }

      socialEquityLogLocalService.incrementSocialEquityAssetEntry_IQ(
          assetEntryId, socialEquityValue);

      socialEquityLogLocalService.incrementSocialEquityUser_CQ(
          assetEntry.getGroupId(), assetEntry.getUserId(), socialEquityValue);
    }

    // Participation Equity

    if (isSocialEquityEnabled(
        assetEntry.getGroupId(),
        assetEntry.getClassName(),
        SocialEquitySettingConstants.TYPE_PARTICIPATION)) {

      List<SocialEquityLog> equityLogs =
          socialEquityLogPersistence.findByU_AID_A_T(
              userId, actionId, true, SocialEquitySettingConstants.TYPE_PARTICIPATION);

      SocialEquityValue socialEquityValue = new SocialEquityValue(0, 0);

      for (SocialEquityLog equityLog : equityLogs) {
        double k = calculateK(equityLog.getValue(), equityLog.getLifespan());
        double b =
            calculateB(equityLog.getActionDate(), equityLog.getValue(), equityLog.getLifespan());

        socialEquityValue.subtract(new SocialEquityValue(k, b));

        socialEquityLogPersistence.remove(equityLog);
      }

      socialEquityLogLocalService.incrementSocialEquityUser_PQ(
          user.getGroup().getGroupId(), userId, socialEquityValue);
    }
  }