1 package org.synchronoss.cpo.jdbc;
2
3 /*-
4 * [[
5 * jdbc
6 * ==
7 * Copyright (C) 2003 - 2026 Exaxis LLC, Synchronoss Technologies Inc
8 * ==
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * ]]
23 */
24
25 import org.synchronoss.cpo.core.BindableCpoWhere;
26 import org.synchronoss.cpo.core.enums.Comparison;
27 import org.synchronoss.cpo.core.enums.Logical;
28 import org.synchronoss.cpo.core.meta.domain.CpoAttribute;
29
30 /**
31 * JDBC implementation of {@link BindableCpoWhere}, resolving a where clause attribute to its
32 * qualified {@code table.column} (or bare column) name using the attribute's {@link
33 * JdbcCpoAttribute} metadata.
34 *
35 * @author david berry
36 */
37 public class JdbcCpoWhere extends BindableCpoWhere {
38 /** Version Id for this class. */
39 private static final long serialVersionUID = 1L;
40
41 /** Create a JdbcCpoWhere */
42 public JdbcCpoWhere() {}
43
44 /**
45 * Create a JdbcCpoWhere
46 *
47 * @param <T> - The type of the value being compared
48 * @param logical - Logical operator
49 * @param attr - Attribute being compared
50 * @param comp - Compare operator
51 * @param value - The value to compare against the attribute
52 */
53 public <T> JdbcCpoWhere(Logical logical, String attr, Comparison comp, T value) {
54 super(logical, attr, comp, value);
55 }
56
57 /**
58 * Create a JdbcCpoWhere
59 *
60 * @param <T> - The type of the value being compared
61 * @param logical - Logical operator
62 * @param attr - Attribute being compared
63 * @param comp - Compare operator
64 * @param value - The value to compare against the attribute
65 * @param not - add the logical not operator
66 */
67 public <T> JdbcCpoWhere(Logical logical, String attr, Comparison comp, T value, boolean not) {
68 super(logical, attr, comp, value, not);
69 }
70
71 @Override
72 protected String buildColumnName(CpoAttribute attribute) {
73 JdbcCpoAttribute jdbcCpoAttribute = (JdbcCpoAttribute) attribute;
74
75 StringBuilder columnName = new StringBuilder();
76
77 if (jdbcCpoAttribute.getDbTable() != null) {
78 columnName.append(jdbcCpoAttribute.getDbTable());
79 columnName.append(".");
80 }
81 if (jdbcCpoAttribute.getDbColumn() != null) {
82 columnName.append(jdbcCpoAttribute.getDbColumn());
83 } else {
84 columnName.append(jdbcCpoAttribute.getDataName());
85 }
86
87 return columnName.toString();
88 }
89 }