Project

General

Profile

« Previous | Next » 

Revision 8422c0cd

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-app #5830

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
65 65
 * @created 20.02.2010
66 66
 */
67 67
@Component
68
public class GlobisSpecTaxImport  extends GlobisImportBase<Reference<?>> implements IMappingImport<Reference<?>, GlobisImportState>{
68
public class GlobisSpecTaxImport  extends GlobisImportBase<Reference> implements IMappingImport<Reference, GlobisImportState>{
69 69
	private static final Logger logger = Logger.getLogger(GlobisSpecTaxImport.class);
70
	
70

  
71 71
	private int modCount = 10000;
72 72
	private static final String pluralString = "taxa";
73 73
	private static final String dbTableName = "specTax";
74 74
	private static final Class<?> cdmTargetClass = Reference.class;
75
	
75

  
76 76
	private static UUID uuidCitedTypeLocality = UUID.fromString("ca431e0a-84ec-4828-935f-df4c8f5cf880");
77 77
	private static UUID uuidCitedTypeMaterial = UUID.fromString("8395021a-e596-4a55-9794-8c03aaad9e16");
78 78

  
......
82 82

  
83 83
	@Override
84 84
	protected String getIdQuery() {
85
		String strRecordQuery = 
86
			" SELECT specTaxId " + 
87
			" FROM " + dbTableName; 
88
		return strRecordQuery;	
85
		String strRecordQuery =
86
			" SELECT specTaxId " +
87
			" FROM " + dbTableName;
88
		return strRecordQuery;
89 89
	}
90 90

  
91 91
	@Override
92 92
	protected String getRecordQuery(GlobisImportConfigurator config) {
93
		String strRecordQuery = 
93
		String strRecordQuery =
94 94
			" SELECT t.*, t.DateCreated as Created_When, t.CreatedBy as Created_Who," +
95
			"        t.ModifiedBy as Updated_who, t.DateModified as Updated_When, t.SpecRemarks as Notes " + 
95
			"        t.ModifiedBy as Updated_who, t.DateModified as Updated_When, t.SpecRemarks as Notes " +
96 96
			" FROM " + getTableName() + " t " +
97 97
			" WHERE ( t.specTaxId IN (" + ID_LIST_TOKEN + ") )";
98 98
		return strRecordQuery;
99 99
	}
100
	
100

  
101 101

  
102 102
	@Override
103 103
	public boolean doPartition(ResultSetPartitioner partitioner, GlobisImportState state) {
104 104
		boolean success = true;
105
		
105

  
106 106
		Set<TaxonBase> objectsToSave = new HashSet<TaxonBase>();
107 107
		Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
108
		
109
		Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE);
110
		Map<String, Reference> referenceMap = (Map<String, Reference>) partitioner.getObjectMap(REFERENCE_NAMESPACE);
111
		
108

  
109
		Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE);
110
		Map<String, Reference> referenceMap = partitioner.getObjectMap(REFERENCE_NAMESPACE);
111

  
112 112
		ResultSet rs = partitioner.getResultSet();
113
		
113

  
114 114
		try {
115
			
115

  
116 116
			int i = 0;
117 117

  
118 118
			//for each reference
119 119
            while (rs.next()){
120
                
120

  
121 121
        		if ((i++ % modCount) == 0 && i!= 1 ){ logger.info(pluralString + " handled: " + (i-1));}
122
				
122

  
123 123
        		Integer specTaxId = rs.getInt("SpecTaxId");
124 124
        		Integer acceptedTaxonId = nullSafeInt(rs, "SpecCurrspecID");
125 125
        		String specSystaxRank = rs.getString("SpecSystaxRank");
126
        		
127
        		//ignore: CountryDummy, currentSpecies, DepositoryDisplay, DepositoryDummy, ReferenceDisplay, 
126

  
127
        		//ignore: CountryDummy, currentSpecies, DepositoryDisplay, DepositoryDummy, ReferenceDisplay,
128 128
        		//        SpecDescriptionImageFile, all *Valid*
129
        		
129

  
130 130
				try {
131
					
131

  
132 132
					//source ref
133
					Reference<?> sourceRef = state.getTransactionalSourceReference();
134
				
133
					Reference sourceRef = state.getTransactionalSourceReference();
134

  
135 135
					Taxon acceptedTaxon =  taxonMap.get(String.valueOf(acceptedTaxonId));
136 136
					TaxonBase<?> thisTaxon = null;
137
					
137

  
138 138
					ZoologicalName name = null;
139 139
					if (isBlank(specSystaxRank) ){
140 140
						name = makeName(state, rs, specTaxId);
......
157 157
						logger.warn(String.format("Unhandled specSystaxRank %s in specTaxId %d", specSystaxRank, specTaxId));
158 158
						name = makeName(state, rs, specTaxId);
159 159
					}
160
					
160

  
161 161
					if (thisTaxon != null){
162 162
						name = CdmBase.deproxy(thisTaxon.getName(), ZoologicalName.class);
163 163
					}else{
164 164
						if (name == null){
165 165
							name = makeName(state, rs, specTaxId);
166 166
						}
167
						
167

  
168 168
						thisTaxon = Taxon.NewInstance(name, sourceRef);
169 169
						objectsToSave.add(thisTaxon);
170 170
					}
171 171
					if (name == null){
172 172
						throw new RuntimeException("Name is still null");
173 173
					}
174
					
174

  
175 175
					handleNomRef(state, referenceMap, rs, name, specTaxId);
176
				
176

  
177 177
					handleTypeInformation(state,rs, name, specTaxId);
178
				
179
				
178

  
179

  
180 180
//					this.doIdCreatedUpdatedNotes(state, ref, rs, refId, REFERENCE_NAMESPACE);
181
				
181

  
182 182
					if (acceptedTaxon != null){
183
						objectsToSave.add(acceptedTaxon); 
183
						objectsToSave.add(acceptedTaxon);
184 184
					}
185
					
185

  
186 186
					//makeMarker1(state, rs, name);   //ignore!
187
					
187

  
188 188
					//make not available
189 189
					makeNotAvailable(state, rs, name, specTaxId);
190
					
190

  
191 191
					//maken invalid
192
					//TODO 
193
					
192
					//TODO
193

  
194 194
					//SpecCitedTypeLocality
195 195
					String citedTypeLocality = rs.getString("SpecCitedTypeLocality");
196 196
					if (isNotBlank(citedTypeLocality)){
......
207 207
					}
208 208

  
209 209
					name.addSource(OriginalSourceType.Import, String.valueOf(specTaxId), SPEC_TAX_NAMESPACE, state.getTransactionalSourceReference(), null);
210
					
210

  
211 211
					namesToSave.add(name);
212
					
212

  
213 213

  
214 214
				} catch (Exception e) {
215 215
					logger.warn("Exception in specTax: SpecTaxId " + specTaxId + ". " + e.getMessage());
216 216
					e.printStackTrace();
217
				} 
218
                
217
				}
218

  
219 219
            }
220
           
220

  
221 221
			logger.warn(pluralString + " to save: " + objectsToSave.size());
222
			getTaxonService().save(objectsToSave);	
222
			getTaxonService().save(objectsToSave);
223 223
			getNameService().save(namesToSave);
224
			
224

  
225 225
			return success;
226 226
		} catch (Exception e) {
227 227
			logger.error("Exception: " +  e);
......
233 233
	private void makeNotAvailable(GlobisImportState state, ResultSet rs, ZoologicalName name, int id) throws SQLException {
234 234
		String notAvailableStr = rs.getString("SpecNotAvailable");
235 235
		String notAvailableReason = rs.getString("SpecNotAvailableReason");
236
		
236

  
237 237
		if (isNotBlank(notAvailableStr) && notAvailableStr.contains("not available")){
238 238
			if (isBlank(notAvailableReason)){
239 239
				logger.warn("Blank notAvailableReason has available: " + id);
......
251 251

  
252 252

  
253 253
		//OLD
254
//				if (notAvailableStr.contains("not available") ){ 
254
//				if (notAvailableStr.contains("not available") ){
255 255
//					UUID uuidNotAvailableMarkerType = state.getTransformer().getMarkerTypeUuid("not available");
256
//					
256
//
257 257
//					MarkerType markerType = getMarkerType(state, uuidNotAvailableMarkerType, "not available", "not available", null);
258 258
//					name.addMarker(Marker.NewInstance(markerType, true));
259 259
//				}
......
267 267
//				name.addExtension(notAvailableReason, notAvailableReasonExtType);
268 268
//			} catch (UndefinedTransformerMethodException e) {
269 269
//				e.printStackTrace();
270
//			} 
270
//			}
271 271
//		}
272
		
272

  
273 273
	}
274 274

  
275 275

  
276 276

  
277 277

  
278
	
278

  
279 279
	private NomenclaturalStatus getNomStatus(GlobisImportState state, String notAvailableReason, int id) {
280 280
		NomenclaturalStatus status = NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ZOO_NOT_AVAILABLE());
281 281
		status.setRuleConsidered(notAvailableReason);
......
307 307
				if (marker1Str.contains("checked") || marker1Str.contains("berpr") ){ //überprüft
308 308
					UUID uuidCheckedMarkerType;
309 309
						uuidCheckedMarkerType = state.getTransformer().getMarkerTypeUuid("checked");
310
					
310

  
311 311
					MarkerType markerType = getMarkerType(state, uuidCheckedMarkerType, "checked", "checked", null);
312 312
					name.addMarker(Marker.NewInstance(markerType, true));
313 313
				}
......
320 320
		} catch (UndefinedTransformerMethodException e) {
321 321
			e.printStackTrace();
322 322
		}
323
		
323

  
324 324
	}
325 325

  
326 326

  
......
328 328
			String citedTypeLocality, String featureLabel) {
329 329
		Feature feature = getFeature(state, featureUuid,featureLabel,featureLabel, null, null);
330 330
		getTaxonNameDescription(name, false, true);
331
		
331

  
332 332
	}
