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.CapitalAssetInformation;
024import org.kuali.ole.fp.businessobject.CreditCardDetail;
025import org.kuali.ole.fp.document.CapitalAssetEditable;
026import org.kuali.ole.fp.document.CreditCardReceiptDocument;
027import org.kuali.ole.sys.context.SpringContext;
028import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
029
030/**
031 * This class is the struts form for Credit Card Receipt document.
032 */
033public class CreditCardReceiptForm extends CapitalAccountingLinesFormBase implements CapitalAssetEditable {
034    protected CreditCardDetail newCreditCardReceipt;
035    protected List<CapitalAssetInformation> capitalAssetInformation;
036
037    /**
038     * Constructs a CreditCardReceiptForm.java.
039     */
040    public CreditCardReceiptForm() {
041        super();
042        
043        setNewCreditCardReceipt(new CreditCardDetail());
044        
045        capitalAssetInformation = new ArrayList<CapitalAssetInformation>();
046        this.capitalAccountingLine.setCanCreateAsset(false); //This document can only edit asset information
047    }
048
049    @Override
050    protected String getDefaultDocumentTypeName() {
051        return "OLE_CCR";
052    }
053    
054    /**
055     * @return CreditCardReceiptDocument
056     */
057    public CreditCardReceiptDocument getCreditCardReceiptDocument() {
058        return (CreditCardReceiptDocument) getDocument();
059    }
060
061    /**
062     * @return CreditCardDetail
063     */
064    public CreditCardDetail getNewCreditCardReceipt() {
065        return newCreditCardReceipt;
066    }
067
068    /**
069     * @param newCreditCardReceipt
070     */
071    public void setNewCreditCardReceipt(CreditCardDetail newCreditCardReceipt) {
072        this.newCreditCardReceipt = newCreditCardReceipt;
073    }
074
075    /**
076     * Overrides the parent to call super.populate and then tells each line to check the associated data dictionary and modify the
077     * values entered to follow all the attributes set for the values of the accounting line.
078     * 
079     * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
080     */
081    @Override
082    public void populate(HttpServletRequest request) {
083        super.populate(request);
084
085        //
086        // now run through all of the accounting lines and make sure they've been uppercased and populated appropriately
087        SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(getNewCreditCardReceipt());
088
089        List<CreditCardDetail> creditCardReceipts = getCreditCardReceiptDocument().getCreditCardReceipts();
090        for (CreditCardDetail detail : creditCardReceipts) {
091            SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(detail);
092        }
093
094    }
095
096    /**
097     * @see org.kuali.ole.fp.document.CapitalAssetEditable#getCapitalAssetInformation()
098     */
099    public List<CapitalAssetInformation> getCapitalAssetInformation() {
100        return this.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}