1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.kew.rule.dao.impl; |
18 |
|
|
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import javax.persistence.EntityManager; |
22 |
|
import javax.persistence.PersistenceContext; |
23 |
|
|
24 |
|
import org.apache.commons.lang.StringUtils; |
25 |
|
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
26 |
|
import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; |
27 |
|
import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; |
28 |
|
import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform; |
29 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
30 |
|
import org.kuali.rice.core.util.RiceConstants; |
31 |
|
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
32 |
|
import org.kuali.rice.kew.rule.dao.RuleTemplateDAO; |
33 |
|
|
34 |
|
|
35 |
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 16 |
Complexity Density: 0.64 |
|
36 |
|
public class RuleTemplateDAOJpaImpl implements RuleTemplateDAO { |
37 |
|
|
38 |
|
@PersistenceContext(unitName="kew-unit") |
39 |
|
private EntityManager entityManager; |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0
|
public List findAll() {... |
42 |
0
|
return entityManager.createNamedQuery("findAllOrderedByName").getResultList(); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
45 |
0
|
public RuleTemplate findByRuleTemplateName(String ruleTemplateName) {... |
46 |
0
|
if (StringUtils.isBlank(ruleTemplateName)) { |
47 |
0
|
return null; |
48 |
|
} |
49 |
|
|
50 |
0
|
Criteria crit = new Criteria(RuleTemplate.class.getName()); |
51 |
0
|
crit.eq("name", ruleTemplateName); |
52 |
0
|
crit.orderBy("ruleTemplateId", false); |
53 |
|
|
54 |
0
|
List ruleTemplates = new QueryByCriteria(entityManager, crit).toQuery().getResultList(); |
55 |
|
|
56 |
0
|
if(ruleTemplates==null||ruleTemplates.size()==0){ |
57 |
0
|
return null; |
58 |
|
} |
59 |
0
|
return (RuleTemplate) ruleTemplates.get(0); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
62 |
0
|
public List findByRuleTemplate(RuleTemplate ruleTemplate) {... |
63 |
0
|
Criteria crit = new Criteria(RuleTemplate.class.getName()); |
64 |
0
|
if (ruleTemplate.getName() != null) { |
65 |
0
|
crit.rawJpql("UPPER(RULE_TMPL_NM) like '"+ ruleTemplate.getName().toUpperCase() +"'"); |
66 |
|
} |
67 |
0
|
if (ruleTemplate.getDescription() != null) { |
68 |
0
|
crit.rawJpql("UPPER(RULE_TMPL_DESC) like '"+ ruleTemplate.getDescription().toUpperCase()+"'"); |
69 |
|
} |
70 |
0
|
return new QueryByCriteria(entityManager, crit).toQuery().getResultList(); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
0
|
public void delete(Long ruleTemplateId) {... |
74 |
0
|
entityManager.remove(findByRuleTemplateId(ruleTemplateId)); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0
|
public RuleTemplate findByRuleTemplateId(Long ruleTemplateId) {... |
78 |
0
|
return entityManager.find(RuleTemplate.class, ruleTemplateId); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
81 |
0
|
public void save(RuleTemplate ruleTemplate) {... |
82 |
0
|
if(ruleTemplate.getRuleTemplateId()==null){ |
83 |
0
|
entityManager.persist(ruleTemplate); |
84 |
|
}else{ |
85 |
0
|
OrmUtils.merge(entityManager, ruleTemplate); |
86 |
|
} |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0
|
public Long getNextRuleTemplateId() {... |
90 |
0
|
return getPlatform().getNextValSQL("KREW_RTE_TMPL_S", entityManager); |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0
|
protected DatabasePlatform getPlatform() {... |
94 |
0
|
return (DatabasePlatform)GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0
|
public EntityManager getEntityManager() {... |
98 |
0
|
return this.entityManager; |
99 |
|
} |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
0
|
public void setEntityManager(EntityManager entityManager) {... |
102 |
0
|
this.entityManager = entityManager; |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
} |