Project

General

Profile

« Previous | Next » 

Revision 70d9ab6a

Added by Katja Luther over 9 years ago

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.java
27 27

  
28 28
import com.microsoft.sqlserver.jdbc.SQLServerException;
29 29

  
30
import eu.etaxonomy.cdm.common.profiler.ProfilerController;
30 31
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
31 32
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
32 33
import eu.etaxonomy.cdm.io.common.Source;
......
189 190
		int count = 0;
190 191
		int pastCount = 0;
191 192
		boolean success = true;
192
		int limit = state.getConfig().getLimitSave();
193
		//int limit = state.getConfig().getLimitSave();
194
		int limit = 100;
193 195

  
194 196
		List<Taxon> taxonList = null;
195 197

  
......
198 200
		List<String> propPath = Arrays.asList(new String[]{"descriptions.elements.*"});
199 201

  
200 202
		logger.debug("Start snapshot, before starting loop");
201
	//	ProfilerController.memorySnapshot();
203
		ProfilerController.memorySnapshot();
202 204
		//taxon descriptions
203 205
		int partitionCount = 0;
204 206
		while ((taxonList = getNextTaxonPartition(Taxon.class, limit, partitionCount++, propPath )) != null   ) {
205 207

  
206 208
			logger.info("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
209
			System.out.println("Fetched " + taxonList.size() + " " + pluralString + ". Exporting...");
207 210

  
208 211
			for (Taxon taxon : taxonList) {
209 212
				countTaxa++;
210 213
				doCount(count++, modCount, pluralString);
211 214
				state.setCurrentTaxon(taxon);
212
				success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
215
				if (!taxon.getDescriptions().isEmpty()){
216
					success &= handleSingleTaxon(taxon, state, notesMapping, occurrenceMapping, addSourceSourceMapping,
213 217
						additionalSourceMapping, vernacularMapping, imageMapping);
218
				}
219
				
214 220
			}
215 221
			taxonList = null;
216 222
			state.setCurrentTaxon(null);
217

  
223
			
218 224
			// Commit transaction
219 225
			commitTransaction(txStatus);
220 226
			logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
227
			System.out.println("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
221 228
			pastCount = count;
222

  
229
			ProfilerController.memorySnapshot();
223 230
			// Start transaction
224 231
			txStatus = startTransaction(true);
225 232
			logger.info("Started new transaction. Fetching some " + pluralString + " (max: " + limit + ") for description import ...");
......
251 258
		int count = 0;
252 259
		int pastCount = 0;
253 260
		boolean success = true;
254
		int limit = state.getConfig().getLimitSave();
255

  
261
		//int limit = state.getConfig().getLimitSave();
262
		int limit = 100;
256 263
		List<TaxonNameDescription> nameDescList = null;
257 264

  
258 265
		TransactionStatus txStatus = startTransaction(true);
......
325 332
			PesiExportMapping vernacularMapping, PesiExportMapping imageMapping) throws SQLException {
326 333
		boolean success = true;
327 334

  
328
		System.out.println("handle single Taxon");
335
		
329 336
		Set<DescriptionBase<?>> descriptions = new HashSet<DescriptionBase<?>>();
330 337
		descriptions.addAll(taxon.getDescriptions());
331 338

  
332 339
		for (DescriptionBase<?> desc : descriptions){
333
			countDescriptions++;
340
			
334 341

  
335 342
			boolean isImageGallery = desc.isImageGallery();
336 343
			for (DescriptionElementBase element : desc.getElements()){
337 344
				success &= handleDescriptionElement(state, notesMapping, occurrenceMapping, vernacularMapping, imageMapping,
338 345
						addSourceSourceMapping, additionalSourceMapping, isImageGallery, element);
346
				countDescriptions++;
339 347
			}
340 348
		}
349
		logger.info("number of handled decriptionelements " + countDescriptions);
341 350
		descriptions = null;
342 351
		return success;
343 352
	}
......
367 376
				if (isPesiDistribution(state, distribution)){
368 377
					countDistribution++;
369 378
					try{
370
					    success &=occurrenceMapping.invoke(element);
379
					    success &=occurrenceMapping.invoke(distribution);
371 380
					}catch(SQLServerException e){
372
					    System.err.println(element.getInDescription().getTitleCache());
381
					    System.err.println(distribution.getInDescription().getTitleCache());
373 382
					    e.printStackTrace();
374 383
					}
375 384
				}
......
503 512
		boolean success =  true;
504 513

  
505 514
		// Get the limit for objects to save within a single transaction.
506
		int limit = state.getConfig().getLimitSave();
507

  
515
		//int limit = state.getConfig().getLimitSave();
516
		int limit = 100;
508 517
		txStatus = startTransaction(true);
509 518
		ExtensionType taxCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.taxCommentUuid);
510 519
		ExtensionType fauCommentExtensionType = (ExtensionType)getTermService().find(PesiTransformer.fauCommentUuid);
......
889 898
		mapping.addMapper(DbExportIgnoreMapper.NewInstance("SourceNameCache", "Use OccurrenceSource table for sources instead"));
890 899

  
891 900
		mapping.addMapper(DbAnnotationMapper.NewInstance(null, "Notes"));
892
	//	mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
901
		mapping.addMapper(ExpertsAndLastActionMapper.NewInstance());
893 902
		mapping.addCollectionMapping(getOccurrenceSourceMapping());
894 903

  
895 904
		return mapping;

Also available in: Unified diff