BATCH-1247: Clean up multilineOrderJob sample

This commit is contained in:
dhgarrette
2009-05-22 06:13:28 +00:00
parent bd57241b6a
commit bf2d9af030
30 changed files with 486 additions and 609 deletions

View File

@@ -52,7 +52,7 @@ public class OrderItemReader implements ItemReader<Order> {
private FieldSetMapper<LineItem> itemMapper;
private FieldSetMapper<ShippingInfo> shippingMapper;
private ItemReader<FieldSet> fieldSetReader;
/**
@@ -67,7 +67,7 @@ public class OrderItemReader implements ItemReader<Order> {
}
log.info("Mapped: " + order);
Order result = order;
order = null;
@@ -80,7 +80,6 @@ public class OrderItemReader implements ItemReader<Order> {
log.debug("FINISHED");
recordFinished = true;
order = null;
return;
}
@@ -90,12 +89,8 @@ public class OrderItemReader implements ItemReader<Order> {
if (Order.LINE_ID_HEADER.equals(lineId)) {
log.debug("STARTING NEW RECORD");
order = headerMapper.mapFieldSet(fieldSet);
return;
}
// mark we are finished with current Order
if (Order.LINE_ID_FOOTER.equals(lineId)) {
else if (Order.LINE_ID_FOOTER.equals(lineId)) {
log.debug("END OF RECORD");
// Do mapping for footer here, because mapper does not allow to pass
@@ -105,74 +100,57 @@ public class OrderItemReader implements ItemReader<Order> {
order.setTotalLines(fieldSet.readInt("TOTAL_LINE_ITEMS"));
order.setTotalItems(fieldSet.readInt("TOTAL_ITEMS"));
// mark we are finished with current Order
recordFinished = true;
return;
}
if (Customer.LINE_ID_BUSINESS_CUST.equals(lineId)) {
else if (Customer.LINE_ID_BUSINESS_CUST.equals(lineId)) {
log.debug("MAPPING CUSTOMER");
if (order.getCustomer() == null) {
order.setCustomer(customerMapper.mapFieldSet(fieldSet));
order.getCustomer().setBusinessCustomer(true);
Customer customer = customerMapper.mapFieldSet(fieldSet);
customer.setBusinessCustomer(true);
order.setCustomer(customer);
}
return;
}
if (Customer.LINE_ID_NON_BUSINESS_CUST.equals(lineId)) {
else if (Customer.LINE_ID_NON_BUSINESS_CUST.equals(lineId)) {
log.debug("MAPPING CUSTOMER");
if (order.getCustomer() == null) {
order.setCustomer(customerMapper.mapFieldSet(fieldSet));
order.getCustomer().setBusinessCustomer(false);
Customer customer = customerMapper.mapFieldSet(fieldSet);
customer.setBusinessCustomer(false);
order.setCustomer(customer);
}
return;
}
if (Address.LINE_ID_BILLING_ADDR.equals(lineId)) {
else if (Address.LINE_ID_BILLING_ADDR.equals(lineId)) {
log.debug("MAPPING BILLING ADDRESS");
order.setBillingAddress(addressMapper.mapFieldSet(fieldSet));
return;
}
if (Address.LINE_ID_SHIPPING_ADDR.equals(lineId)) {
else if (Address.LINE_ID_SHIPPING_ADDR.equals(lineId)) {
log.debug("MAPPING SHIPPING ADDRESS");
order.setShippingAddress(addressMapper.mapFieldSet(fieldSet));
return;
}
if (BillingInfo.LINE_ID_BILLING_INFO.equals(lineId)) {
else if (BillingInfo.LINE_ID_BILLING_INFO.equals(lineId)) {
log.debug("MAPPING BILLING INFO");
order.setBilling(billingMapper.mapFieldSet(fieldSet));
return;
}
if (ShippingInfo.LINE_ID_SHIPPING_INFO.equals(lineId)) {
else if (ShippingInfo.LINE_ID_SHIPPING_INFO.equals(lineId)) {
log.debug("MAPPING SHIPPING INFO");
order.setShipping(shippingMapper.mapFieldSet(fieldSet));
return;
}
if (LineItem.LINE_ID_ITEM.equals(lineId)) {
else if (LineItem.LINE_ID_ITEM.equals(lineId)) {
log.debug("MAPPING LINE ITEM");
if (order.getLineItems() == null) {
order.setLineItems(new ArrayList<LineItem>());
}
order.getLineItems().add(itemMapper.mapFieldSet(fieldSet));
return;
}
else {
log.debug("Could not map LINE_ID=" + lineId);
}
log.debug("Could not map LINE_ID=" + lineId);
}
/**
* @param fieldSetReader reads lines from the file converting them to {@link FieldSet}.
* @param fieldSetReader reads lines from the file converting them to
* {@link FieldSet}.
*/
public void setFieldSetReader(ItemReader<FieldSet> fieldSetReader) {
this.fieldSetReader = fieldSetReader;

View File

@@ -16,16 +16,12 @@
package org.springframework.batch.sample.domain.order.internal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.file.transform.LineAggregator;
import org.springframework.batch.sample.domain.order.Address;
import org.springframework.batch.sample.domain.order.BillingInfo;
import org.springframework.batch.sample.domain.order.Customer;
import org.springframework.batch.sample.domain.order.LineItem;
import org.springframework.batch.sample.domain.order.Order;
@@ -39,80 +35,34 @@ public class OrderProcessor implements ItemProcessor<Order, List<String>> {
/**
* Aggregators for all types of lines in the output file
*/
private Map<String, LineAggregator<Object[]>> aggregators;
private Map<String, LineAggregator<Object>> aggregators;
/**
* Converts information from an Order object to a collection of Strings for
* output.
* @throws Exception
*
* @throws Exception
*/
public List<String> process(Order order) throws Exception {
List<String> result = new ArrayList<String>();
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)));
result.add(aggregators.get("header").aggregate(order));
result.add(aggregators.get("customer").aggregate(order));
result.add(aggregators.get("address").aggregate(order));
result.add(aggregators.get("billing").aggregate(order));
List<LineItem> items = order.getLineItems();
for (LineItem lineItem : items) {
result.add(getAggregator("item").aggregate(OrderFormatterUtils.lineItemArgs(lineItem)));
for (LineItem lineItem : order.getLineItems()) {
result.add(aggregators.get("item").aggregate(lineItem));
}
result.add(getAggregator("footer").aggregate(OrderFormatterUtils.footerArgs(order)));
result.add(aggregators.get("footer").aggregate(order));
return result;
}
public void setAggregators(Map<String, LineAggregator<Object[]>> aggregators) {
public void setAggregators(Map<String, LineAggregator<Object>> aggregators) {
this.aggregators = aggregators;
}
private LineAggregator<Object[]> getAggregator(String name) {
return aggregators.get(name);
}
/**
* Utility class encapsulating formatting of <code>Order</code> and its
* nested objects.
*/
private static class OrderFormatterUtils {
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
static Object[] headerArgs(Order order) {
return new Object[] { "BEGIN_ORDER:", String.valueOf(order.getOrderId()),
dateFormat.format(order.getOrderDate()) };
}
static Object[] footerArgs(Order order) {
return new Object[] { "END_ORDER:", order.getTotalPrice().toString() };
}
static Object[] customerArgs(Order order) {
Customer customer = order.getCustomer();
return new Object[] { "CUSTOMER:", String.valueOf(customer.getRegistrationId()), customer.getFirstName(),
customer.getMiddleName(), customer.getLastName() };
}
static Object[] lineItemArgs(LineItem item) {
return new Object[] { "ITEM:", String.valueOf(item.getItemId()), item.getPrice().toString() };
}
static Object[] billingAddressArgs(Order order) {
Address address = order.getBillingAddress();
return new Object[] { "ADDRESS:", address.getAddrLine1(), address.getCity(), address.getZipCode() };
}
static Object[] billingInfoArgs(Order order) {
BillingInfo billingInfo = order.getBilling();
return new Object[] { "BILLING:", billingInfo.getPaymentId(), billingInfo.getPaymentDesc() };
}
}
}

View File

@@ -0,0 +1,18 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.Address;
import org.springframework.batch.sample.domain.order.Order;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class AddressFieldExtractor implements FieldExtractor<Order> {
public Object[] extract(Order order) {
Address address = order.getBillingAddress();
return new Object[] { "ADDRESS:", address.getAddrLine1(), address.getCity(), address.getZipCode() };
}
}

View File

@@ -0,0 +1,18 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.BillingInfo;
import org.springframework.batch.sample.domain.order.Order;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class BillingInfoFieldExtractor implements FieldExtractor<Order> {
public Object[] extract(Order order) {
BillingInfo billingInfo = order.getBilling();
return new Object[] { "BILLING:", billingInfo.getPaymentId(), billingInfo.getPaymentDesc() };
}
}

View File

@@ -0,0 +1,23 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.Customer;
import org.springframework.batch.sample.domain.order.Order;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class CustomerFieldExtractor implements FieldExtractor<Order> {
public Object[] extract(Order order) {
Customer customer = order.getCustomer();
return new Object[] { "CUSTOMER:", customer.getRegistrationId(), emptyIfNull(customer.getFirstName()),
emptyIfNull(customer.getMiddleName()), emptyIfNull(customer.getLastName()) };
}
private String emptyIfNull(String s) {
return s != null ? s : "";
}
}

View File

@@ -0,0 +1,16 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.Order;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class FooterFieldExtractor implements FieldExtractor<Order> {
public Object[] extract(Order order) {
return new Object[] { "END_ORDER:", order.getTotalPrice() };
}
}

View File

@@ -0,0 +1,20 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import java.text.SimpleDateFormat;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.Order;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class HeaderFieldExtractor implements FieldExtractor<Order> {
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
public Object[] extract(Order order) {
return new Object[] { "BEGIN_ORDER:", order.getOrderId(), dateFormat.format(order.getOrderDate()) };
}
}

View File

@@ -0,0 +1,16 @@
package org.springframework.batch.sample.domain.order.internal.extractor;
import org.springframework.batch.item.file.transform.FieldExtractor;
import org.springframework.batch.sample.domain.order.LineItem;
/**
* @author Dan Garrette
* @since 2.0.1
*/
public class LineItemFieldExtractor implements FieldExtractor<LineItem> {
public Object[] extract(LineItem item) {
return new Object[] { "ITEM:", item.getItemId(), item.getPrice() };
}
}

View File

@@ -14,16 +14,14 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.Address;
public class AddressFieldSetMapper implements FieldSetMapper<Address> {
public static final String ADDRESSEE_COLUMN = "ADDRESSEE";
public static final String ADDRESS_LINE1_COLUMN = "ADDR_LINE1";
public static final String ADDRESS_LINE2_COLUMN = "ADDR_LINE2";
@@ -31,19 +29,18 @@ public class AddressFieldSetMapper implements FieldSetMapper<Address> {
public static final String ZIP_CODE_COLUMN = "ZIP_CODE";
public static final String STATE_COLUMN = "STATE";
public static final String COUNTRY_COLUMN = "COUNTRY";
public Address mapFieldSet(FieldSet fieldSet) {
Address address = new Address();
address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN));
address.setAddrLine1(fieldSet.readString(ADDRESS_LINE1_COLUMN));
address.setAddrLine2(fieldSet.readString(ADDRESS_LINE2_COLUMN));
address.setCity(fieldSet.readString(CITY_COLUMN));
address.setZipCode(fieldSet.readString(ZIP_CODE_COLUMN));
address.setState(fieldSet.readString(STATE_COLUMN));
address.setCountry(fieldSet.readString(COUNTRY_COLUMN));
public Address mapFieldSet(FieldSet fieldSet) {
Address address = new Address();
return address;
}
address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN));
address.setAddrLine1(fieldSet.readString(ADDRESS_LINE1_COLUMN));
address.setAddrLine2(fieldSet.readString(ADDRESS_LINE2_COLUMN));
address.setCity(fieldSet.readString(CITY_COLUMN));
address.setZipCode(fieldSet.readString(ZIP_CODE_COLUMN));
address.setState(fieldSet.readString(STATE_COLUMN));
address.setCountry(fieldSet.readString(COUNTRY_COLUMN));
return address;
}
}

