From b5d653356402244d65a6613190709e2fd0f1740d Mon Sep 17 00:00:00 2001 From: Andreas Kohlbecker Date: Thu, 11 Mar 2010 09:54:22 +0000 Subject: [PATCH] removing changset 8013. "Workaround for out of memory issues: Added logic to split the amount of taxa to be saved into small groups (similar to fauna europaea import --- .../in/BerlinModelTaxonImport.java | 42 +++---------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java b/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java index 3942f575be..0f43ed23e7 100644 --- a/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java +++ b/cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java @@ -16,21 +16,16 @@ import static eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer.T_STATUS_SY import java.sql.ResultSet; import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; import java.util.UUID; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionStatus; import eu.etaxonomy.cdm.common.CdmUtils; import eu.etaxonomy.cdm.io.common.ICdmIO; import eu.etaxonomy.cdm.io.common.ImportHelper; import eu.etaxonomy.cdm.io.common.MapWrapper; import eu.etaxonomy.cdm.io.common.Source; -import eu.etaxonomy.cdm.io.faunaEuropaea.FaunaEuropaeaTaxon; import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.common.Extension; @@ -184,12 +179,7 @@ public class BerlinModelTaxonImport extends BerlinModelImportBase { @Override protected boolean doInvoke(BerlinModelImportState state){ boolean success = true; - - // Get maximum number of taxa to be saved with one service call - int limit = state.getConfig().getLimitSave(); // Added - TransactionStatus txStatus = null; // Added - //make not needed maps empty String teamStore = ICdmIO.TEAM_STORE; MapWrapper store = state.getStore(teamStore); @@ -201,7 +191,7 @@ public class BerlinModelTaxonImport extends BerlinModelImportBase { MapWrapper referenceMap = (MapWrapper)state.getStore(ICdmIO.REFERENCE_STORE); MapWrapper nomRefMap = (MapWrapper)state.getStore(ICdmIO.NOMREF_STORE); MapWrapper taxonMap = (MapWrapper)state.getStore(ICdmIO.TAXON_STORE); - + BerlinModelImportConfigurator config = state.getConfig(); Source source = config.getSource(); @@ -217,23 +207,11 @@ public class BerlinModelTaxonImport extends BerlinModelImportBase { " WHERE (1=1)"; ResultSet rs = source.getResultSet(strQuery) ; -// rs.next(); // Added, needed? - int count = rs.getInt(1); // Added int i = 0; - int currentIndex = 0; //for each reference while (rs.next()){ - // Added block - if ((i++ % limit) == 0) { - - txStatus = startTransaction(); - if(logger.isInfoEnabled()) { - logger.info("i = " + i + " - Transaction started"); - } - } // Added block - if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("PTaxa handled: " + (i-1));} //create TaxonName element @@ -347,22 +325,12 @@ public class BerlinModelTaxonImport extends BerlinModelImportBase { success = false; } } + //invokeRelations(source, cdmApp, deleteAll, taxonMap, referenceMap); + logger.info("saving "+i+" taxa ..."); + getTaxonService().save(taxonMap.objects()); - if (((i % limit) == 0 && i != 1 ) || i == count) { // Added - //invokeRelations(source, cdmApp, deleteAll, taxonMap, referenceMap); - logger.info("saving " + (i-currentIndex) + " taxa ..."); - currentIndex = i; - getTaxonService().save(taxonMap.objects()); - - taxonMap = null; - commitTransaction(txStatus); - - if(logger.isInfoEnabled()) { - logger.info("i = " + i + " - Transaction committed"); - } - } logger.info("end makeTaxa ..." + getSuccessString(success)); - + return success; } catch (SQLException e) { logger.error("SQLException:" + e); -- 2.34.1