01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.routetemplate;
18:
19: import java.io.Serializable;
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: /**
25: * A collection of rules uses by the web tier for rendering and interacting
26: * with the rules GUI.
27: *
28: * @see RuleBaseValues
29: *
30: * @author jhopf
31: * @author rkirkend
32: */
33: public class MyRules implements Serializable {
34:
35: private static final long serialVersionUID = 9178574188141418571L;
36: private List rules;
37:
38: public MyRules() {
39: rules = new ArrayList();
40: }
41:
42: public void addRule(RuleBaseValues rule, Integer counter) {
43: boolean alreadyAdded = false;
44: int location = 0;
45: for (Iterator ruleIter = getRules().iterator(); ruleIter
46: .hasNext();) {
47: RuleBaseValues ruleRow = (RuleBaseValues) ruleIter.next();
48:
49: if (counter != null && counter.intValue() == location) {
50: ruleRow.setActiveInd(rule.getActiveInd());
51: ruleRow.setCurrentInd(rule.getCurrentInd());
52: ruleRow.setLockVerNbr(rule.getLockVerNbr());
53: ruleRow.setDescription(rule.getDescription());
54: ruleRow.setIgnorePrevious(rule.getIgnorePrevious());
55: ruleRow.setDocTypeName(rule.getDocTypeName());
56: ruleRow.setFromDate(rule.getFromDate());
57: ruleRow.setToDate(rule.getToDate());
58: ruleRow.setRuleTemplate(rule.getRuleTemplate());
59: ruleRow.setVersionNbr(rule.getVersionNbr());
60: ruleRow.setResponsibilities(rule.getResponsibilities());
61: ruleRow.setRuleExtensions(rule.getRuleExtensions());
62:
63: alreadyAdded = true;
64: }
65: location++;
66: }
67: if (!alreadyAdded) {
68: getRules().add(rule);
69: }
70: }
71:
72: public RuleBaseValues getRule(int index) {
73: while (getRules().size() <= index) {
74: RuleBaseValues rule = new RuleBaseValues();
75: // rule.setPreviousVersion(new RuleBaseValues());
76: getRules().add(rule);
77: }
78: return (RuleBaseValues) getRules().get(index);
79: }
80:
81: public List getRules() {
82: return rules;
83: }
84:
85: public void setRules(List rules) {
86: this.rules = rules;
87: }
88: }
|