View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.spring;
17  
18  import java.io.File;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import org.kuali.common.util.CollectionUtils;
23  import org.kuali.common.util.execute.Executable;
24  import org.springframework.beans.factory.annotation.Autowired;
25  import org.springframework.context.annotation.Bean;
26  import org.springframework.context.annotation.Configuration;
27  import org.springframework.core.env.Environment;
28  
29  /**
30   * @deprecated
31   */
32  @Deprecated
33  @Configuration
34  public class MetaInfSqlSetupConfigOld {
35  
36  	@Autowired
37  	Environment env;
38  
39  	@Bean
40  	public Executable metaInfExecutable() {
41  		List<org.kuali.common.util.metainf.MetaInfContext> contexts = new ArrayList<org.kuali.common.util.metainf.MetaInfContext>();
42  		contexts.add(getMetaInfContext("metainf.output.schema", "metainf.include.schema"));
43  		contexts.add(getMetaInfContext("metainf.output.data", "metainf.include.data"));
44  		contexts.add(getMetaInfContext("metainf.output.constraints", "metainf.include.constraints"));
45  		contexts.add(getMetaInfContext("metainf.output.other", "metainf.include.other"));
46  
47  		org.kuali.common.util.execute.MetaInfExecutable mie = new org.kuali.common.util.execute.MetaInfExecutable();
48  		mie.setSkip(SpringUtils.getBoolean(env, "metainf.sql.skip", false));
49  		mie.setContexts(contexts);
50  		return mie;
51  
52  	}
53  
54  	protected org.kuali.common.util.metainf.MetaInfContext getMetaInfContext(String outputFileKey, String includesKey) {
55  		String csv = SpringUtils.getProperty(env, includesKey);
56  		List<String> includes = CollectionUtils.getTrimmedListFromCSV(csv);
57  		File outputFile = new File(SpringUtils.getProperty(env, outputFileKey));
58  		File baseDir = new File(SpringUtils.getProperty(env, "project.build.outputDirectory"));
59  
60  		org.kuali.common.util.metainf.MetaInfContext context = new org.kuali.common.util.metainf.MetaInfContext();
61  		context.setBaseDir(baseDir);
62  		context.setOutputFile(outputFile);
63  		context.setIncludes(includes);
64  		return context;
65  	}
66  }