001    /*
002     * Copyright 2011 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    package org.kuali.kfs.fp.document.web.struts;
017    
018    import java.util.Map;
019    
020    import org.kuali.kfs.fp.document.IndirectCostAdjustmentDocument;
021    import org.kuali.kfs.fp.document.validation.impl.IndirectCostAdjustmentDocumentRuleConstants;
022    import org.kuali.kfs.sys.KFSPropertyConstants;
023    import org.kuali.kfs.sys.businessobject.SourceAccountingLine;
024    import org.kuali.kfs.sys.businessobject.TargetAccountingLine;
025    import org.kuali.kfs.sys.context.SpringContext;
026    import org.kuali.kfs.sys.document.AccountingDocument;
027    import org.kuali.kfs.sys.web.struts.KualiAccountingDocumentFormBase;
028    import org.kuali.rice.kns.service.ParameterService;
029    
030    /**
031     * This class is the action form for Indirect Cost Adjustment Document
032     */
033    public class IndirectCostAdjustmentForm extends KualiAccountingDocumentFormBase {
034    
035        /**
036         * Constructs a IndirectCostAdjustmentForm.java.
037         */
038        public IndirectCostAdjustmentForm() {
039            super();
040        }
041    
042        @Override
043        protected String getDefaultDocumentTypeName() {
044            return "ICA";
045        }
046        
047        /**
048         * @return Returns the Indirect Cost Adjustment Document
049         */
050        public IndirectCostAdjustmentDocument getIndirectCostAdjustmentDocument() {
051            return (IndirectCostAdjustmentDocument) getDocument();
052        }
053    
054        /**
055         * @param indirectCostAdjustmentDocument the <code>IndirectCostAdjustmentDocument</code> to set
056         */
057        public void setIndirectCostAdjustmentDocument(IndirectCostAdjustmentDocument indirectCostAdjustmentDocument) {
058            setDocument(indirectCostAdjustmentDocument);
059        }
060    
061        /**
062         * @see org.kuali.module.financial.web.struts.form.KualiFinancialDocumentFormBase#createNewSourceAccountingLine(org.kuali.module.financial.document.FinancialDocument)
063         */
064        @Override
065        public SourceAccountingLine createNewSourceAccountingLine(AccountingDocument financialDocument) {
066            SourceAccountingLine sourceAccountingLine = super.createNewSourceAccountingLine(financialDocument);
067            String objectCode = SpringContext.getBean(ParameterService.class).getParameterValue(IndirectCostAdjustmentDocument.class, IndirectCostAdjustmentDocumentRuleConstants.GRANT_OBJECT_CODE);
068    
069            sourceAccountingLine.setFinancialObjectCode(objectCode);
070            return sourceAccountingLine;
071        }
072    
073        /**
074         * @see org.kuali.module.financial.web.struts.form.KualiFinancialDocumentFormBase#createNewTargetAccountingLine(org.kuali.module.financial.document.FinancialDocument)
075         */
076        @Override
077        public TargetAccountingLine createNewTargetAccountingLine(AccountingDocument financialDocument) {
078            TargetAccountingLine targetAccountingLine = super.createNewTargetAccountingLine(financialDocument);
079            String objectCode = SpringContext.getBean(ParameterService.class).getParameterValue(IndirectCostAdjustmentDocument.class, IndirectCostAdjustmentDocumentRuleConstants.RECEIPT_OBJECT_CODE);
080    
081            targetAccountingLine.setFinancialObjectCode(objectCode);
082            return targetAccountingLine;
083        }
084    
085        /**
086         * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#getForcedReadOnlyFields()
087         */
088        @Override
089        public Map getForcedReadOnlyFields() {
090            Map map = super.getForcedReadOnlyFields();
091            map.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, Boolean.TRUE);
092            return map;
093        }
094    
095    }