001: /*
002: * Copyright 2005-2006 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 edu.iu.uis.eden.routetemplate;
018:
019: import java.io.Serializable;
020: import java.util.ArrayList;
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.List;
024: import java.util.Map;
025:
026: import edu.iu.uis.eden.routetemplate.web.WebRuleBaseValues;
027:
028: /**
029: * A collection of rules uses by the web tier for rendering and interacting
030: * with the rules GUI.
031: *
032: * @see WebRuleBaseValues
033: *
034: * @author ewestfal
035: */
036: public class MyRules2 implements Serializable {
037:
038: private static final long serialVersionUID = -5405951937698910224L;
039: private List rules = new ArrayList();
040:
041: public void addRule(WebRuleBaseValues rule) {
042: addRule(rule, new Integer(rules.size()));
043: }
044:
045: public void addRule(WebRuleBaseValues rule, Integer counter) {
046: boolean alreadyAdded = false;
047: int location = 0;
048: for (Iterator ruleIter = getRules().iterator(); ruleIter
049: .hasNext();) {
050: WebRuleBaseValues ruleRow = (WebRuleBaseValues) ruleIter
051: .next();
052:
053: if (counter != null && counter.intValue() == location) {
054: ruleRow.setActiveInd(rule.getActiveInd());
055: ruleRow.setCurrentInd(rule.getCurrentInd());
056: ruleRow.setLockVerNbr(rule.getLockVerNbr());
057: ruleRow.setDescription(rule.getDescription());
058: ruleRow.setIgnorePrevious(rule.getIgnorePrevious());
059: ruleRow.setDocTypeName(rule.getDocTypeName());
060: ruleRow.setFromDate(rule.getFromDate());
061: ruleRow.setToDate(rule.getToDate());
062: ruleRow.setRuleTemplate(rule.getRuleTemplate());
063: ruleRow.setVersionNbr(rule.getVersionNbr());
064: ruleRow.setResponsibilities(rule.getResponsibilities());
065: ruleRow.setRuleExtensions(rule.getRuleExtensions());
066:
067: alreadyAdded = true;
068: }
069: location++;
070: }
071: if (!alreadyAdded) {
072: getRules().add(rule);
073: }
074: }
075:
076: public WebRuleBaseValues getRule(int index) {
077: while (getRules().size() <= index) {
078: addRule(new WebRuleBaseValues());
079: }
080: return (WebRuleBaseValues) getRules().get(index);
081: }
082:
083: public List getRules() {
084: return rules;
085: }
086:
087: public void setRules(List rules) {
088: this .rules = rules;
089: }
090:
091: public int getSize() {
092: return getRules().size();
093: }
094:
095: public static class MyRule implements Serializable {
096:
097: private static final long serialVersionUID = 1531326501498462883L;
098: private RuleBaseValues rule;
099: private List ruleTemplateAttributes = new ArrayList();
100: private Map fields = new HashMap();
101: private List roles = new ArrayList();
102: private String fromDate;
103: private String toDate;
104:
105: public MyRule() {
106: this (new RuleBaseValues());
107: }
108:
109: public MyRule(RuleBaseValues rule) {
110: this .rule = rule;
111: }
112:
113: public Map getFields() {
114: return fields;
115: }
116:
117: public void setFields(Map fields) {
118: this .fields = fields;
119: }
120:
121: public RuleBaseValues getRule() {
122: return rule;
123: }
124:
125: public void setRule(RuleBaseValues rule) {
126: this .rule = rule;
127: }
128:
129: public List getRuleTemplateAttributes() {
130: return ruleTemplateAttributes;
131: }
132:
133: public void setRuleTemplateAttributes(
134: List ruleTemplateAttributes) {
135: this .ruleTemplateAttributes = ruleTemplateAttributes;
136: }
137:
138: public List getRoles() {
139: return roles;
140: }
141:
142: public void setRoles(List roles) {
143: this .roles = roles;
144: }
145:
146: public String getFromDate() {
147: return fromDate;
148: }
149:
150: public void setFromDate(String fromDate) {
151: this .fromDate = fromDate;
152: }
153:
154: public String getToDate() {
155: return toDate;
156: }
157:
158: public void setToDate(String toDate) {
159: this.toDate = toDate;
160: }
161: }
162:
163: }
|