org.kuali.kfs.sys.businessobject
Class AccountingLineParserBase

java.lang.Object
  extended by org.kuali.kfs.sys.businessobject.AccountingLineParserBase
All Implemented Interfaces:
AccountingLineParser
Direct Known Subclasses:
AssetPaymentAccountingLineParser, AuxiliaryVoucherAccountingLineParser, BasicFormatWithLineDescriptionAccountingLineParser, BudgetAdjustmentAccountingLineParser, CustomerInvoiceAccountingLineParser, GeneralErrorCorrectionDocumentAccountingLineParser, IndirectCostAdjustmentDocumentAccountingLineParser, LaborJournalVoucherAccountingLineParser, LaborLedgerAccountingLineParser, NonCheckDisbursementDocumentAccountingLineParser, PreEncumbranceDocumentAccountingLineParser, PurApAccountingLineParser

public class AccountingLineParserBase
extends Object
implements AccountingLineParser

Base class for parsing serialized AccountingLines for TransactionalDocuments


Field Summary
protected static String[] DEFAULT_FORMAT
           
 
Constructor Summary
AccountingLineParserBase()
           
 
Method Summary
protected  String[] chooseFormat(Class<? extends AccountingLine> accountingLineClass)
           
 String getExpectedAccountingLineFormatAsString(Class<? extends AccountingLine> accountingLineClass)
           
protected  Class getSourceAccountingLineClass(AccountingDocument accountingDocument)
          Given a document, determines what class the source lines of that document uses
 String[] getSourceAccountingLineFormat()
           
protected  Class getTargetAccountingLineClass(AccountingDocument accountingDocument)
          Given a document, determines what class that document uses for target accounting lines
 String[] getTargetAccountingLineFormat()
           
protected  List<AccountingLine> importAccountingLines(String fileName, InputStream stream, AccountingDocument transactionalDocument, boolean isSource)
          Calls the appropriate parseAccountingLine method
 List importSourceAccountingLines(String fileName, InputStream stream, AccountingDocument document)
          generates a list of SourceAccountingLine from the inputStream
 List importTargetAccountingLines(String fileName, InputStream stream, AccountingDocument document)
          generates a list of TargetAccountingLine from the inputStream
protected  Map<String,String> parseAccountingLine(Class<? extends AccountingLine> accountingLineClass, String lineToParse)
          Parses the csv line
 SourceAccountingLine parseSourceAccountingLine(AccountingDocument transactionalDocument, String sourceAccountingLineString)
          parses a comma deliminated string into an SourceAccountingLine by populating the attributes found in the getSourceAccountingLineFormat()
 TargetAccountingLine parseTargetAccountingLine(AccountingDocument transactionalDocument, String targetAccountingLineString)
          parses a comma deliminated string into an TargetAccountingLine by populating the attributes found in the getTargetAccountingLineFormat()
protected  void performCustomSourceAccountingLinePopulation(Map<String,String> attributeValueMap, SourceAccountingLine sourceAccountingLine, String accountingLineAsString)
          Should be voerriden by documents to perform any additional SourceAccountingLine population
protected  void performCustomTargetAccountingLinePopulation(Map<String,String> attributeValueMap, TargetAccountingLine targetAccountingLine, String accountingLineAsString)
          Should be overridden by documents to perform any additional TargetAccountingLine attribute population
protected  AccountingLine populateAccountingLine(AccountingDocument transactionalDocument, Class<? extends AccountingLine> accountingLineClass, String accountingLineAsString, Map<String,String> attributeValueMap, Integer sequenceNumber)
          Populates a source/target line with values
protected  void putCommonAttributesInMap(Map<String,String> attributeValueMap, AccountingDocument document, Integer sequenceNumber)
          Places fields common to both source/target accounting lines in the attribute map
 String[] removeChartFromFormatIfNeeded(String[] format)
          If accounts can cross charts, returns the given format; otherwise returns the format with ChartOfAccountsCode field removed.
protected  String retrieveAttributeLabel(Class clazz, String attributeName)
           
protected  void validateImportedAccountingLine(AccountingLine line, String accountingLineAsString)
          performs any additional accounting line validation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMAT

protected static final String[] DEFAULT_FORMAT
Constructor Detail

AccountingLineParserBase

public AccountingLineParserBase()
Method Detail

getSourceAccountingLineFormat

public String[] getSourceAccountingLineFormat()
Specified by:
getSourceAccountingLineFormat in interface AccountingLineParser
Returns:
SourceAccountingLine attribute format
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#getSourceAccountingLineFormat()

getTargetAccountingLineFormat

public String[] getTargetAccountingLineFormat()
Specified by:
getTargetAccountingLineFormat in interface AccountingLineParser
Returns:
TargetAccountingLine attribute format
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#getTargetAccountingLineFormat()

removeChartFromFormatIfNeeded

public String[] removeChartFromFormatIfNeeded(String[] format)
If accounts can cross charts, returns the given format; otherwise returns the format with ChartOfAccountsCode field removed.


getExpectedAccountingLineFormatAsString

public String getExpectedAccountingLineFormatAsString(Class<? extends AccountingLine> accountingLineClass)
Specified by:
getExpectedAccountingLineFormatAsString in interface AccountingLineParser
Returns:
String representation of the String[] attribute format with each attribute seperated by a comma.
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#getExpectedAccountingLineFormatAsString(java.lang.Class)

