1 package org.synchronoss.cpo.cassandra.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.cassandra.meta.CassandraCpoAttribute;
26 import org.synchronoss.cpo.core.exporter.CoreMetaXmlObjectExporter;
27 import org.synchronoss.cpo.core.exporter.MetaXmlObjectExporter;
28 import org.synchronoss.cpo.core.meta.CpoMetaDescriptor;
29 import org.synchronoss.cpo.core.meta.domain.CpoArgument;
30 import org.synchronoss.cpo.core.meta.domain.CpoAttribute;
31 import org.synchronoss.cpo.cpometa.CtCassandraArgument;
32 import org.synchronoss.cpo.cpometa.CtCassandraAttribute;
33 import org.synchronoss.cpo.cpometa.ObjectFactory;
34
35
36
37
38
39
40 public class CassandraMetaXmlObjectExporter extends CoreMetaXmlObjectExporter
41 implements MetaXmlObjectExporter {
42
43 private final ObjectFactory objectFactory = new ObjectFactory();
44
45
46
47
48
49
50 public CassandraMetaXmlObjectExporter(CpoMetaDescriptor metaDescriptor) {
51 super(metaDescriptor);
52 }
53
54 @Override
55 public void visit(CpoAttribute cpoAttribute) {
56
57
58 if (!(cpoAttribute instanceof CassandraCpoAttribute)) {
59 super.visit(cpoAttribute);
60 return;
61 }
62
63 CassandraCpoAttribute cassAttribute = (CassandraCpoAttribute) cpoAttribute;
64
65 if (currentCtClass != null) {
66
67
68
69 CtCassandraAttribute ctCassandraAttribute = new CtCassandraAttribute();
70
71 ctCassandraAttribute.setJavaName(cassAttribute.getJavaName());
72 ctCassandraAttribute.setJavaType(cassAttribute.getJavaType());
73 ctCassandraAttribute.setDataName(cassAttribute.getDataName());
74 ctCassandraAttribute.setDataType(cassAttribute.getDataType());
75
76 if (cassAttribute.getTransformClassName() != null
77 && !cassAttribute.getTransformClassName().isEmpty()) {
78 ctCassandraAttribute.setTransformClass(cassAttribute.getTransformClassName());
79 }
80
81 if (cassAttribute.getDescription() != null && !cassAttribute.getDescription().isEmpty()) {
82 ctCassandraAttribute.setDescription(cassAttribute.getDescription());
83 }
84
85 if (cassAttribute.getKeyType() != null && !cassAttribute.getKeyType().isEmpty()) {
86 ctCassandraAttribute.setKeyType(cassAttribute.getKeyType());
87 }
88
89 if (cassAttribute.getValueType() != null && !cassAttribute.getValueType().isEmpty()) {
90 ctCassandraAttribute.setValueType(cassAttribute.getValueType());
91 }
92
93
94 currentCtClass
95 .getCpoAttribute()
96 .add(objectFactory.createCassandraAttribute(ctCassandraAttribute));
97 }
98 }
99
100 @Override
101 public void visit(CpoArgument cpoArgument) {
102
103 if (currentCtFunction != null) {
104
105
106
107 CtCassandraArgument ctCassandraArgument = new CtCassandraArgument();
108
109 ctCassandraArgument.setAttributeName(cpoArgument.getName());
110
111 if (cpoArgument.getDescription() != null && !cpoArgument.getDescription().isEmpty()) {
112 ctCassandraArgument.setDescription(cpoArgument.getDescription());
113 }
114
115 currentCtFunction
116 .getCpoArgument()
117 .add(objectFactory.createCassandraArgument(ctCassandraArgument));
118 }
119 }
120 }