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