1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.useroptions; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collection; |
20 | |
import java.util.List; |
21 | |
import java.util.Map; |
22 | |
import java.util.Properties; |
23 | |
import java.util.Map.Entry; |
24 | |
|
25 | |
import org.kuali.rice.kew.useroptions.dao.ReloadActionListDAO; |
26 | |
import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO; |
27 | |
import org.kuali.rice.kew.api.KewApiConstants; |
28 | |
import org.springframework.transaction.annotation.Transactional; |
29 | |
|
30 | |
@Transactional |
31 | 0 | public class UserOptionsServiceImpl implements UserOptionsService { |
32 | |
|
33 | |
private UserOptionsDAO userOptionsDAO; |
34 | |
private ReloadActionListDAO reloadActionListDAO; |
35 | |
|
36 | 0 | private static final Properties defaultProperties = new Properties(); |
37 | |
|
38 | |
static { |
39 | 0 | defaultProperties.setProperty(KewApiConstants.EMAIL_RMNDR_KEY, KewApiConstants.EMAIL_RMNDR_WEEK_VAL); |
40 | 0 | } |
41 | |
|
42 | |
private Long getNewOptionIdForActionList() { |
43 | 0 | return getUserOptionsDAO().getNewOptionIdForActionList(); |
44 | |
} |
45 | |
|
46 | |
public List<UserOptions> findByUserQualified(String principalId, String likeString) { |
47 | 0 | if ((principalId == null)) { |
48 | 0 | return new ArrayList<UserOptions>(0); |
49 | |
} |
50 | 0 | return this.getUserOptionsDAO().findByUserQualified(principalId, likeString); |
51 | |
} |
52 | |
|
53 | |
public UserOptions findByOptionId(String optionId, String principalId) { |
54 | 0 | if (optionId == null || "".equals(optionId) || principalId == null || "".equals(principalId)) { |
55 | 0 | return null; |
56 | |
} |
57 | 0 | return this.getUserOptionsDAO().findByOptionId(optionId, principalId); |
58 | |
} |
59 | |
|
60 | |
public Collection<UserOptions> findByOptionValue(String optionId, String optionValue){ |
61 | 0 | return this.getUserOptionsDAO().findByOptionValue(optionId, optionValue); |
62 | |
} |
63 | |
|
64 | |
public Collection<UserOptions> findByWorkflowUser(String principalId) { |
65 | 0 | return this.getUserOptionsDAO().findByWorkflowUser(principalId); |
66 | |
} |
67 | |
|
68 | |
public void save(UserOptions userOptions) { |
69 | 0 | this.getUserOptionsDAO().save(userOptions); |
70 | 0 | } |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
public void save(String principalId, Map<String,String> optionsMap) { |
78 | |
|
79 | 0 | if (optionsMap != null && optionsMap.size() > 0) { |
80 | 0 | List<UserOptions> toSave = new ArrayList<UserOptions>(); |
81 | 0 | for (Entry<String, String> entry : optionsMap.entrySet()) { |
82 | 0 | UserOptions option = findByOptionId(entry.getKey(), principalId); |
83 | 0 | if (option == null) { |
84 | 0 | option = new UserOptions(); |
85 | 0 | option.setWorkflowId(principalId); |
86 | |
} |
87 | 0 | option.setOptionId(entry.getKey()); |
88 | 0 | option.setOptionVal(entry.getValue()); |
89 | 0 | toSave.add(option); |
90 | 0 | } |
91 | 0 | getUserOptionsDAO().save(toSave); |
92 | |
} |
93 | 0 | } |
94 | |
|
95 | |
public void deleteUserOptions(UserOptions userOptions) { |
96 | 0 | this.getUserOptionsDAO().deleteUserOptions(userOptions); |
97 | 0 | } |
98 | |
|
99 | |
public void save(String principalId, String optionId, String optionValue) { |
100 | 0 | UserOptions option = findByOptionId(optionId, principalId); |
101 | 0 | if (option == null) { |
102 | 0 | option = new UserOptions(); |
103 | 0 | option.setWorkflowId(principalId); |
104 | |
} |
105 | 0 | option.setOptionId(optionId); |
106 | 0 | option.setOptionVal(optionValue); |
107 | 0 | getUserOptionsDAO().save(option); |
108 | 0 | } |
109 | |
|
110 | |
public boolean refreshActionList(String principalId) { |
111 | 0 | return getReloadActionListDAO().checkAndResetReloadActionListFlag(principalId); |
112 | |
} |
113 | |
|
114 | |
public void saveRefreshUserOption(String principalId) { |
115 | 0 | getReloadActionListDAO().setReloadActionListFlag(principalId); |
116 | 0 | } |
117 | |
|
118 | |
public UserOptionsDAO getUserOptionsDAO() { |
119 | 0 | return userOptionsDAO; |
120 | |
} |
121 | |
|
122 | |
public void setUserOptionsDAO(UserOptionsDAO optionsDAO) { |
123 | 0 | userOptionsDAO = optionsDAO; |
124 | 0 | } |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public ReloadActionListDAO getReloadActionListDAO() { |
130 | 0 | return this.reloadActionListDAO; |
131 | |
} |
132 | |
|
133 | |
public void setReloadActionListDAO(ReloadActionListDAO rald) { |
134 | 0 | this.reloadActionListDAO = rald; |
135 | 0 | } |
136 | |
|
137 | |
} |