Project

General

Profile

« Previous | Next » 

Revision 0c392a47

Added by Andreas Müller about 12 years ago

latest updates to PESI export

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
783 783
	 */
784 784
	private boolean doNames(PesiExportState state)  throws SQLException {
785 785
		
786
		PesiExportMapping mapping = getNameMapping();
787
		mapping.initialize(state);
788
		int count = 0;
789
		int pastCount = 0;
790
		List<NonViralName> list;
791
		boolean success = true;
792
		// Get the limit for objects to save within a single transaction.
793
		int limit = state.getConfig().getLimitSave();
786
		boolean success;
787
		try {
788
			PesiExportMapping mapping = getNameMapping();
789
			mapping.initialize(state);
790
			int count = 0;
791
			int pastCount = 0;
792
			List<NonViralName<?>> list;
793
			success = true;
794
			// Get the limit for objects to save within a single transaction.
795
			int limit = state.getConfig().getLimitSave();
794 796

  
795
		
796
		logger.info("PHASE 5: Export Pure Names ...");
797
		// Start transaction
798
		TransactionStatus txStatus = startTransaction(true);
799
		logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
800
		
801
		
802
		int partitionCount = 0;
803
		while ((list = getNextPureNamePartition(null, limit, partitionCount++)).size() > 0   ) {
797
			
798
			logger.info("PHASE 5: Export Pure Names ...");
799
			// Start transaction
800
			TransactionStatus txStatus = startTransaction(true);
801
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
802
			
803
			
804
			int partitionCount = 0;
805
			while ((list = getNextPureNamePartition(null, limit, partitionCount++)) != null   ) {
804 806

  
805
			logger.info("Fetched " + list.size() + " names without taxa. Exporting...");
806
			for (NonViralName<?> taxonName : list) {
807
				doCount(count++, modCount, pluralString);
808
				success &= mapping.invoke(taxonName);
809
			}
807
				logger.info("Fetched " + list.size() + " names without taxa. Exporting...");
808
				for (NonViralName<?> taxonName : list) {
809
					doCount(count++, modCount, pluralString);
810
					success &= mapping.invoke(taxonName);
811
				}
812

  
813
				// Commit transaction
814
				commitTransaction(txStatus);
815
				logger.debug("Committed transaction.");
816
				logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
817
				pastCount = count;
810 818

  
819
				// Start transaction
820
				txStatus = startTransaction(true);
821
				logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
822
			}
823
			if (list == null) {
824
				logger.info("No " + pluralString + " left to fetch.");
825
			}
811 826
			// Commit transaction
812 827
			commitTransaction(txStatus);
813 828
			logger.debug("Committed transaction.");
814
			logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
815
			pastCount = count;
816

  
817
			// Start transaction
818
			txStatus = startTransaction(true);
819
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") ...");
820
		}
821
		if (list.size() == 0) {
822
			logger.info("No " + pluralString + " left to fetch.");
829
		} catch (Exception e) {
830
			logger.error("Error occurred in pure name export");
831
			e.printStackTrace();
832
			success = false;
823 833
		}
824
		// Commit transaction
825
		commitTransaction(txStatus);
826
		logger.debug("Committed transaction.");
827 834
		return success;
828 835
	}
829 836

  

Also available in: Unified diff