Clover Coverage Report - Kuali Student 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 11:14:35 EDT
../../../../../../../img/srcFileCovDistChart8.png 27% of files have more coverage
19   69   9   2.38
2   57   0.47   8
8     1.12  
1    
 
  DictionaryServiceImpl       Line # 16 19 0% 9 6 79.3% 0.79310346
 
  (116)
 
1    package org.kuali.student.common.dictionary.service.impl;
2   
3    import java.util.ArrayList;
4    import java.util.HashMap;
5    import java.util.List;
6    import java.util.Map;
7   
8    import org.apache.log4j.Logger;
9    import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
10    import org.kuali.student.common.dictionary.service.DictionaryService;
11    import org.springframework.context.ApplicationContext;
12    import org.springframework.context.ConfigurableApplicationContext;
13    import org.springframework.context.support.ClassPathXmlApplicationContext;
14    import org.springframework.util.StringUtils;
15   
 
16    public class DictionaryServiceImpl implements DictionaryService{
17    private String[] dictionaryContext;
18    private Map<String, ObjectStructureDefinition> objectStructures;
19    final static Logger LOG = Logger.getLogger(DictionaryServiceImpl.class);
20   
 
21  0 toggle public DictionaryServiceImpl() {
22  0 super();
23    }
24   
 
25  21 toggle public DictionaryServiceImpl(String dictionaryContext) {
26  21 super();
27  21 String[] locations = StringUtils.tokenizeToStringArray(dictionaryContext, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
28  21 this.dictionaryContext = locations;
29  21 init();
30    }
31   
 
32  4 toggle public DictionaryServiceImpl(String[] dictionaryContext) {
33  4 super();
34  4 this.dictionaryContext = dictionaryContext;
35  4 init();
36    }
37   
 
38  25 toggle @SuppressWarnings("unchecked")
39    public synchronized void init() {
40  25 ApplicationContext ac = new ClassPathXmlApplicationContext(dictionaryContext);
41   
42  25 Map<String, ObjectStructureDefinition> beansOfType = (Map<String, ObjectStructureDefinition>) ac.getBeansOfType(ObjectStructureDefinition.class);
43  25 objectStructures = new HashMap<String, ObjectStructureDefinition>();
44  25 for (ObjectStructureDefinition objStr : beansOfType.values()){
45  287 if(objectStructures.containsKey(objStr.getName())){
46  26 LOG.warn("There is already a dictionary structure with the name '"+objStr+"'.");
47    }
48  287 objectStructures.put(objStr.getName(), objStr);
49    }
50    }
51   
 
52  2140 toggle @Override
53    public ObjectStructureDefinition getObjectStructure(String objectTypeKey) {
54  2140 return objectStructures.get(objectTypeKey);
55    }
56   
 
57  6 toggle @Override
58    public List<String> getObjectTypes() {
59  6 return new ArrayList<String>(objectStructures.keySet());
60    }
61   
 
62  0 toggle public String[] getDictionaryContext() {
63  0 return dictionaryContext;
64    }
65   
 
66  0 toggle public void setDictionaryContext(String[] dictionaryContext) {
67  0 this.dictionaryContext = dictionaryContext;
68    }
69    }