1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.impl.style;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.ojb.broker.query.Criteria;
22 import org.apache.ojb.broker.query.QueryByCriteria;
23 import org.kuali.rice.coreservice.impl.style.StyleBo;
24 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
25
26
27
28
29
30
31
32 public class StyleDaoOjb extends PersistenceBrokerDaoSupport implements StyleDao {
33
34 @Override
35 public void saveStyle(StyleBo styleData) {
36 if (styleData == null) {
37 return;
38 }
39 this.getPersistenceBrokerTemplate().store(styleData);
40 }
41
42 @Override
43 public StyleBo getStyle(String styleName) {
44 if (styleName == null) {
45 return null;
46 }
47 Criteria criteria = new Criteria();
48 criteria.addEqualTo("name", styleName);
49 criteria.addEqualTo("active", Boolean.TRUE);
50 return (StyleBo) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(StyleBo.class, criteria));
51 }
52
53 @Override
54 public List<String> getAllStyleNames() {
55 Criteria criteria = new Criteria();
56 criteria.addEqualTo("active", Boolean.TRUE);
57 List<StyleBo> styles = (List<StyleBo>)this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(StyleBo.class, criteria));
58 List<String> styleNames = new ArrayList<String>();
59 for (StyleBo style : styles) {
60 styleNames.add(style.getName());
61 }
62 return styleNames;
63 }
64
65 }