-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddressExtractProcessor.java
55 lines (48 loc) · 1.83 KB
/
AddressExtractProcessor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.vinhuang.processors;
// Import appropriate packages
public class AddressExtractProcessor implements ItemProcessor<Agent, AddressExtractMOutput> {
private static final Logger LOGGER = LoggerFactory.getLogger(AddressExtractProcessor.class);
private static final COUNTRY_USA = "USA";
private Date cycleDate;
/**
* Before step will run prior to processing. Logging can be added here.
*
* @param StepExecution stepExecution
* @return
*/
@Override
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
super.beforeStep(stepExecution);
}
/**
* This method will extract address from agent database. It retrieves agent data from SQL
* I omitted complicated logic that was previously included, and replaced it with a simple
* IF statement that checks the country of origin
*
* @param AgentKey agentKey
* @return AddressExtractOutput output
*/
@Override
public AddressExtractOutput process(Agent agent) throws Exception {
// defaultString will set the value to "" if it's null
AddressExtract output = new AddressExtract();
if(cycleDate != null && COUNTRY_USA.equalsIgnoreCase(agent.getCountry()) {
output.setAddressLine1(defaultString(agent.getAddressLine1()));
output.setAddressLine2(defaultString(agent.getAddressLine2()));
output.setAddressLine3(defaultString(agent.getAddressLine3()));
output.setCity(defaultString(agent.getCity()));
output.setZip(defaultString(agent.getZip()));
} else {
output.setAddressLine1(defaultString(agent.getAddressLine1()));
output.setAddressLine2(defaultString(agent.getAddressLine2()));
output.setAddressLine3(defaultString(agent.getAddressLine3()));
output.setCity("");
output.setZip("");
}
return output;
}
public void setCycleDate(Date cycleDate) {
this.cycleDate = cycleDate;
}
}