parseSourceAccountingLine

public SourceAccountingLine parseSourceAccountingLine(AccountingDocument transactionalDocument,
                                                      String sourceAccountingLineString)
Description copied from interface: AccountingLineParser
parses a comma deliminated string into an SourceAccountingLine by populating the attributes found in the getSourceAccountingLineFormat()

Specified by:
parseSourceAccountingLine in interface AccountingLineParser
Returns:
SourceAccountingLine
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#parseSourceAccountingLine(org.kuali.rice.kns.document.TransactionalDocument, java.lang.String)

getSourceAccountingLineClass

protected Class getSourceAccountingLineClass(AccountingDocument accountingDocument)
Given a document, determines what class the source lines of that document uses

Parameters:
accountingDocument - the document to find the class of the source lines for
Returns:
the class of the source lines

parseTargetAccountingLine

public TargetAccountingLine parseTargetAccountingLine(AccountingDocument transactionalDocument,
                                                      String targetAccountingLineString)
Description copied from interface: AccountingLineParser
parses a comma deliminated string into an TargetAccountingLine by populating the attributes found in the getTargetAccountingLineFormat()

Specified by:
parseTargetAccountingLine in interface AccountingLineParser
Returns:
TargetAccountingLine
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#parseTargetAccountingLine(org.kuali.rice.kns.document.TransactionalDocument, java.lang.String)

getTargetAccountingLineClass

protected Class getTargetAccountingLineClass(AccountingDocument accountingDocument)
Given a document, determines what class that document uses for target accounting lines

Parameters:
accountingDocument - the document to determine the target accounting line class for
Returns:
the class of the target lines for the given document

populateAccountingLine

protected AccountingLine populateAccountingLine(AccountingDocument transactionalDocument,
                                                Class<? extends AccountingLine> accountingLineClass,
                                                String accountingLineAsString,
                                                Map<String,String> attributeValueMap,
                                                Integer sequenceNumber)
Populates a source/target line with values

Parameters:
transactionalDocument -
accountingLineClass -
accountingLineAsString -
attributeValueMap -
sequenceNumber -
Returns:
AccountingLine

putCommonAttributesInMap

protected void putCommonAttributesInMap(Map<String,String> attributeValueMap,
                                        AccountingDocument document,
                                        Integer sequenceNumber)
Places fields common to both source/target accounting lines in the attribute map

Parameters:
attributeValueMap -
document -
sequenceNumber -

parseAccountingLine

protected Map<String,String> parseAccountingLine(Class<? extends AccountingLine> accountingLineClass,
                                                 String lineToParse)
Parses the csv line

Parameters:
accountingLineClass -
lineToParse -
Returns:
Map containing accounting line attribute,value pairs

performCustomSourceAccountingLinePopulation

protected void performCustomSourceAccountingLinePopulation(Map<String,String> attributeValueMap,
                                                           SourceAccountingLine sourceAccountingLine,
                                                           String accountingLineAsString)
Should be voerriden by documents to perform any additional SourceAccountingLine population

Parameters:
attributeValueMap -
sourceAccountingLine -
accountingLineAsString -

performCustomTargetAccountingLinePopulation

protected void performCustomTargetAccountingLinePopulation(Map<String,String> attributeValueMap,
                                                           TargetAccountingLine targetAccountingLine,
                                                           String accountingLineAsString)
Should be overridden by documents to perform any additional TargetAccountingLine attribute population

Parameters:
attributeValueMap -
targetAccountingLine -
accountingLineAsString -

importAccountingLines

protected List<AccountingLine> importAccountingLines(String fileName,
                                                     InputStream stream,
                                                     AccountingDocument transactionalDocument,
                                                     boolean isSource)
Calls the appropriate parseAccountingLine method

Parameters:
stream -
transactionalDocument -
isSource -
Returns:
List

importSourceAccountingLines

public final List importSourceAccountingLines(String fileName,
                                              InputStream stream,
                                              AccountingDocument document)
Description copied from interface: AccountingLineParser
generates a list of SourceAccountingLine from the inputStream

Specified by:
importSourceAccountingLines in interface AccountingLineParser
Returns:
List containing SourceAccountingLines
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#importSourceAccountingLines(java.io.InputStream, org.kuali.rice.kns.document.TransactionalDocument)

importTargetAccountingLines

public final List importTargetAccountingLines(String fileName,
                                              InputStream stream,
                                              AccountingDocument document)
Description copied from interface: AccountingLineParser
generates a list of TargetAccountingLine from the inputStream

Specified by:
importTargetAccountingLines in interface AccountingLineParser
Returns:
List containing SourceAccountingLines
See Also:
org.kuali.rice.kns.bo.AccountingLineParser#importTargetAccountingLines(java.io.InputStream, org.kuali.rice.kns.document.TransactionalDocument)

validateImportedAccountingLine

protected void validateImportedAccountingLine(AccountingLine line,
                                              String accountingLineAsString)
                                       throws AccountingLineParserException
performs any additional accounting line validation

Parameters:
line -
accountingLineAsString -
Throws:
AccountingLineParserException

retrieveAttributeLabel

protected String retrieveAttributeLabel(Class clazz,
                                        String attributeName)

chooseFormat

protected String[] chooseFormat(Class<? extends AccountingLine> accountingLineClass)


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.