001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.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/ecl1.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:
030: import edu.iu.uis.eden.EdenConstants;
031: import edu.iu.uis.eden.doctype.DocumentType;
032: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
033: import edu.iu.uis.eden.export.ExportDataSet;
034: import edu.iu.uis.eden.routetemplate.MyRules2;
035: import edu.iu.uis.eden.routetemplate.RuleBaseValues;
036: import edu.iu.uis.eden.routetemplate.RuleDelegation;
037: import edu.iu.uis.eden.routetemplate.RuleResponsibility;
038: import edu.iu.uis.eden.routetemplate.RuleService;
039: import edu.iu.uis.eden.user.UserId;
040: import edu.iu.uis.eden.user.WorkflowUser;
041: import edu.iu.uis.eden.workgroup.GroupId;
042:
043: public class MockRuleServiceImpl implements RuleService {
044:
045: Map rules = new HashMap();
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:
055: public List fetchAllCurrentRulesForTemplateDocCombination(
056: String ruleTemplateName, String documentType,
057: boolean ignoreCache) {
058: return null;
059: }
060:
061: public Long isLockedForRouting(Long currentRuleBaseValuesId) {
062: return null;
063: }
064:
065: public Long route2(Long routeHeaderId, MyRules2 myRules,
066: WorkflowUser user, String annotation, boolean blanketApprove)
067: throws Exception {
068: return null;
069: }
070:
071: public Long routeRuleWithDelegate(Long routeHeaderId,
072: RuleBaseValues parentRule, RuleBaseValues delegateRule,
073: WorkflowUser user, String annotation, boolean blanketApprove)
074: throws Exception {
075: return null;
076: }
077:
078: public List search(String docTypeName, Long ruleId,
079: Long ruleTemplateId, String ruleDescription,
080: Long workgroupId, String workflowId, String roleName,
081: Boolean delegateRule, Boolean activeInd, Map extensionValues) {
082: return null;
083: }
084:
085: public List search(String docTypeName, String ruleTemplateName,
086: String ruleDescription, GroupId workgroupId, UserId userId,
087: String roleName, Boolean workgroupMember,
088: Boolean delegateRule, Boolean activeInd,
089: Map extensionValues, Collection<String> actionRequestCodes)
090: throws EdenUserNotFoundException {
091: return null;
092: }
093:
094: public void notifyCacheOfRuleChange(RuleBaseValues rule,
095: DocumentType documentType) {
096: }
097:
098: public void addRule(RuleBaseValues rule) {
099: rules.put(rule.getRuleBaseValuesId(), rule);
100:
101: List routeHeaderList = null;
102: if (rulesByRouteHeaderId.get(rule.getRouteHeaderId()) != null) {
103: routeHeaderList = (List) rulesByRouteHeaderId.get(rule
104: .getRouteHeaderId());
105: } else {
106: routeHeaderList = new ArrayList();
107: }
108: routeHeaderList.add(rule);
109: rulesByRouteHeaderId.put(rule.getRouteHeaderId(),
110: routeHeaderList);
111:
112: for (Iterator iter = rule.getResponsibilities().iterator(); iter
113: .hasNext();) {
114: RuleResponsibility resp = (RuleResponsibility) iter.next();
115: responsibilitiesByKey.put(resp.getRuleResponsibilityKey(),
116: resp);
117: responsibilitiesById.put(resp.getResponsibilityId(), resp);
118:
119: List respList = null;
120: if (responsibilitiesByReviewer.get(resp
121: .getRuleResponsibilityName()) != null) {
122: respList = (List) responsibilitiesByReviewer.get(resp
123: .getRuleResponsibilityName());
124: } else {
125: respList = new ArrayList();
126: }
127: respList.add(resp);
128: responsibilitiesByReviewer.put(resp
129: .getRuleResponsibilityName(), respList);
130: }
131: }
132:
133: public Long route2(MyRules2 myRules, WorkflowUser user,
134: String annotation) throws Exception {
135: throw new UnsupportedOperationException(
136: "not implemented in MockRuleServiceImpl");
137: }
138:
139: public void delete(Long ruleBaseValuesId) {
140: throw new UnsupportedOperationException(
141: "not implemented in MockRuleServiceImpl");
142: }
143:
144: public RuleBaseValues findRuleBaseValuesById(Long ruleBaseValuesId) {
145: return (RuleBaseValues) rules.get(ruleBaseValuesId);
146: }
147:
148: public List search(String docTypeName, Long ruleTemplateId,
149: Long workgroupId, String workflowId, String roleName,
150: Boolean delegateRule, Boolean activeInd, Map extensionValues) {
151: throw new UnsupportedOperationException(
152: "not implemented in MockRuleServiceImpl");
153: }
154:
155: public RuleResponsibility findRuleResponsibility(
156: Long responsibilityId) {
157: return (RuleResponsibility) responsibilitiesById
158: .get(responsibilityId);
159: }
160:
161: public void deleteRuleResponsibilityById(Long ruleResponsibilityId) {
162: throw new UnsupportedOperationException(
163: "not implemented in MockRuleServiceImpl");
164: }
165:
166: public RuleResponsibility findByRuleResponsibilityId(
167: Long ruleResponsibilityId) {
168: return (RuleResponsibility) responsibilitiesByKey
169: .get(ruleResponsibilityId);
170: }
171:
172: public List fetchAllCurrentRulesForTemplateDocCombination(
173: String ruleTemplateName, String documentType) {
174: List ruleBaseValues = new ArrayList();
175:
176: for (Iterator iter = rules.values().iterator(); iter.hasNext();) {
177: RuleBaseValues rule = (RuleBaseValues) iter.next();
178: if (rule.getRuleTemplate().getName().equals(
179: ruleTemplateName)
180: && rule.getDocTypeName().equals(documentType)) {
181: ruleBaseValues.add(rule);
182: }
183: }
184: return ruleBaseValues;
185: }
186:
187: public List findByRouteHeaderId(Long routeHeaderId) {
188: return (List) rulesByRouteHeaderId.get(routeHeaderId);
189: }
190:
191: public void makeCurrent(Long routeHeaderId)
192: throws EdenUserNotFoundException {
193: throw new UnsupportedOperationException(
194: "not implemented in MockRuleServiceImpl");
195: }
196:
197: public List findRuleBaseValuesByResponsibilityReviewer(
198: String reviewerName, String type) {
199: List rules = new ArrayList();
200: for (Iterator iter = ((List) responsibilitiesByReviewer
201: .get(reviewerName)).iterator(); iter.hasNext();) {
202: RuleResponsibility resp = (RuleResponsibility) iter.next();
203: if (resp.getRuleResponsibilityType().equals(type)) {
204: rules.add(resp.getRuleBaseValues());
205: }
206: }
207: return rules;
208: }
209:
210: public List fetchAllRules(boolean currentRules) {
211: return new ArrayList(rules.values());
212: }
213:
214: public void saveDeactivationDate(RuleBaseValues rule) {
215: // do anything?
216: }
217:
218: public void validate2(RuleBaseValues ruleBaseValues,
219: RuleDelegation ruleDelegation, List errors)
220: throws Exception {
221: throw new UnsupportedOperationException(
222: "not implemented in MockRuleServiceImpl");
223: }
224:
225: public List fetchAllCurrentRulesForTemplateDocCombination(
226: String ruleTemplateName, String documentType,
227: Timestamp effectiveDate) {
228: return null;
229: }
230:
231: public RuleBaseValues findDefaultRuleByRuleTemplateId(
232: Long ruleTemplateId) {
233: return null;
234: }
235:
236: public void save2(RuleBaseValues ruleBaseValues) throws Exception {
237: throw new UnsupportedOperationException(
238: "not implemented in MockRuleServiceImpl");
239: }
240:
241: public void loadXml(InputStream inputStream, WorkflowUser user) {
242: throw new UnsupportedOperationException(
243: "not implemented in MockRuleServiceImpl");
244: }
245:
246: public Element export(ExportDataSet dataSet) {
247: throw new UnsupportedOperationException(
248: "not implemented in MockRuleServiceImpl");
249: }
250:
251: public void notifyCacheOfDocumentTypeChange(
252: DocumentType documentType) {
253:
254: }
255:
256: public String getRuleDocmentTypeName(List rules) {
257: return EdenConstants.DEFAULT_RULE_DOCUMENT_NAME;
258: }
259: }
|