001 /*
002 * Copyright 2005-2007 The Kuali Foundation
003 *
004 *
005 * Licensed under the Educational Community License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.opensource.org/licenses/ecl2.php
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package mocks;
018
019 import java.io.InputStream;
020 import java.sql.Timestamp;
021 import java.util.ArrayList;
022 import java.util.Collection;
023 import java.util.HashMap;
024 import java.util.Iterator;
025 import java.util.List;
026 import java.util.Map;
027
028 import org.jdom.Element;
029 import org.kuali.rice.kew.doctype.bo.DocumentType;
030 import org.kuali.rice.kew.export.ExportDataSet;
031 import org.kuali.rice.kew.identity.Id;
032 import org.kuali.rice.kew.rule.MyRules2;
033 import org.kuali.rice.kew.rule.RuleBaseValues;
034 import org.kuali.rice.kew.rule.RuleDelegation;
035 import org.kuali.rice.kew.rule.RuleResponsibility;
036 import org.kuali.rice.kew.rule.service.RuleService;
037 import org.kuali.rice.kew.util.KEWConstants;
038 import org.kuali.rice.kim.bo.entity.KimPrincipal;
039
040
041
042 public class MockRuleServiceImpl implements RuleService {
043
044 Map rules = new HashMap();
045 Map<String, RuleBaseValues> rulesByName = new HashMap<String, RuleBaseValues>();
046 Map responsibilitiesByKey = new HashMap();
047 Map responsibilitiesById = new HashMap();
048 Map responsibilitiesByReviewer = new HashMap();
049 Map rulesByRouteHeaderId = new HashMap();
050
051 public RuleBaseValues getParentRule(Long ruleBaseValuesId) {
052 return null;
053 }
054 public List fetchAllCurrentRulesForTemplateDocCombination(String ruleTemplateName, String documentType, boolean ignoreCache) {
055 return null;
056 }
057 public Long isLockedForRouting(Long currentRuleBaseValuesId) {
058 return null;
059 }
060 public Long route2(Long routeHeaderId, MyRules2 myRules, KimPrincipal principal, String annotation, boolean blanketApprove) throws Exception {
061 return null;
062 }
063 public Long routeRuleWithDelegate(Long routeHeaderId, RuleBaseValues parentRule, RuleBaseValues delegateRule, KimPrincipal principal, String annotation, boolean blanketApprove) throws Exception {
064 return null;
065 }
066 public List search(String docTypeName, Long ruleId, Long ruleTemplateId, String ruleDescription, String workgroupId, String principalId, Boolean delegateRule, Boolean activeInd, Map extensionValues, String workflowIdDirective) {
067 return null;
068 }
069 public List search(String docTypeName, String ruleTemplateName, String ruleDescription, String groupId, String principalId, Boolean workgroupMember, Boolean delegateRule, Boolean activeInd, Map extensionValues, Collection<String> actionRequestCodes) {
070 return null;
071 }
072 public void notifyCacheOfRuleChange(RuleBaseValues rule, DocumentType documentType) {
073 }
074
075
076
077 public void flushRuleCache() {
078 // TODO ewestfal - THIS METHOD NEEDS JAVADOCS
079
080 }
081 public RuleBaseValues getRuleByName(String name) {
082 return rulesByName.get(name);
083 }
084 public void addRule(RuleBaseValues rule) {
085 rules.put(rule.getRuleBaseValuesId(), rule);
086 if (rule.getName() != null) {
087 rulesByName.put(rule.getName(), rule);
088 }
089
090 List routeHeaderList = null;
091 if(rulesByRouteHeaderId.get(rule.getRouteHeaderId()) != null){
092 routeHeaderList = (List)rulesByRouteHeaderId.get(rule.getRouteHeaderId());
093 } else {
094 routeHeaderList = new ArrayList();
095 }
096 routeHeaderList.add(rule);
097 rulesByRouteHeaderId.put(rule.getRouteHeaderId(), routeHeaderList);
098
099 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 // do anything?
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 * This overridden method ...
229 *
230 * @see org.kuali.rice.kew.rule.service.RuleService#findRuleBaseValuesByResponsibilityReviewerTemplateDoc(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
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 }