001/*
002 * Copyright 2007 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 * Created on Jul 12, 2004
018 *
019 */
020package org.kuali.ole.pdp.businessobject;
021
022import java.sql.Date;
023import java.util.HashMap;
024import java.util.Map;
025
026import org.apache.commons.lang.StringUtils;
027import org.kuali.ole.sys.businessobject.Bank;
028import org.kuali.ole.sys.context.SpringContext;
029import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
030import org.kuali.rice.core.api.util.type.KualiInteger;
031import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
032import org.kuali.rice.krad.service.KualiModuleService;
033import org.kuali.rice.krad.service.ModuleService;
034import org.kuali.rice.location.api.LocationConstants;
035import org.kuali.rice.location.framework.campus.CampusEbo;
036
037public class DisbursementNumberRange extends PersistableBusinessObjectBase implements MutableInactivatable {
038
039    protected String physCampusProcCode;
040    protected KualiInteger beginDisbursementNbr;
041    protected KualiInteger lastAssignedDisbNbr;
042    protected KualiInteger endDisbursementNbr;
043    protected Date disbNbrRangeStartDt;
044    protected String bankCode;
045    protected String disbursementTypeCode;
046    protected boolean active;
047
048    protected CampusEbo campus;
049    protected Bank bank;
050    protected DisbursementType disbursementType;
051
052    public DisbursementNumberRange() {
053        super();
054    }
055
056    /**
057     * @return
058     */
059    public Bank getBank() {
060        return bank;
061    }
062
063    /**
064     * Gets the bankCode attribute.
065     * 
066     * @return Returns the bankCode.
067     */
068    public String getBankCode() {
069        return bankCode;
070    }
071
072    /**
073     * Sets the bankCode attribute value.
074     * 
075     * @param bankCode The bankCode to set.
076     */
077    public void setBankCode(String bankCode) {
078        this.bankCode = bankCode;
079    }
080
081    /**
082     * @return
083     * @hibernate.property column="BEG_DISB_NBR"
084     */
085    public KualiInteger getBeginDisbursementNbr() {
086        return beginDisbursementNbr;
087    }
088
089    /**
090     * @return
091     * @hibernate.property column="END_DISB_NBR"
092     */
093    public KualiInteger getEndDisbursementNbr() {
094        return endDisbursementNbr;
095    }
096
097    /**
098     * @return
099     * @hibernate.property column="LST_ASND_DISB_NBR"
100     */
101    public KualiInteger getLastAssignedDisbNbr() {
102        return lastAssignedDisbNbr;
103    }
104
105    /**
106     * @return
107     * @hibernate.property column="PHYS_CMP_PROC_CD" length="2"
108     */
109    public String getPhysCampusProcCode() {
110        return physCampusProcCode;
111    }
112
113    /**
114     * @param Bank
115     */
116    @Deprecated
117    public void setBank(Bank bank) {
118        this.bank = bank;
119    }
120
121    /**
122     * @param integer
123     */
124    public void setBeginDisbursementNbr(KualiInteger integer) {
125        beginDisbursementNbr = integer;
126    }
127
128    /**
129     * @param integer
130     */
131    public void setEndDisbursementNbr(KualiInteger integer) {
132        endDisbursementNbr = integer;
133    }
134
135    /**
136     * @param integer
137     */
138    public void setLastAssignedDisbNbr(KualiInteger integer) {
139        lastAssignedDisbNbr = integer;
140    }
141
142    /**
143     * @param string
144     */
145    public void setPhysCampusProcCode(String string) {
146        physCampusProcCode = string;
147    }
148
149    /**
150     * Gets the disbursementTypeCode attribute.
151     * 
152     * @return Returns the disbursementTypeCode.
153     */
154    public String getDisbursementTypeCode() {
155        return disbursementTypeCode;
156    }
157
158    /**
159     * Sets the disbursementTypeCode attribute value.
160     * 
161     * @param disbursementTypeCode The disbursementTypeCode to set.
162     */
163    public void setDisbursementTypeCode(String disbursementTypeCode) {
164        this.disbursementTypeCode = disbursementTypeCode;
165    }
166
167    /**
168     * Gets the disbursementType attribute.
169     * 
170     * @return Returns the disbursementType.
171     */
172    public DisbursementType getDisbursementType() {
173        return disbursementType;
174    }
175
176    /**
177     * Sets the disbursementType attribute value.
178     * 
179     * @param disbursementType The disbursementType to set.
180     */
181    public void setDisbursementType(DisbursementType disbursementType) {
182        this.disbursementType = disbursementType;
183    }
184
185    /**
186     * Gets the campus attribute.
187     * 
188     * @return Returns the campus.
189     */
190    public CampusEbo getCampus() {
191        if ( StringUtils.isBlank(physCampusProcCode) ) {
192            campus = null;
193        } else {
194            if ( campus == null || !StringUtils.equals( campus.getCode(),physCampusProcCode) ) {
195                ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
196                if ( moduleService != null ) {
197                    Map<String,Object> keys = new HashMap<String, Object>(1);
198                    keys.put(LocationConstants.PrimaryKeyConstants.CODE, physCampusProcCode);
199                    campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
200                } else {
201                    throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
202                }
203            }
204        }
205        return campus;
206    }
207
208    /**
209     * Sets the campus attribute value.
210     * 
211     * @param campus The campus to set.
212     */
213    public void setCampus(CampusEbo campus) {
214        this.campus = campus;
215    }
216
217    /**
218     * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#isActive()
219     */
220    @Override
221    public boolean isActive() {
222        return active;
223    }
224
225    /**
226     * @see org.kuali.rice.core.api.mo.common.active.MutableInactivatable#setActive(boolean)
227     */
228    @Override
229    public void setActive(boolean active) {
230        this.active = active;
231    }
232
233    /**
234     * Gets the disbNbrRangeStartDt attribute.
235     * 
236     * @return Returns the disbNbrRangeStartDt.
237     */
238    public Date getDisbNbrRangeStartDt() {
239        return disbNbrRangeStartDt;
240    }
241
242    /**
243     * Sets the disbNbrRangeStartDt attribute value.
244     * 
245     * @param disbNbrRangeStartDt The disbNbrRangeStartDt to set.
246     */
247    public void setDisbNbrRangeStartDt(Date disbNbrRangeStartDt) {
248        this.disbNbrRangeStartDt = disbNbrRangeStartDt;
249    }
250
251}