5
5
import ca .bc .gov .educ .api .batchgraduation .entity .BatchStatusEnum ;
6
6
import ca .bc .gov .educ .api .batchgraduation .repository .BatchGradAlgorithmJobHistoryRepository ;
7
7
import ca .bc .gov .educ .api .batchgraduation .repository .BatchGradAlgorithmStudentRepository ;
8
+ import org .slf4j .Logger ;
9
+ import org .slf4j .LoggerFactory ;
8
10
import org .springframework .beans .factory .annotation .Autowired ;
9
11
import org .springframework .stereotype .Service ;
10
12
import org .springframework .transaction .annotation .Transactional ;
15
17
@ Service
16
18
public class GradBatchHistoryService {
17
19
20
+ private static final Logger LOGGER = LoggerFactory .getLogger (GradBatchHistoryService .class );
21
+
18
22
@ Autowired
19
23
private BatchGradAlgorithmJobHistoryRepository batchGradAlgorithmJobHistoryRepository ;
20
24
@@ -31,10 +35,12 @@ public BatchGradAlgorithmJobHistoryEntity getGradAlgorithmJobHistory(Long batchI
31
35
public BatchGradAlgorithmJobHistoryEntity saveGradAlgorithmJobHistory (BatchGradAlgorithmJobHistoryEntity ent ) {
32
36
Optional <BatchGradAlgorithmJobHistoryEntity > optional = batchGradAlgorithmJobHistoryRepository .findByJobExecutionId (ent .getJobExecutionId ());
33
37
if (optional .isPresent ()) {
34
- // update
38
+ LOGGER . info ( "Updating BatchGradAlgorithmJobHistoryEntity for Id :{} Status: {}, EndTime: {} " , ent . getJobExecutionId (), ent . getStatus (), ent . getEndTime ());
35
39
BatchGradAlgorithmJobHistoryEntity current = optional .get ();
36
40
current .setStatus (ent .getStatus ());
37
- current .setEndTime (ent .getEndTime ());
41
+ if (BatchStatusEnum .COMPLETED .name ().equalsIgnoreCase (ent .getStatus ()) || BatchStatusEnum .FAILED .name ().equalsIgnoreCase (ent .getStatus ()) || BatchStatusEnum .STOPPED .name ().equalsIgnoreCase (ent .getStatus ())) {
42
+ current .setEndTime (ent .getEndTime ());
43
+ }
38
44
current .setExpectedStudentsProcessed (ent .getExpectedStudentsProcessed ());
39
45
current .setActualStudentsProcessed (ent .getActualStudentsProcessed ());
40
46
current .setFailedStudentsProcessed (ent .getFailedStudentsProcessed ());
0 commit comments