RESOLVED - BATCH-779: RFC: make FieldSetMapper and LineAggregator extend ItemProcessor
reverted to original method names
This commit is contained in:
@@ -6,7 +6,7 @@ import org.springframework.batch.sample.domain.football.Game;
|
||||
|
||||
public class GameFieldSetMapper implements FieldSetMapper<Game> {
|
||||
|
||||
public Game process(FieldSet fs) {
|
||||
public Game map(FieldSet fs) {
|
||||
|
||||
if(fs == null){
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.batch.sample.domain.football.Player;
|
||||
|
||||
public class PlayerFieldSetMapper implements FieldSetMapper<Player> {
|
||||
|
||||
public Player process(FieldSet fs) {
|
||||
public Player map(FieldSet fs) {
|
||||
|
||||
if(fs == null){
|
||||
return null;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
|
||||
* @return an {@link AggregateItem} that wraps the return value from the
|
||||
* delegate
|
||||
*/
|
||||
public AggregateItem<T> process(FieldSet fieldSet) {
|
||||
public AggregateItem<T> map(FieldSet fieldSet) {
|
||||
|
||||
if (fieldSet.readString(0).equals(begin)) {
|
||||
return AggregateItem.getHeader();
|
||||
@@ -92,7 +92,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
|
||||
return AggregateItem.getFooter();
|
||||
}
|
||||
|
||||
return new AggregateItem<T>(delegate.process(fieldSet));
|
||||
return new AggregateItem<T>(delegate.map(fieldSet));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AddressFieldSetMapper implements FieldSetMapper<Address> {
|
||||
public static final String COUNTRY_COLUMN = "COUNTRY";
|
||||
|
||||
|
||||
public Address process(FieldSet fieldSet) {
|
||||
public Address map(FieldSet fieldSet) {
|
||||
Address address = new Address();
|
||||
|
||||
address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN));
|
||||
|
||||
@@ -27,7 +27,7 @@ public class BillingFieldSetMapper implements FieldSetMapper<BillingInfo> {
|
||||
public static final String PAYMENT_TYPE_ID_COLUMN = "PAYMENT_TYPE_ID";
|
||||
public static final String PAYMENT_DESC_COLUMN = "PAYMENT_DESC";
|
||||
|
||||
public BillingInfo process(FieldSet fieldSet) {
|
||||
public BillingInfo map(FieldSet fieldSet) {
|
||||
BillingInfo info = new BillingInfo();
|
||||
|
||||
info.setPaymentId(fieldSet.readString(PAYMENT_TYPE_ID_COLUMN));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CustomerFieldSetMapper implements FieldSetMapper<Customer> {
|
||||
public static final String REG_ID_COLUMN = "REG_ID";
|
||||
public static final String VIP_COLUMN = "VIP";
|
||||
|
||||
public Customer process(FieldSet fieldSet) {
|
||||
public Customer map(FieldSet fieldSet) {
|
||||
Customer customer = new Customer();
|
||||
|
||||
if (Customer.LINE_ID_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class HeaderFieldSetMapper implements FieldSetMapper<Order> {
|
||||
public static final String ORDER_ID_COLUMN = "ORDER_ID";
|
||||
public static final String ORDER_DATE_COLUMN = "ORDER_DATE";
|
||||
|
||||
public Order process(FieldSet fieldSet) {
|
||||
public Order map(FieldSet fieldSet) {
|
||||
Order order = new Order();
|
||||
order.setOrderId(fieldSet.readLong(ORDER_ID_COLUMN));
|
||||
order.setOrderDate(fieldSet.readDate(ORDER_DATE_COLUMN));
|
||||
|
||||
@@ -33,7 +33,7 @@ public class OrderItemFieldSetMapper implements FieldSetMapper<LineItem> {
|
||||
public static final String ITEM_ID_COLUMN = "ITEM_ID";
|
||||
|
||||
|
||||
public LineItem process(FieldSet fieldSet) {
|
||||
public LineItem map(FieldSet fieldSet) {
|
||||
LineItem item = new LineItem();
|
||||
|
||||
item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN));
|
||||
|
||||
@@ -89,7 +89,7 @@ public class OrderItemReader implements ItemReader<Order> {
|
||||
// start a new Order
|
||||
if (Order.LINE_ID_HEADER.equals(lineId)) {
|
||||
log.debug("STARTING NEW RECORD");
|
||||
order = headerMapper.process(fieldSet);
|
||||
order = headerMapper.map(fieldSet);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class OrderItemReader implements ItemReader<Order> {
|
||||
log.debug("MAPPING CUSTOMER");
|
||||
|
||||
if (order.getCustomer() == null) {
|
||||
order.setCustomer(customerMapper.process(fieldSet));
|
||||
order.setCustomer(customerMapper.map(fieldSet));
|
||||
order.getCustomer().setBusinessCustomer(true);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class OrderItemReader implements ItemReader<Order> {
|
||||
log.debug("MAPPING CUSTOMER");
|
||||
|
||||
if (order.getCustomer() == null) {
|
||||
order.setCustomer(customerMapper.process(fieldSet));
|
||||
order.setCustomer(customerMapper.map(fieldSet));
|
||||
order.getCustomer().setBusinessCustomer(false);
|
||||
}
|
||||
|
||||
@@ -134,25 +134,25 @@ public class OrderItemReader implements ItemReader<Order> {
|
||||
|
||||
if (Address.LINE_ID_BILLING_ADDR.equals(lineId)) {
|
||||
log.debug("MAPPING BILLING ADDRESS");
|
||||
order.setBillingAddress(addressMapper.process(fieldSet));
|
||||
order.setBillingAddress(addressMapper.map(fieldSet));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Address.LINE_ID_SHIPPING_ADDR.equals(lineId)) {
|
||||
log.debug("MAPPING SHIPPING ADDRESS");
|
||||
order.setShippingAddress(addressMapper.process(fieldSet));
|
||||
order.setShippingAddress(addressMapper.map(fieldSet));
|
||||
return;
|
||||
}
|
||||
|
||||
if (BillingInfo.LINE_ID_BILLING_INFO.equals(lineId)) {
|
||||
log.debug("MAPPING BILLING INFO");
|
||||
order.setBilling(billingMapper.process(fieldSet));
|
||||
order.setBilling(billingMapper.map(fieldSet));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ShippingInfo.LINE_ID_SHIPPING_INFO.equals(lineId)) {
|
||||
log.debug("MAPPING SHIPPING INFO");
|
||||
order.setShipping(shippingMapper.process(fieldSet));
|
||||
order.setShipping(shippingMapper.map(fieldSet));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class OrderItemReader implements ItemReader<Order> {
|
||||
if (order.getLineItems() == null) {
|
||||
order.setLineItems(new ArrayList<LineItem>());
|
||||
}
|
||||
order.getLineItems().add(itemMapper.process(fieldSet));
|
||||
order.getLineItems().add(itemMapper.map(fieldSet));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,18 +50,18 @@ public class OrderProcessor implements ItemProcessor<Order, List<String>> {
|
||||
|
||||
List<String> result = new ArrayList<String>();
|
||||
|
||||
result.add(getAggregator("header").process(OrderFormatterUtils.headerArgs(order)));
|
||||
result.add(getAggregator("customer").process(OrderFormatterUtils.customerArgs(order)));
|
||||
result.add(getAggregator("address").process(OrderFormatterUtils.billingAddressArgs(order)));
|
||||
result.add(getAggregator("billing").process(OrderFormatterUtils.billingInfoArgs(order)));
|
||||
result.add(getAggregator("header").aggregate(OrderFormatterUtils.headerArgs(order)));
|
||||
result.add(getAggregator("customer").aggregate(OrderFormatterUtils.customerArgs(order)));
|
||||
result.add(getAggregator("address").aggregate(OrderFormatterUtils.billingAddressArgs(order)));
|
||||
result.add(getAggregator("billing").aggregate(OrderFormatterUtils.billingInfoArgs(order)));
|
||||
|
||||
List<LineItem> items = order.getLineItems();
|
||||
|
||||
for (LineItem lineItem : items) {
|
||||
result.add(getAggregator("item").process(OrderFormatterUtils.lineItemArgs(lineItem)));
|
||||
result.add(getAggregator("item").aggregate(OrderFormatterUtils.lineItemArgs(lineItem)));
|
||||
}
|
||||
|
||||
result.add(getAggregator("footer").process(OrderFormatterUtils.footerArgs(order)));
|
||||
result.add(getAggregator("footer").aggregate(OrderFormatterUtils.footerArgs(order)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ShippingFieldSetMapper implements FieldSetMapper<ShippingInfo> {
|
||||
public static final String SHIPPING_TYPE_ID_COLUMN = "SHIPPING_TYPE_ID";
|
||||
public static final String SHIPPER_ID_COLUMN = "SHIPPER_ID";
|
||||
|
||||
public ShippingInfo process(FieldSet fieldSet) {
|
||||
public ShippingInfo map(FieldSet fieldSet) {
|
||||
ShippingInfo info = new ShippingInfo();
|
||||
|
||||
info.setShipperId(fieldSet.readString(SHIPPER_ID_COLUMN));
|
||||
|
||||
@@ -26,11 +26,11 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.item.file.transform.LineTokenizer#tokenize(java.lang.String)
|
||||
*/
|
||||
public FieldSet process(String line) {
|
||||
public FieldSet tokenize(String line) {
|
||||
|
||||
if(line.charAt(0) == 'F'){
|
||||
//line starts with F, so the footer tokenizer should tokenize it.
|
||||
FieldSet fs = footerTokenizer.process(line);
|
||||
FieldSet fs = footerTokenizer.tokenize(line);
|
||||
long customerUpdateTotal = stepExecution.getReadCount();
|
||||
long fileUpdateTotal = fs.readLong(1);
|
||||
if(customerUpdateTotal != fileUpdateTotal){
|
||||
@@ -45,7 +45,7 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS
|
||||
}
|
||||
else if(line.charAt(0) == 'A' || line.charAt(0) == 'U' || line.charAt(0) == 'D'){
|
||||
//line starts with A,U, or D, so it must be a customer operation.
|
||||
return customerTokenizer.process(line);
|
||||
return customerTokenizer.tokenize(line);
|
||||
}
|
||||
else{
|
||||
//If the line doesn't start with any of the characters above, it must obviously be invalid.
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.batch.item.file.mapping.FieldSetMapper;
|
||||
*/
|
||||
public class CustomerUpdateFieldSetMapper implements FieldSetMapper<CustomerUpdate> {
|
||||
|
||||
public CustomerUpdate process(FieldSet fs) {
|
||||
public CustomerUpdate map(FieldSet fs) {
|
||||
|
||||
CustomerOperation operation = CustomerOperation.fromCode(fs.readChar(0));
|
||||
String name = fs.readString(1);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TradeFieldSetMapper implements FieldSetMapper<Trade> {
|
||||
public static final int PRICE_COLUMN = 2;
|
||||
public static final int CUSTOMER_COLUMN = 3;
|
||||
|
||||
public Trade process(FieldSet fieldSet) {
|
||||
public Trade map(FieldSet fieldSet) {
|
||||
|
||||
Trade trade = new Trade();
|
||||
trade.setIsin(fieldSet.readString(ISIN_COLUMN));
|
||||
|
||||
Reference in New Issue
Block a user