View File

@@ -14,25 +14,23 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.BillingInfo;
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 mapFieldSet(FieldSet fieldSet) {
BillingInfo info = new BillingInfo();
info.setPaymentId(fieldSet.readString(PAYMENT_TYPE_ID_COLUMN));
info.setPaymentDesc(fieldSet.readString(PAYMENT_DESC_COLUMN));
public BillingInfo mapFieldSet(FieldSet fieldSet) {
BillingInfo info = new BillingInfo();
return info;
}
info.setPaymentId(fieldSet.readString(PAYMENT_TYPE_ID_COLUMN));
info.setPaymentDesc(fieldSet.readString(PAYMENT_DESC_COLUMN));
return info;
}
}

View File

@@ -14,16 +14,14 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.Customer;
public class CustomerFieldSetMapper implements FieldSetMapper<Customer> {
public static final String LINE_ID_COLUMN = "LINE_ID";
public static final String COMPANY_NAME_COLUMN = "COMPANY_NAME";
public static final String LAST_NAME_COLUMN = "LAST_NAME";
@@ -33,26 +31,26 @@ public class CustomerFieldSetMapper implements FieldSetMapper<Customer> {
public static final String REGISTERED_COLUMN = "REGISTERED";
public static final String REG_ID_COLUMN = "REG_ID";
public static final String VIP_COLUMN = "VIP";
public Customer mapFieldSet(FieldSet fieldSet) {
Customer customer = new Customer();
if (Customer.LINE_ID_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {
customer.setCompanyName(fieldSet.readString(COMPANY_NAME_COLUMN));
//business customer must be always registered
customer.setRegistered(true);
}
public Customer mapFieldSet(FieldSet fieldSet) {
Customer customer = new Customer();
if (Customer.LINE_ID_NON_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {
customer.setLastName(fieldSet.readString(LAST_NAME_COLUMN));
customer.setFirstName(fieldSet.readString(FIRST_NAME_COLUMN));
customer.setMiddleName(fieldSet.readString(MIDDLE_NAME_COLUMN));
customer.setRegistered(TRUE_SYMBOL.equals(fieldSet.readString(REGISTERED_COLUMN)));
}
if (Customer.LINE_ID_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {
customer.setCompanyName(fieldSet.readString(COMPANY_NAME_COLUMN));
// business customer must be always registered
customer.setRegistered(true);
}
customer.setRegistrationId(fieldSet.readLong(REG_ID_COLUMN));
customer.setVip(TRUE_SYMBOL.equals(fieldSet.readString(VIP_COLUMN)));
if (Customer.LINE_ID_NON_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) {
customer.setLastName(fieldSet.readString(LAST_NAME_COLUMN));
customer.setFirstName(fieldSet.readString(FIRST_NAME_COLUMN));
customer.setMiddleName(fieldSet.readString(MIDDLE_NAME_COLUMN));
customer.setRegistered(TRUE_SYMBOL.equals(fieldSet.readString(REGISTERED_COLUMN)));
}
return customer;
}
customer.setRegistrationId(fieldSet.readLong(REG_ID_COLUMN));
customer.setVip(TRUE_SYMBOL.equals(fieldSet.readString(VIP_COLUMN)));
return customer;
}
}

View File

@@ -14,24 +14,22 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.Order;
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 mapFieldSet(FieldSet fieldSet) {
Order order = new Order();
order.setOrderId(fieldSet.readLong(ORDER_ID_COLUMN));
order.setOrderDate(fieldSet.readDate(ORDER_DATE_COLUMN));
return order;
}
public Order mapFieldSet(FieldSet fieldSet) {
Order order = new Order();
order.setOrderId(fieldSet.readLong(ORDER_ID_COLUMN));
order.setOrderDate(fieldSet.readDate(ORDER_DATE_COLUMN));
return order;
}
}

View File

@@ -14,15 +14,14 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.LineItem;
public class OrderItemFieldSetMapper implements FieldSetMapper<LineItem> {
public static final String TOTAL_PRICE_COLUMN = "TOTAL_PRICE";
public static final String QUANTITY_COLUMN = "QUANTITY";
public static final String HANDLING_PRICE_COLUMN = "HANDLING_PRICE";
@@ -31,20 +30,19 @@ public class OrderItemFieldSetMapper implements FieldSetMapper<LineItem> {
public static final String DISCOUNT_PERC_COLUMN = "DISCOUNT_PERC";
public static final String PRICE_COLUMN = "PRICE";
public static final String ITEM_ID_COLUMN = "ITEM_ID";
public LineItem mapFieldSet(FieldSet fieldSet) {
LineItem item = new LineItem();
item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN));
item.setPrice(fieldSet.readBigDecimal(PRICE_COLUMN));
item.setDiscountPerc(fieldSet.readBigDecimal(DISCOUNT_PERC_COLUMN));
item.setDiscountAmount(fieldSet.readBigDecimal(DISCOUNT_AMOUNT_COLUMN));
item.setShippingPrice(fieldSet.readBigDecimal(SHIPPING_PRICE_COLUMN));
item.setHandlingPrice(fieldSet.readBigDecimal(HANDLING_PRICE_COLUMN));
item.setQuantity(fieldSet.readInt(QUANTITY_COLUMN));
item.setTotalPrice(fieldSet.readBigDecimal(TOTAL_PRICE_COLUMN));
public LineItem mapFieldSet(FieldSet fieldSet) {
LineItem item = new LineItem();
return item;
}
item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN));
item.setPrice(fieldSet.readBigDecimal(PRICE_COLUMN));
item.setDiscountPerc(fieldSet.readBigDecimal(DISCOUNT_PERC_COLUMN));
item.setDiscountAmount(fieldSet.readBigDecimal(DISCOUNT_AMOUNT_COLUMN));
item.setShippingPrice(fieldSet.readBigDecimal(SHIPPING_PRICE_COLUMN));
item.setHandlingPrice(fieldSet.readBigDecimal(HANDLING_PRICE_COLUMN));
item.setQuantity(fieldSet.readInt(QUANTITY_COLUMN));
item.setTotalPrice(fieldSet.readBigDecimal(TOTAL_PRICE_COLUMN));
return item;
}
}

