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