FILE(FIXED) TO FILE(DELIMITED)
-
Batch Job Xml Sample
<?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:batch-int="http://www.springframework.org/schema/batch-integration"
xsi:schemaLocation="http://www.bankwareglobal.com/schema/batchex http://www.bankwareglobal.com/schema/batchex/spring-batch-ex.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<import resource="classpath:JobConfig.xml"/>
<job-component xmlns="http://www.bankwareglobal.com/schema/batchex" id="jobcomp" with-dependon="true">
<base-package name="bxm.dft.smp.batch.bean">
<include name="MSmpFixedToDelimited*Btch"/>
</base-package>
</job-component>
<!--
* Batch job : FILE(FIXED) TO FILE(DELIMITED) sample
* Batch step
- JSmpFixedToDelimited100 : FILE(FIXED) TO FILE(DELIMITED) sample initialization process
- JSmpFixedToDelimited200 : Write process that converts a FIXED-format file to a DELIMITED-format file
-->
<job id="JSmpFixedToDelimited" xmlns="http://www.bankwareglobal.com/schema/batchex">
<step id="JSmpFixedToDelimited100" next="JSmpFixedToDelimited200" parent="parentStep">
<tasklet ref="MSmpFixedToDelimitedInitBtch"/>
</step>
<step id="JSmpFixedToDelimited200" parent="parentStep">
<tasklet>
<chunk reader="RJSmpFixedToDelimited200" processor="MSmpFixedToDelimitedBtch" writer="WJSmpFixedToDelimited200"/>
</tasklet>
</step>
</job>
<!--
* Bean configuration to read the sample employee information Fixed File
-->
<bean id="RJSmpFixedToDelimited200" parent="RFix" scope="step">
<property name="resource" value="file:///data1/prod/bxm400/dat/fixed_file_#{jobParameters['oDate']}.txt" />
<property name="encoding" value="UTF-8" />
<property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpFixedToDelimitedBtch01Dto" />
</bean>
<!--
* Bean configuration to write the sample employee information to a Delimited File
-->
<bean id="WJSmpFixedToDelimited200" parent="WDelimit" scope="step">
<property name="resource" value="file:///data1/prod/bxm400/dat/delimited_file_#{jobParameters['oDate']}.txt" />
<property name="encoding" value="UTF-8" />
<property name="delimiter" value=";"/>
<property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpFixedToDelimitedBtch01Dto" />
</bean>
</beans>
-
Batch Source Code Sample
@BxmBean("MSmpFixedToDelimitedBtch")
@Scope("step")
@BxmCategory(logicalName = "FILE(FIXED) TO FILE(DELIMITED) sample")
public class MSmpFixedToDelimitedBtch
implements ItemProcessor<MSmpFixedToDelimitedBtch01Dto, MSmpFixedToDelimitedBtch01Dto> {
final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* process
* - Performs processing of each target record according to business requirements.
*/
@Override
@BxmCategory(logicalName = "process : process sample employee information")
public MSmpFixedToDelimitedBtch01Dto process(MSmpFixedToDelimitedBtch01Dto in) throws Exception {
MSmpFixedToDelimitedBtch01Dto out = null;
/**
* Check data read from file
*/
if (in.getFeduEmpNo() == 0 || in.getFeduDeptNo() == 0) {
logger.warn("Employee No.[{}], Department No.[{}] is not valid. It will be skipped.",
new Object[] { in.getFeduEmpNo(), in.getFeduDeptNo() });
return null;
}
/**
* Execute individual business logic
* ...
* ...
*/
out = in;
return out;
}
}