| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 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 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@author |
| 40 |
|
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 9 |
Complexity Density: 0.5 |
|
| 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 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 48 |
0
|
public DataDictionaryServiceImpl() {... |
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0
|
public String getServiceNamespaceSuffix() {... |
| 52 |
0
|
return serviceNamespaceSuffix; |
| 53 |
|
} |
| 54 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
0
|
public void setServiceNamespaceSuffix(String serviceNamespaceSuffix) {... |
| 56 |
0
|
this.serviceNamespaceSuffix = serviceNamespaceSuffix; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 60 |
0
|
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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0
|
private String calcRefObjectURI (Class<?> objectClass) {... |
| 76 |
0
|
return CommonConstants.REF_OBJECT_URI_GLOBAL_PREFIX + this.serviceNamespaceSuffix + "/" + objectClass.getSimpleName(); |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 79 |
0
|
@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 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 92 |
0
|
@Override... |
| 93 |
|
public List<String> getDataDictionaryEntryKeys(ContextInfo context) |
| 94 |
|
throws OperationFailedException, |
| 95 |
|
MissingParameterException, |
| 96 |
|
PermissionDeniedException { |
| 97 |
0
|
return new ArrayList(studMap.keySet()); |
| 98 |
|
} |
| 99 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 100 |
0
|
@Override... |
| 101 |
|
public DataObjectEntry getDataObjectEntry(String entryKey) { |
| 102 |
0
|
return riceMap.get(entryKey); |
| 103 |
|
} |
| 104 |
|
} |