diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java index 8b1adb526..e61b1a910 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java @@ -131,6 +131,12 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); } bulkLoadFileDAO.persist(bulkLoadFile); + history.setBulkLoad(bulkLoad); + history.setBulkLoadFile(bulkLoadFile); + bulkLoadFileHistoryDAO.persist(history); + + Log.info("Firing Pending Bulk File History Event: " + history.getId()); + pendingFileJobEvents.fireAsync(new PendingLoadJobEvent(history.getId())); } else if (load.getBulkloadStatus().isForced()) { bulkLoadFile = bulkLoadFiles.getResults().get(0); if (history.getBulkloadStatus().isNotRunning()) { @@ -142,27 +148,26 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean Log.info("Cleaning up downloaded file: " + localFilePath); new File(localFilePath).delete(); } + if (cleanUp) { + bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); + } + bulkLoadFileDAO.merge(bulkLoadFile); + history.setBulkLoad(bulkLoad); + history.setBulkLoadFile(bulkLoadFile); + bulkLoadFileHistoryDAO.persist(history); + + Log.info("Firing Pending Bulk File History Event: " + history.getId()); + pendingFileJobEvents.fireAsync(new PendingLoadJobEvent(history.getId())); } else { Log.info("Bulk File already exists not creating it"); bulkLoadFile = bulkLoadFiles.getResults().get(0); Log.info("Cleaning up downloaded file: " + localFilePath); new File(localFilePath).delete(); bulkLoadFile.setLocalFilePath(null); + bulkLoadFileDAO.merge(bulkLoadFile); Log.info("File already exists not running load"); - return; } - - history.setBulkLoad(bulkLoad); - history.setBulkLoadFile(bulkLoadFile); - bulkLoadFileHistoryDAO.persist(history); - if (cleanUp) { - bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); - } - bulkLoadFileDAO.merge(bulkLoadFile); - bulkLoadDAO.merge(load); - Log.info("Firing Pending Bulk File History Event: " + history.getId()); - pendingFileJobEvents.fireAsync(new PendingLoadJobEvent(history.getId())); } protected void startLoad(BulkLoad load) {