333 333

  
334 334

  
335 335
	private Pattern patternAll = Pattern.compile("(.+,\\s.+)(\\(.+\\))");
336
	
336

  
337 337

  
338 338
	private void handleTypeInformation(GlobisImportState state, ResultSet rs, ZoologicalName name, Integer specTaxId) throws SQLException {
339 339
		if (! hasTypeInformation(rs)){
340 340
			return;
341 341
		}
342
		
342

  
343 343
		FieldUnit fieldObservation = makeTypeFieldObservation(state, rs);
344
		
344

  
345 345
		//typeDepository
346 346
		String specTypeDepositoriesStr = rs.getString("SpecTypeDepository");
347
		String[] specTypeDepositories; 
347
		String[] specTypeDepositories;
348 348
		if (isNotBlank(specTypeDepositoriesStr) ){
349 349
			specTypeDepositories = specTypeDepositoriesStr.trim().split(";");
350 350
		}else{
351 351
			specTypeDepositories = new String[0];
352 352
		}
353
		
353

  
354 354
		//TODO several issues
355 355
		if (specTypeDepositories.length == 0){
356 356
			DerivedUnit specimen = makeSingleTypeSpecimen(fieldObservation);
......
359 359
		}else{
360 360
			for (String specTypeDepositoryStr : specTypeDepositories){
361 361
				specTypeDepositoryStr = specTypeDepositoryStr.trim();
362
				
362

  
363 363
				//Specimen
364 364
				DerivedUnit specimen = makeSingleTypeSpecimen(fieldObservation);
365
	
365

  
366 366
				if (specTypeDepositoryStr.equals("??")){
367 367
					//unknown
368 368
					//TODO marker unknown ?
......
376 376
				}else{
377 377
					specTypeDepositoryStr = makeAdditionalSpecimenInformation(
378 378
							specTypeDepositoryStr, specimen, specTaxId);
379
					
379

  
380 380
					Collection collection = makeCollection(state, specTypeDepositoryStr, specimen, specTaxId);
381 381
					String collectionCode = collection.getCode();
382 382
					if (isBlank(collectionCode)){
......
385 385
					if (isBlank(collectionCode)){
386 386
						logger.warn("Collection has empty representation: " + specTypeDepositoryStr + ", specTaxId" +  specTaxId);
387 387
					}
388
					makeTypeIdInSource(state, specimen, collectionCode , specTaxId);	
388
					makeTypeIdInSource(state, specimen, collectionCode , specTaxId);
389 389
				}
390
				
390

  
391 391
				//type Designation
392 392
				makeTypeDesignation(name, rs, specimen, specTaxId);
393 393
			}
394 394
		}
395 395

  
396
		
396

  
397 397
	}
398 398

  
399 399

  
......
428 428

  
429 429

  
430 430
	/**
431
	 * @param state 
431
	 * @param state
432 432
	 * @param specTypeDepositoryStr
433 433
	 * @param specimen
434
	 * @param specTaxId 
434
	 * @param specTaxId
435 435
	 */
436 436
	protected Collection makeCollection(GlobisImportState state, String specTypeDepositoryStr, DerivedUnit specimen, Integer specTaxId) {
437
		
437

  
438 438
		//Collection
439 439
		specTypeDepositoryStr = specTypeDepositoryStr.replace("Washington, D.C.", "Washington@ D.C.")
440 440
				.replace("St.-Raymond, Quebec", "St.-Raymond@ Quebec")
441 441
				.replace("St.Petersburg", "St. Petersburg");
442
		
443
		
442

  
443

  
444 444
		Collection collection = handleSpecialCase(specTypeDepositoryStr, state, specimen);
445 445
		if (collection == null){
446 446
			String[] split = specTypeDepositoryStr.split(",");
......
459 459
					collection.setCode("??");
460 460
					//TODO deduplicate ??
461 461
				}
462
				
462

  
463 463
			}else{
464 464
				String collectionStr = split[0];
465 465
				String location = split[1].replace("@", ",").trim();
466
				
466

  
467 467
				collection = state.getRelatedObject(COLLECTION_NAMESPACE, collectionStr, Collection.class);
468 468
				if (collection == null){
469 469
					collection = Collection.NewInstance();
......
474 474
					}
475 475
					collection.setTownOrLocation(location);
476 476
					state.addRelatedObject(COLLECTION_NAMESPACE, collection.getCode(), collection);
477
						
477

  
478 478
				}else if (! CdmUtils.nullSafeEqual(location, collection.getTownOrLocation())){
479 479
					if (! normalizeTownOrLocation(location, collection)){
480 480
						String message = "Location (%s) is not equal to location (%s) of existing collection, specTaxId: " + specTaxId;
481 481
						logger.warn(String.format(message, location, collection.getTownOrLocation(), collection.getCode()));
482 482
					}
483
					
483

  
484 484
				}
485
				
485

  
486 486
				specimen.setCollection(collection);
487 487
			}
