Clover Coverage Report - KS Services API 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
18   104   9   2.25
2   71   0.5   8
8     1.12  
1    
 
  DataDictionaryServiceImpl       Line # 41 18 0% 9 28 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.student.datadictionary;
17   
18    import java.io.IOException;
19    import java.util.ArrayList;
20    import java.util.LinkedHashMap;
21    import java.util.List;
22    import java.util.Map;
23    import org.kuali.rice.kns.datadictionary.DataObjectEntry;
24    import org.kuali.student.common.dto.ContextInfo;
25    import org.kuali.student.common.exceptions.DoesNotExistException;
26    import org.kuali.student.common.exceptions.MissingParameterException;
27    import org.kuali.student.common.exceptions.OperationFailedException;
28    import org.kuali.student.common.exceptions.PermissionDeniedException;
29    import org.kuali.student.common.service.CommonConstants;
30    import org.kuali.student.datadictionary.dto.DictionaryEntryInfo;
31    import org.kuali.student.datadictionary.service.DataDictionaryService;
32    import org.springframework.context.ApplicationContext;
33    import org.springframework.context.support.ClassPathXmlApplicationContext;
34   
35    /**
36    * Dictionary Service implementation that reads the dictionary from the spring beans and feeds
37    * both the Student dictionary and the RICE dictionary
38    *
39    * @author nwright
40    */
 
41    public class DataDictionaryServiceImpl implements DataDictionaryService, RiceDataDictionaryServiceInfc {
42   
43    private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DataDictionaryServiceImpl.class);
44    private String serviceNamespaceSuffix;
45    private Map<String, DictionaryEntryInfo> studMap;
46    private Map<String, DataObjectEntry> riceMap;
47   
 
48  0 toggle public DataDictionaryServiceImpl() {
49    }
50   
 
51  0 toggle public String getServiceNamespaceSuffix() {
52  0 return serviceNamespaceSuffix;
53    }
54   
 
55  0 toggle public void setServiceNamespaceSuffix(String serviceNamespaceSuffix) {
56  0 this.serviceNamespaceSuffix = serviceNamespaceSuffix;
57    }
58   
59   
 
60  0 toggle public void setDictionaryLocations(List<String> locations) throws IOException {
61  0 for (String location : locations) {
62  0 ApplicationContext ac = new ClassPathXmlApplicationContext(location);
63  0 Map<String, DataObjectEntry> beansOfType =
64    (Map<String, DataObjectEntry>) ac.getBeansOfType(DataObjectEntry.class);
65  0 studMap = new LinkedHashMap<String, DictionaryEntryInfo>();
66  0 riceMap = new LinkedHashMap<String, DataObjectEntry>();
67  0 for (DataObjectEntry entry : beansOfType.values()) {
68  0 LOG.debug(entry.getObjectClass());
69  0 riceMap.put(entry.getFullClassName(), entry);
70  0 studMap.put(calcRefObjectURI (entry.getObjectClass()), new Rice2StudentDictionaryEntryConverter().convert(entry));
71    }
72    }
73    }
74   
 
75  0 toggle private String calcRefObjectURI (Class<?> objectClass) {
76  0 return CommonConstants.REF_OBJECT_URI_GLOBAL_PREFIX + this.serviceNamespaceSuffix + "/" + objectClass.getSimpleName();
77    }
78   
 
79  0 toggle @Override
80    public DictionaryEntryInfo getDataDictionaryEntry(String entryKey, ContextInfo context)
81    throws OperationFailedException,
82    MissingParameterException,
83    PermissionDeniedException,
84    DoesNotExistException {
85  0 DictionaryEntryInfo entry = studMap.get(entryKey);
86  0 if (entry == null) {
87  0 throw new DoesNotExistException(entryKey);
88    }
89  0 return entry;
90    }
91   
 
92  0 toggle @Override
93    public List<String> getDataDictionaryEntryKeys(ContextInfo context)
94    throws OperationFailedException,
95    MissingParameterException,
96    PermissionDeniedException {
97  0 return new ArrayList(studMap.keySet());
98    }
99   
 
100  0 toggle @Override
101    public DataObjectEntry getDataObjectEntry(String entryKey) {
102  0 return riceMap.get(entryKey);
103    }
104    }