1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.process;
17
18 import org.apache.camel.Exchange;
19 import org.apache.camel.Predicate;
20 import org.kuali.ole.docstore.utility.BulkIngestStatistics;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24
25
26
27
28
29
30 public class SplitPredicate
31 implements Predicate {
32 private Logger logger = LoggerFactory.getLogger(SplitPredicate.class);
33 private Integer batchSize = 1000;
34 private BulkIngestStatistics bulkLoadStatistics = BulkIngestStatistics.getInstance();
35
36 public SplitPredicate(Integer batchSize) {
37 this.batchSize = batchSize;
38 }
39
40 public boolean matches(Exchange exchange) {
41
42 if (exchange.getProperty("CamelSplitComplete") != null && Boolean.TRUE
43 .equals(exchange.getProperty("CamelSplitComplete"))) {
44 logger.info("Processing End Of File: " + exchange.getProperty("CamelFileExchangeFile"));
45 bulkLoadStatistics.setLastBatch(true);
46 return true;
47 }
48
49 if (exchange.getProperty("CamelAggregatedSize").equals(batchSize)) {
50 return true;
51 }
52
53 return false;
54 }
55 }