1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package mocks;
18
19 import java.io.InputStream;
20 import java.sql.Timestamp;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.jdom.Element;
29 import org.kuali.rice.core.api.impex.ExportDataSet;
30 import org.kuali.rice.kew.doctype.bo.DocumentType;
31 import org.kuali.rice.kew.rule.RuleBaseValues;
32 import org.kuali.rice.kew.rule.RuleDelegation;
33 import org.kuali.rice.kew.rule.RuleResponsibility;
34 import org.kuali.rice.kew.rule.service.RuleService;
35 import org.kuali.rice.kew.util.KEWConstants;
36 import org.kuali.rice.kim.bo.entity.KimPrincipal;
37
38
39
40 public class MockRuleServiceImpl implements RuleService {
41
42 Map rules = new HashMap();
43 Map<String, RuleBaseValues> rulesByName = new HashMap<String, RuleBaseValues>();
44 Map responsibilitiesByKey = new HashMap();
45 Map responsibilitiesById = new HashMap();
46 Map responsibilitiesByReviewer = new HashMap();
47 Map rulesByRouteHeaderId = new HashMap();
48
49 public RuleBaseValues getParentRule(Long ruleBaseValuesId) {
50 return null;
51 }
52 public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType, boolean ignoreCache) {
53 return null;
54 }
55 public Long isLockedForRouting(Long currentRuleBaseValuesId) {
56 return null;
57 }
58 public Long routeRuleWithDelegate(Long routeHeaderId, RuleBaseValues parentRule, RuleBaseValues delegateRule, KimPrincipal principal, String annotation, boolean blanketApprove) throws Exception {
59 return null;
60 }
61 public List search(String docTypeName, Long ruleId, Long ruleTemplateId, String ruleDescription, String workgroupId, String principalId, Boolean delegateRule, Boolean activeInd, Map extensionValues, String workflowIdDirective) {
62 return null;
63 }
64 public List search(String docTypeName, String ruleTemplateName, String ruleDescription, String groupId, String principalId, Boolean workgroupMember, Boolean delegateRule, Boolean activeInd, Map extensionValues, Collection<String> actionRequestCodes) {
65 return null;
66 }
67 public void notifyCacheOfRuleChange(RuleBaseValues rule, DocumentType documentType) {
68 }
69
70
71
72 public void flushRuleCache() {
73
74
75 }
76 public RuleBaseValues getRuleByName(String name) {
77 return rulesByName.get(name);
78 }
79 public void addRule(RuleBaseValues rule) {
80 rules.put(rule.getRuleBaseValuesId(), rule);
81 if (rule.getName() != null) {
82 rulesByName.put(rule.getName(), rule);
83 }
84
85 List routeHeaderList = null;
86 if(rulesByRouteHeaderId.get(rule.getRouteHeaderId()) != null){
87 routeHeaderList = (List)rulesByRouteHeaderId.get(rule.getRouteHeaderId());
88 } else {
89 routeHeaderList = new ArrayList();
90 }
91 routeHeaderList.add(rule);
92 rulesByRouteHeaderId.put(rule.getRouteHeaderId(), routeHeaderList);
93
94 for (Iterator iter = rule.getResponsibilities().iterator(); iter.hasNext();) {
95 RuleResponsibility resp = (RuleResponsibility) iter.next();
96 responsibilitiesByKey.put(resp.getRuleResponsibilityKey(), resp);
97 responsibilitiesById.put(resp.getResponsibilityId(), resp);
98
99 List respList = null;
100 if(responsibilitiesByReviewer.get(resp.getRuleResponsibilityName()) != null){
101 respList = (List)responsibilitiesByReviewer.get(resp.getRuleResponsibilityName());
102 } else {
103 respList = new ArrayList();
104 }
105 respList.add(resp);
106 responsibilitiesByReviewer.put(resp.getRuleResponsibilityName(), respList);
107 }
108 }
109
110 public void delete(Long ruleBaseValuesId) {
111 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
112 }
113
114 public RuleBaseValues findRuleBaseValuesByName(String name) {
115 return null;
116 }
117
118 public RuleBaseValues findRuleBaseValuesById(Long ruleBaseValuesId) {
119 return (RuleBaseValues) rules.get(ruleBaseValuesId);
120 }
121
122 public List search(String docTypeName, Long ruleTemplateId, Long workgroupId, String workflowId, Boolean delegateRule, Boolean activeInd, Map extensionValues) {
123 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
124 }
125
126 public RuleResponsibility findRuleResponsibility(Long responsibilityId) {
127 return (RuleResponsibility) responsibilitiesById.get(responsibilityId);
128 }
129
130 public void deleteRuleResponsibilityById(Long ruleResponsibilityId) {
131 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
132 }
133
134 public RuleResponsibility findByRuleResponsibilityId(Long ruleResponsibilityId) {
135 return (RuleResponsibility) responsibilitiesByKey.get(ruleResponsibilityId);
136 }
137
138 public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType) {
139 List ruleBaseValues = new ArrayList();
140
141 for (Iterator iter = rules.values().iterator(); iter.hasNext();) {
142 RuleBaseValues rule = (RuleBaseValues) iter.next();
143 if(rule.getRuleTemplate().getName().equals(ruleTemplateName) && rule.getDocTypeName().equals(documentType)){
144 ruleBaseValues.add(rule);
145 }
146 }
147 return ruleBaseValues;
148 }
149
150 public List findByRouteHeaderId(Long routeHeaderId) {
151 return (List) rulesByRouteHeaderId.get(routeHeaderId);
152 }
153
154 public void makeCurrent(Long routeHeaderId) {
155 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
156 }
157
158 public void makeCurrent(RuleBaseValues rule, boolean isRetroactiveUpdatePermitted) {
159 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
160 }
161
162 public void makeCurrent(RuleDelegation ruleDelegation, boolean isRetroactiveUpdatePermitted) {
163 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
164 }
165
166 public List findRuleBaseValuesByResponsibilityReviewer(String reviewerName, String type) {
167 List rules = new ArrayList();
168 for (Iterator iter = ((List) responsibilitiesByReviewer.get(reviewerName)).iterator(); iter.hasNext();) {
169 RuleResponsibility resp = (RuleResponsibility) iter.next();
170 if(resp.getRuleResponsibilityType().equals(type)){
171 rules.add(resp.getRuleBaseValues());
172 }
173 }
174 return rules;
175 }
176
177 public List fetchAllRules(boolean currentRules) {
178 return new ArrayList(rules.values());
179 }
180
181 public void saveDeactivationDate(RuleBaseValues rule) {
182
183 }
184
185 public void validate2(RuleBaseValues ruleBaseValues, RuleDelegation ruleDelegation, List errors) throws Exception {
186 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
187 }
188
189 public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType, Timestamp effectiveDate) {
190 return null;
191 }
192 public RuleBaseValues findDefaultRuleByRuleTemplateId(Long ruleTemplateId) {
193 return null;
194 }
195
196 public void save2(RuleBaseValues ruleBaseValues) throws Exception {
197 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
198 }
199
200 public void loadXml(InputStream inputStream, String principalId) {
201 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
202 }
203 public Element export(ExportDataSet dataSet) {
204 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
205 }
206 @Override
207 public boolean supportPrettyPrint() {
208 return true;
209 }
210 public void notifyCacheOfDocumentTypeChange(DocumentType documentType) {
211
212 }
213 public String getRuleDocmentTypeName(List rules) {
214 return KEWConstants.DEFAULT_RULE_DOCUMENT_NAME;
215 }
216
217
218
219
220
221 public List findRuleBaseValuesByResponsibilityReviewerTemplateDoc(String ruleTemplateName, String documentType, String reviewerName, String type) {
222 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
223 }
224 public Long getDuplicateRuleId(RuleBaseValues rule) {
225 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
226 }
227 public Long findResponsibilityIdForRule(String ruleName,
228 String ruleResponsibilityName, String ruleResponsibilityType) {
229 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
230 }
231 public RuleBaseValues saveRule(RuleBaseValues rule,
232 boolean isRetroactiveUpdatePermitted) {
233 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
234 }
235 public RuleDelegation saveRuleDelegation(RuleDelegation ruleDelegation,
236 boolean isRetroactiveUpdatePermitted) {
237 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
238 }
239 public List<RuleDelegation> saveRuleDelegations(
240 List<RuleDelegation> ruleDelegationsToSave, boolean isRetroactiveUpdatePermitted) {
241 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
242 }
243 public List<RuleBaseValues> saveRules(List<RuleBaseValues> rulesToSave, boolean isRetroactiveUpdatePermitted) {
244 throw new UnsupportedOperationException("not implemented in MockRuleServiceImpl");
245 }
246
247
248
249
250 }