View Javadoc

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