@@ -0,0 +1,2873 @@
+/*%0A * Copyright 2008-2013 the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *        http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.broadleafcommerce.common.util.sql.importsql;%0A%0Aimport org.hibernate.tool.hbm2ddl.SingleLineSqlCommandExtractor;%0A%0Aimport java.io.Reader;%0A%0A/**%0A * This is a utility class that is only meant to be used for testing the BLC demo on SQL Server. In our current%0A * import sql files, there are a number of value declarations that are incompatible with Sql Server. This%0A * custom extractor takes care of transforming those values into something SQL Server understands.%0A *%0A * @author Jeff Fischer%0A */%0Apublic class DemoSqlServerSingleLineSqlCommandExtractor extends SingleLineSqlCommandExtractor %7B%0A%0A    private static final String BOOLEANTRUEMATCH = %22(?i)(true)%22;%0A    private static final String BOOLEANFALSEMATCH = %22(?i)(false)%22;%0A    private static final String TIMESTAMPMATCH = %22(?i)(current_date)%22;%0A    public static final String TRUE = %22'TRUE'%22;%0A    public static final String FALSE = %22'FALSE'%22;%0A    public static final String CURRENT_TIMESTAMP = %22CURRENT_TIMESTAMP%22;%0A%0A    @Override%0A    public String%5B%5D extractCommands(Reader reader) %7B%0A        String%5B%5D statements = super.extractCommands(reader);%0A        for (int j=0; j%3Cstatements.length; j++) %7B%0A            //try start matches%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(BOOLEANTRUEMATCH + %22%5C%5Cs*%5B,%5D%22, TRUE + %22,%22);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(BOOLEANFALSEMATCH + %22%5C%5Cs*%5B,%5D%22, FALSE + %22,%22);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(TIMESTAMPMATCH + %22%5C%5Cs*%5B,%5D%22, CURRENT_TIMESTAMP + %22,%22);%0A%0A            //try middle matches%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + BOOLEANTRUEMATCH + %22%5C%5Cs*%5B,%5D%22, %22,%22 + TRUE + %22,%22);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + BOOLEANFALSEMATCH + %22%5C%5Cs*%5B,%5D%22, %22,%22 + FALSE + %22,%22);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + TIMESTAMPMATCH + %22%5C%5Cs*%5B,%5D%22, %22,%22 + CURRENT_TIMESTAMP + %22,%22);%0A%0A            //try end matches%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + BOOLEANTRUEMATCH, %22,%22 + TRUE);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + BOOLEANFALSEMATCH, %22,%22 + FALSE);%0A            statements%5Bj%5D = statements%5Bj%5D.replaceAll(%22%5B,%5D%5C%5Cs*%22 + TIMESTAMPMATCH, %22,%22 + CURRENT_TIMESTAMP);%0A        %7D%0A%0A        return statements;%0A    %7D%0A%7D%0A

Allow dynamic conversion of import sql for SQL Server compatibility