488 488
		}
......
567 567
				return true;
568 568
			} else if ("coll. Dantchenko".equals(collection.getName())){
569 569
				if (! "Moscow".equals(collection.getTownOrLocation())){
570
					collection.setTownOrLocation("Moscow");  
570
					collection.setTownOrLocation("Moscow");
571 571
					getCollectionService().saveOrUpdate(collection);
572 572
				}
573 573
				return true;
574 574
			} else if ("coll. S. Nakano".equals(collection.getName())){
575 575
				if (! "Tokyo".equals(collection.getTownOrLocation())){
576
					collection.setTownOrLocation("Tokyo");  
576
					collection.setTownOrLocation("Tokyo");
577 577
					getCollectionService().saveOrUpdate(collection);
578 578
				}
579 579
				return true;
580 580
			} else if ("coll. A. Yagishita".equals(collection.getName())){
581 581
				if (! "Toride Ibaraki".equals(collection.getTownOrLocation())){
582
					collection.setTownOrLocation("Toride Ibaraki");  
582
					collection.setTownOrLocation("Toride Ibaraki");
583 583
					getCollectionService().saveOrUpdate(collection);
584 584
				}
585 585
				return true;
586 586
			} else if ("coll. H. Sugiyama".equals(collection.getName())){
587 587
				if (! "Gifu".equals(collection.getTownOrLocation())){
588
					collection.setTownOrLocation("Gifu");  
588
					collection.setTownOrLocation("Gifu");
589 589
					getCollectionService().saveOrUpdate(collection);
590 590
				}
591 591
				return true;
592 592
			} else if ("MDMO".equals(collection.getCode())){
593 593
				if (! "Moscow".equals(collection.getTownOrLocation())){
594
					collection.setTownOrLocation("Moscow");  
594
					collection.setTownOrLocation("Moscow");
595 595
					getCollectionService().saveOrUpdate(collection);
596 596
				}
597 597
				return true;
598 598
			} else if ("coll. W. Eckweiler".equals(collection.getName())){
599 599
				if (! "Frankfurt am Main".equals(collection.getTownOrLocation())){
600
					collection.setTownOrLocation("Frankfurt am Main");  
600
					collection.setTownOrLocation("Frankfurt am Main");
601 601
					getCollectionService().saveOrUpdate(collection);
602 602
				}
603 603
				return true;
604 604
			} else if ("coll. T. Frankenbach".equals(collection.getName())){
605 605
				if (! "Wangen".equals(collection.getTownOrLocation())){
606
					collection.setTownOrLocation("Wangen");  
606
					collection.setTownOrLocation("Wangen");
607 607
					getCollectionService().saveOrUpdate(collection);
608 608
				}
609 609
				return true;
610 610
			}