View File

@@ -14,27 +14,25 @@
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order.internal;
package org.springframework.batch.sample.domain.order.internal.mapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.ShippingInfo;
public class ShippingFieldSetMapper implements FieldSetMapper<ShippingInfo> {
public static final String ADDITIONAL_SHIPPING_INFO_COLUMN = "ADDITIONAL_SHIPPING_INFO";
public static final String ADDITIONAL_SHIPPING_INFO_COLUMN = "ADDITIONAL_SHIPPING_INFO";
public static final String SHIPPING_TYPE_ID_COLUMN = "SHIPPING_TYPE_ID";
public static final String SHIPPER_ID_COLUMN = "SHIPPER_ID";
public ShippingInfo mapFieldSet(FieldSet fieldSet) {
ShippingInfo info = new ShippingInfo();
ShippingInfo info = new ShippingInfo();
info.setShipperId(fieldSet.readString(SHIPPER_ID_COLUMN));
info.setShippingTypeId(fieldSet.readString(SHIPPING_TYPE_ID_COLUMN));
info.setShippingInfo(fieldSet.readString(ADDITIONAL_SHIPPING_INFO_COLUMN));
info.setShipperId(fieldSet.readString(SHIPPER_ID_COLUMN));
info.setShippingTypeId(fieldSet.readString(SHIPPING_TYPE_ID_COLUMN));
info.setShippingInfo(fieldSet.readString(ADDITIONAL_SHIPPING_INFO_COLUMN));
return info;
}
return info;
}
}

View File

@@ -1,4 +1,3 @@
FHE;20070215-0001;2007-02-15
HEA;0013100345;2007-02-15
NCU;Smith;Peter;;T;20014539;F
BAD;;Oak Street 31/A;;Small Town;00235;IL;US
@@ -19,4 +18,3 @@ LIT;2134747319;55.29;10;0;7.99;2.99;6;364.45
LIT;1044359501;339.99;10;0;7.99;2.99;2;633.94
SIN;FEDX;AMS;
FOT;5;36;14043.74
FFT;2;14311.08

View File

@@ -0,0 +1,17 @@
BEGIN_ORDER:13100345 2007/02/15
CUSTOMER:20014539 Peter Smith
ADDRESS:Oak Street 31/A Small Town00235
BILLING:VISA VISA-12345678903
ITEM:104439104137.49
ITEM:2134776319221.99
END_ORDER: 267.34
BEGIN_ORDER:13100346 2007/02/15
CUSTOMER:72155919
ADDRESS:St. Andrews Road 31 London 55342
BILLING:AMEX AMEX-72345678903
ITEM:10443191011070.50
ITEM:213472721921.79
ITEM:104433930179.95
ITEM:213474731955.29
ITEM:1044359501339.99
END_ORDER: 14043.74

View File

