public class ItemParserBase extends Object implements ItemParser
| Modifier and Type | Field and Description |
|---|---|
protected static String[] |
COMMODITY_CODE_DISABLED_FORMAT |
protected static String[] |
DEFAULT_FORMAT
The default format defines the expected item property names and their order in the import file.
|
| Constructor and Description |
|---|
ItemParserBase() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkItemClass(Class<? extends PurApItem> itemClass)
Checks whether the specified item class is a subclass of PurApItem;
throws exceptions if not.
|
protected void |
checkItemFile(org.apache.struts.upload.FormFile itemFile)
Checks whether the specified item import file is not null and of a valid format;
throws exceptions if conditions not satisfied.
|
protected PurApItem |
genItemWithRetrievedAttributes(Map<String,String> itemMap,
Class<? extends PurApItem> itemClass)
Generates an item instance and populates it with the specified attribute map.
|
protected String |
getAttributeLabel(Class clazz,
String attributeName)
Retrieves the attribute label for the specified attribute.
|
String |
getExpectedItemFormatAsString(Class<? extends PurApItem> itemClass)
Returns the expected format of the items to be imported.
|
String[] |
getItemFormat()
Returns the defined format of item lines in the item import file.
|
List<PurApItem> |
importItems(org.apache.struts.upload.FormFile itemFile,
Class<? extends PurApItem> itemClass,
String documentNumber)
Parses the items from the specified import file line by line,
and generates items of the specified type from the parsed data.
|
PurApItem |
parseItem(String itemLine,
Class<? extends PurApItem> itemClass,
String documentNumber)
Parses the specified item line into an instance of the specified PurApItem subclass.
|
protected void |
populateExtraAttributes(PurApItem item,
String documentNumber)
Populates extra item attributes not contained in the imported item data to default values.
|
protected Map<String,String> |
retrieveItemAttributes(String itemLine)
Parses a line of item data from a csv file and retrieves the attributes as key-value string pairs into a map.
|
protected static final String[] DEFAULT_FORMAT
protected static final String[] COMMODITY_CODE_DISABLED_FORMAT
public ItemParserBase()
public String[] getItemFormat()
ItemParsergetItemFormat in interface ItemParserItemParser.getItemFormat()public String getExpectedItemFormatAsString(Class<? extends PurApItem> itemClass)
ItemParsergetExpectedItemFormatAsString in interface ItemParseritemClass - the class of the items to be importedItemParser.getExpectedItemFormatAsString(java.lang.Class)protected String getAttributeLabel(Class clazz, String attributeName)
clazz - the class in which the specified attribute is definedattributeName - the name of the specified attributeprotected void checkItemClass(Class<? extends PurApItem> itemClass)
itemClass - the specified item classprotected void checkItemFile(org.apache.struts.upload.FormFile itemFile)
itemClass - the specified item import fileprotected Map<String,String> retrieveItemAttributes(String itemLine)
itemLine - a string read from a line in the item import fileprotected PurApItem genItemWithRetrievedAttributes(Map<String,String> itemMap, Class<? extends PurApItem> itemClass)
itemMap - the specified attribute map from which attributes are populateditemClass - the class of which the new item instance shall be createdprotected void populateExtraAttributes(PurApItem item, String documentNumber)
item - the item to be populateddocumentNumber - the number of the docment that contains the itempublic PurApItem parseItem(String itemLine, Class<? extends PurApItem> itemClass, String documentNumber)
ItemParserparseItem in interface ItemParseritemLine - the item line string to be parseditemClass - the subclass of the item to be generateddocumentNumber - the number of the docment that contains the item to be generatedItemParser.parseItem(java.lang.String, java.lang.Class, java.lang.String)public List<PurApItem> importItems(org.apache.struts.upload.FormFile itemFile, Class<? extends PurApItem> itemClass, String documentNumber)
ItemParserimportItems in interface ItemParseritemFile - the input file from which items are parseditemClass - a subclass of PurApItem, of which new items shall be generateddocumentNumber - the number of the docment that contains the items to be importedorg.kuali.ole.module.purap.util.ItemParser#parseItem(org.apache.struts.upload.FormFile, java.lang.Class, java.lang.String)Copyright © 2004–2014 The Kuali Foundation. All rights reserved.