001
014
015 package com.liferay.portal.upgrade.v5_2_3.util;
016
017 import com.liferay.portal.kernel.dao.jdbc.DataAccess;
018
019 import java.sql.Connection;
020 import java.sql.PreparedStatement;
021 import java.sql.ResultSet;
022
023
026 public class ResourceCodeDependencyManager extends DependencyManager {
027
028 public void update(
029 long oldPrimaryKeyValue, Object[] oldColumnValues,
030 Object[] oldExtraColumnValues, long newPrimaryKeyValue,
031 Object[] newColumnValues, Object[] newExtraColumnValues)
032 throws Exception {
033
034 long codeId = newPrimaryKeyValue;
035
036 long resourceId = getResourceId(codeId);
037
038 deleteDuplicateData("Resource_", codeId);
039
040 if (resourceId > 0) {
041 DependencyManager resourceDependencyManager =
042 new ResourceDependencyManager();
043
044 resourceDependencyManager.setPrimaryKeyName("resourceId");
045
046 resourceDependencyManager.update(resourceId);
047 }
048 }
049
050 protected long getResourceId(long codeId) throws Exception {
051 Connection con = null;
052 PreparedStatement ps = null;
053 ResultSet rs = null;
054
055 try {
056 con = DataAccess.getConnection();
057
058 ps = con.prepareStatement(
059 "select resourceId from Resource_ where codeId = ?");
060
061 ps.setLong(1, codeId);
062
063 rs = ps.executeQuery();
064
065 while (rs.next()) {
066 long resourceId = rs.getLong("resourceId");
067
068 return resourceId;
069 }
070 }
071 finally {
072 DataAccess.cleanUp(con, ps, rs);
073 }
074
075 return 0;
076 }
077
078 }