Project

General

Profile

« Previous | Next » 

Revision bb5bac58

Added by Andreas Müller over 4 years ago

minor, cleanup

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java
12 12
import java.sql.ResultSet;
13 13
import java.sql.SQLException;
14 14
import java.util.HashMap;
15
import java.util.HashSet;
16 15
import java.util.List;
17 16
import java.util.Map;
18 17
import java.util.Set;
......
55 54
			" SELECT DISTINCT [Kingdom name], [Phylum name], [Subphylum name], [Class name], [Subclass name], [Order name], [Family name], g.[NAME OF FUNGUS] as GenusName, c.PreferredName as SpeciesName " +
56 55
			" FROM [tblPESIfungi-Classification] c  LEFT OUTER JOIN " +
57 56
                      " tblGenera g ON c.PreferredNameFDCnumber = g.[RECORD NUMBER]" +
58
//			" WHERE ( dr.id IN (" + ID_LIST_TOKEN + ") )";
59 57
			" ORDER BY [Kingdom name], [Phylum name], [Subphylum name], [Class name], [Subclass name], [Order name],  [Family name], GenusName, SpeciesName ";
60 58
		return strRecordQuery;
61 59
	}
......
77 75
		String lastSubclass = "";
78 76
		String lastOrder = "";
79 77
		String lastFamily = "";
80
//		String lastGenus = "";
81
//		String lastSpecies = "";
82 78

  
83 79
		Taxon taxonKingdom = null;
84 80
		Taxon taxonPhylum = null;
......
87 83
		Taxon taxonSubclass = null;
88 84
		Taxon taxonOrder = null;
89 85
		Taxon taxonFamily = null;
90
//		Taxon taxonGenus = null;
91
//		Taxon taxonSpecies = null;
92 86

  
93 87
		Taxon higherTaxon = null;
94 88

  
......
107 101
				String subclass = rs.getString("Subclass name");
108 102
				String order = rs.getString("Order name");
109 103
				String family = rs.getString("Family name");
110
//				String genus = rs.getString("GenusName");
111
//				String species = rs.getString("SpeciesName");
112 104

  
113
//				if (isNewTaxon(species, lastSpecies)){
114
//					if (isNewTaxon(genus, lastGenus)){
115 105
				if (isNewTaxon(family, lastFamily)){
116 106
					if (isNewTaxon(order,lastOrder)){
117 107
						if (isNewTaxon(subclass,lastSubclass)){
......
178 168
					taxonFamily = makeTaxon(state, family, Rank.FAMILY());
179 169
					if (taxonFamily != null){
180 170
						try{
181
							//if this shown a warning see single issue in #2826 about Glomerelllaceae (which has 2 different parents)
171
							//if this shows a warning see single issue in #2826 about Glomerellaceae (which has 2 different parents)
182 172
						    getClassification(state).addParentChild(higherTaxon, taxonFamily, null, null);
183 173
						}catch(IllegalStateException e){
184 174
							if (e.getMessage().startsWith("The child taxon is already part of the tree")){
185 175
								//TaxonNode node = getClassification(state).getNode(taxonFamily);
186 176
								logger.warn(e.getMessage() + taxonFamily.getTitleCache() + " " + higherTaxon.getTitleCache());
187

  
188
								}
177
							}
189 178
						}
190 179
					}
191 180
					higherTaxon = isIncertisSedis(family) ? higherTaxon : taxonFamily;
192 181
					lastFamily = family;
193 182
					getTaxonService().saveOrUpdate(higherTaxon);
194 183
				}
195
//						else{
196
//							higherTaxon = taxonFamily;
197
//						}
198
//						taxonGenus = makeTaxon(state, genus, Rank.GENUS());
199
//						if (taxonGenus != null){
200
//							getClassification(state).addParentChild(higherTaxon, taxonGenus, null, null);
201
//						}
202
//						higherTaxon = isIncertisSedis(genus) ? higherTaxon : taxonGenus;
203
//						lastGenus = genus;
204
//					}else{
205
//						higherTaxon = taxonGenus;
206
//					}
207
//					taxonSpecies = makeTaxon(state, species, Rank.SPECIES());
208
//					if (taxonSpecies != null){
209
//						getClassification(state).addParentChild(higherTaxon, taxonSpecies, null, null);
210
//					}
211
//					higherTaxon = isIncertisSedis(species) ? higherTaxon : taxonSpecies;
212
//					lastSpecies = species;
213
//					getTaxonService().saveOrUpdate(higherTaxon);
214
//				}
215 184
				getTaxonService().saveOrUpdate(higherTaxon);
216 185
			}
