View Javadoc

1   /*
2    * Copyright 2006-2011 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  
17  package org.kuali.rice.krad.datadictionary;
18  
19  import org.kuali.rice.core.api.config.ConfigurationException;
20  import org.kuali.rice.krad.service.DataDictionaryService;
21  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
22  import org.springframework.beans.factory.InitializingBean;
23  
24  import java.util.List;
25  
26  /**
27   * Puts a data dictionary file location in the data dictionary
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   *
30   */
31  public class DataDictionaryLocationConfigurer implements InitializingBean {
32  
33  	private List<String> dataDictionaryPackages;
34  	
35  	private DataDictionaryService dataDictionaryService;
36  	
37  	public DataDictionaryLocationConfigurer(DataDictionaryService dataDictionaryService){
38  		this.dataDictionaryService = dataDictionaryService;
39  	}
40  	
41  	public void afterPropertiesSet() throws Exception {
42  		if (dataDictionaryPackages == null || dataDictionaryPackages.isEmpty()) {
43  			throw new ConfigurationException("datatDictionaryPackages empty when initializing DataDictionaryLocation bean.");
44  		}
45  		if(dataDictionaryService!=null)
46  			dataDictionaryService.addDataDictionaryLocations(getDataDictionaryPackages());
47  		else
48  			KRADServiceLocatorWeb.getDataDictionaryService().addDataDictionaryLocations(getDataDictionaryPackages());
49  	}
50  
51  	public List<String> getDataDictionaryPackages() {
52  		return dataDictionaryPackages;
53  	}
54  
55  	public void setDataDictionaryPackages(List<String> dataDictionaryPackages) {
56  		this.dataDictionaryPackages = dataDictionaryPackages;
57  	}
58  
59  }