611 611
		}
612
		
612

  
613 613
		return result;
614 614
	}
615 615

  
......
669 669
				state.addRelatedObject(COLLECTION_NAMESPACE, collection.getName(), collection);
670 670
			}
671 671
			specimen.setCollection(collection);
672
			
672

  
673 673
		}else if (specTypeDepositoryStr.equals("coll. L. V. Kaabak, A .V. Sotshivko & V. V. Titov, Moscow")){
674 674
			String colName = "coll. L. V. Kaabak, A .V. Sotshivko & V. V. Titov";
675 675
			collection = state.getRelatedObject(COLLECTION_NAMESPACE, colName, Collection.class);
......
713 713
		}else{
714 714
			collection = null;
715 715
		}
716
		
717
		
716

  
717

  
718 718
		return collection;
719 719
	}
720 720

  
......
722 722
	 * @param specTypeDepositoriesStr
723 723
	 * @param specTypeDepositoryStr
724 724
	 * @param specimen
725
	 * @param specTaxId 
725
	 * @param specTaxId
726 726
	 * @return
727 727
	 */
728 728
	protected String makeAdditionalSpecimenInformation( String specTypeDepositoryStr, DerivedUnit specimen, Integer specTaxId) {
......
731 731
			Marker.NewInstance(specimen, true, MarkerType.IS_DOUBTFUL());
732 732
			specTypeDepositoryStr = specTypeDepositoryStr.substring(0, specTypeDepositoryStr.length() -1).trim();
733 733
		}