217

  
218

  
219 186
		} catch (SQLException e) {
220 187
			e.printStackTrace();
221 188
			logger.error(e.getMessage());
......
226 193
		logger.info("End higher classification ...");
227 194

  
228 195
		return;
229

  
230 196
	}
231 197

  
232

  
233 198
	private boolean isIncertisSedis(String uninomial) {
234 199
		return  uninomial.equalsIgnoreCase(INCERTAE_SEDIS) || uninomial.equalsIgnoreCase(FOSSIL_FUNGI);
235 200
	}
236 201

  
237

  
238 202
	private boolean isNewTaxon(String uninomial, String lastUninomial) {
239 203
		boolean result =  !uninomial.equalsIgnoreCase(lastUninomial);
240 204
		result |= lastUninomial.equalsIgnoreCase(INCERTAE_SEDIS);
......
246 210
		if (uninomial.equalsIgnoreCase(INCERTAE_SEDIS) || uninomial.equalsIgnoreCase(FOSSIL_FUNGI)){
247 211
			return null;
248 212
		}
249
		Taxon taxon = state.getRelatedObject(IndexFungorumSupraGeneraImport.NAMESPACE_SUPRAGENERIC_NAMES, uninomial, Taxon.class);
213
		Taxon taxon = state.getRelatedObject(IndexFungorumImportBase.NAMESPACE_SUPRAGENERIC_NAMES, uninomial, Taxon.class);
250 214
		if (taxon == null){
251 215
			if (! newRank.equals(Rank.KINGDOM())){
252 216
				logger.warn("Taxon not found for uninomial " + uninomial);
......
262 226
		return taxon;
263 227
	}
264 228

  
265

  
266 229
	@Override
267 230
	public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, IndexFungorumImportState state) {
268 231
		String nameSpace;
269 232
		Class<?> cdmClass;
270 233
		Set<String> idSet;
271
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
234
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
272 235

  
273 236
		try{
274
			Set<String> taxonNameSet = new HashSet<String>();
237
//			Set<String> taxonNameSet = new HashSet<>();
275 238
//			while (rs.next()){
276 239
//				handleForeignKey(rs, taxonIdSet,"tu_accfinal" );
277 240
//			}
278 241

  
279 242
			//taxon map
280
			nameSpace = IndexFungorumSupraGeneraImport.NAMESPACE_SUPRAGENERIC_NAMES ;
243
			nameSpace = IndexFungorumImportBase.NAMESPACE_SUPRAGENERIC_NAMES ;
281 244
			cdmClass = TaxonBase.class;
282 245
//			idSet = taxonNameSet;
283
			Map<String, TaxonBase<?>> taxonMap = new HashMap<String, TaxonBase<?>>();
246
			Map<String, TaxonBase<?>> taxonMap = new HashMap<>();
284 247
			List<Taxon> list = getTaxonService().list(Taxon.class, null, null, null, null);
285 248
			for (Taxon taxon : list){
286 249
				taxonMap.put(CdmBase.deproxy(taxon.getName()).getGenusOrUninomial(), taxon);
......
289 252

  
290 253
			//source reference
291 254
			Reference sourceReference = getReferenceService().find(PesiTransformer.uuidSourceRefIndexFungorum);
292
			Map<String, Reference> referenceMap = new HashMap<String, Reference>();
255
			Map<String, Reference> referenceMap = new HashMap<>();
293 256
			referenceMap.put(SOURCE_REFERENCE, sourceReference);
294 257
			result.put(NAMESPACE_REFERENCE, referenceMap);
295 258

  
......
308 271
	protected boolean isIgnore(IndexFungorumImportState state){
309 272
		return ! state.getConfig().isDoRelTaxa();
310 273
	}
311

  
312

  
313

  
314

  
315

  
316 274
}

Also available in: Unified diff