001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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: package org.kuali.module.labor.bo;
018:
019: import static org.kuali.kfs.KFSPropertyConstants.ACCOUNT_NUMBER;
020: import static org.kuali.kfs.KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE;
021: import static org.kuali.kfs.KFSPropertyConstants.FINANCIAL_OBJECT_CODE;
022: import static org.kuali.kfs.KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE;
023: import static org.kuali.kfs.KFSPropertyConstants.ORGANIZATION_REFERENCE_ID;
024: import static org.kuali.kfs.KFSPropertyConstants.POSITION_NUMBER;
025: import static org.kuali.kfs.KFSPropertyConstants.PROJECT_CODE;
026: import static org.kuali.kfs.KFSPropertyConstants.SUB_ACCOUNT_NUMBER;
027:
028: import org.kuali.kfs.KFSPropertyConstants;
029: import org.kuali.kfs.bo.AccountingLine;
030: import org.kuali.kfs.bo.AccountingLineParserBase;
031: import org.kuali.kfs.bo.SourceAccountingLine;
032: import org.kuali.kfs.bo.TargetAccountingLine;
033: import org.kuali.module.labor.LaborPropertyConstants;
034:
035: /**
036: * Labor Extended class for parsing serialized <code>AccountingLine</code>s for <code>TransactionalDocument</code>s
037: */
038: public class LaborLedgerAccountingLineParser extends
039: AccountingLineParserBase {
040:
041: protected static final String[] LABOR_LEDGER_FORMAT = {
042: CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER,
043: FINANCIAL_OBJECT_CODE, FINANCIAL_SUB_OBJECT_CODE,
044: PROJECT_CODE, ORGANIZATION_REFERENCE_ID, POSITION_NUMBER,
045: LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_YEAR,
046: LaborPropertyConstants.PAYROLL_END_DATE_FISCAL_PERIOD_CODE,
047: LaborPropertyConstants.PAYROLL_TOTAL_HOURS,
048: KFSPropertyConstants.AMOUNT };
049:
050: /**
051: * Constructs a LaborLedgerAccountingLineParser.java.
052: */
053: public LaborLedgerAccountingLineParser() {
054:
055: }
056:
057: /**
058: * Gets the LABOR_LEDGER_FORMAT the SourceAccountingLineFormat.
059: *
060: * @return Returns the LABOR_LEDGER_FORMAT.
061: * @see org.kuali.core.bo.AccountingLineParser#getSourceAccountingLineFormat()
062: */
063: public String[] getSourceAccountingLineFormat() {
064: return LABOR_LEDGER_FORMAT;
065: }
066:
067: /**
068: * Gets the LABOR_LEDGER_FORMAT the TargetAccountingLineFormat.
069: *
070: * @return Returns the LABOR_LEDGER_FORMAT.
071: * @see org.kuali.core.bo.AccountingLineParser#getTargetAccountingLineFormat()
072: */
073: public String[] getTargetAccountingLineFormat() {
074: return LABOR_LEDGER_FORMAT;
075: }
076:
077: /**
078: * Will return the format determing if the line is Source or Target.
079: *
080: * @param accountingLineClass
081: * @return Returns The format.
082: */
083: private String[] chooseFormat(
084: Class<? extends AccountingLine> accountingLineClass) {
085: String[] format = null;
086: if (SourceAccountingLine.class
087: .isAssignableFrom(accountingLineClass)) {
088: format = getSourceAccountingLineFormat();
089: } else if (TargetAccountingLine.class
090: .isAssignableFrom(accountingLineClass)) {
091: format = getTargetAccountingLineFormat();
092: } else {
093: throw new IllegalStateException(
094: "unknow accounting line class: "
095: + accountingLineClass);
096: }
097:
098: return format;
099: }
100: }
|