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:
017: package org.kuali.module.kra.routingform.bo;
018:
019: import java.util.ArrayList;
020: import java.util.LinkedHashMap;
021: import java.util.List;
022:
023: import org.kuali.core.bo.PersistableBusinessObjectBase;
024: import org.kuali.kfs.KFSPropertyConstants;
025:
026: /**
027: * Class representing a RoutingFormResearchRiskType.
028: */
029: public class RoutingFormResearchRisk extends
030: PersistableBusinessObjectBase {
031:
032: private String documentNumber;
033: private String researchRiskTypeCode;
034: private String researchRiskDescription;
035: private Integer routingFormResearchRiskStudyNextSequenceNumber;
036:
037: private ResearchRiskType researchRiskType;
038: private RoutingFormResearchRiskStudy newResearchRiskStudy;
039:
040: private List<RoutingFormResearchRiskStudy> researchRiskStudies;
041:
042: /**
043: * Default constructor.
044: */
045: public RoutingFormResearchRisk() {
046: super ();
047: newResearchRiskStudy = new RoutingFormResearchRiskStudy();
048: researchRiskStudies = new ArrayList<RoutingFormResearchRiskStudy>();
049: }
050:
051: public RoutingFormResearchRisk(String documentNumber,
052: ResearchRiskType researchRiskType) {
053: this ();
054: this .documentNumber = documentNumber;
055: this .researchRiskTypeCode = researchRiskType
056: .getResearchRiskTypeCode();
057: this .researchRiskType = researchRiskType;
058: }
059:
060: /**
061: * Gets the documentNumber attribute.
062: *
063: * @return Returns the documentNumber
064: */
065: public String getDocumentNumber() {
066: return documentNumber;
067: }
068:
069: /**
070: * Sets the documentNumber attribute.
071: *
072: * @param documentNumber The documentNumber to set.
073: */
074: public void setDocumentNumber(String documentNumber) {
075: this .documentNumber = documentNumber;
076: }
077:
078: /**
079: * Gets the researchRiskTypeCode attribute.
080: *
081: * @return Returns the researchRiskTypeCode
082: */
083: public String getResearchRiskTypeCode() {
084: return researchRiskTypeCode;
085: }
086:
087: /**
088: * Sets the researchRiskTypeCode attribute.
089: *
090: * @param researchRiskTypeCode The researchRiskTypeCode to set.
091: */
092: public void setResearchRiskTypeCode(String researchRiskTypeCode) {
093: this .researchRiskTypeCode = researchRiskTypeCode;
094: }
095:
096: /**
097: * Gets the researchRiskDescription attribute.
098: *
099: * @return Returns the researchRiskDescription
100: */
101: public String getResearchRiskDescription() {
102: return researchRiskDescription;
103: }
104:
105: /**
106: * Sets the researchRiskDescription attribute.
107: *
108: * @param researchRiskDescription The researchRiskDescription to set.
109: */
110: public void setResearchRiskDescription(
111: String researchRiskDescription) {
112: this .researchRiskDescription = researchRiskDescription;
113: }
114:
115: /**
116: * Gets the routingFormResearchRiskStudyNextSequenceNumber attribute.
117: *
118: * @return Returns the routingFormResearchRiskStudyNextSequenceNumber.
119: */
120: public Integer getRoutingFormResearchRiskStudyNextSequenceNumber() {
121: // TODO This should come from the database.
122: if (this .researchRiskStudies.isEmpty()) {
123: return new Integer(1);
124: } else {
125: return this .researchRiskStudies.get(
126: this .researchRiskStudies.size() - 1)
127: .getRoutingFormResearchRiskStudySequenceNumber() + 1;
128: }
129: }
130:
131: /**
132: * Sets the routingFormResearchRiskStudyNextSequenceNumber attribute value.
133: *
134: * @param routingFormResearchRiskStudyNextSequenceNumber The routingFormResearchRiskStudyNextSequenceNumber to set.
135: */
136: public void setRoutingFormResearchRiskStudyNextSequenceNumber(
137: Integer routingFormResearchRiskStudyNextSequenceNumber) {
138: this .routingFormResearchRiskStudyNextSequenceNumber = routingFormResearchRiskStudyNextSequenceNumber;
139: }
140:
141: /**
142: * Gets the researchRiskType attribute.
143: *
144: * @return Returns the researchRiskType.
145: */
146: public ResearchRiskType getResearchRiskType() {
147: return researchRiskType;
148: }
149:
150: /**
151: * Sets the researchRiskType attribute value.
152: *
153: * @param researchRiskType The researchRiskType to set.
154: * @deprecated
155: */
156: public void setResearchRiskType(ResearchRiskType researchRiskType) {
157: this .researchRiskType = researchRiskType;
158: }
159:
160: /**
161: * Gets the researchRiskStudies attribute.
162: *
163: * @return Returns the researchRiskStudies.
164: */
165: public List<RoutingFormResearchRiskStudy> getResearchRiskStudies() {
166: return researchRiskStudies;
167: }
168:
169: public RoutingFormResearchRiskStudy getResearchRiskStudy(int index) {
170: while (getResearchRiskStudies().size() <= index) {
171: getResearchRiskStudies().add(
172: new RoutingFormResearchRiskStudy());
173: }
174: return (RoutingFormResearchRiskStudy) getResearchRiskStudies()
175: .get(index);
176: }
177:
178: public int getNumStudies() {
179: if (this .getResearchRiskStudies() != null) {
180: return this .getResearchRiskStudies().size();
181: }
182: return 0;
183: }
184:
185: public void addNewResearchRiskStudyToList() {
186: this .newResearchRiskStudy
187: .setRoutingFormResearchRiskStudySequenceNumber(this
188: .getRoutingFormResearchRiskStudyNextSequenceNumber());
189: this .researchRiskStudies.add(this .newResearchRiskStudy);
190: this .newResearchRiskStudy = new RoutingFormResearchRiskStudy();
191: }
192:
193: /**
194: * Sets the researchRiskStudies attribute.
195: *
196: * @param researchRiskStudies The researchRiskStudies to set.
197: */
198: public void setResearchRiskStudies(
199: List<RoutingFormResearchRiskStudy> researchRiskStudies) {
200: this .researchRiskStudies = researchRiskStudies;
201: }
202:
203: public RoutingFormResearchRiskStudy getNewResearchRiskStudy() {
204: return newResearchRiskStudy;
205: }
206:
207: public void setNewResearchRiskStudy(
208: RoutingFormResearchRiskStudy newResearchRiskStudy) {
209: this .newResearchRiskStudy = newResearchRiskStudy;
210: }
211:
212: /**
213: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
214: */
215: protected LinkedHashMap toStringMapper() {
216: LinkedHashMap m = new LinkedHashMap();
217: m
218: .put(KFSPropertyConstants.DOCUMENT_NUMBER,
219: this .documentNumber);
220: m.put("researchRiskTypeCode", this.researchRiskTypeCode);
221: return m;
222: }
223: }
|