001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.kra.budget.bo;
017:
018: import java.util.LinkedHashMap;
019:
020: import org.apache.commons.lang.StringUtils;
021: import org.kuali.core.bo.PersistableBusinessObjectBase;
022: import org.kuali.kfs.KFSPropertyConstants;
023:
024: /**
025: * Account Business Object
026: */
027: public class BudgetTask extends PersistableBusinessObjectBase implements
028: Comparable {
029:
030: private static final long serialVersionUID = 2905826718156063909L;
031: private String documentNumber;
032: private Integer budgetTaskSequenceNumber;
033: private String budgetTaskName;
034: private boolean budgetTaskOnCampus;
035:
036: public BudgetTask() {
037: super ();
038: }
039:
040: public BudgetTask(String documentNumber,
041: Integer budgetTaskSequenceNumber) {
042: this ();
043: this .documentNumber = documentNumber;
044: this .budgetTaskSequenceNumber = budgetTaskSequenceNumber;
045: }
046:
047: public BudgetTask(BudgetTask template) {
048: this .documentNumber = template.getDocumentNumber();
049: this .budgetTaskSequenceNumber = template
050: .getBudgetTaskSequenceNumber();
051: this .budgetTaskName = template.getBudgetTaskName();
052: this .setBudgetTaskOnCampus(template.isBudgetTaskOnCampus());
053: }
054:
055: /**
056: * @return Returns the documentNumber.
057: */
058: public String getDocumentNumber() {
059: return documentNumber;
060: }
061:
062: /**
063: * @param documentNumber The documentNumber to set.
064: */
065: public void setDocumentNumber(String documentNumber) {
066: this .documentNumber = documentNumber;
067: }
068:
069: /**
070: * @return Returns the budgetTaskName.
071: */
072: public String getBudgetTaskName() {
073: return budgetTaskName;
074: }
075:
076: /**
077: * @param budgetTaskName The budgetTaskName to set.
078: */
079: public void setBudgetTaskName(String budgetTaskName) {
080: this .budgetTaskName = budgetTaskName;
081: }
082:
083: /**
084: * @param budgetTaskOnCampus
085: */
086: public void setBudgetTaskOnCampus(boolean budgetTaskOnCampus) {
087: this .budgetTaskOnCampus = budgetTaskOnCampus;
088: }
089:
090: /**
091: * @return Returns boolean saying whether or not a budgetTask is on campus.
092: */
093: public boolean isBudgetTaskOnCampus() {
094: return budgetTaskOnCampus;
095: }
096:
097: /**
098: * @return Returns the budgetTaskSequenceNumber.
099: */
100: public Integer getBudgetTaskSequenceNumber() {
101: return budgetTaskSequenceNumber;
102: }
103:
104: /**
105: * @param budgetTaskSequenceNumber The budgetTaskSequenceNumber to set.
106: */
107: public void setBudgetTaskSequenceNumber(
108: Integer budgetTaskSequenceNumber) {
109: this .budgetTaskSequenceNumber = budgetTaskSequenceNumber;
110: }
111:
112: /*
113: * (non-Javadoc)
114: *
115: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
116: */
117: protected LinkedHashMap toStringMapper() {
118: LinkedHashMap m = new LinkedHashMap();
119: m
120: .put(KFSPropertyConstants.DOCUMENT_NUMBER,
121: this .documentNumber);
122: m
123: .put("budgetTaskSequenceNumber",
124: this .budgetTaskSequenceNumber);
125: return m;
126:
127: }
128:
129: /**
130: * Implementing equals since I need contains to behave reasonably in a hashed datastructure.
131: *
132: * @see java.lang.Object#equals(java.lang.Object)
133: */
134: public boolean equals(Object obj) {
135: boolean equal = false;
136:
137: if (obj != null) {
138: if (this .getClass().equals(obj.getClass())) {
139: BudgetTask other = (BudgetTask) obj;
140:
141: if (this .getDocumentNumber().equals(
142: other.getDocumentNumber())
143: && this .getBudgetTaskSequenceNumber().equals(
144: other.getBudgetTaskSequenceNumber())
145: && StringUtils.equals(getBudgetTaskName(),
146: other.getBudgetTaskName())) {
147: equal = true;
148: }
149: }
150: }
151:
152: return equal;
153: }
154:
155: /**
156: * Calcluates hashCode based on current values of documentNumber, budgetTaskSequenceNumber and budgetTaskName fields. Somewhat
157: * dangerous, since those fields are mutable, but I don't expect people to be editing those values directly for Tasks stored in
158: * hashed datastructures. (this is based on Account.hashCode()) - TAD
159: *
160: * @see java.lang.Object#hashCode()
161: */
162: public int hashCode() {
163: String hashString = getDocumentNumber() + "|"
164: + getBudgetTaskSequenceNumber() + "|"
165: + getBudgetTaskName();
166:
167: return hashString.hashCode();
168: }
169:
170: /**
171: * @see java.lang.Comparable#compareTo(java.lang.Object)
172: */
173: public int compareTo(Object o) {
174: return this .getBudgetTaskSequenceNumber().compareTo(
175: ((BudgetTask) o).getBudgetTaskSequenceNumber());
176: }
177: }
|