1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.coeus.s2sgen.impl.location;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.kuali.coeus.common.api.country.CountryContract;
23 import org.kuali.coeus.common.api.country.KcCountryService;
24 import org.kuali.coeus.common.api.state.KcStateService;
25 import org.kuali.coeus.common.api.state.StateContract;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.beans.factory.annotation.Qualifier;
28 import org.springframework.stereotype.Component;
29
30 @Component("s2SLocationService")
31 public class S2SLocationServiceImpl implements S2SLocationService {
32
33 @Autowired
34 @Qualifier("kcCountryService")
35 private KcCountryService kcCountryService;
36
37 @Autowired
38 @Qualifier("kcStateService")
39 private KcStateService kcStateService;
40
41
42
43
44
45
46
47 @Override
48 public CountryContract getCountryFromCode(String countryCode) {
49 if(StringUtils.isBlank(countryCode)) return null;
50 CountryContract country = getKcCountryService().getCountryByAlternateCode(countryCode);
51 if(country==null){
52 country = getKcCountryService().getCountry(countryCode);
53 }
54 return country;
55 }
56
57
58
59
60
61
62
63
64
65 @Override
66 public StateContract getStateFromName(String countryAlternateCode, String stateName) {
67 CountryContract country = getCountryFromCode(countryAlternateCode);
68
69 StateContract state = getKcStateService().getState(country.getCode(), stateName);
70 return state;
71 }
72
73 public KcStateService getKcStateService() {
74 return kcStateService;
75 }
76
77 public void setKcStateService(KcStateService kcStateService) {
78 this.kcStateService = kcStateService;
79 }
80
81 public KcCountryService getKcCountryService() {
82 return kcCountryService;
83 }
84
85 public void setKcCountryService(KcCountryService kcCountryService) {
86 this.kcCountryService = kcCountryService;
87 }
88 }