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.exporter;
22
23 import org.synchronoss.cpo.core.cpoCoreMeta.CtArgument;
24 import org.synchronoss.cpo.core.cpoCoreMeta.CtAttribute;
25 import org.synchronoss.cpo.exporter.CoreMetaXmlObjectExporter;
26 import org.synchronoss.cpo.exporter.MetaXmlObjectExporter;
27 import org.synchronoss.cpo.jdbc.JdbcCpoArgument;
28 import org.synchronoss.cpo.jdbc.JdbcCpoAttribute;
29 import org.synchronoss.cpo.jdbc.cpoJdbcMeta.CtJdbcArgument;
30 import org.synchronoss.cpo.jdbc.cpoJdbcMeta.CtJdbcAttribute;
31 import org.synchronoss.cpo.meta.CpoMetaDescriptor;
32 import org.synchronoss.cpo.meta.domain.CpoArgument;
33 import org.synchronoss.cpo.meta.domain.CpoAttribute;
34
35
36
37
38
39
40
41 public class JdbcMetaXmlObjectExporter extends CoreMetaXmlObjectExporter implements MetaXmlObjectExporter {
42
43 public JdbcMetaXmlObjectExporter(CpoMetaDescriptor metaDescriptor) {
44 super(metaDescriptor);
45 }
46
47 @Override
48 public void visit(CpoAttribute cpoAttribute) {
49
50
51 if (!(cpoAttribute instanceof JdbcCpoAttribute)) {
52 super.visit(cpoAttribute);
53 return;
54 }
55
56 JdbcCpoAttribute jdbcAttribute = (JdbcCpoAttribute) cpoAttribute;
57
58 if (currentCtClass != null) {
59
60
61 CtJdbcAttribute ctJdbcAttribute = CtJdbcAttribute.Factory.newInstance();
62
63 ctJdbcAttribute.setJavaName(jdbcAttribute.getJavaName());
64 ctJdbcAttribute.setJavaType(jdbcAttribute.getJavaType());
65 ctJdbcAttribute.setDataName(jdbcAttribute.getDataName());
66 ctJdbcAttribute.setDataType(jdbcAttribute.getDataType());
67
68 if (jdbcAttribute.getTransformClassName() != null && jdbcAttribute.getTransformClassName().length() > 0) {
69 ctJdbcAttribute.setTransformClass(jdbcAttribute.getTransformClassName());
70 }
71
72 if (jdbcAttribute.getDescription() != null && jdbcAttribute.getDescription().length() > 0) {
73 ctJdbcAttribute.setDescription(jdbcAttribute.getDescription());
74 }
75
76 if (jdbcAttribute.getDbTable() != null && jdbcAttribute.getDbTable().length() > 0) {
77 ctJdbcAttribute.setDbTable(jdbcAttribute.getDbTable());
78 }
79
80 if (jdbcAttribute.getDbColumn() != null && jdbcAttribute.getDbColumn().length() > 0) {
81 ctJdbcAttribute.setDbColumn(jdbcAttribute.getDbColumn());
82 }
83
84
85 CtAttribute ctAttribute = currentCtClass.addNewCpoAttribute();
86 ctAttribute.set(ctJdbcAttribute);
87 }
88 }
89
90 @Override
91 public void visit(CpoArgument cpoArgument) {
92
93
94 if (!(cpoArgument instanceof JdbcCpoArgument)) {
95 super.visit(cpoArgument);
96 return;
97 }
98
99 JdbcCpoArgument jdbcArgument = (JdbcCpoArgument) cpoArgument;
100
101 if (currentCtFunction != null) {
102
103
104 CtJdbcArgument ctJdbcArgument = CtJdbcArgument.Factory.newInstance();
105
106 ctJdbcArgument.setAttributeName(jdbcArgument.getAttributeName());
107
108 if (jdbcArgument.getDescription() != null && jdbcArgument.getDescription().length() > 0) {
109 ctJdbcArgument.setDescription(jdbcArgument.getDescription());
110 }
111
112 if (jdbcArgument.isInParameter() && jdbcArgument.isOutParameter()) {
113 ctJdbcArgument.setScope(CtJdbcArgument.Scope.BOTH);
114 } else if (jdbcArgument.isInParameter()) {
115 ctJdbcArgument.setScope(CtJdbcArgument.Scope.IN);
116 } else if (jdbcArgument.isOutParameter()) {
117 ctJdbcArgument.setScope(CtJdbcArgument.Scope.OUT);
118 }
119
120 if (jdbcArgument.getTypeInfo() != null && !jdbcArgument.getTypeInfo().isEmpty()) {
121 ctJdbcArgument.setTypeInfo(jdbcArgument.getTypeInfo());
122 }
123
124 CtArgument ctArgument = currentCtFunction.addNewCpoArgument();
125 ctArgument.set(ctJdbcArgument);
126 }
127 }
128 }