734
		
734

  
735 735
		//brackets
736 736
		Matcher matcher = patternAll.matcher(specTypeDepositoryStr);
737 737
		if (matcher.find()){
738 738
			//has brackets
739 739
			String brackets = matcher.group(2);
740 740
			brackets = brackets.substring(1, brackets.length()-1);
741
			
741

  
742 742
			//TODO this is unwanted according to Alexander
743 743
			brackets = brackets.replace("[mm]", "\u2642\u2642");
744 744
			brackets = brackets.replace("[m]", "\u2642");
745 745
			brackets = brackets.replace("[ff]", "\u2640\u2640");
746 746
			brackets = brackets.replace("[f]", "\u2640");
747 747
			brackets = brackets.replace("[m/f]", "\u26a5");
748
			
748

  
749 749
			if (brackets.contains("[") || brackets.contains("]")){
750 750
				logger.warn ("There are still '[', ']' in the bracket part: " + brackets + "; specTaxId: " + specTaxId);
751 751
			}
752
			
753
			//TODO replace mm/ff by Unicode male 
752

  
753
			//TODO replace mm/ff by Unicode male
754 754
			specimen.setTitleCache(brackets, true);
755 755
			specTypeDepositoryStr = matcher.group(1).trim();
756 756
		}
......
781 781
	 * @return
782 782
	 * @throws SQLException
783 783
	 */
