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