private void harvestAuthorities() { ArrayList<RFHarvesterUploaderInterface> uploadsList = new ArrayList<RFHarvesterUploaderInterface>(); final RFHarvesterUploaderInterface authoritiesSOLRUploader = new UploadAuthoritiesSolr(); uploadsList.add(authoritiesSOLRUploader); RFHarvesterLogger.info("Begin merging phase"); authoritiesSOLRUploader.mergeOldTable(); RFHarvesterLogger.info("Begin replacement phase"); authoritiesSOLRUploader.replaceOldTable(); }
private void harvestPortfolio() { final int collectionId = 5; RFHarvesterState.updateConfiguration("Portfolio"); if (RFHarvesterState.checkRunningStatus() != 1) { RFHarvesterState.updateStatus("ERREUR!!!"); RFHarvesterState.updateMessage( "Impossible de lancer une moissons tant que l'historique contient des moissons ayant le statut: 'En cours'"); System.exit(ExitCodes.EX_NOPERM.value()); } final ArrayList<RFHarvesterUploaderInterface> uploadsList = new ArrayList<RFHarvesterUploaderInterface>(); final RFHarvesterDownloaderInterface DI = new PortfolioDownloader(collectionId); // long downloadMillis = 0; // try // { // Date downloadDate = RFHarvesterDatation.DataToDate(2015, 2, 1); // //downloadDate = RFHarvesterDatation.DataToDate(2015, 5, 4); // downloadMillis = downloadDate.getTime(); // } // catch(ParseException e) // { // e.printStackTrace(); // System.exit(0); // Program won't run with parsing error // } final RFHarvesterUploaderInterface controlsMySQLUploader = new UploadControlsMySQL(collectionId); uploadsList.add(controlsMySQLUploader); final RFHarvesterUploaderInterface metadatasMySQLUploader = new UploadMetadatasMySQL(collectionId); uploadsList.add(metadatasMySQLUploader); final RFHarvesterUploaderInterface portfoliodatasMySQLUploader = new UploadPortfolioDatasMySQL(collectionId); uploadsList.add(portfoliodatasMySQLUploader); final RFHarvesterUploaderInterface volumesMySQLUploader = new UploadVolumesMySQL(collectionId); uploadsList.add(volumesMySQLUploader); final RFHarvesterUploaderInterface collectionsMySQLUploader = new UploadCollectionsMySQL(collectionId); uploadsList.add(collectionsMySQLUploader); final RFHarvesterUploaderInterface noticesSOLR6Uploader = new UploadNoticesSolr5(collectionId); uploadsList.add(noticesSOLR6Uploader); RFHarvesterLogger.info("Begin initialisation phase"); ExecutorService es = Executors.newCachedThreadPool(); for (final RFHarvesterUploaderInterface UI : uploadsList) es.execute( new Runnable() { public void run() { UI.initTable(); } }); es.shutdown(); try { while (!es.awaitTermination(10, TimeUnit.SECONDS)) ; } catch (InterruptedException e) { e.printStackTrace(); System.exit(0); } final long usedDownloadMillis = 0; RFHarvesterLogger.info("Begin backup/downloading phase"); es = Executors.newCachedThreadPool(); // for(final RFHarvesterUploaderInterface UI : uploadsList) // es.execute(new Runnable() // { // public void run() // { // UI.copyIntoOld(); // } // }); es.execute( new Runnable() { public void run() { try { DI.download(uploadsList, usedDownloadMillis); } catch (Exception e) { e.printStackTrace(); System.exit(0); } } }); es.shutdown(); try { while (!es.awaitTermination(10, TimeUnit.SECONDS)) ; } catch (InterruptedException e) { e.printStackTrace(); System.exit(0); } RFHarvesterLogger.info("Begin merging phase"); es = Executors.newCachedThreadPool(); controlsMySQLUploader.mergeOldTable(); // noticesSOLRUploader.mergeOldTable(); // noticesSOLR1Uploader.mergeOldTable(); noticesSOLR6Uploader.mergeOldTable(); metadatasMySQLUploader.mergeOldTable(); volumesMySQLUploader.mergeOldTable(); portfoliodatasMySQLUploader.mergeOldTable(); collectionsMySQLUploader.mergeOldTable(); RFHarvesterLogger.info("Begin replacement phase"); es = Executors.newCachedThreadPool(); // es.execute(new Runnable() // { // public void run() // { // noticesSOLRUploader.replaceOldTable(); // } // }); // es.execute(new Runnable() // { // public void run() // { // noticesSOLR1Uploader.replaceOldTable(); // } // }); es.execute( new Runnable() { public void run() { noticesSOLR6Uploader.replaceOldTable(); } }); es.shutdown(); try { while (!es.awaitTermination(1, TimeUnit.SECONDS)) ; } catch (InterruptedException e) { e.printStackTrace(); System.exit(0); } es = Executors.newCachedThreadPool(); es.execute( new Runnable() { public void run() { controlsMySQLUploader.replaceOldTable(); } }); es.execute( new Runnable() { public void run() { metadatasMySQLUploader.replaceOldTable(); } }); es.execute( new Runnable() { public void run() { portfoliodatasMySQLUploader.replaceOldTable(); } }); es.execute( new Runnable() { public void run() { volumesMySQLUploader.replaceOldTable(); } }); es.execute( new Runnable() { public void run() { collectionsMySQLUploader.replaceOldTable(); } }); es.shutdown(); try { while (!es.awaitTermination(1, TimeUnit.SECONDS)) ; } catch (InterruptedException e) { e.printStackTrace(); System.exit(0); } }