1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
31
32 @Deprecated
33 @Configuration
34 public class MetaInfSqlSetupConfig {
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("sql.metainf.output.schema", "sql.metainf.include.schema"));
43 contexts.add(getMetaInfContext("sql.metainf.output.data", "sql.metainf.include.data"));
44 contexts.add(getMetaInfContext("sql.metainf.output.constraints", "sql.metainf.include.constraints"));
45 contexts.add(getMetaInfContext("sql.metainf.output.other", "sql.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, "sql.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 }