Project

General

Profile

« Previous | Next » 

Revision 495cebda

Added by Andreas Müller about 11 years ago

updates to globis import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisCurrentSpeciesImport.java
29 29
import eu.etaxonomy.cdm.model.description.Distribution;
30 30
import eu.etaxonomy.cdm.model.description.PresenceTerm;
31 31
import eu.etaxonomy.cdm.model.description.TaxonDescription;
32
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;
32
import eu.etaxonomy.cdm.model.location.NamedArea;
33 33
import eu.etaxonomy.cdm.model.name.Rank;
34 34
import eu.etaxonomy.cdm.model.name.ZoologicalName;
35 35
import eu.etaxonomy.cdm.model.reference.Reference;
......
116 116
				
117 117
        		Integer taxonId = rs.getInt("IDcurrentspec");
118 118
        		
119
        		
120 119
        		//String dtSpcJahr -> ignore !
121 120
        		//empty: fiSpcLiteratur
122 121
        		
......
134 133
					boolean hasNewParent = false; //true if any parent is new
135 134
					
136 135
					//species
137
					Taxon species = createObject(rs, state);
136
					Taxon species = createObject(rs, state, taxonId);
138 137
					
139 138
					
140 139
					String familyStr = rs.getString("dtSpcFamakt");
......
142 141
					String tribeStr = rs.getString("dtSpcTribakt");
143 142
					
144 143
					//family
145
					Taxon family = getTaxon(state, rs, familyStr, null, Rank.FAMILY(), null, taxonMap);
144
					Taxon family = getTaxon(state, rs, familyStr, null, Rank.FAMILY(), null, taxonMap, taxonId);
146 145
					
147 146
					//subfamily
148
					Taxon subFamily = getTaxon(state, rs, subFamilyStr, null, Rank.SUBFAMILY(), null, taxonMap);
147
					Taxon subFamily = getTaxon(state, rs, subFamilyStr, null, Rank.SUBFAMILY(), null, taxonMap, taxonId);
149 148
					Taxon subFamilyParent = getParent(subFamily, classification);
150 149
					if (subFamilyParent != null){
151 150
						if (! compareTaxa(family, subFamilyParent)){
......
157 156
					nextHigherTaxon = subFamily;
158 157
					
159 158
					//tribe
160
					Taxon tribe = getTaxon(state, rs, tribeStr, null, Rank.TRIBE(), null, taxonMap);
159
					Taxon tribe = getTaxon(state, rs, tribeStr, null, Rank.TRIBE(), null, taxonMap, taxonId);
161 160
					if (tribe != null){
162 161
						Taxon tribeParent = getParent(tribe, classification);
163 162
						if (tribeParent != null){
......
174 173
					//genus
175 174
					String genusStr = rs.getString("dtSpcGenusakt");
176 175
					String genusAuthorStr = rs.getString("dtSpcGenusaktauthor");
177
					Taxon genus = getTaxon(state, rs, genusStr, null, Rank.GENUS(), genusAuthorStr, taxonMap);
176
					Taxon genus = getTaxon(state, rs, genusStr, null, Rank.GENUS(), genusAuthorStr, taxonMap, taxonId);
178 177
					Taxon genusParent = getParent(genus, classification);
179 178
					
180 179
					if (genusParent != null){
......
191 190
					String subGenusAuthorStr = rs.getString("dtSpcSubgenaktauthor");
192 191
					boolean hasSubgenus = StringUtils.isNotBlank(subGenusStr) || StringUtils.isNotBlank(subGenusAuthorStr);
193 192
					if (hasSubgenus){
194
						Taxon subGenus = getTaxon(state, rs, genusStr, subGenusStr, Rank.SUBGENUS(), subGenusAuthorStr, taxonMap);
193
						Taxon subGenus = getTaxon(state, rs, genusStr, subGenusStr, Rank.SUBGENUS(), subGenusAuthorStr, taxonMap, taxonId);
195 194
						classification.addParentChild(nextHigherTaxon, subGenus, sourceRef, null);
196 195
						nextHigherTaxon = subGenus;
197 196
					}
......
256 255
			
257 256
			countryStr = normalizeCountry(countryStr);
258 257
			
259
			WaterbodyOrCountry country = getCountry(state, countryStr);
258
			NamedArea country = getCountry(state, countryStr);
260 259
			
261 260
			PresenceTerm status;
262 261
			if (isDoubtful){
......
348 347

  
349 348

  
350 349

  
351
	private Taxon getTaxon(GlobisImportState state, ResultSet rs, String uninomial, String infraGenericEpi, Rank rank, String author, Map<String, Taxon> taxonMap) {
350
	private Taxon getTaxon(GlobisImportState state, ResultSet rs, String uninomial, String infraGenericEpi, Rank rank, String author, Map<String, Taxon> taxonMap, Integer taxonId) {
352 351
		if (isBlank(uninomial)){
353 352
			return null;
354 353
		}
......
366 365
			taxon = Taxon.NewInstance(name, state.getTransactionalSourceReference());
367 366
			
368 367
			taxonMap.put(key, taxon);
369
			handleAuthorAndYear(author, name);
368
			handleAuthorAndYear(author, name, taxonId);
370 369
			getTaxonService().save(taxon);
371 370
		}
372 371
		
......
392 391
	/* (non-Javadoc)
393 392
	 * @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase)
394 393
	 */
395
	public Taxon createObject(ResultSet rs, GlobisImportState state)
394
	public Taxon createObject(ResultSet rs, GlobisImportState state, Integer taxonId)
396 395
			throws SQLException {
397 396
		String speciesEpi = rs.getString("dtSpcSpcakt");
398 397
		String subGenusEpi = rs.getString("dtSpcSubgenakt");
......
406 405
			zooName.setInfraGenericEpithet(subGenusEpi);
407 406
		}
408 407
		zooName.setGenusOrUninomial(genusEpi);
409
		handleAuthorAndYear(author, zooName);
408
		handleAuthorAndYear(author, zooName, taxonId);
410 409
		
411 410
		Taxon taxon = Taxon.NewInstance(zooName, state.getTransactionalSourceReference());
412 411
		

Also available in: Unified diff