../fw.batch/src/main/java/com/xxxxxxx/drvpp/fw/batch/controller/ApplicationControllerImpl.java
1 | |
package com.xxxxxxx.drvpp.fw.batch.controller; |
2 | |
3 | |
import java.util.HashMap; |
4 | |
import java.util.List; |
5 | |
import java.util.Map; |
6 | |
7 | |
import org.apache.ibatis.session.SqlSession; |
8 | |
import org.springframework.context.ApplicationContext; |
9 | |
10 | |
import com.xxxxxxx.drvpp.fw.batch.util.BatchParameter; |
11 | |
import com.xxxxxxx.drvpp.fw.batch.util.Business; |
12 | |
import com.xxxxxxx.drvpp.fw.common.log.Logger; |
13 | |
import com.xxxxxxx.drvpp.fw.common.log.LoggerFactory; |
14 | |
import com.xxxxxxx.drvpp.fw.common.log.LoggerFactoryBuilder; |
15 | |
import com.xxxxxxx.drvpp.fw.common.mybatis.MyBatisSessionFactory; |
16 | |
import com.xxxxxxx.drvpp.fw.common.util.BeanFactoryBuilder; |
17 | |
18 | 0 |
public class ApplicationControllerImpl implements ApplicationController { |
19 | 0 |
private BatchParameter parameter = null; |
20 | |
21 | |
public int doExecute(String[] args) { |
22 | |
|
23 | 0 |
LoggerFactoryBuilder loggerFactoryBuilder = LoggerFactoryBuilder |
| 0 |
Path coverage: 0/5
A: 0
B: 0
C: 0
D: 0
E: 0
|
24 | 0 |
.getInstance(); |
25 | 0 |
LoggerFactory loggerFactory = loggerFactoryBuilder.getLoggerFactory(); |
26 | 0 |
Logger logger = loggerFactory.getLogger(this.getClass()); |
27 | |
28 | |
|
29 | 0 |
MyBatisSessionFactory sessionFactory = MyBatisSessionFactory |
30 | 0 |
.getInstance(); |
31 | 0 |
SqlSession sqlSession = sessionFactory.openSession(); |
32 | |
33 | |
|
34 | 0 |
BeanFactoryBuilder builder = BeanFactoryBuilder.getInstance(); |
35 | 0 |
ApplicationContext applicationContext = builder.build(); |
36 | |
37 | |
|
38 | 0 |
List<Business> flow = (List<Business>) applicationContext |
39 | 0 |
.getBean("businessList"); |
40 | |
41 | |
|
42 | 0 |
Map<String, Object> input = new HashMap<String, Object>(); |
43 | 0 |
Map<String, Object> output = new HashMap<String, Object>(); |
44 | 0 |
int result = -1; |
45 | 0 |
for (Business b : flow) { |
46 | |
|
47 | 0 |
parameter = new BatchParameter(); |
48 | 0 |
parameter.setSqlSession(sqlSession); |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | 0 |
parameter.setArgs(args); |
54 | |
55 | 0 |
result = -1; |
56 | |
try { |
57 | 0 |
input.clear(); |
58 | 0 |
input.putAll(output); |
59 | 0 |
output.clear(); |
60 | |
61 | |
|
62 | 0 |
result = b.doExecute(parameter); |
63 | 0 |
} catch (Exception e) { |
64 | |
|
65 | 0 |
e.printStackTrace(); |
66 | 0 |
} finally { |
67 | |
|
68 | 0 |
if (result == 0) { |
69 | 0 |
sqlSession.commit(); |
70 | 0 |
} else { |
71 | 0 |
sqlSession.rollback(); |
72 | 0 |
if (result < 0) { |
73 | 0 |
break; |
74 | |
} |
75 | |
} |
76 | 0 |
} |
77 | |
} |
78 | |
79 | 0 |
return result; |
80 | |
} |
81 | |
82 | |
public BatchParameter getParameter() { |
83 | 0 |
return parameter; |
84 | |
} |
85 | |
} |