1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.ksb.messaging.bam.dao.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.persistence.EntityManager; |
21 | |
import javax.persistence.PersistenceContext; |
22 | |
import javax.xml.namespace.QName; |
23 | |
|
24 | |
import org.kuali.rice.core.reflect.ObjectDefinition; |
25 | |
import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry; |
26 | |
import org.kuali.rice.ksb.messaging.bam.dao.BAMDAO; |
27 | |
|
28 | |
|
29 | 0 | public class BAMDaoJpaImpl implements BAMDAO { |
30 | |
|
31 | |
private EntityManager entityManager; |
32 | |
|
33 | |
@PersistenceContext |
34 | |
public void setEntityManager(EntityManager entityManager) { |
35 | 0 | this.entityManager = entityManager; |
36 | 0 | } |
37 | |
|
38 | |
public void clearBAMTables() { |
39 | 0 | entityManager.createQuery("delete bte from BAMTargetEntry bte").executeUpdate(); |
40 | 0 | entityManager.createQuery("delete bp from BAMParam bp").executeUpdate(); |
41 | 0 | } |
42 | |
|
43 | |
public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) { |
44 | 0 | return (List<BAMTargetEntry>) entityManager.createQuery("select bte from BAMTargetEntry bte where bte.serviceName = :serviceName and bte.methodName = :methodName").setParameter("serviceName", serviceName.toString()).setParameter("methodName", methodName).getResultList(); |
45 | |
} |
46 | |
|
47 | |
public void save(BAMTargetEntry bamEntry) { |
48 | 0 | if(bamEntry.getBamId() == null) { |
49 | 0 | entityManager.persist(bamEntry); |
50 | |
} |
51 | |
else { |
52 | 0 | entityManager.merge(bamEntry); |
53 | |
} |
54 | 0 | } |
55 | |
|
56 | |
public List<BAMTargetEntry> getCallsForService(QName serviceName) { |
57 | 0 | return (List<BAMTargetEntry>) entityManager.createQuery("select bte from BAMTargetEntry bte where bte.serviceName = :serviceName").setParameter("serviceName", serviceName.toString()).getResultList(); |
58 | |
} |
59 | |
|
60 | |
public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef) { |
61 | 0 | QName qname = new QName(objDef.getServiceNamespace(), objDef.getClassName()); |
62 | 0 | return (List<BAMTargetEntry>) entityManager.createQuery("select bte from BAMTargetEntry bte where bte.serviceName like :serviceName%").setParameter("serviceName", qname.toString()).getResultList(); |
63 | |
} |
64 | |
|
65 | |
public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) { |
66 | 0 | QName qname = new QName(objDef.getServiceNamespace(), objDef.getClassName()); |
67 | 0 | return (List<BAMTargetEntry>) entityManager.createQuery("select bte from BAMTargetEntry bte where bte.serviceName like :serviceName% and bte.methodName = :methodName").setParameter("serviceName", qname.toString()).setParameter("methodName", methodName).getResultList(); |
68 | |
} |
69 | |
|
70 | |
} |