1 package org.synchronoss.cpo.jdbc.exporter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.synchronoss.cpo.core.exporter.CoreMetaXmlObjectExporter;
26 import org.synchronoss.cpo.core.exporter.MetaXmlObjectExporter;
27 import org.synchronoss.cpo.core.meta.CpoMetaDescriptor;
28 import org.synchronoss.cpo.core.meta.domain.CpoArgument;
29 import org.synchronoss.cpo.core.meta.domain.CpoAttribute;
30 import org.synchronoss.cpo.cpometa.CtJdbcArgument;
31 import org.synchronoss.cpo.cpometa.CtJdbcAttribute;
32 import org.synchronoss.cpo.cpometa.ObjectFactory;
33 import org.synchronoss.cpo.cpometa.StArgumentScope;
34 import org.synchronoss.cpo.jdbc.JdbcCpoArgument;
35 import org.synchronoss.cpo.jdbc.JdbcCpoAttribute;
36
37
38
39
40
41
42
43 public class JdbcMetaXmlObjectExporter extends CoreMetaXmlObjectExporter
44 implements MetaXmlObjectExporter {
45
46 protected ObjectFactory objectFactory = new ObjectFactory();
47
48
49
50
51
52
53 public JdbcMetaXmlObjectExporter(CpoMetaDescriptor metaDescriptor) {
54 super(metaDescriptor);
55 }
56
57 @Override
58 public void visit(CpoAttribute cpoAttribute) {
59
60
61 if (!(cpoAttribute instanceof JdbcCpoAttribute)) {
62 super.visit(cpoAttribute);
63 return;
64 }
65
66 JdbcCpoAttribute jdbcAttribute = (JdbcCpoAttribute) cpoAttribute;
67
68 if (currentCtClass != null) {
69
70
71
72 CtJdbcAttribute ctJdbcAttribute = new CtJdbcAttribute();
73 var jaxbElement = objectFactory.createJdbcAttribute(ctJdbcAttribute);
74
75 currentCtClass.getCpoAttribute().add(jaxbElement);
76
77 ctJdbcAttribute.setJavaName(jdbcAttribute.getJavaName());
78 ctJdbcAttribute.setJavaType(jdbcAttribute.getJavaType());
79 ctJdbcAttribute.setDataName(jdbcAttribute.getDataName());
80 ctJdbcAttribute.setDataType(jdbcAttribute.getDataType());
81
82 if (jdbcAttribute.getTransformClassName() != null
83 && !jdbcAttribute.getTransformClassName().isEmpty()) {
84 ctJdbcAttribute.setTransformClass(jdbcAttribute.getTransformClassName());
85 }
86
87 if (jdbcAttribute.getDescription() != null && !jdbcAttribute.getDescription().isEmpty()) {
88 ctJdbcAttribute.setDescription(jdbcAttribute.getDescription());
89 }
90
91 if (jdbcAttribute.getDbTable() != null && !jdbcAttribute.getDbTable().isEmpty()) {
92 ctJdbcAttribute.setDbTable(jdbcAttribute.getDbTable());
93 }
94
95 if (jdbcAttribute.getDbColumn() != null && !jdbcAttribute.getDbColumn().isEmpty()) {
96 ctJdbcAttribute.setDbColumn(jdbcAttribute.getDbColumn());
97 }
98 }
99 }
100
101 @Override
102 public void visit(CpoArgument cpoArgument) {
103
104
105 if (!(cpoArgument instanceof JdbcCpoArgument)) {
106 super.visit(cpoArgument);
107 return;
108 }
109
110 JdbcCpoArgument jdbcArgument = (JdbcCpoArgument) cpoArgument;
111
112 if (currentCtFunction != null) {
113
114
115
116 CtJdbcArgument ctJdbcArgument = new CtJdbcArgument();
117 var jaxbElement = objectFactory.createJdbcArgument(ctJdbcArgument);
118 currentCtFunction.getCpoArgument().add(jaxbElement);
119
120 ctJdbcArgument.setAttributeName(jdbcArgument.getName());
121
122 if (jdbcArgument.getDescription() != null && !jdbcArgument.getDescription().isEmpty()) {
123 ctJdbcArgument.setDescription(jdbcArgument.getDescription());
124 }
125
126 if (jdbcArgument.isInParameter() && jdbcArgument.isOutParameter()) {
127 ctJdbcArgument.setScope(StArgumentScope.BOTH);
128 } else if (jdbcArgument.isInParameter()) {
129 ctJdbcArgument.setScope(StArgumentScope.IN);
130 } else if (jdbcArgument.isOutParameter()) {
131 ctJdbcArgument.setScope(StArgumentScope.OUT);
132 }
133
134 if (jdbcArgument.getTypeInfo() != null && !jdbcArgument.getTypeInfo().isEmpty()) {
135 ctJdbcArgument.setTypeInfo(jdbcArgument.getTypeInfo());
136 }
137 }
138 }
139 }