001    /**
002     * Copyright (c) 2000-2012 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.portal.tools.samplesqlbuilder;
016    
017    import com.liferay.portal.dao.db.MySQLDB;
018    import com.liferay.portal.kernel.util.StringUtil;
019    
020    /**
021     * A simplified version of MySQLDB for sample SQL generation. This should not be
022     * used for any other purposes.
023     *
024     * @author Shuyang Zhou
025     */
026    public class SampleMySQLDB extends MySQLDB {
027    
028            @Override
029            public String buildSQL(String template) {
030                    return StringUtil.replace(template, _GENERIC_TEMPLATE, _MYSQL_TEMPLATE);
031            }
032    
033            private static final String[] _GENERIC_TEMPLATE = {
034                    "TRUE", "FALSE", "'01/01/1970'", "CURRENT_TIMESTAMP",
035                    "COMMIT_TRANSACTION"
036            };
037    
038            private static final String[] _MYSQL_TEMPLATE = {
039                    "1", "0", "'1970-01-01'", "now()", "commit"
040            };
041    
042    }