1
22
23 package com.liferay.portal.upgrade.v5_1_5.util;
24
25 import com.liferay.portal.kernel.dao.jdbc.DataAccess;
26
27 import java.sql.Connection;
28 import java.sql.PreparedStatement;
29 import java.sql.ResultSet;
30
31
37 public class ResourceCodeDependencyManager extends DependencyManager {
38
39 public void update(
40 long oldPrimaryKeyValue, Object[] oldColumnValues,
41 Object[] oldExtraColumnValues, long newPrimaryKeyValue,
42 Object[] newColumnValues, Object[] newExtraColumnValues)
43 throws Exception {
44
45 long codeId = newPrimaryKeyValue;
46
47 long resourceId = getResourceId(codeId);
48
49 deleteDuplicateData("Resource_", codeId);
50
51 if (resourceId > 0) {
52 DependencyManager resourceDependencyManager =
53 new ResourceDependencyManager();
54
55 resourceDependencyManager.setPrimaryKeyName("resourceId");
56
57 resourceDependencyManager.update(resourceId);
58 }
59 }
60
61 protected long getResourceId(long codeId) throws Exception {
62 Connection con = null;
63 PreparedStatement ps = null;
64 ResultSet rs = null;
65
66 try {
67 con = DataAccess.getConnection();
68
69 ps = con.prepareStatement(
70 "select resourceId from Resource_ where codeId = ?");
71
72 ps.setLong(1, codeId);
73
74 rs = ps.executeQuery();
75
76 while (rs.next()) {
77 long resourceId = rs.getLong("resourceId");
78
79 return resourceId;
80 }
81 }
82 finally {
83 DataAccess.cleanUp(con, ps, rs);
84 }
85
86 return 0;
87 }
88
89 }