Clover Coverage Report - KS R2 POC 0.0.1-SNAPSHOT (Aggregated)
Coverage timestamp: Mon May 23 2011 04:02:06 EDT
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
45   115   14   9
14   88   0.31   5
5     2.8  
1    
 
  DataProviderForKimEntityInfoImpl       Line # 30 45 0% 14 64 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15    package org.kuali.student.kim.identity.mock;
16   
17    import java.util.ArrayList;
18    import java.util.List;
19    import org.apache.log4j.Logger;
20    import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo;
21    import org.kuali.rice.kim.bo.entity.dto.KimEntityInfo;
22    import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo;
23    import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
24    import org.kuali.rice.kns.datadictionary.validation.DataType;
25   
26    /**
27    * Provides values to compare
28    * @author nwright
29    */
 
30    public class DataProviderForKimEntityInfoImpl implements DataProviderForKimEntityInfoInfc {
31   
32    final static Logger LOG = Logger.getLogger(DataProviderForKimEntityInfoImpl.class);
33   
 
34  0 toggle public DataProviderForKimEntityInfoImpl() {
35    }
36   
 
37  0 toggle @Override
38    public List<Object> getValues(KimEntityInfo obj, String fieldKey) {
39  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_FIRST_NAME)) {
40  0 List<Object> dvs = new ArrayList();
41  0 for (KimEntityNameInfo nameInfo : obj.getNames()) {
42  0 dvs.add(nameInfo.getFirstName());
43    }
44  0 return dvs;
45    }
46  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_LAST_NAME)) {
47  0 List<Object> dvs = new ArrayList();
48  0 for (KimEntityNameInfo nameInfo : obj.getNames()) {
49  0 dvs.add(nameInfo.getLastName());
50    }
51  0 return dvs;
52    }
53  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_MIDDLE_NAME)) {
54  0 List<Object> dvs = new ArrayList();
55  0 for (KimEntityNameInfo nameInfo : obj.getNames()) {
56  0 dvs.add(nameInfo.getMiddleName());
57    }
58  0 return dvs;
59    }
60  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PRINCIPALS_PRINCIPALNAME)) {
61  0 List<Object> dvs = new ArrayList();
62  0 for (KimPrincipalInfo prinInfo : obj.getPrincipals()) {
63  0 dvs.add(prinInfo.getPrincipalName());
64    }
65  0 return dvs;
66    }
67  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PRINCIPALS_PRINCIPALID)) {
68  0 List<Object> dvs = new ArrayList();
69  0 for (KimPrincipalInfo prinInfo : obj.getPrincipals()) {
70  0 dvs.add(prinInfo.getPrincipalId());
71    }
72  0 return dvs;
73    }
74  0 if (fieldKey.equals(IdentityServiceConstants.KIM_PERSON_AFFILIATION_TYPE_CODE)) {
75  0 List<Object> dvs = new ArrayList();
76  0 for (KimEntityAffiliationInfo affInfo : obj.getAffiliations()) {
77  0 dvs.add(affInfo.getAffiliationTypeCode());
78    }
79  0 return dvs;
80    }
81  0 throw new IllegalArgumentException("Search criteria " + fieldKey + " is not supported");
82    }
83   
 
84  0 toggle @Override
85    public DataType getDataType(String fieldKey) {
86  0 for (String supportedKey : IdentityServiceConstants.SUPPORTED_SEARCH_FIELD_KEYS) {
87  0 if (supportedKey.equals(fieldKey)) {
88  0 return DataType.STRING;
89    }
90    }
91  0 throw new IllegalArgumentException("Search criteria " + fieldKey + " is not supported");
92    }
93   
 
94  0 toggle @Override
95    public boolean supportsField(String fieldKey) {
96  0 try {
97  0 getDataType(fieldKey);
98  0 return true;
99    } catch (IllegalArgumentException ex) {
100  0 return false;
101    }
102    }
103   
 
104  0 toggle @Override
105    public Object parseValue(String fieldKey, String value) throws IllegalArgumentException {
106  0 DataType dt = this.getDataType(fieldKey);
107  0 switch (dt) {
108  0 case STRING:
109  0 return value.toLowerCase();
110  0 default:
111  0 throw new IllegalArgumentException("Search criteria " + fieldKey + " has a data type that is not supported");
112    }
113   
114    }
115    }