|
|
|
|
@ -8,6 +8,7 @@ import org.leolo.nrdatad.ConfigurationManager;
|
|
|
|
|
import org.leolo.nrdatad.Constants; |
|
|
|
|
import org.leolo.nrdatad.db.CorpusDao; |
|
|
|
|
import org.leolo.nrdatad.model.Corpus; |
|
|
|
|
import org.leolo.nrdatad.model.Smart; |
|
|
|
|
import org.leolo.nrdatad.util.HttpUtil; |
|
|
|
|
import org.quartz.Job; |
|
|
|
|
import org.quartz.JobExecutionContext; |
|
|
|
|
@ -17,6 +18,7 @@ import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
|
|
|
|
|
public class ReferenceDataJob implements Job { |
|
|
|
|
|
|
|
|
|
@ -26,7 +28,7 @@ public class ReferenceDataJob implements Job {
|
|
|
|
|
public void execute(JobExecutionContext context) throws JobExecutionException { |
|
|
|
|
log.atInfo().log("Load reference data triggered at {}", context.getFireTime()); |
|
|
|
|
//There are 3 different kind of reference data. Create 3 thread and deal with them
|
|
|
|
|
// new Thread(()->{processCORPUS();}).start();
|
|
|
|
|
new Thread(()->{processCORPUS();}).start(); |
|
|
|
|
new Thread(()->{processSMART();}).start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -47,6 +49,23 @@ public class ReferenceDataJob implements Job {
|
|
|
|
|
JSONObject rootObj = new JSONObject(json); |
|
|
|
|
JSONArray rootArray = rootObj.getJSONArray("BERTHDATA"); |
|
|
|
|
log.atInfo().log("{} entries found", rootArray.length()); |
|
|
|
|
Collection<Smart> smarts = new ArrayList<>(); |
|
|
|
|
for (int i = 0; i < rootArray.length(); i++) { |
|
|
|
|
JSONObject obj = rootArray.getJSONObject(i); |
|
|
|
|
Smart smart = Smart.parseJSON(obj); |
|
|
|
|
if(!smart.checkEnums()){ |
|
|
|
|
log.atInfo().log("Improper SMART record: {}", obj); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
smarts.add(smart); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
conf.getDatabaseManager().getSmartDao().truncateTable(); |
|
|
|
|
conf.getDatabaseManager().getSmartDao().addAll(smarts); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
log.atError().withThrowable(e).log("Unable to insert records"); |
|
|
|
|
} |
|
|
|
|
log.atInfo().log("Done inserting SMART"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void processCORPUS(){ |
|
|
|
|
|