784
	protected FieldUnit makeTypeFieldObservation(GlobisImportState state, 
784
	protected FieldUnit makeTypeFieldObservation(GlobisImportState state,
785 785
			ResultSet rs) throws SQLException {
786
		
786

  
787 787
		String countryString = rs.getString("SpecTypeCountry");
788
		
788

  
789 789
		SpecimenOrObservationType unitType = SpecimenOrObservationType.PreservedSpecimen;
790 790
		DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(unitType);
791
		
791

  
792 792
		NamedArea typeCountry = getCountry(state, countryString);
793 793
		facade.setCountry(typeCountry);
794 794
		FieldUnit fieldObservation = facade.innerFieldUnit();
......
800 800

  
801 801
	/**
802 802
	 * @param name
803
	 * @param rs 
803
	 * @param rs
804 804
	 * @param status
805 805
	 * @param specimen
806
	 * @param specTaxId 
807
	 * @throws SQLException 
806
	 * @param specTaxId
807
	 * @throws SQLException
808 808
	 */
809 809
	protected void makeTypeDesignation(ZoologicalName name, ResultSet rs, DerivedUnit specimen, Integer specTaxId) throws SQLException {
810 810
		//type
......
814 814
		SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance();
815 815
		typeDesignation.setTypeStatus(status);
816 816
		typeDesignation.setTypeSpecimen(specimen);
817
		
817

  
818 818
		name.addTypeDesignation(typeDesignation, true);
819 819
	}
820 820

  
......
848 848
	 * @param referenceMap
849 849
	 * @param rs
850 850
	 * @param name
851
	 * @param specTaxId 
851
	 * @param specTaxId
852 852
	 * @return
853 853
	 * @throws SQLException
854 854
	 */
855
	private Reference<?> handleNomRef(GlobisImportState state, Map<String, Reference> referenceMap, ResultSet rs,
855
	private Reference handleNomRef(GlobisImportState state, Map<String, Reference> referenceMap, ResultSet rs,
856 856
			ZoologicalName name, Integer specTaxId) throws SQLException {
857 857
		//ref
858 858
		Integer refId = nullSafeInt(rs, "fiSpecRefID");
859
		Reference<?> nomRef = null;
859
		Reference nomRef = null;
860 860
		if (refId != null){
861 861
			nomRef = referenceMap.get(String.valueOf(refId));
862 862
			if (nomRef == null && state.getConfig().getDoReferences().equals(state.getConfig().getDoReferences().ALL)){
......
865 865
				name.setNomenclaturalReference(nomRef);
866 866
			}
867 867
		}
868
		
868

  
869 869
		//refDetail
870 870
		String refDetail = rs.getString("SpecPage");
871 871
		if (isNotBlank(refDetail)){
......
876 876

  
877 877

  
878 878

  
879
	
879

  
880 880
	private void validateAcceptedTaxon(Taxon acceptedTaxon, ResultSet rs, Integer specTaxId, Integer acceptedTaxonId) throws SQLException {
881 881
		if (acceptedTaxon == null){
882 882
			logger.warn("Accepted taxon is null for taxon taxon to validate. SpecTaxId " + specTaxId + ", accTaxonId: " + acceptedTaxonId);
883 883
			return;
884 884
		}
885
		
886
		//TODO 
885

  
886
		//TODO
887 887
		ZoologicalName name = CdmBase.deproxy(acceptedTaxon.getName(), ZoologicalName.class);
888
		
888

  
889 889
		String specName = rs.getString("SpecName");
890 890
		if (! name.getSpecificEpithet().equals(specName)){
891 891
			logger.warn(String.format("Species epithet is not equal for accepted taxon: %s - %s. SpecTaxId: %d", name.getSpecificEpithet(), specName, specTaxId));
......
898 898

  
899 899
	private Synonym getSynonym(GlobisImportState state, ResultSet rs, Integer specTaxId) throws SQLException {
900 900
		ZoologicalName name = makeName(state, rs, specTaxId);
901
				
901

  
902 902
		Synonym synonym = Synonym.NewInstance(name, state.getTransactionalSourceReference());
903
		
903

  
904 904
		return synonym;
905 905
	}
906 906

  
......
910 910
	/**
911 911
	 * @param state
912 912
	 * @param rs
913
	 * @param specTaxId 
913
	 * @param specTaxId
914 914
	 * @return
915 915
	 * @throws SQLException
916 916
	 */
......
926 926
				e.printStackTrace();
927 927
			}
928 928
		}
929
		
929

  
930 930
		//name
931 931
		ZoologicalName name = ZoologicalName.NewInstance(rank);
932 932
		makeNamePartsAndCache(state, rs, rankStr, name);
933
		
933

  
934 934

  
935 935
//		name.setGenusOrUninomial(genusOrUninomial);
936 936
		String authorStr = rs.getString("SpecAuthor");
937 937
		String yearStr = rs.getString("SpecYear");
938 938
		String authorAndYearStr = CdmUtils.concat(", ", authorStr, yearStr);
939 939
		handleAuthorAndYear(authorAndYearStr, name, specTaxId, state);
940
		
940

  
941 941
		return name;
942 942
	}
943 943

  
......
950 950
		String citedSpecies = rs.getString("SpecCitedSpecies");
951 951
		String citedSubspecies = rs.getString("SpecCitedSubspecies");
952 952
		String lastEpithet = rs.getString("SpecName");
953
		
954
		
953

  
954

  
955 955
		String cache = CdmUtils.concat(" ", new String[]{citedFamily, citedGenus, citedSpecies, citedSubspecies, rank, lastEpithet});
956 956
		name.setGenusOrUninomial(citedGenus);
957 957
		//TODO separate authors
......
963 963
				name.setInfraSpecificEpithet(lastEpithet);
964 964
			}
965 965
		}
966
		
966

  
967 967
		//TODO check if cache needs protection
968 968
		name.setNameCache(cache, true);
969 969
	}
......
973 973
		String nameSpace;
974 974
		Class<?> cdmClass;
975 975
		Set<String> idSet;
976
		
976

  
977 977
		Set<AgentBase> agents = state.getAgents();
978 978
		getAgentService().saveOrUpdate(agents);
979
		
979

  
980 980
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
981 981
		try{
982 982
			Set<String> taxonIdSet = new HashSet<String>();
983 983
			Set<String> referenceIdSet = new HashSet<String>();
984
			
984

  
985 985
			while (rs.next()){
986 986
				handleForeignKey(rs, taxonIdSet, "SpecCurrspecID");
987 987
				handleForeignKey(rs, referenceIdSet, "fiSpecRefID");
988 988
			}
989
			
989

  
990 990
			//taxon map
991 991
			nameSpace = TAXON_NAMESPACE;
992 992
			cdmClass = Taxon.class;
......
1000 1000
			idSet = referenceIdSet;
1001 1001
			Map<String, Reference> referenceMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
1002 1002
			result.put(nameSpace, referenceMap);
1003
			
1003

  
1004 1004
			//collection map
1005 1005
			nameSpace = COLLECTION_NAMESPACE;
1006 1006
			List<Collection> listCollection = getCollectionService().list(Collection.class, null, null, null, null);
......
1015 1015
				}
1016 1016
			}
