Project

General

Profile

« Previous | Next » 

Revision 86c8aa4d

Added by Andreas Müller over 15 years ago

io TaxonX minor changes (v2.0)

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/taxonx/TaxonXNomenclatureImport.java
50 50
public class TaxonXNomenclatureImport extends CdmIoBase<IImportConfigurator> implements ICdmIO<IImportConfigurator> {
51 51
	private static final Logger logger = Logger.getLogger(TaxonXNomenclatureImport.class);
52 52

  
53
	@SuppressWarnings("unused")
53 54
	private static int modCount = 10000;
54 55

  
55 56
	public TaxonXNomenclatureImport(){
......
92 93
			for (Element elSynonymy : elSynonymyList){
93 94
				String synonymName = elSynonymy.getChildTextTrim("name");
94 95
				if (elSynonymy.getChild("type", nsTaxonx) != null || elSynonymy.getChild("type_loc", nsTaxonx) != null){
95
					Synonym synonym = getSynonym(config, taxon, synonymName);
96
					Synonym synonym = getSynonym(txConfig, taxon, synonymName);
96 97
					if (synonym != null){
97 98
						isChanged |= doNomenclaturalType(txConfig, elSynonymy, nsTaxonx, synonym.getName());
98 99
					}
......
108 109
		return true;
109 110
	}
110 111
	
111
	private Synonym getSynonym(IImportConfigurator config, Taxon taxon, String synName){
112
	private Synonym getSynonym(TaxonXImportConfigurator config, Taxon taxon, String synName){
112 113
		Synonym result = null;
113 114
		unlazySynonym(config, taxon);
114 115
		Set<Synonym> synList = taxon.getSynonyms();
......
117 118
				return syn;  //only first synonym is returned
118 119
			}
119 120
		}
120
		logger.warn("Synonym ("+synName+ ")not found for taxon " + taxon.getTitleCache());
121
		logger.warn("Synonym ("+synName+ ")not found for taxon " + taxon.getTitleCache() + getBracketSourceName(config));
121 122
		return result;
122 123
	}
123 124
	
......
177 178
			SimpleSpecimen simpleSpecimen = SimpleSpecimen.NewInstance();
178 179
			//elType
179 180
			if (elType != null){
180
				doElType(elType, simpleSpecimen);
181
				doElType(elType, simpleSpecimen, config);
181 182
			}//elType
182 183
			
183 184
			//typeLoc
......
199 200
		return false;
200 201
	}
201 202

  
202
	private boolean doElType(Element elType, SimpleSpecimen simpleSpecimen){
203
	private boolean doElType(Element elType, SimpleSpecimen simpleSpecimen, TaxonXImportConfigurator config){
203 204
		//type
204 205
		String text = elType.getTextNormalize();
205 206
		if (text.endsWith(";")){
......
207 208
		}
208 209
		String[] type = text.split(";");
209 210
		if (type.length != 3 ){
210
			logger.warn("<nomenclature><type> is of unsupported format: " + elType.getTextNormalize());
211
			if (text.equals("")){
212
				logger.info("<nomenclature><type> is empty: " + getBracketSourceName(config));
213
			}else{
214
				logger.warn("<nomenclature><type> is of unsupported format: " + elType.getTextNormalize() + getBracketSourceName(config));
215
			}
211 216
			simpleSpecimen.setTitleCache(elType.getTextNormalize());
212 217
		}else{
213 218
			String strLocality = type[0].trim();
......
258 263
			typeLocStatus = typeLocStatus.trim();
259 264
			int pos = typeLocStatus.indexOf(" ");
260 265
			if (pos == -1){
261
				logger.warn("Unknown format for type_loc : " + typeLocStatus);
266
				logger.warn("Unknown format or empty type_loc : '" +typeLocStatus + "'" + getBracketSourceName(config));
262 267
				result.put(originalSpecimen, null);
263 268
			}else{
264 269
				String statusString = typeLocStatus.substring(0,pos); 
265
				TypeDesignationStatus status = getStatusByStatusString(statusString.trim());
270
				TypeDesignationStatus status = getStatusByStatusString(statusString.trim(), config);
266 271
				//TODO
267 272
				//String[] collectionStrings = typeLocStatus.substring(pos).split(",");
268 273
				String tmpCollString = typeLocStatus.substring(pos).trim();
269 274
				//for(String collectionString : collectionStrings){
270 275
					if (tmpCollString.contains("typ")){
271
						logger.warn("Is this really only a collection string?");
276
						logger.warn("Is this really only a collection string? : "  + tmpCollString + getBracketSourceName(config));
272 277
					}
273 278
					Specimen specimen;
274 279
					specimen = (Specimen)originalSpecimen.clone();
......
340 345
				logger.warn("Unknown format: " + typeLocStatus);
341 346
			}else{
342 347
				String statusString = typeLocStatus.substring(0,pos); 
343
				TypeDesignationStatus status = getStatusByStatusString(statusString.trim());
348
				TypeDesignationStatus status = getStatusByStatusString(statusString.trim(), config);
344 349
				String[] collectionStrings = typeLocStatus.substring(pos).split(",");
345 350
				for(String collectionString : collectionStrings){
346 351
					if (taxonBase != null){
......
383 388
	 * @param statusString
384 389
	 * @return TypeDesignationStatus
385 390
	 */
386
	private static TypeDesignationStatus getStatusByStatusString(String statusString){
391
	private static TypeDesignationStatus getStatusByStatusString(String statusString, TaxonXImportConfigurator config){
387 392
		TypeDesignationStatus result = null;
388 393
		if (statusString == null || "".equals(statusString.trim())){
389 394
			return null;
......
399 404
		}
400 405
		result = statusMap.get(statusString);
401 406
		if (statusString.equals("type")){
402
			logger.info("No type designation type");
407
			logger.info("No type designation type" + getBracketSourceName(config));
403 408
		}else if (result == null){
404
			logger.warn("Unknown type status string: " + statusString);
409
			logger.warn("Unknown type status string: " + statusString + getBracketSourceName(config));
405 410
		}
406 411
		return result;
407 412
	}
......
436 441
		//taxonService.saveTaxon(taxon);
437 442
		commitTransaction(txStatus);
438 443
	}
444
	
445
	private static String getBracketSourceName(TaxonXImportConfigurator config){
446
		return "(" + config.getSourceNameString() + ")";
447
	}
439 448

  
440 449
	
441 450
}

Also available in: Unified diff