@@ -21,21 +21,17 @@
</batch:step>
</batch:job>
<bean id="itemReader"
class="org.springframework.batch.sample.iosample.internal.MultiLineTradeItemReader">
<bean id="itemReader" class="org.springframework.batch.sample.iosample.internal.MultiLineTradeItemReader">
<property name="delegate">
<bean class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="data/iosample/input/multiLine.txt" />
<property name="lineMapper">
<bean
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer" />
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer" />
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
<bean class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
</property>
</bean>
</property>
@@ -43,15 +39,12 @@
</property>
</bean>
<bean id="itemWriter"
class="org.springframework.batch.sample.iosample.internal.MultiLineTradeItemWriter">
<bean id="itemWriter" class="org.springframework.batch.sample.iosample.internal.MultiLineTradeItemWriter">
<property name="delegate">
<bean class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource"
value="file:target/test-outputs/multiLineOutput.txt" />
<property name="resource" value="file:target/test-outputs/multiLineOutput.txt" />
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.PassThroughLineAggregator" />
<bean class="org.springframework.batch.item.file.transform.PassThroughLineAggregator" />
</property>
</bean>
</property>

View File

@@ -3,8 +3,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="orderFileTokenizer"
class="org.springframework.batch.item.file.transform.PatternMatchingCompositeLineTokenizer">
<bean id="orderFileTokenizer" class="org.springframework.batch.item.file.transform.PatternMatchingCompositeLineTokenizer">
<property name="tokenizers">
<map>
<entry key="HEA*" value-ref="headerRecordTokenizer" />
@@ -16,17 +15,14 @@
<entry key="BIN*" value-ref="billingLineTokenizer" />
<entry key="SIN*" value-ref="shippingLineTokenizer" />
<entry key="LIT*" value-ref="itemLineTokenizer" />
<entry key="*" value-ref="defaultLineTokenizer" />
<entry key="*" value-ref="defaultLineTokenizer" />
</map>
</property>
</bean>
<bean id="defaultLineTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
</bean>
<bean id="defaultLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"/>
<bean id="parentLineTokenizer" abstract="true"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<bean id="parentLineTokenizer" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer" abstract="true">
<property name="delimiter" value=";"/>
</bean>
@@ -63,8 +59,7 @@
</bean>
<bean id="itemLineTokenizer" parent="parentLineTokenizer">
<property name="names"
value="LINE_ID,ITEM_ID,PRICE,DISCOUNT_PERC,DISCOUNT_AMOUNT,SHIPPING_PRICE,HANDLING_PRICE,QUANTITY,TOTAL_PRICE" />
<property name="names" value="LINE_ID,ITEM_ID,PRICE,DISCOUNT_PERC,DISCOUNT_AMOUNT,SHIPPING_PRICE,HANDLING_PRICE,QUANTITY,TOTAL_PRICE" />
</bean>
</beans>

View File

