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 public class UserOptionsServiceImpl implements UserOptionsService {
32
33 private UserOptionsDAO userOptionsDAO;
34 private ReloadActionListDAO reloadActionListDAO;
35
36 private static final Properties defaultProperties = new Properties();
37
38 static {
39 defaultProperties.setProperty(KewApiConstants.EMAIL_RMNDR_KEY, KewApiConstants.EMAIL_RMNDR_WEEK_VAL);
40 }
41
42 private Long getNewOptionIdForActionList() {
43 return getUserOptionsDAO().getNewOptionIdForActionList();
44 }
45
46 public List<UserOptions> findByUserQualified(String principalId, String likeString) {
47 if ((principalId == null)) {
48 return new ArrayList<UserOptions>(0);
49 }
50 return this.getUserOptionsDAO().findByUserQualified(principalId, likeString);
51 }
52
53 public UserOptions findByOptionId(String optionId, String principalId) {
54 if (optionId == null || "".equals(optionId) || principalId == null || "".equals(principalId)) {
55 return null;
56 }
57 return this.getUserOptionsDAO().findByOptionId(optionId, principalId);
58 }
59
60 public Collection<UserOptions> findByOptionValue(String optionId, String optionValue){
61 return this.getUserOptionsDAO().findByOptionValue(optionId, optionValue);
62 }
63
64 public Collection<UserOptions> findByWorkflowUser(String principalId) {
65 return this.getUserOptionsDAO().findByWorkflowUser(principalId);
66 }
67
68 public void save(UserOptions userOptions) {
69 this.getUserOptionsDAO().save(userOptions);
70 }
71
72
73
74
75
76
77 public void save(String principalId, Map<String,String> optionsMap) {
78
79 if (optionsMap != null && optionsMap.size() > 0) {
80 List<UserOptions> toSave = new ArrayList<UserOptions>();
81 for (Entry<String, String> entry : optionsMap.entrySet()) {
82 UserOptions option = findByOptionId(entry.getKey(), principalId);
83 if (option == null) {
84 option = new UserOptions();
85 option.setWorkflowId(principalId);
86 }
87 option.setOptionId(entry.getKey());
88 option.setOptionVal(entry.getValue());
89 toSave.add(option);
90 }
91 getUserOptionsDAO().save(toSave);
92 }
93 }
94
95 public void deleteUserOptions(UserOptions userOptions) {
96 this.getUserOptionsDAO().deleteUserOptions(userOptions);
97 }
98
99 public void save(String principalId, String optionId, String optionValue) {
100 UserOptions option = findByOptionId(optionId, principalId);
101 if (option == null) {
102 option = new UserOptions();
103 option.setWorkflowId(principalId);
104 }
105 option.setOptionId(optionId);
106 option.setOptionVal(optionValue);
107 getUserOptionsDAO().save(option);
108 }
109
110 public boolean refreshActionList(String principalId) {
111 return getReloadActionListDAO().checkAndResetReloadActionListFlag(principalId);
112 }
113
114 public void saveRefreshUserOption(String principalId) {
115 getReloadActionListDAO().setReloadActionListFlag(principalId);
116 }
117
118 public UserOptionsDAO getUserOptionsDAO() {
119 return userOptionsDAO;
120 }
121
122 public void setUserOptionsDAO(UserOptionsDAO optionsDAO) {
123 userOptionsDAO = optionsDAO;
124 }
125
126
127
128
129 public ReloadActionListDAO getReloadActionListDAO() {
130 return this.reloadActionListDAO;
131 }
132
133 public void setReloadActionListDAO(ReloadActionListDAO rald) {
134 this.reloadActionListDAO = rald;
135 }
136
137 }