Esempio n. 1
0
  protected void upgradeMicroblogActivities() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer();
        PreparedStatement ps =
            connection.prepareStatement(
                "select activityId, extraData from SocialActivity where " + "classNameId = ?")) {

      ps.setLong(1, PortalUtil.getClassNameId(MicroblogsEntry.class));

      try (ResultSet rs = ps.executeQuery()) {
        while (rs.next()) {
          long activityId = rs.getLong("activityId");
          String extraData = rs.getString("extraData");

          JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(extraData);

          long parentMicroblogsEntryId = extraDataJSONObject.getLong("receiverMicroblogsEntryId");

          extraDataJSONObject.put("parentMicroblogsEntryId", parentMicroblogsEntryId);

          extraDataJSONObject.remove("receiverMicroblogsEntryId");

          updateSocialActivity(activityId, extraDataJSONObject);
        }
      }
    }
  }
  protected void upgradeMicroblogActivities() throws Exception {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      con = DataAccess.getUpgradeOptimizedConnection();

      ps =
          con.prepareStatement(
              "select activityId, extraData from SocialActivity where " + "classNameId = ?");

      ps.setLong(1, PortalUtil.getClassNameId(MicroblogsEntry.class));

      rs = ps.executeQuery();

      while (rs.next()) {
        long activityId = rs.getLong("activityId");
        String extraData = rs.getString("extraData");

        JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(extraData);

        long parentMicroblogsEntryId = extraDataJSONObject.getLong("receiverMicroblogsEntryId");

        extraDataJSONObject.put("parentMicroblogsEntryId", parentMicroblogsEntryId);

        extraDataJSONObject.remove("receiverMicroblogsEntryId");

        updateSocialActivity(activityId, extraDataJSONObject);
      }
    } finally {
      DataAccess.cleanUp(con, ps, rs);
    }
  }