@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="fileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" ref="fileInputLocator" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="orderFileTokenizer" />
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<bean id="fileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" ref="fileOutputLocator" />
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.RecursiveCollectionLineAggregator" />
</property>
</bean>
<bean id="delimitedLineAggregator" class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer" />
<bean id="fixedLineAggregator" class="org.springframework.batch.item.file.transform.FormatterLineAggregator" />
</beans>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/batch" xmlns:beans="http://www.springframework.org/schema/beans"
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
@@ -8,146 +8,70 @@
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<beans:import resource="multilineOrderInputTokenizers.xml" />
<beans:import resource="multilineOrderOutputAggregators.xml" />
<beans:import resource="multilineOrderIo.xml" />
<import resource="multilineOrderInputTokenizers.xml" />
<import resource="multilineOrderOutputAggregators.xml" />
<import resource="multilineOrderValidator.xml" />
<job id="multilineOrderJob">
<step id="step1">
<tasklet>
<chunk reader="reader" processor="processor" writer="fileItemWriter" commit-interval="5">
<streams>
<stream ref="fileItemWriter"/>
<stream ref="fileItemReader"/>
</streams>
</chunk>
</tasklet>
</step>
</job>
<batch:job id="multilineOrderJob">
<batch:step id="step1">
<batch:tasklet>
<batch:chunk reader="reader" processor="processor" writer="fileItemWriter" commit-interval="5">
<batch:streams>
<batch:stream ref="fileItemReader"/>
<batch:stream ref="fileItemWriter"/>
</batch:streams>
</batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<beans:bean id="reader" class="org.springframework.batch.sample.domain.order.internal.OrderItemReader">
<beans:property name="fieldSetReader" ref="fileItemReader" />
<beans:property name="headerMapper" ref="headerFieldSetMapper" />
<beans:property name="customerMapper" ref="customerFieldSetMapper" />
<beans:property name="addressMapper" ref="addressFieldSetMapper" />
<beans:property name="billingMapper" ref="billingFieldSetMapper" />
<beans:property name="itemMapper" ref="orderItemFieldSetMapper" />
<beans:property name="shippingMapper" ref="shippingFieldSetMapper" />
</beans:bean>
<bean id="reader" class="org.springframework.batch.sample.domain.order.internal.OrderItemReader">
<property name="fieldSetReader" ref="fileItemReader" />
<property name="headerMapper" ref="headerFieldSetMapper" />
<property name="customerMapper" ref="customerFieldSetMapper" />
<property name="addressMapper" ref="addressFieldSetMapper" />
<property name="billingMapper" ref="billingFieldSetMapper" />
<property name="itemMapper" ref="orderItemFieldSetMapper" />
<property name="shippingMapper" ref="shippingFieldSetMapper" />
</bean>
<beans:bean id="processor" class="org.springframework.batch.item.support.CompositeItemProcessor">
<beans:property name="itemProcessors">
<beans:list>
<beans:bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<beans:constructor-arg ref="validator" />
</beans:bean>
<beans:bean class="org.springframework.batch.sample.domain.order.internal.OrderProcessor">
<beans:property name="aggregators" ref="outputAggregators" />
</beans:bean>
</beans:list>
</beans:property>
</beans:bean>
<bean id="fileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="data/multilineOrderJob/input/multilineOrderInput.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="orderFileTokenizer" />
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<beans:bean id="headerFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.HeaderFieldSetMapper" />
<beans:bean id="customerFieldSetMapper"
class="org.springframework.batch.sample.domain.order.internal.CustomerFieldSetMapper" />
<beans:bean id="addressFieldSetMapper"
class="org.springframework.batch.sample.domain.order.internal.AddressFieldSetMapper" />
<beans:bean id="billingFieldSetMapper"
class="org.springframework.batch.sample.domain.order.internal.BillingFieldSetMapper" />
<beans:bean id="orderItemFieldSetMapper"
class="org.springframework.batch.sample.domain.order.internal.OrderItemFieldSetMapper" />
<beans:bean id="shippingFieldSetMapper"
class="org.springframework.batch.sample.domain.order.internal.ShippingFieldSetMapper" />
<bean id="headerFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.HeaderFieldSetMapper" />
<bean id="customerFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.CustomerFieldSetMapper" />
<bean id="addressFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.AddressFieldSetMapper" />
<bean id="billingFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.BillingFieldSetMapper" />
<bean id="orderItemFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.OrderItemFieldSetMapper" />
<bean id="shippingFieldSetMapper" class="org.springframework.batch.sample.domain.order.internal.mapper.ShippingFieldSetMapper" />
<beans:bean id="validator" class="org.springframework.batch.item.validator.SpringValidator">
<beans:property name="validator">
<beans:bean id="orderValidator" class="org.springmodules.validation.valang.ValangValidator">
<beans:property name="valang">
<beans:value>
<![CDATA[
{ orderId : ? > 0 AND ? <= 9999999999 : 'Incorrect order ID' : 'error.order.id' }
{ orderDate : isFutureDate(?) = FALSE : 'Future date is not allowed' : 'error.order.date.future' }
{ totalLines : ? = size(lineItems) : 'Bad count of order lines' : 'error.order.lines.badcount'}
<bean id="processor" class="org.springframework.batch.item.support.CompositeItemProcessor">
<property name="itemProcessors">
<list>
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="validator" />
</bean>
<bean class="org.springframework.batch.sample.domain.order.internal.OrderProcessor">
<property name="aggregators" ref="outputAggregators"/>
</bean>
</list>
</property>
</bean>
{ customer.registered : customer.businessCustomer = FALSE OR ? = TRUE : 'Business customer must be registered' : 'error.customer.registration'}
{ customer.companyName : customer.businessCustomer = FALSE OR ? HAS TEXT : 'Company name for business customer is mandatory' : 'error.customer.companyname'}
{ customer.firstName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Firstname for non-business customer is mandatory' : 'error.customer.firstname'}
{ customer.lastName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Lastname name for non-business customer is mandatory' : 'error.customer.lastname'}
{ customer.registrationId : customer.registered = FALSE OR (? > 0 AND ? < 99999999) : 'Incorrect registration ID' : 'error.customer.registrationid'}
<bean id="fileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" value="file:target/test-outputs/multilineOrderOutput.txt" />
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.RecursiveCollectionLineAggregator" />
</property>
</bean>
{ billingAddress.addressee : ? HAS NO TEXT OR length(?) <= 60 : 'Maximum length for Addressee is 60 characters' : 'error.baddress.addresse.length'}
{ billingAddress.addrLine1 : ? HAS TEXT AND length(?) <= 50 : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ billingAddress.addrLine2 : ? HAS NO TEXT OR length(?) <= 50 : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ billingAddress.city : ? HAS TEXT AND length(?) <= 30 : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ billingAddress.zipCode : ? HAS TEXT AND length(?) <= 50 : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ billingAddress.zipCode : match('[0-9]{5}',?) = TRUE : 'ZipCode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ billingAddress.state : (? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ billingAddress.country : ? HAS TEXT AND length(?) <= 50 : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ shippingAddress.addressee : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 60) : 'Addressee is mandatory and maximum length for addressee is 60 characters' : 'error.saddress.addresse.length'}
{ shippingAddress.addrLine1 : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ shippingAddress.addrLine2 : shippingAddress IS NULL OR (? HAS NO TEXT OR length(?) <= 50) : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ shippingAddress.city : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 30) : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (match('[0-9]{5}',?) = TRUE) : 'Zipcode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ shippingAddress.state : shippingAddress IS NULL OR ((? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2)) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ shippingAddress.country : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ billing.paymentId : ? IN 'VISA','AMEX','ECMC','DCIN','PAYP' : 'Invalid payment type' : 'error.billing.type' }
{ billing.paymentDesc : match('[A-Z]{4}-[0-9]{10,11}',?) = TRUE : 'Invalid format of payment description' : 'error.billing.desc' }
{ shipping.shipperId : ? IN 'FEDX', 'UPS', 'DHL', 'DPD' : 'Invalid shipper ID' : 'error.shipping.shipper'}
{ shipping.shippingTypeId : ? IN 'STD', 'EXP', 'AMS', 'AME' : 'Invalid shipping type' : 'error.shipping.type' }
{ shipping.shippingInfo : ? HAS NO TEXT OR length(?) <= 100 : 'Maximum length for additional shipping info is 100 characters' }
{ lineItems : validateTotalItemsCount(totalItems,?) = TRUE : 'Bad count of total line items' : 'error.lineitems.badcount' }
{ lineItems : validateIds(?) = TRUE : 'One or more invalid item IDs' : 'error.lineitems.id' }
{ lineItems : validatePrices(?) = TRUE : 'One or more invalid item prices' : 'error.lineitems.price' }
{ lineItems : validateDiscounts(?) = TRUE : 'One or more invalid item discounts' : 'error.lineitems.discount' }
{ lineItems : validateShippingPrices(?) = TRUE : 'One or more invalid item shipping prices' : 'error.lineitems.shipping' }
{ lineItems : validateHandlingPrices(?) = TRUE : 'One or more invalid item handling prices' : 'error.lineitems.handling' }
{ lineItems : validateQuantities(?) = TRUE : 'One or more invalid item quantities' : 'error.lineitems.quantity' }
{ lineItems : validateTotalPrices(?) = TRUE : 'One or more invalid item total prices' : 'error.lineitems.totalprice' }
]]>
</beans:value>
</beans:property>
<beans:property name="customFunctions">
<beans:map>
<beans:entry key="isFutureDate"
value="org.springframework.batch.sample.domain.order.internal.valang.FutureDateFunction" />
<beans:entry key="validateTotalItemsCount"
value="org.springframework.batch.sample.domain.order.internal.valang.TotalOrderItemsFunction" />
<beans:entry key="validateIds"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateIdsFunction" />
<beans:entry key="validatePrices"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidatePricesFunction" />
<beans:entry key="validateDiscounts"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateDiscountsFunction" />
<beans:entry key="validateShippingPrices"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateShippingPricesFunction" />
<beans:entry key="validateHandlingPrices"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateHandlingPricesFunction" />
<beans:entry key="validateQuantities"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateQuantitiesFunction" />
<beans:entry key="validateTotalPrices"
value="org.springframework.batch.sample.domain.order.internal.valang.ValidateTotalPricesFunction" />
</beans:map>
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<!-- "{" <key> : <rule> : <message> : [ <error_code> [ : <error_parameters> ] ] "}"
-->
<beans:bean id="fileInputLocator" class="org.springframework.core.io.ClassPathResource">
<beans:constructor-arg type="java.lang.String"
value="data/multilineOrderJob/input/20070122.teststream.multilineOrderStep.txt" />
</beans:bean>
<beans:bean id="fileOutputLocator" class="org.springframework.core.io.FileSystemResource">
<beans:constructor-arg type="java.lang.String"
value="target/test-outputs/20070122.teststream.multilineOrderStep.TEMP.txt" />
</beans:bean>
</beans:beans>
</beans>

View File

@@ -6,34 +6,56 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<util:map id="outputAggregators">
<entry key="header" value-ref="outputHeader" />
<entry key="footer" value-ref="outputFooter" />
<entry key="header" value-ref="outputHeader" />
<entry key="footer" value-ref="outputFooter" />
<entry key="customer" value-ref="outputCustomer" />
<entry key="address" value-ref="outputAddress" />
<entry key="billing" value-ref="outputBilling" />
<entry key="item" value-ref="outputLineItem" />
<entry key="address" value-ref="outputAddress" />
<entry key="billing" value-ref="outputBilling" />
<entry key="item" value-ref="outputLineItem" />
</util:map>
<bean id="outputHeader" class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-12s%-10s%-30s" />
<bean id="baseAggregator" class="org.springframework.batch.item.file.transform.FormatterLineAggregator" abstract="true" />
<bean id="outputFooter"
class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-10s%20s"/>
<bean id="outputCustomer" class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-9s%-10s%-10s%-10s%-10s" />
<bean id="outputAddress"
class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-8s%-20s%-10s%-10s" />
<bean id="outputBilling"
class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-8s%-10s%-20s"/>
<bean id="outputLineItem"
class="org.springframework.batch.item.file.transform.FormatterLineAggregator"
p:format="%-5s%-10s%-10s" />
<bean id="outputHeader" parent="baseAggregator">
<property name="format" value="%-12s%-10s%-30s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.HeaderFieldExtractor"/>
</property>
</bean>
<bean id="outputFooter" parent="baseAggregator">
<property name="format" value="%-10s%20s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.FooterFieldExtractor"/>
</property>
</bean>
<bean id="outputCustomer" parent="baseAggregator">
<property name="format" value="%-9s%-10s%-10s%-10s%-10s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.CustomerFieldExtractor"/>
</property>
</bean>
<bean id="outputAddress" parent="baseAggregator">
<property name="format" value="%-8s%-20s%-10s%-10s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.AddressFieldExtractor"/>
</property>
</bean>
<bean id="outputBilling" parent="baseAggregator">
<property name="format" value="%-8s%-10s%-20s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.BillingInfoFieldExtractor"/>
</property>
</bean>
<bean id="outputLineItem" parent="baseAggregator">
<property name="format" value="%-5s%-10s%-10s"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.sample.domain.order.internal.extractor.LineItemFieldExtractor"/>
</property>
</bean>
</beans>

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="validator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="orderValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<!-- "{" <key> : <rule> : <message> : [ <error_code> [ : <error_parameters> ] ] "}" -->
<![CDATA[
{ orderId : ? > 0 AND ? <= 9999999999 : 'Incorrect order ID' : 'error.order.id' }
{ orderDate : isFutureDate(?) = FALSE : 'Future date is not allowed' : 'error.order.date.future' }
{ totalLines : ? = size(lineItems) : 'Bad count of order lines' : 'error.order.lines.badcount'}
{ customer.registered : customer.businessCustomer = FALSE OR ? = TRUE : 'Business customer must be registered' : 'error.customer.registration'}
{ customer.companyName : customer.businessCustomer = FALSE OR ? HAS TEXT : 'Company name for business customer is mandatory' : 'error.customer.companyname'}
{ customer.firstName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Firstname for non-business customer is mandatory' : 'error.customer.firstname'}
{ customer.lastName : customer.businessCustomer = TRUE OR ? HAS TEXT : 'Lastname name for non-business customer is mandatory' : 'error.customer.lastname'}
{ customer.registrationId : customer.registered = FALSE OR (? > 0 AND ? < 99999999) : 'Incorrect registration ID' : 'error.customer.registrationid'}
{ billingAddress.addressee : ? HAS NO TEXT OR length(?) <= 60 : 'Maximum length for Addressee is 60 characters' : 'error.baddress.addresse.length'}
{ billingAddress.addrLine1 : ? HAS TEXT AND length(?) <= 50 : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ billingAddress.addrLine2 : ? HAS NO TEXT OR length(?) <= 50 : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ billingAddress.city : ? HAS TEXT AND length(?) <= 30 : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ billingAddress.zipCode : ? HAS TEXT AND length(?) <= 50 : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ billingAddress.zipCode : match('[0-9]{5}',?) = TRUE : 'ZipCode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ billingAddress.state : (? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ billingAddress.country : ? HAS TEXT AND length(?) <= 50 : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ shippingAddress.addressee : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 60) : 'Addressee is mandatory and maximum length for addressee is 60 characters' : 'error.saddress.addresse.length'}
{ shippingAddress.addrLine1 : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Address line1 is mandatory and maximum length for address line1 is 50 characters' : 'error.baddress.addrline1.length'}
{ shippingAddress.addrLine2 : shippingAddress IS NULL OR (? HAS NO TEXT OR length(?) <= 50) : 'Maximum length for address line2 is 50 characters' : 'error.baddress.addrline2.length'}
{ shippingAddress.city : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 30) : 'City is mandatory and maximum length for city is 30 characters' : 'error.baddress.city.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Zipcode is mandatory and maximum length for zipcode is 5 characters' : 'error.baddress.zipcode.length'}
{ shippingAddress.zipCode : shippingAddress IS NULL OR (match('[0-9]{5}',?) = TRUE) : 'Zipcode must contain exactly 5 digits' : 'error.baddress.zipcode.format'}
{ shippingAddress.state : shippingAddress IS NULL OR ((? HAS NO TEXT AND billingAddress.country != 'United States') OR (? HAS TEXT AND length(?) <= 2)) : 'Maximum length for state is 2 characters' : 'error.baddress.state.length'}
{ shippingAddress.country : shippingAddress IS NULL OR (? HAS TEXT AND length(?) <= 50) : 'Country is mandatory and maximum length for country is 50 characters' : 'error.baddress.country.length'}
{ billing.paymentId : ? IN 'VISA','AMEX','ECMC','DCIN','PAYP' : 'Invalid payment type' : 'error.billing.type' }
{ billing.paymentDesc : match('[A-Z]{4}-[0-9]{10,11}',?) = TRUE : 'Invalid format of payment description' : 'error.billing.desc' }
{ shipping.shipperId : ? IN 'FEDX', 'UPS', 'DHL', 'DPD' : 'Invalid shipper ID' : 'error.shipping.shipper'}
{ shipping.shippingTypeId : ? IN 'STD', 'EXP', 'AMS', 'AME' : 'Invalid shipping type' : 'error.shipping.type' }
{ shipping.shippingInfo : ? HAS NO TEXT OR length(?) <= 100 : 'Maximum length for additional shipping info is 100 characters' }
{ lineItems : validateTotalItemsCount(totalItems,?) = TRUE : 'Bad count of total line items' : 'error.lineitems.badcount' }
{ lineItems : validateIds(?) = TRUE : 'One or more invalid item IDs' : 'error.lineitems.id' }
{ lineItems : validatePrices(?) = TRUE : 'One or more invalid item prices' : 'error.lineitems.price' }
{ lineItems : validateDiscounts(?) = TRUE : 'One or more invalid item discounts' : 'error.lineitems.discount' }
{ lineItems : validateShippingPrices(?) = TRUE : 'One or more invalid item shipping prices' : 'error.lineitems.shipping' }
{ lineItems : validateHandlingPrices(?) = TRUE : 'One or more invalid item handling prices' : 'error.lineitems.handling' }
{ lineItems : validateQuantities(?) = TRUE : 'One or more invalid item quantities' : 'error.lineitems.quantity' }
{ lineItems : validateTotalPrices(?) = TRUE : 'One or more invalid item total prices' : 'error.lineitems.totalprice' }
]]>
</value>
</property>
<property name="customFunctions">
<map>
<entry key="isFutureDate" value="org.springframework.batch.sample.domain.order.internal.valang.FutureDateFunction" />
<entry key="validateTotalItemsCount" value="org.springframework.batch.sample.domain.order.internal.valang.TotalOrderItemsFunction" />
<entry key="validateIds" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateIdsFunction" />
<entry key="validatePrices" value="org.springframework.batch.sample.domain.order.internal.valang.ValidatePricesFunction" />
<entry key="validateDiscounts" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateDiscountsFunction" />
<entry key="validateShippingPrices" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateShippingPricesFunction" />
<entry key="validateHandlingPrices" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateHandlingPricesFunction" />
<entry key="validateQuantities" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateQuantitiesFunction" />
<entry key="validateTotalPrices" value="org.springframework.batch.sample.domain.order.internal.valang.ValidateTotalPricesFunction" />
</map>
</property>
</bean>
</property>
</bean>
</beans>

View File

@@ -16,50 +16,27 @@
package org.springframework.batch.sample;
import static org.junit.Assert.assertEquals;
import static org.springframework.batch.test.AssertFile.assertFileEquals;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.test.AbstractJobTests;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.StringUtils;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration()
public class MultilineOrderJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
public class MultilineOrderJobFunctionalTests extends AbstractJobTests {
private static final String EXPECTED_OUTPUT =
"BEGIN_ORDER:13100345 2007/02/15 "+
"CUSTOMER:20014539 Peter Smith "+
"ADDRESS:Oak Street 31/A Small Town00235 "+
"BILLING:VISA VISA-12345678903 "+
"ITEM:104439104137.49 "+
"ITEM:2134776319221.99 "+
"END_ORDER: 267.34"+
"BEGIN_ORDER:13100346 2007/02/15 "+
"CUSTOMER:72155919 "+
"ADDRESS:St. Andrews Road 31 London 55342 "+
"BILLING:AMEX AMEX-72345678903 "+
"ITEM:10443191011070.50 "+
"ITEM:213472721921.79 "+
"ITEM:104433930179.95 "+
"ITEM:213474731955.29 "+
"ITEM:1044359501339.99 "+
"END_ORDER: 14043.74";
private static final String ACTUAL = "target/test-outputs/multilineOrderOutput.txt";
private static final String EXPECTED = "data/multilineOrderJob/result/multilineOrderOutput.txt";
private Resource fileOutputLocator = new FileSystemResource("target/test-outputs/20070122.teststream.multilineOrderStep.TEMP.txt");
/**
* Read the output file and compare it with expected string
* @throws IOException
*/
protected void validatePostConditions() throws Exception {
assertEquals(EXPECTED_OUTPUT, StringUtils.replace(IOUtils.toString(fileOutputLocator.getInputStream()), System.getProperty("line.separator"), ""));
@Test
public void testJob() throws Exception {
this.launchJob();
assertFileEquals(new ClassPathResource(EXPECTED), new FileSystemResource(ACTUAL));
}
}

View File

@@ -3,10 +3,9 @@ package org.springframework.batch.sample.domain.order;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.AddressFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.AddressFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final String ADDRESSEE = "Jan Hrach";
@@ -16,8 +15,6 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final String STATE = "";
private static final String COUNTRY = "Slovakia";
private static final String ZIP_CODE = "80000";
protected Object expectedDomainObject() {
Address address = new Address();
@@ -32,19 +29,13 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
}
protected FieldSet fieldSet() {
String[] tokens =
new String[]{ADDRESSEE, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY, STATE, COUNTRY, ZIP_CODE};
String[] columnNames =
new String[]{
AddressFieldSetMapper.ADDRESSEE_COLUMN,
AddressFieldSetMapper.ADDRESS_LINE1_COLUMN,
AddressFieldSetMapper.ADDRESS_LINE2_COLUMN,
AddressFieldSetMapper.CITY_COLUMN,
AddressFieldSetMapper.STATE_COLUMN,
AddressFieldSetMapper.COUNTRY_COLUMN,
AddressFieldSetMapper.ZIP_CODE_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
String[] tokens = new String[] { ADDRESSEE, ADDRESS_LINE_1, ADDRESS_LINE_2, CITY, STATE, COUNTRY, ZIP_CODE };
String[] columnNames = new String[] { AddressFieldSetMapper.ADDRESSEE_COLUMN,
AddressFieldSetMapper.ADDRESS_LINE1_COLUMN, AddressFieldSetMapper.ADDRESS_LINE2_COLUMN,
AddressFieldSetMapper.CITY_COLUMN, AddressFieldSetMapper.STATE_COLUMN,
AddressFieldSetMapper.COUNTRY_COLUMN, AddressFieldSetMapper.ZIP_CODE_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}
protected FieldSetMapper<Address> fieldSetMapper() {

View File

@@ -3,14 +3,14 @@ package org.springframework.batch.sample.domain.order;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.BillingFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.BillingFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests{
public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final String PAYMENT_ID = "777";
private static final String PAYMENT_DESC = "My last penny";
protected Object expectedDomainObject() {
BillingInfo bInfo = new BillingInfo();
bInfo.setPaymentDesc(PAYMENT_DESC);
@@ -19,12 +19,9 @@ public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests{
}
protected FieldSet fieldSet() {
String[] tokens = new String[]{
PAYMENT_ID,
PAYMENT_DESC};
String[] columnNames = new String[]{
BillingFieldSetMapper.PAYMENT_TYPE_ID_COLUMN,
BillingFieldSetMapper.PAYMENT_DESC_COLUMN};
String[] tokens = new String[] { PAYMENT_ID, PAYMENT_DESC };
String[] columnNames = new String[] { BillingFieldSetMapper.PAYMENT_TYPE_ID_COLUMN,
BillingFieldSetMapper.PAYMENT_DESC_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}

View File

@@ -3,13 +3,12 @@ package org.springframework.batch.sample.domain.order;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.CustomerFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.CustomerFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final boolean BUSINESS_CUSTOMER = false;
//private static final String COMPANY_NAME = "Accenture";
private static final String FIRST_NAME = "Jan";
private static final String LAST_NAME = "Hrach";
private static final String MIDDLE_NAME = "";
@@ -30,23 +29,13 @@ public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests {
}
protected FieldSet fieldSet() {
String[] tokens = new String[]{
Customer.LINE_ID_NON_BUSINESS_CUST,
FIRST_NAME,
LAST_NAME,
MIDDLE_NAME,
CustomerFieldSetMapper.TRUE_SYMBOL,
String.valueOf(REG_ID),
CustomerFieldSetMapper.TRUE_SYMBOL};
String[] columnNames = new String[]{
CustomerFieldSetMapper.LINE_ID_COLUMN,
CustomerFieldSetMapper.FIRST_NAME_COLUMN,
CustomerFieldSetMapper.LAST_NAME_COLUMN,
CustomerFieldSetMapper.MIDDLE_NAME_COLUMN,
CustomerFieldSetMapper.REGISTERED_COLUMN,
CustomerFieldSetMapper.REG_ID_COLUMN,
CustomerFieldSetMapper.VIP_COLUMN};
String[] tokens = new String[] { Customer.LINE_ID_NON_BUSINESS_CUST, FIRST_NAME, LAST_NAME, MIDDLE_NAME,
CustomerFieldSetMapper.TRUE_SYMBOL, String.valueOf(REG_ID), CustomerFieldSetMapper.TRUE_SYMBOL };
String[] columnNames = new String[] { CustomerFieldSetMapper.LINE_ID_COLUMN,
CustomerFieldSetMapper.FIRST_NAME_COLUMN, CustomerFieldSetMapper.LAST_NAME_COLUMN,
CustomerFieldSetMapper.MIDDLE_NAME_COLUMN, CustomerFieldSetMapper.REGISTERED_COLUMN,
CustomerFieldSetMapper.REG_ID_COLUMN, CustomerFieldSetMapper.VIP_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright 2006-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.sample.domain.order;
import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.springframework.batch.item.file.transform.DelimitedLineAggregator;
import org.springframework.batch.item.file.transform.LineAggregator;
import org.springframework.batch.sample.domain.order.internal.OrderProcessor;
public class FlatFileOrderAggregatorTests {
@Test
public void testWrite() throws Exception {
// Create and set-up Order
Order order = new Order();
order.setOrderDate(new GregorianCalendar(2007, GregorianCalendar.JUNE, 1).getTime());
order.setCustomer(new Customer());
order.setBilling(new BillingInfo());
order.setBillingAddress(new Address());
List<LineItem> lineItems = new ArrayList<LineItem>();
LineItem item = new LineItem();
item.setPrice(BigDecimal.valueOf(0));
lineItems.add(item);
lineItems.add(item);
order.setLineItems(lineItems);
order.setTotalPrice(BigDecimal.valueOf(0));
// create aggregator stub
LineAggregator<Object[]> aggregator = new DelimitedLineAggregator<Object[]>();
// create map of aggregators and set it to writer
Map<String, LineAggregator<Object[]>> aggregators = new HashMap<String, LineAggregator<Object[]>>();
OrderProcessor converter = new OrderProcessor();
aggregators.put("header", aggregator);
aggregators.put("customer", aggregator);
aggregators.put("address", aggregator);
aggregators.put("billing", aggregator);
aggregators.put("item", aggregator);
aggregators.put("footer", aggregator);
converter.setAggregators(aggregators);
// call tested method
List<String> list = converter.process(order);
// verify method calls
assertEquals(7, list.size());
assertEquals("BEGIN_ORDER:,0,2007/06/01", list.get(0));
}
}

View File

@@ -5,7 +5,7 @@ import java.util.Calendar;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.HeaderFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.HeaderFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests {
@@ -24,14 +24,9 @@ public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests {
}
protected FieldSet fieldSet() {
String[] tokens = new String[]{
String.valueOf(ORDER_ID),
DATE
};
String[] columnNames = new String[]{
HeaderFieldSetMapper.ORDER_ID_COLUMN,
HeaderFieldSetMapper.ORDER_DATE_COLUMN
};
String[] tokens = new String[] { String.valueOf(ORDER_ID), DATE };
String[] columnNames = new String[] { HeaderFieldSetMapper.ORDER_ID_COLUMN,
HeaderFieldSetMapper.ORDER_DATE_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}

View File

@@ -5,10 +5,10 @@ import java.math.BigDecimal;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.OrderItemFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.OrderItemFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests{
public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final BigDecimal DISCOUNT_AMOUNT = new BigDecimal("1");
private static final BigDecimal DISCOUNT_PERC = new BigDecimal("2");
@@ -33,26 +33,14 @@ public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests{
}
protected FieldSet fieldSet() {
String[] tokens = new String[]{
String.valueOf(DISCOUNT_AMOUNT),
String.valueOf(DISCOUNT_PERC),
String.valueOf(HANDLING_PRICE),
String.valueOf(ITEM_ID),
String.valueOf(PRICE),
String.valueOf(QUANTITY),
String.valueOf(SHIPPING_PRICE),
String.valueOf(TOTAL_PRICE)
};
String[] columnNames = new String[]{
OrderItemFieldSetMapper.DISCOUNT_AMOUNT_COLUMN,
OrderItemFieldSetMapper.DISCOUNT_PERC_COLUMN,
OrderItemFieldSetMapper.HANDLING_PRICE_COLUMN,
OrderItemFieldSetMapper.ITEM_ID_COLUMN,
OrderItemFieldSetMapper.PRICE_COLUMN,
OrderItemFieldSetMapper.QUANTITY_COLUMN,
OrderItemFieldSetMapper.SHIPPING_PRICE_COLUMN,
OrderItemFieldSetMapper.TOTAL_PRICE_COLUMN
};
String[] tokens = new String[] { String.valueOf(DISCOUNT_AMOUNT), String.valueOf(DISCOUNT_PERC),
String.valueOf(HANDLING_PRICE), String.valueOf(ITEM_ID), String.valueOf(PRICE),
String.valueOf(QUANTITY), String.valueOf(SHIPPING_PRICE), String.valueOf(TOTAL_PRICE) };
String[] columnNames = new String[] { OrderItemFieldSetMapper.DISCOUNT_AMOUNT_COLUMN,
OrderItemFieldSetMapper.DISCOUNT_PERC_COLUMN, OrderItemFieldSetMapper.HANDLING_PRICE_COLUMN,
OrderItemFieldSetMapper.ITEM_ID_COLUMN, OrderItemFieldSetMapper.PRICE_COLUMN,
OrderItemFieldSetMapper.QUANTITY_COLUMN, OrderItemFieldSetMapper.SHIPPING_PRICE_COLUMN,
OrderItemFieldSetMapper.TOTAL_PRICE_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}

View File

@@ -3,10 +3,10 @@ package org.springframework.batch.sample.domain.order;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.DefaultFieldSet;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.batch.sample.domain.order.internal.ShippingFieldSetMapper;
import org.springframework.batch.sample.domain.order.internal.mapper.ShippingFieldSetMapper;
import org.springframework.batch.sample.support.AbstractFieldSetMapperTests;
public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests{
public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests {
private static final String SHIPPER_ID = "1";
private static final String SHIPPING_INFO = "most interesting and informative shipping info ever";
@@ -21,12 +21,9 @@ public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests{
}
protected FieldSet fieldSet() {
String[] tokens = new String[]{SHIPPER_ID, SHIPPING_INFO, SHIPPING_TYPE_ID};
String[] columnNames = new String[]{
ShippingFieldSetMapper.SHIPPER_ID_COLUMN,
ShippingFieldSetMapper.ADDITIONAL_SHIPPING_INFO_COLUMN,
ShippingFieldSetMapper.SHIPPING_TYPE_ID_COLUMN
};
String[] tokens = new String[] { SHIPPER_ID, SHIPPING_INFO, SHIPPING_TYPE_ID };
String[] columnNames = new String[] { ShippingFieldSetMapper.SHIPPER_ID_COLUMN,
ShippingFieldSetMapper.ADDITIONAL_SHIPPING_INFO_COLUMN, ShippingFieldSetMapper.SHIPPING_TYPE_ID_COLUMN };
return new DefaultFieldSet(tokens, columnNames);
}