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