1 /*
2 * Copyright (C) 2003-2012 David E. Berry
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * A copy of the GNU Lesser General Public License may also be found at
19 * http://www.gnu.org/licenses/lgpl.txt
20 */
21 package org.synchronoss.cpo.cassandra.meta;
22
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.synchronoss.cpo.CpoException;
26 import org.synchronoss.cpo.cassandra.transform.CassandraCpoTransform;
27 import org.synchronoss.cpo.meta.CpoMetaDescriptor;
28 import org.synchronoss.cpo.meta.domain.CpoAttribute;
29
30 import java.lang.reflect.Method;
31
32 /**
33 * JdbcCpoAttribute. A class that includes the Jdbc specifc attributes that are additional to the CpoAttribute attributes
34 *
35 * @author david berry
36 */
37 public class CassandraCpoAttribute extends CpoAttribute implements java.io.Serializable, Cloneable {
38
39 private static final Logger logger = LoggerFactory.getLogger(CassandraCpoAttribute.class);
40 /**
41 * Version Id for this class.
42 */
43 private static final long serialVersionUID = 1L;
44 //Transform attributes
45 private CassandraCpoTransform cassandraTransform = null;
46 private Method transformPSOutMethod = null;
47
48 public CassandraCpoAttribute() {
49 }
50
51
52 // private void dumpMethod(Method m) {
53 // logger.debug("========================");
54 // logger.debug("===> Declaring Class: " + m.getDeclaringClass().getName());
55 // logger.debug("===> Method Signature: " + m.toString());
56 // logger.debug("===> Generic Signature: " + m.toGenericString());
57 // logger.debug("===> Method isBridge: " + m.isBridge());
58 // logger.debug("===> Method isSynthetic: " + m.isSynthetic());
59 // logger.debug("========================");
60 // }
61
62 @Override
63 protected void initTransformClass(CpoMetaDescriptor metaDescriptor) throws CpoException {
64 super.initTransformClass(metaDescriptor);
65 if (getCpoTransform() != null && getCpoTransform() instanceof CassandraCpoTransform) {
66 cassandraTransform = (CassandraCpoTransform) getCpoTransform();
67
68 for (Method m : findMethods(cassandraTransform.getClass(), TRANSFORM_OUT_NAME, 2, true)) {
69 if (m.getParameterTypes()[0].getName().equals("org.synchronoss.cpo.cassandra.CassandraBoundStatementFactory")) {
70 transformPSOutMethod = m;
71 }
72 }
73 }
74
75 // TODO Revisit this. Initializing the java sql type here. Not sure that this is the right place.
76 setDataTypeInt(metaDescriptor.getDataTypeInt(getDataType()));
77 }
78 }