1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.dictionary.service.impl.old;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import javax.jws.WebService;
24
25 import org.kuali.student.common.dictionary.old.dto.ObjectStructure;
26 import org.kuali.student.common.dictionary.service.old.DictionaryService;
27 import org.springframework.context.ApplicationContext;
28 import org.springframework.context.ConfigurableApplicationContext;
29 import org.springframework.context.support.ClassPathXmlApplicationContext;
30 import org.springframework.util.StringUtils;
31
32 @WebService(endpointInterface = "org.kuali.student.core.dictionary.service.DictionaryService", serviceName = "DictionaryService", portName = "DictionaryService", targetNamespace = "http://student.kuali.org/wsdl/dictionary")
33 @Deprecated
34 public class DictionaryServiceSpringImpl implements DictionaryService {
35
36 private String[] dictionaryContext;
37 private Map<String, ObjectStructure> objectStructures;
38
39 public DictionaryServiceSpringImpl() {
40 super();
41 }
42
43 public DictionaryServiceSpringImpl(String dictionaryContext) {
44 super();
45 String[] locations = StringUtils.tokenizeToStringArray(dictionaryContext, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
46 this.dictionaryContext = locations;
47 init();
48 }
49
50 public DictionaryServiceSpringImpl(String[] dictionaryContext) {
51 super();
52 this.dictionaryContext = dictionaryContext;
53 init();
54 }
55
56 @SuppressWarnings("unchecked")
57 public void init() {
58 ApplicationContext ac = new ClassPathXmlApplicationContext(dictionaryContext);
59
60 Map<String, ObjectStructure> beansOfType = (Map<String, ObjectStructure>) ac.getBeansOfType(ObjectStructure.class);
61 objectStructures = new HashMap<String, ObjectStructure>();
62 for (ObjectStructure objStr : beansOfType.values()){
63
64 if(objStr.getId()!=null){
65 if(objStr.getId().startsWith("object.")){
66 if(!objStr.getId().startsWith("object.field.")){
67 objectStructures.put(objStr.getKey(), objStr);
68 }
69 }else{
70 objectStructures.put(objStr.getKey(), objStr);
71 }
72 }else{
73 objectStructures.put(objStr.getKey(), objStr);
74 }
75 }
76 }
77
78 @Override
79 public ObjectStructure getObjectStructure(String objectTypeKey) {
80 return objectStructures.get(objectTypeKey);
81 }
82
83 @Override
84 public List<String> getObjectTypes() {
85 return new ArrayList<String>(objectStructures.keySet());
86 }
87
88 public String[] getDictionaryContext() {
89 return dictionaryContext;
90 }
91
92 public void setDictionaryContext(String[] dictionaryContext) {
93 this.dictionaryContext = dictionaryContext;
94 }
95
96 }