Project

General

Profile

« Previous | Next » 

Revision e0935f63

Added by Andreas Müller over 4 years ago

adapt some classes to new CommonService.getSourcedObjectSByIdInSourceC and cleanup

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisCurrentSpeciesImport.java
41 41
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
42 42
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
43 43

  
44

  
45 44
/**
46 45
 * @author a.mueller
47 46
 * @since 20.02.2010
48 47
 */
49 48
@Component
50 49
public class GlobisCurrentSpeciesImport  extends GlobisImportBase<Taxon> {
51
	private static final Logger logger = Logger.getLogger(GlobisCurrentSpeciesImport.class);
50

  
51
    private static final long serialVersionUID = -4392659482520384118L;
52
    private static final Logger logger = Logger.getLogger(GlobisCurrentSpeciesImport.class);
52 53

  
53 54
	private int modCount = 10000;
54 55
	private static final String pluralString = "current taxa";
......
78 79
	}
79 80

  
80 81
	@Override
81
	public boolean doPartition(ResultSetPartitioner partitioner, GlobisImportState state) {
82
	public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, GlobisImportState state) {
82 83
		boolean success = true;
83 84

  
84
		Set<TaxonBase> objectsToSave = new HashSet<TaxonBase>();
85
		Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE);
85
		@SuppressWarnings("rawtypes")
86
        Set<TaxonBase> objectsToSave = new HashSet<>();
87
		@SuppressWarnings("unchecked")
88
        Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE);
86 89
		ResultSet rs = partitioner.getResultSet();
87 90

  
88 91
		Classification classification = getClassification(state);
......
230 233
				countryStr = countryStr.substring(1).trim();
231 234
			}
232 235

  
233

  
234

  
235 236
			countryStr = normalizeCountry(countryStr);
236 237

  
237 238
			NamedArea country = getCountry(state, countryStr);
......
255 256
		}
256 257
	}
257 258

  
258

  
259

  
260
	/**
261
	 * @param countryStr
262
	 * @return
263
	 */
264 259
	private String normalizeCountry(String countryStr) {
265 260
		String result = countryStr.trim();
266 261
		if (result.endsWith(".")){
......
294 289
//		}
295 290
	}
296 291

  
297

  
298

  
299

  
300 292
	/**
301 293
	 * Compares 2 taxa, returns true of both taxa look similar
302 294
	 * @param genus
......
315 307
		return true;
316 308
	}
317 309

  
318

  
319

  
320

  
321 310
	private Taxon getParent(Taxon child, Classification classification) {
322 311
		if (child == null){
323 312
			logger.warn("Child is null");
......
335 324
		return null;
336 325
	}
337 326

  
338

  
339

  
340

  
341 327
	private Taxon getTaxon(GlobisImportState state, ResultSet rs, String uninomial, String infraGenericEpi, Rank rank, String author, Map<String, Taxon> taxonMap, Integer taxonId) {
342 328
		if (isBlank(uninomial)){
343 329
			return null;
......
379 365

  
380 366
	}
381 367

  
382
	/* (non-Javadoc)
383
	 * @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase)
384
	 */
385 368
	public Taxon createObject(ResultSet rs, GlobisImportState state, Integer taxonId)
386 369
			throws SQLException {
387 370
		String speciesEpi = rs.getString("dtSpcSpcakt");
......
403 386
		return taxon;
404 387
	}
405 388

  
406

  
407

  
408

  
409 389
	@Override
410 390
	public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, GlobisImportState state) {
411
		String nameSpace;
412
		Class cdmClass;
391

  
392
	    String nameSpace;
413 393
		Set<String> idSet;
414
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
394
		Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
415 395
		try{
416
			Set<String> taxonIdSet = new HashSet<String>();
396
			Set<String> taxonIdSet = new HashSet<>();
417 397

  
418 398
			while (rs.next()){
419 399
//				handleForeignKey(rs, taxonIdSet, "taxonId");
......
421 401

  
422 402
			//taxon map
423 403
			nameSpace = TAXON_NAMESPACE;
424
			cdmClass = Taxon.class;
425 404
			idSet = taxonIdSet;
426
			Map<String, Taxon> objectMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
405
			Map<String, Taxon> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class, idSet, nameSpace);
427 406
			result.put(nameSpace, objectMap);
428 407

  
429 408

  
......
433 412
		return result;
434 413
	}
435 414

  
436
	/* (non-Javadoc)
437
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator)
438
	 */
439 415
	@Override
440 416
	protected boolean doCheck(GlobisImportState state){
441 417
		IOValidator<GlobisImportState> validator = new GlobisCurrentSpeciesImportValidator();
442 418
		return validator.validate(state);
443 419
	}
444 420

  
445

  
446
	/* (non-Javadoc)
447
	 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
448
	 */
449 421
	@Override
450 422
    protected boolean isIgnore(GlobisImportState state){
451 423
		return ! state.getConfig().isDoCurrentTaxa();

Also available in: Unified diff