Delegator delegator = dctx.getDelegator();
Locale locale = (Locale) context.get("locale");
String productStoreId = (String) context.get("productStoreId");
try {
ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
GetMyeBaySellingCall api = new GetMyeBaySellingCall(apiContext);
ItemListCustomizationType itemListType = new ItemListCustomizationType();
itemListType.setInclude(Boolean.TRUE);
itemListType.setIncludeNotes(Boolean.TRUE);
itemListType.setSort(ItemSortTypeCodeType.ITEM_ID_DESCENDING);
String entriesPerPage = (String) context.get("entriesPerPage");
String pageNumber = (String) context.get("pageNumber");
String listingType = (String) context.get("listingType");
PaginationType page = new PaginationType();
if (UtilValidate.isNotEmpty(entriesPerPage)) {
page.setEntriesPerPage(Integer.valueOf(entriesPerPage));
}
if (UtilValidate.isNotEmpty(pageNumber)) {
page.setPageNumber(Integer.valueOf(pageNumber));
}
itemListType.setPagination(page);
if (UtilValidate.isNotEmpty(listingType)) {
itemListType.setListingType(ListingTypeCodeType.valueOf(listingType));
} else {
itemListType.setListingType(ListingTypeCodeType.FIXED_PRICE_ITEM);
}
DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
DetailLevelCodeType.RETURN_ALL,
DetailLevelCodeType.ITEM_RETURN_ATTRIBUTES,
DetailLevelCodeType.ITEM_RETURN_DESCRIPTION
};
api.setDetailLevel(detailLevels);
api.setActiveList(itemListType);
api.setScheduledList(itemListType);
api.setSoldList(itemListType);
api.setUnsoldList(itemListType);
api.getMyeBaySelling();
ItemType[] tempActiveItems = null;
if (api.getReturnedActiveList() != null) tempActiveItems = (api.getReturnedActiveList().getItemArray()).getItem();
final ItemType[] activeItems = tempActiveItems;
// Display active items in table.
AbstractTableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return 0; }
public int getRowCount() { return activeItems == null ? 0 : activeItems.length;}
public Map<String, Object> getValueAt(int row, int col) {
ItemType item = activeItems[row];
return itemToColumns(item);
}
};
//add To List
List<Map<Object, Object>> activeList = getDataModelToList(dataModel);
int activeSize = dataModel.getRowCount();
ItemType[] tempItems = null;
if (api.getReturnedScheduledList() != null) tempItems = (api.getReturnedScheduledList().getItemArray()).getItem();
final ItemType[] scheItems = tempItems;
// Display Scheduled items in table.
dataModel = new AbstractTableModel() {
public int getColumnCount() { return 0; }
public int getRowCount() { return scheItems == null ? 0 : scheItems.length;}
public Map<String, Object> getValueAt(int row, int col) {
ItemType item = scheItems[row];
return schItemToColumns(item);
}
};
// set data
List<Map<Object, Object>> scheduledList = getDataModelToList(dataModel);
int scheduledSize = dataModel.getRowCount();
OrderTransactionType[] tempSoldItems = null;
if (UtilValidate.isNotEmpty(api.getReturnedSoldList())) tempSoldItems = (api.getReturnedSoldList().getOrderTransactionArray()).getOrderTransaction();
// add to list
List<Map<String, Object>> soldList = FastList.newInstance();
if (UtilValidate.isNotEmpty(tempSoldItems)) {
soldList = EbayStore.getOrderTransactions(tempSoldItems);
}
int soldSize = tempSoldItems == null ? 0 : tempSoldItems.length;
ItemType[] tempUnSoldItems = null;
if (UtilValidate.isNotEmpty(api.getReturnedUnsoldList())) tempUnSoldItems = (api.getReturnedUnsoldList().getItemArray()).getItem();
final ItemType[] unSoldItems = tempUnSoldItems;
// Display unsold items in table.
dataModel = new AbstractTableModel() {
public int getColumnCount() { return 0; }
public int getRowCount() { return unSoldItems == null ? 0 : unSoldItems.length;}