01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.rice.test.lifecycles;
17:
18: import org.kuali.rice.core.Core;
19: import org.kuali.rice.lifecycle.Lifecycle;
20: import org.kuali.rice.test.SQLDataLoader;
21:
22: /**
23: * A lifecycle for loading SQL datasets.
24: *
25: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
26: */
27: public class SQLDataLoaderLifecycle implements Lifecycle {
28: private boolean started;
29:
30: private SQLDataLoader sqlDataLoader;
31:
32: private String filename;
33:
34: private String delimiter;
35:
36: public SQLDataLoaderLifecycle() {
37: this ("classpath:DefaultTestData.sql", ";");
38: }
39:
40: public SQLDataLoaderLifecycle(String filename, String delimiter) {
41: this .filename = filename;
42: this .delimiter = delimiter;
43: }
44:
45: public boolean isStarted() {
46: return started;
47: }
48:
49: public void start() throws Exception {
50: if (new Boolean(Core.getCurrentContextConfig().getProperty(
51: "use.sqlDataLoaderLifecycle"))) {
52: sqlDataLoader = new SQLDataLoader(filename, delimiter);
53: sqlDataLoader.runSql();
54: started = true;
55: }
56: }
57:
58: public void stop() throws Exception {
59: // TODO: may way to do something with the dataLoader
60: started = false;
61: }
62: }
|