001 /**
002 * Copyright 2010-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.common.jdbc.convert;
017
018 import org.kuali.common.jdbc.convert.DirectoryContext;
019 import org.kuali.common.jdbc.convert.DirectoryConverter;
020 import org.kuali.common.jdbc.convert.PostConversionProcessor;
021 import org.kuali.common.jdbc.convert.SqlConverter;
022 import org.kuali.common.util.execute.Executable;
023
024 import java.io.File;
025
026 /**
027 * This is a helper class for launching a DirectoryConverter from a spring context
028 *
029 * @author andrewlubbers
030 */
031 public class DirectoryConverterExecutable implements Executable {
032
033 private String inputSqlFolder;
034
035 private String includedFilePattern;
036
037 private String excludedFilePattern;
038
039 private PostConversionProcessor postConversionProcessor;
040
041 private SqlConverter sqlConverter;
042
043 public void execute() {
044 File directory = new File(inputSqlFolder);
045
046 DirectoryContext context = new DirectoryContext();
047 context.setConverter(sqlConverter);
048 context.setDirectory(directory);
049 context.setInclude(includedFilePattern);
050 context.setExclude(excludedFilePattern);
051 context.setPostProcessor(postConversionProcessor);
052 DirectoryConverter dc = new DirectoryConverter();
053 dc.convert(context);
054 }
055
056 public String getExcludedFilePattern() {
057 return excludedFilePattern;
058 }
059
060 public void setExcludedFilePattern(String excludedFilePattern) {
061 this.excludedFilePattern = excludedFilePattern;
062 }
063
064 public String getIncludedFilePattern() {
065 return includedFilePattern;
066 }
067
068 public void setIncludedFilePattern(String includedFilePattern) {
069 this.includedFilePattern = includedFilePattern;
070 }
071
072 public String getInputSqlFolder() {
073 return inputSqlFolder;
074 }
075
076 public void setInputSqlFolder(String inputSqlFolder) {
077 this.inputSqlFolder = inputSqlFolder;
078 }
079
080 public PostConversionProcessor getPostConversionProcessor() {
081 return postConversionProcessor;
082 }
083
084 public void setPostConversionProcessor(PostConversionProcessor postConversionProcessor) {
085 this.postConversionProcessor = postConversionProcessor;
086 }
087
088 public SqlConverter getSqlConverter() {
089 return sqlConverter;
090 }
091
092 public void setSqlConverter(SqlConverter sqlConverter) {
093 this.sqlConverter = sqlConverter;
094 }
095 }