001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.util.dao.orm;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.OrderByComparator;
020    
021    import java.sql.SQLException;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Bruno Farache
026     * @author Raymond Aug??
027     */
028    public class CustomSQLUtil {
029    
030            public static String appendCriteria(String sql, String criteria) {
031                    return _instance._customSQL.appendCriteria(sql, criteria);
032            }
033    
034            public static String get(String id) {
035                    return _instance._customSQL.get(id);
036            }
037    
038            public static boolean isVendorDB2() {
039                    return _instance._customSQL.isVendorDB2();
040            }
041    
042            public static boolean isVendorHSQL() {
043                    return _instance._customSQL.isVendorHSQL();
044            }
045    
046            public static boolean isVendorInformix() {
047                    return _instance._customSQL.isVendorInformix();
048            }
049    
050            public static boolean isVendorMySQL() {
051                    return _instance._customSQL.isVendorMySQL();
052            }
053    
054            public static boolean isVendorOracle() {
055                    return _instance._customSQL.isVendorOracle();
056            }
057    
058            public static boolean isVendorSybase() {
059                    return _instance._customSQL.isVendorSybase();
060            }
061    
062            public static String[] keywords(String keywords) {
063                    return _instance._customSQL.keywords(keywords);
064            }
065    
066            public static String[] keywords(String keywords, boolean lowerCase) {
067                    return _instance._customSQL.keywords(keywords, lowerCase);
068            }
069    
070            public static String[] keywords(String[] keywordsArray) {
071                    return _instance._customSQL.keywords(keywordsArray);
072            }
073    
074            public static String[] keywords(String[] keywordsArray, boolean lowerCase) {
075                    return _instance._customSQL.keywords(keywordsArray, lowerCase);
076            }
077    
078            public static void reloadCustomSQL() throws SQLException {
079                    _instance._customSQL.reloadCustomSQL();
080            }
081    
082            public static String removeGroupBy(String sql) {
083                    return _instance._customSQL.removeGroupBy(sql);
084            }
085    
086            public static String removeOrderBy(String sql) {
087                    return _instance._customSQL.removeOrderBy(sql);
088            }
089    
090            public static String replaceAndOperator(String sql, boolean andOperator) {
091                    return _instance._customSQL.replaceAndOperator(sql, andOperator);
092            }
093    
094            public static String replaceGroupBy(String sql, String groupBy) {
095                    return _instance._customSQL.replaceGroupBy(sql, groupBy);
096            }
097    
098            public static String replaceIsNull(String sql) {
099                    return _instance._customSQL.replaceIsNull(sql);
100            }
101    
102            public static String replaceKeywords(
103                    String sql, String field, boolean last, int[] values) {
104    
105                    return _instance._customSQL.replaceKeywords(sql, field, last, values);
106            }
107    
108            public static String replaceKeywords(
109                    String sql, String field, boolean last, long[] values) {
110    
111                    return _instance._customSQL.replaceKeywords(sql, field, last, values);
112            }
113    
114            public static String replaceKeywords(
115                    String sql, String field, String operator, boolean last,
116                    String[] values) {
117    
118                    return _instance._customSQL.replaceKeywords(
119                            sql, field, operator, last, values);
120            }
121    
122            public static String replaceOrderBy(String sql, OrderByComparator obc) {
123                    return _instance._customSQL.replaceOrderBy(sql, obc);
124            }
125    
126            private CustomSQLUtil() {
127                    try {
128                            _customSQL = new CustomSQL();
129                    }
130                    catch (Exception e) {
131                            _log.error(e, e);
132                    }
133            }
134    
135            private static Log _log = LogFactoryUtil.getLog(CustomSQLUtil.class);
136    
137            private static CustomSQLUtil _instance = new CustomSQLUtil();
138    
139            private CustomSQL _customSQL;
140    
141    }