1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.synchronoss.cpo.jdbc;
22
23 import org.slf4j.*;
24 import org.synchronoss.cpo.CpoException;
25 import org.synchronoss.cpo.jdbc.meta.JdbcCpoMetaDescriptor;
26 import org.synchronoss.cpo.meta.CpoMetaDescriptor;
27 import org.synchronoss.cpo.meta.domain.CpoAttribute;
28 import org.synchronoss.cpo.transform.jdbc.JdbcCpoTransform;
29
30 import java.lang.reflect.Method;
31 import java.sql.Types;
32
33
34
35
36
37
38 public class JdbcCpoAttribute extends CpoAttribute implements java.io.Serializable, java.lang.Cloneable {
39
40 private static final Logger logger = LoggerFactory.getLogger(JdbcCpoAttribute.class);
41
42
43
44 private static final long serialVersionUID = 1L;
45 private String dbTable_ = null;
46 private String dbColumn_ = null;
47 private int javaSqlType_ = Types.NULL;
48
49 private JdbcCpoTransform jdbcTransform = null;
50 private Method transformPSOutMethod = null;
51 private Method transformCSOutMethod = null;
52
53 public JdbcCpoAttribute() {
54 }
55
56 public void setDbTable(String dbTable) {
57 dbTable_ = dbTable;
58 }
59
60 public void setDbColumn(String dbColumn) {
61 dbColumn_ = dbColumn;
62 }
63
64 public String getDbTable() {
65 return dbTable_;
66 }
67
68 public String getDbColumn() {
69 return dbColumn_;
70 }
71
72 protected void setJavaSqlType(int type) {
73 javaSqlType_ = type;
74
75 }
76
77 protected int getJavaSqlType() {
78 return this.javaSqlType_;
79 }
80
81
82
83
84
85
86
87
88
89
90
91 @Override
92 protected void initTransformClass(CpoMetaDescriptor metaDescriptor) throws CpoException {
93 super.initTransformClass(metaDescriptor);
94 if (getCpoTransform() != null && getCpoTransform() instanceof JdbcCpoTransform) {
95 jdbcTransform = (JdbcCpoTransform) getCpoTransform();
96
97 for (Method m : findMethods(jdbcTransform.getClass(), TRANSFORM_OUT_NAME, 2, true)) {
98 if (m.getParameterTypes()[0].getName().equals("org.synchronoss.cpo.jdbc.JdbcPreparedStatementFactory")) {
99 transformPSOutMethod = m;
100 } else if (m.getParameterTypes()[0].getName().equals("org.synchronoss.cpo.jdbc.JdbcCallableStatementFactory")) {
101 transformCSOutMethod = m;
102 }
103 }
104 }
105
106
107 setJavaSqlType(((JdbcCpoMetaDescriptor)metaDescriptor).getJavaSqlType(getDataType()));
108 }
109 }