1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.useroptions.dao.impl; |
17 | |
|
18 | |
import org.apache.ojb.broker.PersistenceBroker; |
19 | |
import org.apache.ojb.broker.query.Criteria; |
20 | |
import org.apache.ojb.broker.query.QueryByCriteria; |
21 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
22 | |
import org.kuali.rice.core.api.util.RiceConstants; |
23 | |
import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform; |
24 | |
import org.kuali.rice.kew.useroptions.UserOptions; |
25 | |
import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO; |
26 | |
import org.springmodules.orm.ojb.PersistenceBrokerCallback; |
27 | |
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
28 | |
|
29 | |
import java.util.ArrayList; |
30 | |
import java.util.Collection; |
31 | |
import java.util.List; |
32 | |
|
33 | |
|
34 | 0 | public class UserOptionsDAOOjbImpl extends PersistenceBrokerDaoSupport implements UserOptionsDAO { |
35 | |
|
36 | |
public Long getNewOptionIdForActionList() { |
37 | 0 | return (Long)this.getPersistenceBrokerTemplate().execute(new PersistenceBrokerCallback() { |
38 | |
public Object doInPersistenceBroker(PersistenceBroker broker) { |
39 | 0 | return getPlatform().getNextValSQL("KREW_ACTN_LIST_OPTN_S", broker); |
40 | |
} |
41 | |
}); |
42 | |
} |
43 | |
|
44 | |
protected DatabasePlatform getPlatform() { |
45 | 0 | return (DatabasePlatform)GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM); |
46 | |
} |
47 | |
|
48 | |
public List<UserOptions> findByUserQualified(String principalId, String likeString) { |
49 | 0 | Criteria criteria = new Criteria(); |
50 | 0 | criteria.addEqualTo("workflowId", principalId); |
51 | 0 | criteria.addLike("optionId", likeString); |
52 | 0 | return new ArrayList<UserOptions>(this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(UserOptions.class, criteria))); |
53 | |
} |
54 | |
|
55 | |
public void deleteByUserQualified(String principalId, String likeString) { |
56 | 0 | Criteria criteria = new Criteria(); |
57 | 0 | criteria.addEqualTo("workflowId", principalId); |
58 | 0 | criteria.addLike("optionId", likeString); |
59 | 0 | this.getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(UserOptions.class, criteria)); |
60 | 0 | } |
61 | |
|
62 | |
public Collection<UserOptions> findByWorkflowUser(String principalId) { |
63 | 0 | UserOptions userOptions = new UserOptions(); |
64 | 0 | userOptions.setWorkflowId(principalId); |
65 | 0 | return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions)); |
66 | |
} |
67 | |
|
68 | |
public void save(UserOptions userOptions) { |
69 | 0 | this.getPersistenceBrokerTemplate().store(userOptions); |
70 | 0 | } |
71 | |
|
72 | |
public void save(Collection<UserOptions> userOptions) { |
73 | 0 | if (userOptions != null) for (UserOptions option : userOptions) { |
74 | 0 | this.getPersistenceBrokerTemplate().store(option); |
75 | |
} |
76 | 0 | } |
77 | |
|
78 | |
public void deleteUserOptions(UserOptions userOptions) { |
79 | 0 | this.getPersistenceBrokerTemplate().delete(userOptions); |
80 | 0 | } |
81 | |
|
82 | |
public UserOptions findByOptionId(String optionId, String principalId) { |
83 | 0 | UserOptions userOptions = new UserOptions(); |
84 | 0 | userOptions.setOptionId(optionId); |
85 | 0 | userOptions.setWorkflowId(principalId); |
86 | 0 | return (UserOptions) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(userOptions)); |
87 | |
} |
88 | |
|
89 | |
public Collection<UserOptions> findByOptionValue(String optionId, String optionValue) { |
90 | 0 | UserOptions userOptions = new UserOptions(); |
91 | 0 | userOptions.setOptionId(optionId); |
92 | 0 | userOptions.setOptionVal(optionValue); |
93 | 0 | return this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(userOptions)); |
94 | |
} |
95 | |
} |