View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.common.impex.util;
17  
18  import java.util.List;
19  import java.util.Properties;
20  
21  import org.kuali.common.impex.config.DumpConfigConstants;
22  import org.kuali.common.impex.spring.DumpDatabaseExecutableConfig;
23  import org.kuali.common.util.CollectionUtils;
24  import org.kuali.common.util.PropertyUtils;
25  import org.kuali.common.util.config.service.DefaultConfigService;
26  import org.kuali.common.util.config.supplier.ConfigPropertiesSupplier;
27  import org.kuali.common.util.config.supplier.PropertiesSupplier;
28  import org.kuali.common.util.execute.SpringExecutable;
29  import org.kuali.common.util.spring.SpringUtils;
30  
31  public class SchemaExportUtility {
32  
33  	public static void main(String[] args) {
34  
35  		String propertiesLocation = getPropertiesLocation(args);
36  
37  		if (propertiesLocation == null) {
38  			printHelpAndExit();
39  		}
40  
41  		try {
42  			List<Class<?>> annotatedClasses = CollectionUtils.asList(DumpDatabaseExecutableConfig.class);
43  			Properties overrides = PropertyUtils.load(propertiesLocation);
44  			PropertiesSupplier supplier = new ConfigPropertiesSupplier(DumpConfigConstants.CONFIG_IDS, new DefaultConfigService(), overrides);
45  			SpringExecutable executable = SpringUtils.getSpringExecutable(supplier, annotatedClasses);
46  			executable.execute();
47  		} catch (Exception e) {
48  			e.printStackTrace();
49  		}
50  
51  	}
52  
53  	protected static String getPropertiesLocation(String[] args) {
54  		if (args == null || args.length < 1) {
55  			return null;
56  		} else {
57  			return args[0];
58  		}
59  	}
60  
61  	private static void printHelpAndExit() {
62  		System.out.println("Expects exactly one argument, a property file location.");
63  		System.exit(1);
64  	}
65  
66  }