1017 1017
			result.put(nameSpace, collectionMap);
1018
			
1018

  
1019 1019
		} catch (SQLException e) {
1020 1020
			throw new RuntimeException(e);
1021 1021
		}
1022 1022
		return result;
1023 1023
	}
1024
	
1024

  
1025 1025
	/* (non-Javadoc)
1026 1026
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator)
1027 1027
	 */
......
1030 1030
		IOValidator<GlobisImportState> validator = new GlobisSpecTaxaImportValidator();
1031 1031
		return validator.validate(state);
1032 1032
	}
1033
	
1034
	
1033

  
1034

  
1035 1035
	/* (non-Javadoc)
1036 1036
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
1037 1037
	 */
1038
	protected boolean isIgnore(GlobisImportState state){
1038
	@Override
1039
    protected boolean isIgnore(GlobisImportState state){
1039 1040
		return ! state.getConfig().isDoSpecTaxa();
1040 1041
	}
1041 1042

  
......
1043 1044

  
1044 1045

  
1045 1046
	@Override
1046
	public Reference<?> createObject(ResultSet rs, GlobisImportState state)
1047
	public Reference createObject(ResultSet rs, GlobisImportState state)
1047 1048
			throws SQLException {
1048 1049
		// not needed
1049 1050
		return null;

Also available in: Unified diff