|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MyDaoImpl | Line # 24 | 16 | 0% | 6 | 3 | 87% |
0.8695652
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(7) | |||
Result | |||
0.5652174
|
org.kuali.student.common_test_tester.ServiceCommonTest.testClientCaching org.kuali.student.common_test_tester.ServiceCommonTest.testClientCaching | 1 PASS | |
0.5652174
|
org.kuali.student.common_test_tester.DaoCommonTest.test2 org.kuali.student.common_test_tester.DaoCommonTest.test2 | 1 PASS | |
0.5652174
|
org.kuali.student.common_test_tester.DaoCommonTest.test1 org.kuali.student.common_test_tester.DaoCommonTest.test1 | 1 PASS | |
0.3478261
|
org.kuali.student.common_test_tester.ServiceCommonCopyTest.test2 org.kuali.student.common_test_tester.ServiceCommonCopyTest.test2 | 1 PASS | |
0.2173913
|
org.kuali.student.common_test_tester.ServiceCommonTest.testDaoLoader org.kuali.student.common_test_tester.ServiceCommonTest.testDaoLoader | 1 PASS | |
0.13043478
|
org.kuali.student.common_test_tester.ServiceCommonCopyTest.test1 org.kuali.student.common_test_tester.ServiceCommonCopyTest.test1 | 1 PASS | |
0.13043478
|
org.kuali.student.common_test_tester.ServiceCommonTest.test1 org.kuali.student.common_test_tester.ServiceCommonTest.test1 | 1 PASS | |
1 | /** | |
2 | * Copyright 2010 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 | ||
16 | package org.kuali.student.common_test_tester.support; | |
17 | ||
18 | import java.util.List; | |
19 | ||
20 | import javax.persistence.EntityManager; | |
21 | import javax.persistence.PersistenceContext; | |
22 | import javax.persistence.Query; | |
23 | ||
24 | public class MyDaoImpl implements MyDao { | |
25 | ||
26 | private EntityManager entityManager; | |
27 | ||
28 | 4 | @PersistenceContext |
29 | public void setEntityManager(EntityManager entityManager) { | |
30 | 4 | this.entityManager = entityManager; |
31 | } | |
32 | ||
33 | 8 | public String createValue(Value value) { |
34 | 8 | entityManager.persist(value); |
35 | 8 | return value.getId(); |
36 | } | |
37 | ||
38 | 7 | public String findValue(String id) { |
39 | 7 | Value tv = entityManager.find(Value.class, id); |
40 | 7 | if(tv==null){ |
41 | 0 | return null; |
42 | } | |
43 | 7 | return tv.getValue(); |
44 | } | |
45 | ||
46 | 3 | @SuppressWarnings("unchecked") |
47 | public Value findValueFromValue(String value) { | |
48 | 3 | Query q = entityManager.createQuery("SELECT v FROM Value v WHERE v.value=:valueIn"); |
49 | 3 | q.setParameter("valueIn", value); |
50 | 3 | for(Value tv : (List<Value>)q.getResultList()){ |
51 | 3 | return tv; |
52 | } | |
53 | 0 | return null; |
54 | } | |
55 | ||
56 | 1 | public boolean updateValue(String id, String value) { |
57 | 1 | Value v = entityManager.find(Value.class, id); |
58 | 1 | v.setValue(value); |
59 | 1 | entityManager.merge(v); |
60 | 1 | return true; |
61 | } | |
62 | ||
63 | } |
|