001/*
002 * Copyright 2006 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 */
016package org.kuali.ole.fp.document.web.struts;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import javax.servlet.http.HttpServletRequest;
022
023import org.kuali.ole.fp.businessobject.AdvanceDepositDetail;
024import org.kuali.ole.fp.businessobject.CapitalAssetInformation;
025import org.kuali.ole.fp.document.AdvanceDepositDocument;
026import org.kuali.ole.fp.document.CapitalAssetEditable;
027import org.kuali.ole.sys.context.SpringContext;
028import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
029
030/**
031 * This class is the struts form for Advance Deposit document.
032 */
033public class AdvanceDepositForm extends CapitalAccountingLinesFormBase implements CapitalAssetEditable {
034    protected AdvanceDepositDetail newAdvanceDeposit;
035    protected List<CapitalAssetInformation> capitalAssetInformation;
036
037    /**
038     * Constructs a AdvanceDepositForm.java.
039     */
040    public AdvanceDepositForm() {
041        super();
042
043        AdvanceDepositDetail advanceDepositDetail = new AdvanceDepositDetail();
044        advanceDepositDetail.setDefaultBankCode();
045        setNewAdvanceDeposit(advanceDepositDetail);
046
047        capitalAssetInformation = new ArrayList<CapitalAssetInformation>();
048        this.capitalAccountingLine.setCanCreateAsset(false); //This document can only edit asset information
049    }
050
051    @Override
052    protected String getDefaultDocumentTypeName() {
053        return "OLE_AD";
054    }
055    
056    /**
057     * @return AdvanceDepositDocument
058     */
059    public AdvanceDepositDocument getAdvanceDepositDocument() {
060        return (AdvanceDepositDocument) getDocument();
061    }
062
063    /**
064     * @return AdvanceDepositDetail
065     */
066    public AdvanceDepositDetail getNewAdvanceDeposit() {
067        return newAdvanceDeposit;
068    }
069
070    /**
071     * @param newAdvanceDeposit
072     */
073    public void setNewAdvanceDeposit(AdvanceDepositDetail newAdvanceDeposit) {
074        this.newAdvanceDeposit = newAdvanceDeposit;
075    }
076
077    /**
078     * Overrides the parent to call super.populate and then tells each line to check the associated data dictionary and modify the
079     * values entered to follow all the attributes set for the values of the accounting line.
080     * 
081     * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
082     */
083    @Override
084    public void populate(HttpServletRequest request) {
085        super.populate(request);
086
087        // now run through all of the accounting lines and make sure they've been uppercased and populated appropriately
088        SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(getNewAdvanceDeposit());
089
090        List<AdvanceDepositDetail> advancedDeposits = getAdvanceDepositDocument().getAdvanceDeposits();
091        for (AdvanceDepositDetail detail : advancedDeposits) {
092            SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(detail);
093        }
094    }
095
096    /**
097     * @see org.kuali.ole.fp.document.CapitalAssetEditable#getCapitalAssetInformation()
098     */
099    public List<CapitalAssetInformation> getCapitalAssetInformation() {
100        return capitalAssetInformation;
101    }
102
103    /**
104     * @see org.kuali.ole.fp.document.CapitalAssetEditable#setCapitalAssetInformation(org.kuali.ole.fp.businessobject.CapitalAssetInformation)
105     */
106    public void setCapitalAssetInformation(List<CapitalAssetInformation> capitalAssetInformation) {
107        this.capitalAssetInformation = capitalAssetInformation;
108    }
109}