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.util.ArrayList;
020: import java.util.Iterator;
021: import java.util.List;
022:
023: import edu.iu.uis.eden.WorkflowPersistable;
024: import edu.iu.uis.eden.util.Utilities;
025:
026: /**
027: * An extension of a {@link RuleBaseValues}. Provides attribute-specific data
028: * extensions to the rule for a particular {@link RuleAttribute}. Contains
029: * a List of {@link RuleExtensionValue}s.
030: *
031: * @see RuleBaseValues
032: * @see RuleAttribute
033: * @see RuleExtensionValue
034: *
035: * @author rkirkend
036: * @author jhopf
037: * @author ahamid
038: */
039: public class RuleExtension implements WorkflowPersistable {
040:
041: private static final long serialVersionUID = 8178135296413950516L;
042:
043: private Long ruleExtensionId;
044:
045: private Long ruleTemplateAttributeId;
046:
047: private Long ruleBaseValuesId;
048:
049: private Integer lockVerNbr;
050:
051: private RuleBaseValues ruleBaseValues;
052:
053: private RuleTemplateAttribute ruleTemplateAttribute;
054:
055: private List<RuleExtensionValue> extensionValues;
056:
057: public RuleExtension() {
058: extensionValues = new ArrayList<RuleExtensionValue>();
059: }
060:
061: public List<RuleExtensionValue> getExtensionValues() {
062: return extensionValues;
063: }
064:
065: public void setExtensionValues(
066: List<RuleExtensionValue> extensionValues) {
067: this .extensionValues = extensionValues;
068: }
069:
070: public RuleTemplateAttribute getRuleTemplateAttribute() {
071: return ruleTemplateAttribute;
072: }
073:
074: public void setRuleTemplateAttribute(
075: RuleTemplateAttribute ruleTemplateAttribute) {
076: this .ruleTemplateAttribute = ruleTemplateAttribute;
077: }
078:
079: public RuleExtensionValue getRuleExtensionValue(int index) {
080: while (getExtensionValues().size() <= index) {
081: getExtensionValues().add(new RuleExtensionValue());
082: }
083: return (RuleExtensionValue) getExtensionValues().get(index);
084: }
085:
086: public RuleBaseValues getRuleBaseValues() {
087: return ruleBaseValues;
088: }
089:
090: public void setRuleBaseValues(RuleBaseValues ruleBaseValues) {
091: this .ruleBaseValues = ruleBaseValues;
092: }
093:
094: public Integer getLockVerNbr() {
095: return lockVerNbr;
096: }
097:
098: public void setLockVerNbr(Integer lockVerNbr) {
099: this .lockVerNbr = lockVerNbr;
100: }
101:
102: public Long getRuleBaseValuesId() {
103: return ruleBaseValuesId;
104: }
105:
106: public void setRuleBaseValuesId(Long ruleBaseValuesId) {
107: this .ruleBaseValuesId = ruleBaseValuesId;
108: }
109:
110: public Long getRuleExtensionId() {
111: return ruleExtensionId;
112: }
113:
114: public void setRuleExtensionId(Long ruleExtensionId) {
115: this .ruleExtensionId = ruleExtensionId;
116: }
117:
118: public Long getRuleTemplateAttributeId() {
119: return ruleTemplateAttributeId;
120: }
121:
122: public void setRuleTemplateAttributeId(Long ruleTemplateAttributeId) {
123: this .ruleTemplateAttributeId = ruleTemplateAttributeId;
124: }
125:
126: public Object copy(boolean preserveKeys) {
127: RuleExtension ruleExtensionClone = new RuleExtension();
128: if (preserveKeys && (ruleExtensionId != null)) {
129: ruleExtensionClone.setRuleExtensionId(new Long(
130: ruleExtensionId.longValue()));
131: }
132: if ((extensionValues != null) && !extensionValues.isEmpty()) {
133: List extensionValueList = new ArrayList();
134:
135: for (Iterator i = extensionValues.iterator(); i.hasNext();) {
136: RuleExtensionValue ruleExtensionValue = (RuleExtensionValue) i
137: .next();
138: RuleExtensionValue ruleExtensionValueCopy = (RuleExtensionValue) ruleExtensionValue
139: .copy(preserveKeys);
140: ruleExtensionValueCopy.setExtension(ruleExtensionClone);
141: extensionValueList.add(ruleExtensionValueCopy);
142: }
143: ruleExtensionClone.setExtensionValues(extensionValueList);
144: }
145:
146: // if(ruleTemplateAttribute != null){
147: // ruleExtensionClone.setRuleTemplateAttribute((RuleTemplateAttribute)ruleTemplateAttribute.copy(preserveKeys));
148: // }
149: ruleExtensionClone
150: .setRuleTemplateAttribute(getRuleTemplateAttribute());
151: ruleExtensionClone
152: .setRuleTemplateAttributeId(getRuleTemplateAttributeId());
153: return ruleExtensionClone;
154: }
155:
156: public boolean equals(Object o) {
157: if (o == null)
158: return false;
159: if (!(o instanceof RuleExtension))
160: return false;
161: RuleExtension pred = (RuleExtension) o;
162: return Utilities.equals(ruleBaseValues.getRuleTemplate(), pred
163: .getRuleBaseValues().getRuleTemplate())
164: && Utilities.equals(ruleTemplateAttribute, pred
165: .getRuleTemplateAttribute())
166: && Utilities.collectionsEquivalent(extensionValues,
167: pred.getExtensionValues());
168: }
169:
170: public String toString() {
171: return "[RuleExtension:" + " ruleExtensionId="
172: + ruleExtensionId + ", ruleTemplateAttributeId="
173: + ruleTemplateAttributeId + ", ruleBaseValuesId="
174: + ruleBaseValuesId + ", ruleBaseValues="
175: + ruleBaseValues + ", ruleTemplateAttribute="
176: + ruleTemplateAttribute + ", extensionValues="
177: + extensionValues + ", lockVerNbr=" + lockVerNbr + "]";
178: }
179: }
|