Project

General

Profile

« Previous | Next » 

Revision 726f3b15

Added by Andreas Müller over 9 years ago

add OccurrenceNote to BM import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelOccurrenceImport.java
92 92
			String emCode = config.isIncludesAreaEmCode()? ", emArea.EMCode" : "";
93 93
			String strQuery =   //DISTINCT because otherwise emOccurrenceSource creates multiple records for a single distribution 
94 94
            " SELECT DISTINCT PTaxon.RIdentifier AS taxonId, emOccurrence.OccurrenceId, emOccurrence.Native, emOccurrence.Introduced, " +
95
            		" emOccurrence.Cultivated, emOccurSumCat.emOccurSumCatId, emOccurSumCat.Short, emOccurSumCat.Description, " +  
95
            		" emOccurrence.Cultivated, emOccurrence.Notes occNotes, " +
96
            		" emOccurSumCat.emOccurSumCatId, emOccurSumCat.Short, emOccurSumCat.Description, " +  
96 97
                	" emOccurSumCat.OutputCode, emArea.AreaId, emArea.TDWGCode " + emCode + 
97 98
                " FROM emOccurrence INNER JOIN " +  
98 99
                	" emArea ON emOccurrence.AreaFk = emArea.AreaId INNER JOIN " + 
......
316 317

  
317 318
		try {
318 319
			//map to store the mapping of duplicate berlin model occurrences to their real distributions
319
			//duplicated may occurr due to area mappings from BM areas to TDWG areas
320
			//duplicated may occur due to area mappings from BM areas to TDWG areas
320 321
			Map<Integer, String> duplicateMap = new HashMap<Integer, String>();
321 322
			int oldTaxonId = -1;
322 323
			TaxonDescription oldDescription = null;
......
331 332
                
332 333
                int occurrenceId = rs.getInt("OccurrenceId");
333 334
                int newTaxonId = rs.getInt("taxonId");
335
                String notes = nullSafeTrim(rs.getString("occNotes"));
334 336
                
335 337
                Integer emStatusId = nullSafeInt(rs, "emOccurSumCatId");
336 338
                
......
349 351
                    
350 352
					List<NamedArea> areas = makeAreaList(state, rs,	occurrenceId);
351 353
                     
352
                     //create description(elements)
353
                     TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId, sourceRef);
354
                     for (NamedArea area : areas){
355
                           Distribution distribution = Distribution.NewInstance(area, status);
356
                           if (status == null){
357
                        	   AnnotationType annotationType = AnnotationType.EDITORIAL();
358
                        	   Annotation annotation = Annotation.NewInstance(alternativeStatusString, annotationType, null);
359
                        	   distribution.addAnnotation(annotation);
360
                        	   distribution.addMarker(Marker.NewInstance(MarkerType.PUBLISH(), false));
361
                           }
362
//                         distribution.setCitation(sourceRef);
363
                           if (taxonDescription != null) { 
364
                        	   Distribution duplicate = checkIsNoDuplicate(taxonDescription, distribution, duplicateMap , occurrenceId);
365
                               if (duplicate == null){
366
	                        	   taxonDescription.addElement(distribution); 
367
	                               distribution.addImportSource(String.valueOf(occurrenceId), NAMESPACE, state.getTransactionalSourceReference(), null);
368
	                        	   countDistributions++; 
369
	                               if (taxonDescription != oldDescription){ 
370
	                            	   taxaToSave.add(taxonDescription.getTaxon()); 
371
	                                   oldDescription = taxonDescription; 
372
	                                   countDescriptions++; 
373
	                               	} 
374
                               }else{                          	  
375
                            	   countDuplicates++;
376
                            	   duplicate.addImportSource(String.valueOf(occurrenceId), NAMESPACE, state.getTransactionalSourceReference(), null);
377
                            	   logger.info("Distribution is duplicate");	                           }
378
	                       	} else { 
379
	                       		logger.warn("Distribution " + area.getLabel() + " ignored. OccurrenceId = " + occurrenceId);
380
	                       		success = false;
381
	                       	}
382
                     }
383
                     
354
                    //create description(elements)
355
                    TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId, sourceRef);
356
                    for (NamedArea area : areas){
357
                    	Distribution distribution = Distribution.NewInstance(area, status);
358
                        if (status == null){
359
                        	AnnotationType annotationType = AnnotationType.EDITORIAL();
360
                        	Annotation annotation = Annotation.NewInstance(alternativeStatusString, annotationType, null);
361
                        	distribution.addAnnotation(annotation);
362
                        	distribution.addMarker(Marker.NewInstance(MarkerType.PUBLISH(), false));
363
                        }
364
//                      distribution.setCitation(sourceRef);
365
                        if (taxonDescription != null) { 
366
                        	Distribution duplicate = checkIsNoDuplicate(taxonDescription, distribution, duplicateMap , occurrenceId);
367
                            if (duplicate == null){
368
                            	taxonDescription.addElement(distribution); 
369
	                            distribution.addImportSource(String.valueOf(occurrenceId), NAMESPACE, state.getTransactionalSourceReference(), null);
370
	                        	countDistributions++; 
371
	                            if (taxonDescription != oldDescription){ 
372
	                            	taxaToSave.add(taxonDescription.getTaxon()); 
373
	                                oldDescription = taxonDescription; 
374
	                                countDescriptions++; 
375
	                            } 
376
                            }else{                          	  
377
                            	countDuplicates++;
378
                            	duplicate.addImportSource(String.valueOf(occurrenceId), NAMESPACE, state.getTransactionalSourceReference(), null);
379
                            	logger.info("Distribution is duplicate");	                           }
380
                        } else { 
381
                        	logger.warn("Distribution " + area.getLabel() + " ignored. OccurrenceId = " + occurrenceId);
382
	                       	success = false;
383
	                    }
384
                        //notes
385
                        if (isNotBlank(notes)){
386
                        	Annotation annotation = Annotation.NewInstance(notes, Language.DEFAULT());
387
                        	distribution.addAnnotation(annotation);
388
                        }
389
                    }
384 390
                } catch (UnknownCdmTypeException e) {
385 391
                     logger.error("Unknown presenceAbsence status id: " + emStatusId); 
386 392
                	e.printStackTrace();
387 393
                     success = false;
388 394
                }
389
                
390 395
            }
391 396
           
392 397
            logger.info("Distributions: " + countDistributions + ", Descriptions: " + countDescriptions );

Also available in: Unified diff