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