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 */
016
017package org.kuali.ole.fp.businessobject;
018
019import static org.kuali.ole.sys.OLEPropertyConstants.ACCOUNT_NUMBER;
020import static org.kuali.ole.sys.OLEPropertyConstants.AMOUNT;
021import static org.kuali.ole.sys.OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE;
022import static org.kuali.ole.sys.OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE;
023import static org.kuali.ole.sys.OLEPropertyConstants.ORGANIZATION_REFERENCE_ID;
024import static org.kuali.ole.sys.OLEPropertyConstants.PROJECT_CODE;
025import static org.kuali.ole.sys.OLEPropertyConstants.SUB_ACCOUNT_NUMBER;
026
027import java.util.Map;
028
029import org.kuali.ole.fp.document.IndirectCostAdjustmentDocument;
030import org.kuali.ole.fp.document.validation.impl.IndirectCostAdjustmentDocumentRuleConstants;
031import org.kuali.ole.sys.businessobject.AccountingLineParserBase;
032import org.kuali.ole.sys.businessobject.SourceAccountingLine;
033import org.kuali.ole.sys.businessobject.TargetAccountingLine;
034import org.kuali.ole.sys.context.SpringContext;
035import org.kuali.rice.coreservice.framework.parameter.ParameterService;
036
037/**
038 * This class represents an <code>IndirectCostAdjustmentDocument</code> accounting line parser.
039 * 
040 * @see org.kuali.ole.fp.document.IndirectCostAdjustmentDocument
041 */
042public class IndirectCostAdjustmentDocumentAccountingLineParser extends AccountingLineParserBase {
043    protected static final String[] ICA_FORMAT = { CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER, FINANCIAL_SUB_OBJECT_CODE, PROJECT_CODE, ORGANIZATION_REFERENCE_ID, AMOUNT };
044
045    /**
046     * @see org.kuali.rice.krad.bo.AccountingLineParserBase#getSourceAccountingLineFormat()
047     */
048    @Override
049    public String[] getSourceAccountingLineFormat() {
050        return removeChartFromFormatIfNeeded(ICA_FORMAT);
051    }
052
053    /**
054     * @see org.kuali.rice.krad.bo.AccountingLineParserBase#getTargetAccountingLineFormat()
055     */
056    @Override
057    public String[] getTargetAccountingLineFormat() {
058        return removeChartFromFormatIfNeeded(ICA_FORMAT);
059    }
060
061    /**
062     * @see org.kuali.rice.krad.bo.AccountingLineParserBase#performCustomSourceAccountingLinePopulation(java.util.Map,
063     *      org.kuali.rice.krad.bo.SourceAccountingLine, java.lang.String)
064     */
065    @Override
066    protected void performCustomSourceAccountingLinePopulation(Map<String, String> attributeValueMap, SourceAccountingLine sourceAccountingLine, String accountingLineAsString) {
067        super.performCustomSourceAccountingLinePopulation(attributeValueMap, sourceAccountingLine, accountingLineAsString);
068        String financialObjectCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(IndirectCostAdjustmentDocument.class, IndirectCostAdjustmentDocumentRuleConstants.GRANT_OBJECT_CODE);
069        sourceAccountingLine.setFinancialObjectCode(financialObjectCode);
070    }
071
072    /**
073     * @see org.kuali.rice.krad.bo.AccountingLineParserBase#performCustomTargetAccountingLinePopulation(java.util.Map,
074     *      org.kuali.rice.krad.bo.TargetAccountingLine, java.lang.String)
075     */
076    @Override
077    protected void performCustomTargetAccountingLinePopulation(Map<String, String> attributeValueMap, TargetAccountingLine targetAccountingLine, String accountingLineAsString) {
078        super.performCustomTargetAccountingLinePopulation(attributeValueMap, targetAccountingLine, accountingLineAsString);
079        String financialObjectCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(IndirectCostAdjustmentDocument.class, IndirectCostAdjustmentDocumentRuleConstants.RECEIPT_OBJECT_CODE);
080        targetAccountingLine.setFinancialObjectCode(financialObjectCode);
081    }
082
083}