Revision e0935f63
Added by Andreas Müller over 4 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraCollectionImport.java | ||
---|---|---|
90 | 90 |
Set<Collection> collectionsToSave = new HashSet<Collection>(); |
91 | 91 |
|
92 | 92 |
|
93 |
Map<String, Collection> collectionMap = partitioner.getObjectMap(NAMESPACE_COLLECTION);
|
|
94 |
|
|
93 |
@SuppressWarnings("unchecked")
|
|
94 |
Map<String, Collection> collectionMap = partitioner.getObjectMap(NAMESPACE_COLLECTION); |
|
95 | 95 |
|
96 | 96 |
ResultSet rs = partitioner.getResultSet(); |
97 | 97 |
|
... | ... | |
198 | 198 |
@Override |
199 | 199 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
200 | 200 |
String nameSpace; |
201 |
Class cdmClass; |
|
202 | 201 |
Set<String> idSet; |
203 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
202 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
204 | 203 |
|
205 | 204 |
try{ |
206 |
Set<String> collectionIdSet = new HashSet<String>();
|
|
205 |
Set<String> collectionIdSet = new HashSet<>(); |
|
207 | 206 |
|
208 | 207 |
while (rs.next()){ |
209 | 208 |
handleForeignKey(rs, collectionIdSet, "partOfFk"); |
... | ... | |
211 | 210 |
|
212 | 211 |
//type specimen map |
213 | 212 |
nameSpace = NAMESPACE_COLLECTION; |
214 |
cdmClass = Collection.class; |
|
215 | 213 |
idSet = collectionIdSet; |
216 |
Map<String, Collection> collectionMap = (Map<String, Collection>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
214 |
Map<String, Collection> collectionMap = getCommonService().getSourcedObjectsByIdInSourceC(Collection.class, idSet, nameSpace);
|
|
217 | 215 |
result.put(nameSpace, collectionMap); |
218 | 216 |
|
219 | 217 |
|
... | ... | |
224 | 222 |
|
225 | 223 |
} |
226 | 224 |
|
227 |
|
|
228 |
/* (non-Javadoc) |
|
229 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
230 |
*/ |
|
231 | 225 |
@Override |
232 | 226 |
protected boolean doCheck(BerlinModelImportState state){ |
233 | 227 |
IOValidator<BerlinModelImportState> validator = new AlgaTerraCollectionImportValidator(); |
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraDnaImport.java | ||
---|---|---|
362 | 362 |
@Override |
363 | 363 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
364 | 364 |
String nameSpace; |
365 |
Class<?> cdmClass; |
|
366 | 365 |
Set<String> idSet; |
367 | 366 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
368 | 367 |
|
369 | 368 |
try{ |
370 | 369 |
Set<String> taxonIdSet = new HashSet<>(); |
371 |
|
|
372 | 370 |
Set<String> ecoFactFkSet = new HashSet<>(); |
373 |
|
|
374 | 371 |
while (rs.next()){ |
375 | 372 |
handleForeignKey(rs, taxonIdSet, "taxonId"); |
376 | 373 |
handleForeignKey(rs, ecoFactFkSet, "ecoFactId"); |
... | ... | |
378 | 375 |
|
379 | 376 |
//taxon map |
380 | 377 |
nameSpace = BerlinModelTaxonImport.NAMESPACE; |
381 |
cdmClass = TaxonBase.class; |
|
382 | 378 |
idSet = taxonIdSet; |
383 |
Map<String, TaxonBase> objectMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
379 |
Map<String, TaxonBase> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, nameSpace);
|
|
384 | 380 |
result.put(nameSpace, objectMap); |
385 | 381 |
|
386 | 382 |
|
387 | 383 |
//eco fact derived unit map |
388 |
nameSpace = AlgaTerraFactEcologyImport.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
389 |
cdmClass = DerivedUnit.class; |
|
384 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
390 | 385 |
idSet = ecoFactFkSet; |
391 |
Map<String, DerivedUnit> derivedUnitMap = (Map<String, DerivedUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
386 |
Map<String, DerivedUnit> derivedUnitMap = getCommonService().getSourcedObjectsByIdInSourceC(DerivedUnit.class, idSet, nameSpace);
|
|
392 | 387 |
result.put(nameSpace, derivedUnitMap); |
393 | 388 |
|
394 | 389 |
} catch (SQLException e) { |
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraEcoFactImport.java | ||
---|---|---|
355 | 355 |
|
356 | 356 |
@Override |
357 | 357 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
358 |
String nameSpace; |
|
359 |
Class<?> cdmClass;
|
|
358 |
|
|
359 |
String nameSpace;
|
|
360 | 360 |
Set<String> idSet; |
361 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
361 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
362 | 362 |
|
363 | 363 |
try{ |
364 |
Set<String> fieldObservationIdSet = new HashSet<String>();
|
|
365 |
Set<String> termsIdSet = new HashSet<String>();
|
|
366 |
Set<String> collectionIdSet = new HashSet<String>();
|
|
364 |
Set<String> fieldObservationIdSet = new HashSet<>(); |
|
365 |
Set<String> termsIdSet = new HashSet<>(); |
|
366 |
Set<String> collectionIdSet = new HashSet<>(); |
|
367 | 367 |
|
368 | 368 |
while (rs.next()){ |
369 | 369 |
handleForeignKey(rs, fieldObservationIdSet, "DuplicateFk"); |
... | ... | |
374 | 374 |
} |
375 | 375 |
|
376 | 376 |
//field observation map for duplicates |
377 |
nameSpace = AlgaTerraEcoFactImport.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
|
378 |
cdmClass = FieldUnit.class; |
|
377 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
|
379 | 378 |
idSet = fieldObservationIdSet; |
380 |
Map<String, FieldUnit> fieldObservationMap = (Map<String, FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
379 |
Map<String, FieldUnit> fieldObservationMap = getCommonService().getSourcedObjectsByIdInSourceC(FieldUnit.class, idSet, nameSpace);
|
|
381 | 380 |
result.put(nameSpace, fieldObservationMap); |
382 | 381 |
|
383 | 382 |
//collections |
384 | 383 |
nameSpace = AlgaTerraCollectionImport.NAMESPACE_COLLECTION; |
385 |
cdmClass = Collection.class; |
|
386 | 384 |
idSet = collectionIdSet; |
387 |
Map<String, Collection> collectionMap = (Map<String, Collection>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
385 |
Map<String, Collection> collectionMap = getCommonService().getSourcedObjectsByIdInSourceC(Collection.class, idSet, nameSpace);
|
|
388 | 386 |
result.put(nameSpace, collectionMap); |
389 | 387 |
|
390 | 388 |
//sub-collections |
391 | 389 |
nameSpace = AlgaTerraCollectionImport.NAMESPACE_SUBCOLLECTION; |
392 |
cdmClass = Collection.class; |
|
393 | 390 |
idSet = collectionIdSet; |
394 |
Map<String, Collection> subCollectionMap = (Map<String, Collection>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
391 |
Map<String, Collection> subCollectionMap = getCommonService().getSourcedObjectsByIdInSourceC(Collection.class, idSet, nameSpace);
|
|
395 | 392 |
result.put(nameSpace, subCollectionMap); |
396 | 393 |
|
397 | 394 |
//terms |
398 |
nameSpace = AlgaTerraEcoFactImport.TERMS_NAMESPACE;
|
|
399 |
cdmClass = FieldUnit.class; //???????? |
|
395 |
nameSpace = AlgaTerraSpecimenImportBase.TERMS_NAMESPACE;
|
|
396 |
Class<FieldUnit> cdmClass = FieldUnit.class; //????????
|
|
400 | 397 |
idSet = termsIdSet; |
401 |
Map<String, DefinedTermBase> termMap = (Map<String, DefinedTermBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
398 |
//FIXME something not correct here with the classes |
|
399 |
Map<String, DefinedTermBase> termMap = (Map)getCommonService().getSourcedObjectsByIdInSourceC(cdmClass, idSet, nameSpace); |
|
402 | 400 |
result.put(nameSpace, termMap); |
403 | 401 |
|
404 | 402 |
} catch (SQLException e) { |
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraFactEcologyImport.java | ||
---|---|---|
283 | 283 |
@Override |
284 | 284 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
285 | 285 |
String nameSpace; |
286 |
Class<?> cdmClass; |
|
287 | 286 |
Set<String> idSet; |
288 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
287 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
289 | 288 |
|
290 | 289 |
try{ |
291 |
Set<String> taxonIdSet = new HashSet<String>();
|
|
292 |
Set<String> extensionFkSet = new HashSet<String>();
|
|
293 |
Set<String> referenceIdSet = new HashSet<String>();
|
|
290 |
Set<String> taxonIdSet = new HashSet<>(); |
|
291 |
Set<String> extensionFkSet = new HashSet<>(); |
|
292 |
Set<String> referenceIdSet = new HashSet<>(); |
|
294 | 293 |
|
295 | 294 |
while (rs.next()){ |
296 | 295 |
handleForeignKey(rs, taxonIdSet, "taxonId"); |
... | ... | |
300 | 299 |
|
301 | 300 |
//taxon map |
302 | 301 |
nameSpace = BerlinModelTaxonImport.NAMESPACE; |
303 |
cdmClass = TaxonBase.class; |
|
304 | 302 |
idSet = taxonIdSet; |
305 |
Map<String, TaxonBase> objectMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
303 |
@SuppressWarnings("rawtypes") |
|
304 |
Map<String, TaxonBase> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, nameSpace); |
|
306 | 305 |
result.put(nameSpace, objectMap); |
307 | 306 |
|
308 | 307 |
//derived unit map |
309 |
nameSpace = AlgaTerraFactEcologyImport.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
310 |
cdmClass = DerivedUnit.class; |
|
308 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
311 | 309 |
idSet = extensionFkSet; |
312 |
Map<String, DerivedUnit> derivedUnitMap = (Map<String, DerivedUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
310 |
Map<String, DerivedUnit> derivedUnitMap = getCommonService().getSourcedObjectsByIdInSourceC(DerivedUnit.class, idSet, nameSpace);
|
|
313 | 311 |
result.put(nameSpace, derivedUnitMap); |
314 | 312 |
|
315 | 313 |
//reference map |
316 | 314 |
nameSpace = BerlinModelReferenceImport.REFERENCE_NAMESPACE; |
317 |
cdmClass = Reference.class; |
|
318 | 315 |
idSet = referenceIdSet; |
319 |
Map<String, Reference> referenceMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
316 |
Map<String, Reference> referenceMap = getCommonService().getSourcedObjectsByIdInSourceC(Reference.class, idSet, nameSpace);
|
|
320 | 317 |
result.put(nameSpace, referenceMap); |
321 | 318 |
|
322 | 319 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraMorphologyImport.java | ||
---|---|---|
56 | 56 |
*/ |
57 | 57 |
@Component |
58 | 58 |
public class AlgaTerraMorphologyImport extends AlgaTerraSpecimenImportBase { |
59 |
private static final Logger logger = Logger.getLogger(AlgaTerraMorphologyImport.class); |
|
60 | 59 |
|
60 |
private static final long serialVersionUID = 5978046406702163690L; |
|
61 |
private static final Logger logger = Logger.getLogger(AlgaTerraMorphologyImport.class); |
|
61 | 62 |
|
62 | 63 |
private static int modCount = 5000; |
63 | 64 |
private static final String pluralString = "morpho facts"; |
... | ... | |
245 | 246 |
} |
246 | 247 |
|
247 | 248 |
|
248 |
|
|
249 |
|
|
250 | 249 |
private void makeValveFeatures(AlgaTerraImportState state, |
251 | 250 |
Map<String, Feature> featureMap2, |
252 | 251 |
TermVocabulary<Feature> algaTerraMorphoFeatures2) { |
... | ... | |
259 | 258 |
|
260 | 259 |
} |
261 | 260 |
|
262 |
|
|
263 | 261 |
private void handleSingleValve(AlgaTerraImportState state, |
264 | 262 |
Map<String, Feature> featureMap2, |
265 | 263 |
TermVocabulary<Feature> algaTerraMorphoFeatures2, String valveStr) { |
... | ... | |
307 | 305 |
|
308 | 306 |
|
309 | 307 |
@Override |
310 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
308 |
public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState bmState) {
|
|
311 | 309 |
boolean success = true; |
312 | 310 |
|
313 | 311 |
AlgaTerraImportState state = (AlgaTerraImportState)bmState; |
314 |
Set<SpecimenOrObservationBase> objectsToSave = new HashSet<SpecimenOrObservationBase>(); |
|
312 |
@SuppressWarnings("rawtypes") |
|
313 |
Set<SpecimenOrObservationBase> objectsToSave = new HashSet<>(); |
|
315 | 314 |
|
316 | 315 |
ResultSet rs = partitioner.getResultSet(); |
317 | 316 |
|
... | ... | |
483 | 482 |
return ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
484 | 483 |
} |
485 | 484 |
|
486 |
|
|
487 |
|
|
488 | 485 |
private void makeParameter(AlgaTerraImportState state, ResultSet rs, DescriptionBase<?> descriptionBase) throws SQLException { |
489 | 486 |
for (int i = 1; i <= 10; i++){ |
490 | 487 |
String valueStr = rs.getString(String.format("P%dValue", i)); |
... | ... | |
524 | 521 |
}else if (isNotBlank(valueStr) || isNotBlank(unitStr) ){ |
525 | 522 |
logger.warn("There is value or unit without parameter: " + i); |
526 | 523 |
} |
527 |
|
|
528 |
|
|
529 | 524 |
} |
530 |
|
|
531 | 525 |
} |
532 | 526 |
|
533 | 527 |
private String normalizeAndModifyValue(AlgaTerraImportState state, String valueStr, Set<DefinedTerm> valueModifier) { |
... | ... | |
575 | 569 |
} |
576 | 570 |
} |
577 | 571 |
|
578 |
|
|
579 | 572 |
@Override |
580 | 573 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
581 |
String nameSpace; |
|
582 |
Class<?> cdmClass;
|
|
574 |
|
|
575 |
String nameSpace;
|
|
583 | 576 |
Set<String> idSet; |
584 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
577 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
585 | 578 |
|
586 | 579 |
try{ |
587 |
Set<String> ecoFactFkSet = new HashSet<String>();
|
|
580 |
Set<String> ecoFactFkSet = new HashSet<>(); |
|
588 | 581 |
|
589 | 582 |
while (rs.next()){ |
590 | 583 |
handleForeignKey(rs, ecoFactFkSet, "ecoFactId"); |
591 | 584 |
} |
592 | 585 |
|
593 | 586 |
//eco fact derived unit map |
594 |
nameSpace = AlgaTerraFactEcologyImport.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
595 |
cdmClass = DerivedUnit.class; |
|
587 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE; |
|
596 | 588 |
idSet = ecoFactFkSet; |
597 |
Map<String, DerivedUnit> derivedUnitMap = (Map<String, DerivedUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
589 |
Map<String, DerivedUnit> derivedUnitMap = getCommonService().getSourcedObjectsByIdInSourceC(DerivedUnit.class, idSet, nameSpace);
|
|
598 | 590 |
result.put(nameSpace, derivedUnitMap); |
599 | 591 |
|
600 | 592 |
} catch (SQLException e) { |
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraPictureImport.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 |
*/ |
... | ... | |
36 | 36 |
|
37 | 37 |
|
38 | 38 |
/** |
39 |
* Import for AlgaTerra images from table
|
|
39 |
* Import for AlgaTerra images from table |
|
40 | 40 |
* @author a.mueller |
41 | 41 |
* @since 18.01.2013 |
42 | 42 |
*/ |
... | ... | |
44 | 44 |
public class AlgaTerraPictureImport extends AlgaTerraImageImportBase { |
45 | 45 |
private static final Logger logger = Logger.getLogger(AlgaTerraPictureImport.class); |
46 | 46 |
|
47 |
|
|
47 |
|
|
48 | 48 |
private static int modCount = 5000; |
49 | 49 |
private static final String pluralString = "pictures"; |
50 |
private static final String dbTableName = "Picture"; //??
|
|
51 |
|
|
50 |
private static final String dbTableName = "Picture"; //?? |
|
51 |
|
|
52 | 52 |
public AlgaTerraPictureImport(){ |
53 | 53 |
super(dbTableName, pluralString); |
54 | 54 |
} |
55 |
|
|
56 |
|
|
55 |
|
|
56 |
|
|
57 | 57 |
/* (non-Javadoc) |
58 | 58 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getIdQuery() |
59 | 59 |
*/ |
60 | 60 |
@Override |
61 | 61 |
protected String getIdQuery(BerlinModelImportState state) { |
62 |
String result = " SELECT p.PictureId "
|
|
63 |
+ " FROM Picture p INNER JOIN Fact f ON p.PictureId = f.ExtensionFk LEFT OUTER JOIN PTaxon pt ON f.PTNameFk = pt.PTNameFk AND f.PTRefFk = pt.PTRefFk "
|
|
62 |
String result = " SELECT p.PictureId " |
|
63 |
+ " FROM Picture p INNER JOIN Fact f ON p.PictureId = f.ExtensionFk LEFT OUTER JOIN PTaxon pt ON f.PTNameFk = pt.PTNameFk AND f.PTRefFk = pt.PTRefFk " |
|
64 | 64 |
+ " WHERE f.FactCategoryFk = 205 AND p.RestrictedFlag = 0 " |
65 | 65 |
+ " ORDER BY p.PictureId "; |
66 | 66 |
return result; |
... | ... | |
71 | 71 |
*/ |
72 | 72 |
@Override |
73 | 73 |
protected String getRecordQuery(BerlinModelImportConfigurator config) { |
74 |
String strQuery =
|
|
75 |
|
|
74 |
String strQuery = |
|
75 |
|
|
76 | 76 |
" SELECT p.*, f.*, pt.RIdentifier, p.PicturePhrase as FigurePhrase, p.PictureFile as fileName, p.PicturePath as filePath " + |
77 |
" FROM Picture p INNER JOIN Fact f ON p.PictureId = f.ExtensionFk LEFT OUTER JOIN PTaxon pt ON f.PTNameFk = pt.PTNameFk AND f.PTRefFk = pt.PTRefFk "
|
|
78 |
+ " WHERE f.FactCategoryFk = 205 AND ( p.PictureID IN (" + ID_LIST_TOKEN + ") )"
|
|
77 |
" FROM Picture p INNER JOIN Fact f ON p.PictureId = f.ExtensionFk LEFT OUTER JOIN PTaxon pt ON f.PTNameFk = pt.PTNameFk AND f.PTRefFk = pt.PTRefFk " |
|
78 |
+ " WHERE f.FactCategoryFk = 205 AND ( p.PictureID IN (" + ID_LIST_TOKEN + ") )" |
|
79 | 79 |
+ " ORDER BY p.PictureId, f.factId, pt.RIdentifier "; |
80 | 80 |
; |
81 | 81 |
return strQuery; |
... | ... | |
84 | 84 |
/* (non-Javadoc) |
85 | 85 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#doPartition(eu.etaxonomy.cdm.io.berlinModel.in.ResultSetPartitioner, eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState) |
86 | 86 |
*/ |
87 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
87 |
@Override |
|
88 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
88 | 89 |
boolean success = true; |
89 |
|
|
90 |
|
|
90 | 91 |
AlgaTerraImportState state = (AlgaTerraImportState)bmState; |
91 |
|
|
92 |
|
|
92 | 93 |
// Set<SpecimenOrObservationBase> specimenToSave = new HashSet<SpecimenOrObservationBase>(); |
93 | 94 |
Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>(); |
94 |
|
|
95 |
|
|
95 | 96 |
// Map<String, DerivedUnitBase> ecoFactMap = (Map<String, DerivedUnitBase>) partitioner.getObjectMap(AlgaTerraSpecimenImportBase.ECO_FACT_DERIVED_UNIT_NAMESPACE); |
96 |
Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>) partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE);
|
|
97 |
Map<String, DerivedUnit> specimenMap = (Map<String, DerivedUnit>) partitioner.getObjectMap(AlgaTerraFactEcologyImport.FACT_ECOLOGY_NAMESPACE);
|
|
98 |
|
|
97 |
Map<String, TaxonBase> taxonMap = partitioner.getObjectMap(BerlinModelTaxonImport.NAMESPACE); |
|
98 |
Map<String, DerivedUnit> specimenMap = partitioner.getObjectMap(AlgaTerraFactEcologyImport.FACT_ECOLOGY_NAMESPACE); |
|
99 |
|
|
99 | 100 |
ResultSet rs = partitioner.getResultSet(); |
100 | 101 |
|
101 | 102 |
try { |
102 |
|
|
103 |
|
|
103 | 104 |
int i = 0; |
104 | 105 |
|
105 | 106 |
//for each reference |
106 | 107 |
while (rs.next()){ |
107 |
|
|
108 |
|
|
108 | 109 |
if ((i++ % modCount) == 0 && i!= 1 ){ logger.info(pluralString + " handled: " + (i-1));} |
109 |
|
|
110 |
|
|
110 | 111 |
int pictureId = rs.getInt("PictureID"); |
111 | 112 |
int taxonId = rs.getInt("RIdentifier"); |
112 | 113 |
int factId = rs.getInt("FactId"); |
113 |
|
|
114 |
|
|
114 |
|
|
115 |
|
|
115 | 116 |
//TODO etc. Created, Notes, Copyright, TermsOfUse etc. |
116 |
|
|
117 |
|
|
117 | 118 |
try { |
118 |
|
|
119 |
|
|
119 | 120 |
TaxonBase<?> taxonBase = taxonMap.get(String.valueOf(taxonId)); |
120 | 121 |
if (taxonBase == null){ |
121 | 122 |
logger.warn("Could not find taxon (" + taxonId +") for picture fact " + factId); |
122 | 123 |
}else if (! taxonBase.isInstanceOf(Taxon.class)){ |
123 | 124 |
logger.warn("Taxon is not of class Taxon but " + taxonBase.getClass() + ". RIdentifier: " + taxonId + " PictureId: " + pictureId + ", FactId: "+ factId); |
124 |
|
|
125 |
|
|
125 | 126 |
}else{ |
126 | 127 |
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
127 |
|
|
128 |
|
|
128 | 129 |
Media media = handleSingleImage(rs, taxon, state, partitioner, PathType.Image); |
129 |
|
|
130 |
|
|
130 | 131 |
handlePictureSpecificFields(rs, media, state, specimenMap); |
131 |
|
|
132 |
taxaToSave.add(taxon);
|
|
132 |
|
|
133 |
taxaToSave.add(taxon); |
|
133 | 134 |
} |
134 |
|
|
135 |
|
|
135 | 136 |
|
136 | 137 |
} catch (Exception e) { |
137 | 138 |
logger.warn("Exception in " + getTableName() + ": PictureId " + pictureId + ". " + e.getMessage()); |
138 | 139 |
e.printStackTrace(); |
139 |
}
|
|
140 |
|
|
140 |
} |
|
141 |
|
|
141 | 142 |
} |
142 |
|
|
143 |
|
|
143 | 144 |
// logger.warn("Specimen: " + countSpecimen + ", Descriptions: " + countDescriptions ); |
144 | 145 |
|
145 | 146 |
logger.warn(pluralString + " to save: " + taxaToSave.size()); |
146 |
// getOccurrenceService().save(taxaToSave);
|
|
147 |
getTaxonService().save(taxaToSave);
|
|
148 |
|
|
147 |
// getOccurrenceService().save(taxaToSave); |
|
148 |
getTaxonService().save(taxaToSave); |
|
149 |
|
|
149 | 150 |
return success; |
150 | 151 |
} catch (SQLException e) { |
151 | 152 |
logger.error("SQLException:" + e); |
... | ... | |
172 | 173 |
} |
173 | 174 |
} |
174 | 175 |
} |
175 |
|
|
176 |
|
|
176 | 177 |
} |
177 | 178 |
|
178 | 179 |
|
179 | 180 |
@Override |
180 | 181 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
181 |
String nameSpace; |
|
182 |
Class<?> cdmClass;
|
|
182 |
|
|
183 |
String nameSpace;
|
|
183 | 184 |
Set<String> idSet; |
184 | 185 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
185 |
|
|
186 |
|
|
186 | 187 |
try{ |
187 | 188 |
Set<String> taxonIdSet = new HashSet<String>(); |
188 | 189 |
Set<String> specimenIdSet = new HashSet<String>(); |
189 |
|
|
190 |
|
|
190 | 191 |
while (rs.next()){ |
191 | 192 |
handleForeignKey(rs, taxonIdSet, "RIdentifier"); |
192 | 193 |
handleForeignKey(rs, specimenIdSet, "FactFk"); |
193 | 194 |
} |
194 |
|
|
195 |
|
|
195 | 196 |
//taxon map |
196 | 197 |
nameSpace = BerlinModelTaxonImport.NAMESPACE; |
197 |
cdmClass = TaxonBase.class; |
|
198 | 198 |
idSet = taxonIdSet; |
199 |
Map<String, TaxonBase> taxonMap = (Map<String,TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
199 |
@SuppressWarnings("rawtypes") |
|
200 |
Map<String, TaxonBase> taxonMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, nameSpace); |
|
200 | 201 |
result.put(nameSpace, taxonMap); |
201 | 202 |
|
202 | 203 |
//fact specimen map |
203 |
nameSpace = AlgaTerraFactEcologyImport.FACT_ECOLOGY_NAMESPACE; |
|
204 |
cdmClass = SpecimenOrObservationBase.class; |
|
204 |
nameSpace = AlgaTerraSpecimenImportBase.FACT_ECOLOGY_NAMESPACE; |
|
205 | 205 |
idSet = specimenIdSet; |
206 |
Map<String, SpecimenOrObservationBase> specimenMap = (Map<String,SpecimenOrObservationBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
206 |
@SuppressWarnings("rawtypes") |
|
207 |
Map<String, SpecimenOrObservationBase> specimenMap = getCommonService().getSourcedObjectsByIdInSourceC(SpecimenOrObservationBase.class, idSet, nameSpace); |
|
207 | 208 |
result.put(nameSpace, specimenMap); |
208 | 209 |
|
209 |
|
|
210 |
|
|
210 | 211 |
} catch (SQLException e) { |
211 | 212 |
throw new RuntimeException(e); |
212 | 213 |
} |
... | ... | |
225 | 226 |
AlgaTerraImportConfigurator config = ((AlgaTerraImportState) bmState).getAlgaTerraConfigurator(); |
226 | 227 |
return ! ( config.isDoTypes() && config.isDoImages()) ; |
227 | 228 |
} |
228 |
|
|
229 |
|
|
229 | 230 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraSiteImagesImport.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 |
*/ |
... | ... | |
19 | 19 |
import org.apache.log4j.Logger; |
20 | 20 |
import org.springframework.stereotype.Component; |
21 | 21 |
|
22 |
import eu.etaxonomy.cdm.io.algaterra.AlgaTerraImageImportBase.PathType; |
|
23 | 22 |
import eu.etaxonomy.cdm.io.algaterra.validation.AlgaTerraTypeImportValidator; |
24 | 23 |
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator; |
25 | 24 |
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState; |
... | ... | |
39 | 38 |
public class AlgaTerraSiteImagesImport extends AlgaTerraImageImportBase { |
40 | 39 |
private static final Logger logger = Logger.getLogger(AlgaTerraSiteImagesImport.class); |
41 | 40 |
|
42 |
|
|
41 |
|
|
43 | 42 |
private static int modCount = 5000; |
44 | 43 |
private static final String pluralString = "site images"; |
45 |
private static final String dbTableName = "SiteImages"; //??
|
|
46 |
|
|
44 |
private static final String dbTableName = "SiteImages"; //?? |
|
45 |
|
|
47 | 46 |
public AlgaTerraSiteImagesImport(){ |
48 | 47 |
super(dbTableName, pluralString); |
49 | 48 |
} |
50 |
|
|
51 |
|
|
49 |
|
|
50 |
|
|
52 | 51 |
/* (non-Javadoc) |
53 | 52 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getIdQuery() |
54 | 53 |
*/ |
55 | 54 |
@Override |
56 | 55 |
protected String getIdQuery(BerlinModelImportState state) { |
57 |
String result = " SELECT SiteId "
|
|
58 |
+ " FROM SiteImages "
|
|
56 |
String result = " SELECT SiteId " |
|
57 |
+ " FROM SiteImages " |
|
59 | 58 |
+ " ORDER BY EcoFactFk "; |
60 | 59 |
return result; |
61 | 60 |
} |
... | ... | |
65 | 64 |
*/ |
66 | 65 |
@Override |
67 | 66 |
protected String getRecordQuery(BerlinModelImportConfigurator config) { |
68 |
String strQuery =
|
|
69 |
|
|
67 |
String strQuery = |
|
68 |
|
|
70 | 69 |
" SELECT si.*, si.Comment as FigurePhrase, si.Picture as fileName, si.Path as filePath " + |
71 |
" FROM SiteImages si "
|
|
72 |
+ " WHERE (si.SiteID IN (" + ID_LIST_TOKEN + ") )"
|
|
70 |
" FROM SiteImages si " |
|
71 |
+ " WHERE (si.SiteID IN (" + ID_LIST_TOKEN + ") )" |
|
73 | 72 |
+ " ORDER BY EcoFactFk "; |
74 | 73 |
; |
75 | 74 |
return strQuery; |
... | ... | |
78 | 77 |
/* (non-Javadoc) |
79 | 78 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#doPartition(eu.etaxonomy.cdm.io.berlinModel.in.ResultSetPartitioner, eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState) |
80 | 79 |
*/ |
81 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
80 |
@Override |
|
81 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
82 | 82 |
boolean success = true; |
83 |
|
|
83 |
|
|
84 | 84 |
AlgaTerraImportState state = (AlgaTerraImportState)bmState; |
85 |
|
|
85 |
|
|
86 | 86 |
Set<SpecimenOrObservationBase> unitsToSave = new HashSet<SpecimenOrObservationBase>(); |
87 |
|
|
88 |
Map<String, FieldUnit> ecoFactFieldObservationMap = (Map<String, FieldUnit>) partitioner.getObjectMap(AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE);
|
|
89 |
|
|
87 |
|
|
88 |
Map<String, FieldUnit> ecoFactFieldObservationMap = partitioner.getObjectMap(AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE); |
|
89 |
|
|
90 | 90 |
ResultSet rs = partitioner.getResultSet(); |
91 | 91 |
|
92 | 92 |
try { |
93 |
|
|
93 |
|
|
94 | 94 |
int i = 0; |
95 | 95 |
|
96 | 96 |
//for each reference |
97 | 97 |
while (rs.next()){ |
98 |
|
|
98 |
|
|
99 | 99 |
if ((i++ % modCount) == 0 && i!= 1 ){ logger.info(pluralString + " handled: " + (i-1));} |
100 |
|
|
100 |
|
|
101 | 101 |
int figureId = rs.getInt("SiteId"); |
102 | 102 |
int ecoFactFk = rs.getInt("EcoFactFk"); |
103 |
|
|
104 |
|
|
103 |
|
|
104 |
|
|
105 | 105 |
//TODO etc. Created, Notes, Copyright, TermsOfUse etc. |
106 |
|
|
106 |
|
|
107 | 107 |
try { |
108 |
|
|
108 |
|
|
109 | 109 |
//TODO use deduplicated ecofact |
110 | 110 |
FieldUnit fieldObservation = ecoFactFieldObservationMap.get(String.valueOf(ecoFactFk)); |
111 |
|
|
111 |
|
|
112 | 112 |
if (fieldObservation == null){ |
113 | 113 |
logger.warn("Could not find eco fact field observation (" + ecoFactFk +") for site image " + figureId); |
114 | 114 |
}else{ |
115 |
|
|
115 |
|
|
116 | 116 |
} |
117 |
|
|
117 |
|
|
118 | 118 |
//field observation |
119 | 119 |
Media media = handleSingleImage(rs, fieldObservation, state, partitioner, PathType.Site); |
120 |
|
|
120 |
|
|
121 | 121 |
handleSiteImageSpecificFields(rs, media, state); |
122 |
|
|
123 |
unitsToSave.add(fieldObservation);
|
|
124 |
|
|
122 |
|
|
123 |
unitsToSave.add(fieldObservation); |
|
124 |
|
|
125 | 125 |
|
126 | 126 |
} catch (Exception e) { |
127 | 127 |
logger.warn("Exception in " + getTableName() + ": SiteId " + figureId + ". " + e.getMessage()); |
128 | 128 |
e.printStackTrace(); |
129 |
}
|
|
130 |
|
|
129 |
} |
|
130 |
|
|
131 | 131 |
} |
132 |
|
|
132 |
|
|
133 | 133 |
// logger.warn("Specimen: " + countSpecimen + ", Descriptions: " + countDescriptions ); |
134 | 134 |
|
135 | 135 |
logger.warn(pluralString + " to save: " + unitsToSave.size()); |
136 |
getOccurrenceService().saveOrUpdate(unitsToSave);
|
|
137 |
|
|
136 |
getOccurrenceService().saveOrUpdate(unitsToSave); |
|
137 |
|
|
138 | 138 |
return success; |
139 | 139 |
} catch (SQLException e) { |
140 | 140 |
logger.error("SQLException:" + e); |
... | ... | |
146 | 146 |
|
147 | 147 |
private void handleSiteImageSpecificFields(ResultSet rs, Media media, AlgaTerraImportState state) throws SQLException { |
148 | 148 |
//TODO |
149 |
|
|
149 |
|
|
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
|
153 | 153 |
@Override |
154 | 154 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
155 |
String nameSpace; |
|
156 |
Class<?> cdmClass;
|
|
155 |
|
|
156 |
String nameSpace;
|
|
157 | 157 |
Set<String> idSet; |
158 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
159 |
|
|
158 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
159 |
|
|
160 | 160 |
try{ |
161 |
Set<String> ecoFactIdSet = new HashSet<String>();
|
|
162 |
|
|
161 |
Set<String> ecoFactIdSet = new HashSet<>(); |
|
162 |
|
|
163 | 163 |
while (rs.next()){ |
164 | 164 |
handleForeignKey(rs, ecoFactIdSet, "EcoFactFk"); |
165 | 165 |
} |
166 |
|
|
166 |
|
|
167 | 167 |
//field observation map |
168 | 168 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
169 |
cdmClass = FieldUnit.class; |
|
170 | 169 |
idSet = ecoFactIdSet; |
171 |
Map<String, FieldUnit> fieldObservationMap = (Map<String,FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
170 |
Map<String, FieldUnit> fieldObservationMap = getCommonService().getSourcedObjectsByIdInSourceC(FieldUnit.class, idSet, nameSpace);
|
|
172 | 171 |
result.put(nameSpace, fieldObservationMap); |
173 | 172 |
|
174 |
|
|
173 |
|
|
175 | 174 |
} catch (SQLException e) { |
176 | 175 |
throw new RuntimeException(e); |
177 | 176 |
} |
... | ... | |
189 | 188 |
AlgaTerraImportConfigurator config = ((AlgaTerraImportState) bmState).getAlgaTerraConfigurator(); |
190 | 189 |
return ! ( config.isDoEcoFacts() && config.isDoImages()) ; |
191 | 190 |
} |
192 |
|
|
191 |
|
|
193 | 192 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java | ||
---|---|---|
98 | 98 |
|
99 | 99 |
//reference map |
100 | 100 |
String nameSpace = BerlinModelReferenceImport.REFERENCE_NAMESPACE; |
101 |
Class<?> cdmClass = Reference.class; |
|
102 |
@SuppressWarnings("unchecked") |
|
103 |
Map<String, Reference> refMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
101 |
Class<Reference> cdmClass = Reference.class; |
|
102 |
Map<String, Reference> refMap = getCommonService().getSourcedObjectsByIdInSourceC(cdmClass, idSet, nameSpace); |
|
104 | 103 |
|
105 | 104 |
String classificationName = "Classification - No Name"; |
106 | 105 |
|
... | ... | |
666 | 665 |
|
667 | 666 |
private Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForFlatPartition( ResultSet rs) { |
668 | 667 |
String nameSpace; |
669 |
Class cdmClass; |
|
670 | 668 |
Set<String> idSet; |
671 | 669 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
672 | 670 |
|
673 | 671 |
try{ |
674 | 672 |
Set<String> taxonIdSet = new HashSet<>(); |
675 |
Set<String> referenceIdSet = new HashSet<>(); |
|
676 | 673 |
// Set<String> classificationIdSet = new HashSet<>(); |
677 | 674 |
while (rs.next()){ |
678 | 675 |
handleForeignKey(rs, taxonIdSet, "RIdentifier"); |
... | ... | |
681 | 678 |
|
682 | 679 |
//taxon map |
683 | 680 |
nameSpace = BerlinModelTaxonImport.NAMESPACE; |
684 |
cdmClass = TaxonBase.class; |
|
685 | 681 |
idSet = taxonIdSet; |
686 |
Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
682 |
@SuppressWarnings("rawtypes") |
|
683 |
Map<String, TaxonBase> taxonMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, nameSpace); |
|
687 | 684 |
result.put(nameSpace, taxonMap); |
688 | 685 |
|
689 | 686 |
// //tree map |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisCommonNameImport.java | ||
---|---|---|
47 | 47 |
*/ |
48 | 48 |
@Component |
49 | 49 |
public class GlobisCommonNameImport extends GlobisImportBase<Taxon> { |
50 |
private static final Logger logger = Logger.getLogger(GlobisCommonNameImport.class); |
|
50 |
|
|
51 |
private static final long serialVersionUID = 2462539699442149049L; |
|
52 |
private static final Logger logger = Logger.getLogger(GlobisCommonNameImport.class); |
|
51 | 53 |
|
52 | 54 |
private int modCount = 10000; |
53 | 55 |
private static final String pluralString = "common names"; |
... | ... | |
80 | 82 |
} |
81 | 83 |
|
82 | 84 |
@Override |
83 |
public boolean doPartition(ResultSetPartitioner partitioner, GlobisImportState state) { |
|
85 |
public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, GlobisImportState state) {
|
|
84 | 86 |
boolean success = true; |
85 | 87 |
|
86 |
Set<TaxonBase> objectsToSave = new HashSet<TaxonBase>(); |
|
88 |
@SuppressWarnings("rawtypes") |
|
89 |
Set<TaxonBase> objectsToSave = new HashSet<>(); |
|
87 | 90 |
|
88 |
Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE); |
|
91 |
@SuppressWarnings("unchecked") |
|
92 |
Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE); |
|
89 | 93 |
|
90 | 94 |
ResultSet rs = partitioner.getResultSet(); |
91 | 95 |
|
... | ... | |
159 | 163 |
} |
160 | 164 |
} |
161 | 165 |
|
162 |
|
|
163 |
private Map<String,Language> languageMap = new HashMap<String,Language>(); |
|
166 |
private Map<String,Language> languageMap = new HashMap<>(); |
|
164 | 167 |
private Language getLanguage(String isoLang) { |
165 | 168 |
Language result = languageMap.get(isoLang); |
166 | 169 |
if (result == null){ |
... | ... | |
229 | 232 |
@Override |
230 | 233 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, GlobisImportState state) { |
231 | 234 |
String nameSpace; |
232 |
Class<?> cdmClass; |
|
233 | 235 |
Set<String> idSet; |
234 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
236 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
235 | 237 |
try{ |
236 |
Set<String> taxonIdSet = new HashSet<String>();
|
|
238 |
Set<String> taxonIdSet = new HashSet<>(); |
|
237 | 239 |
|
238 | 240 |
while (rs.next()){ |
239 | 241 |
handleForeignKey(rs, taxonIdSet, "IDCurrentSpec"); |
... | ... | |
241 | 243 |
|
242 | 244 |
//taxon map |
243 | 245 |
nameSpace = TAXON_NAMESPACE; |
244 |
cdmClass = Taxon.class; |
|
245 | 246 |
idSet = taxonIdSet; |
246 |
Map<String, Taxon> objectMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
247 |
Map<String, Taxon> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class, idSet, nameSpace);
|
|
247 | 248 |
result.put(nameSpace, objectMap); |
248 | 249 |
|
249 | 250 |
|
... | ... | |
253 | 254 |
return result; |
254 | 255 |
} |
255 | 256 |
|
256 |
|
|
257 | 257 |
@Override |
258 |
protected boolean doCheck(GlobisImportState state){
|
|
258 |
protected boolean doCheck(GlobisImportState state){
|
|
259 | 259 |
// IOValidator<GlobisImportState> validator = new GlobisCurrentSpeciesImportValidator(); |
260 | 260 |
return true; |
261 | 261 |
} |
... | ... | |
264 | 264 |
protected boolean isIgnore(GlobisImportState state){ |
265 | 265 |
return ! state.getConfig().isDoCommonNames(); |
266 | 266 |
} |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 | 267 |
} |
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(); |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisImageImport.java | ||
---|---|---|
51 | 51 |
/** |
52 | 52 |
* @author a.mueller |
53 | 53 |
* @since 20.02.2010 |
54 |
* @version 1.0 |
|
55 | 54 |
*/ |
56 | 55 |
@Component |
57 | 56 |
public class GlobisImageImport extends GlobisImportBase<Taxon> { |
58 |
private static final Logger logger = Logger.getLogger(GlobisImageImport.class); |
|
57 |
|
|
58 |
private static final long serialVersionUID = 5697033145326415146L; |
|
59 |
private static final Logger logger = Logger.getLogger(GlobisImageImport.class); |
|
59 | 60 |
|
60 | 61 |
private int modCount = 1000; |
61 | 62 |
|
... | ... | |
70 | 71 |
super(pluralString, dbTableName, cdmTargetClass); |
71 | 72 |
} |
72 | 73 |
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
/* (non-Javadoc) |
|
77 |
* @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#getIdQuery() |
|
78 |
*/ |
|
79 | 74 |
@Override |
80 | 75 |
protected String getIdQuery() { |
81 | 76 |
String strRecordQuery = |
... | ... | |
84 | 79 |
return strRecordQuery; |
85 | 80 |
} |
86 | 81 |
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
91 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
92 |
*/ |
|
93 | 82 |
@Override |
94 | 83 |
protected String getRecordQuery(GlobisImportConfigurator config) { |
95 | 84 |
String strRecordQuery = |
... | ... | |
101 | 90 |
return strRecordQuery; |
102 | 91 |
} |
103 | 92 |
|
104 |
|
|
105 |
|
|
106 |
/* (non-Javadoc) |
|
107 |
* @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#doPartition(eu.etaxonomy.cdm.io.common.ResultSetPartitioner, eu.etaxonomy.cdm.io.globis.GlobisImportState) |
|
108 |
*/ |
|
109 | 93 |
@Override |
110 |
public boolean doPartition(ResultSetPartitioner partitioner, GlobisImportState state) { |
|
94 |
public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, GlobisImportState state) {
|
|
111 | 95 |
boolean success = true; |
112 | 96 |
|
113 | 97 |
Set<Media> objectsToSave = new HashSet<>(); |
114 | 98 |
|
115 |
Map<String, DerivedUnit> typeMap = partitioner.getObjectMap(TYPE_NAMESPACE); |
|
99 |
@SuppressWarnings("unchecked") |
|
100 |
Map<String, DerivedUnit> typeMap = partitioner.getObjectMap(TYPE_NAMESPACE); |
|
116 | 101 |
|
117 |
Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE); |
|
118 |
Map<String, TaxonName> specTaxNameMap = partitioner.getObjectMap(SPEC_TAX_NAMESPACE); |
|
102 |
@SuppressWarnings("unchecked") |
|
103 |
Map<String, Taxon> taxonMap = partitioner.getObjectMap(TAXON_NAMESPACE); |
|
104 |
@SuppressWarnings("unchecked") |
|
105 |
Map<String, TaxonName> specTaxNameMap = partitioner.getObjectMap(SPEC_TAX_NAMESPACE); |
|
119 | 106 |
|
120 | 107 |
ResultSet rs = partitioner.getResultSet(); |
121 | 108 |
|
... | ... | |
144 | 131 |
// [file lab2], same as Dateiname04 but less data |
145 | 132 |
// Dateipfad |
146 | 133 |
|
147 |
Set<Media> recordMedia = new HashSet<Media>();
|
|
134 |
Set<Media> recordMedia = new HashSet<>(); |
|
148 | 135 |
|
149 | 136 |
try { |
150 | 137 |
|
... | ... | |
175 | 162 |
//not type specimen |
176 | 163 |
if (specimen == null){ |
177 | 164 |
specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
178 |
specimen.setTitleCache("Specimen for " + title );
|
|
165 |
specimen.setTitleCache("Specimen for " + title, true);
|
|
179 | 166 |
String collectionCode = transformCopyright2CollectionCode(copyright); |
180 | 167 |
//TODO |
181 | 168 |
Collection collection = getCollection(collectionCode); |
182 | 169 |
specimen.setCollection(collection); |
183 | 170 |
} |
184 | 171 |
|
185 |
|
|
186 | 172 |
//source |
187 | 173 |
specimen.addSource(OriginalSourceType.Import, String.valueOf(bildID), IMAGE_NAMESPACE, state.getTransactionalSourceReference(), null); |
188 | 174 |
|
... | ... | |
285 | 271 |
return null; |
286 | 272 |
} |
287 | 273 |
|
288 |
|
|
289 |
|
|
290 |
|
|
291 | 274 |
private String getNameFromFileOs(ResultSet rs) throws SQLException { |
292 | 275 |
String fileOS = rs.getString("file OS"); |
293 | 276 |
Pattern pattern = Pattern.compile("(.+)(_.{4}(-.{1,3})?(_Nr\\d{3,4})?_.{2,3}\\.jpg)"); |
... | ... | |
301 | 284 |
} |
302 | 285 |
} |
303 | 286 |
|
304 |
|
|
305 |
|
|
306 |
|
|
307 | 287 |
private void makeAllMedia(GlobisImportState state, ResultSet rs, Set<Media> recordMedia, Set<Media> objectsToSave) throws SQLException{ |
308 | 288 |
//make image path |
309 | 289 |
String pathShort = rs.getString("Dateipfad_kurz"); |
... | ... | |
413 | 393 |
|
414 | 394 |
@Override |
415 | 395 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, GlobisImportState state) { |
416 |
String nameSpace; |
|
417 |
Class<?> cdmClass;
|
|
396 |
|
|
397 |
String nameSpace;
|
|
418 | 398 |
Set<String> idSet; |
419 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
399 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
420 | 400 |
try{ |
421 | 401 |
Set<String> currSpecIdSet = new HashSet<>(); |
422 | 402 |
Set<String> specTaxIdSet = new HashSet<>(); |
... | ... | |
430 | 410 |
|
431 | 411 |
//specTax map |
432 | 412 |
nameSpace = SPEC_TAX_NAMESPACE; |
433 |
cdmClass = TaxonName.class; |
|
434 | 413 |
idSet = specTaxIdSet; |
435 |
Map<String, TaxonName> specTaxNameMap = (Map<String, TaxonName>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
414 |
Map<String, TaxonName> specTaxNameMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonName.class, idSet, nameSpace);
|
|
436 | 415 |
result.put(nameSpace, specTaxNameMap); |
437 | 416 |
|
438 | 417 |
// //taxon map |
439 | 418 |
// nameSpace = TAXON_NAMESPACE; |
440 |
// cdmClass = Taxon.class; |
|
441 | 419 |
// idSet = currSpecIdSet; |
442 |
// Map<String, Taxon> taxonMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
420 |
// Map<String, Taxon> taxonMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class, idSet, nameSpace);
|
|
443 | 421 |
// result.put(nameSpace, taxonMap); |
444 | 422 |
|
445 | 423 |
|
446 | 424 |
//type map |
447 |
nameSpace = GlobisSpecTaxImport.TYPE_NAMESPACE; |
|
448 |
cdmClass = DerivedUnit.class; |
|
425 |
nameSpace = GlobisImportBase.TYPE_NAMESPACE; |
|
449 | 426 |
idSet = typeIdSet; |
450 |
Map<String, DerivedUnit> typeMap = (Map<String, DerivedUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
427 |
Map<String, DerivedUnit> typeMap = getCommonService().getSourcedObjectsByIdInSourceC(DerivedUnit.class, idSet, nameSpace);
|
|
451 | 428 |
result.put(nameSpace, typeMap); |
452 | 429 |
|
453 | 430 |
|
... | ... | |
468 | 445 |
} |
469 | 446 |
} |
470 | 447 |
|
471 |
/* (non-Javadoc) |
|
472 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
473 |
*/ |
|
474 | 448 |
@Override |
475 | 449 |
protected boolean doCheck(GlobisImportState state){ |
476 | 450 |
IOValidator<GlobisImportState> validator = new GlobisImageImportValidator(); |
477 | 451 |
return validator.validate(state); |
478 | 452 |
} |
479 | 453 |
|
480 |
|
|
481 |
/* (non-Javadoc) |
|
482 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
483 |
*/ |
|
484 | 454 |
@Override |
485 | 455 |
protected boolean isIgnore(GlobisImportState state){ |
486 | 456 |
return ! state.getConfig().isDoImages(); |
487 | 457 |
} |
488 | 458 |
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
/* (non-Javadoc) |
|
493 |
* @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#doInvoke(eu.etaxonomy.cdm.io.globis.GlobisImportState) |
|
494 |
*/ |
|
495 | 459 |
@Override |
496 | 460 |
protected void doInvoke(GlobisImportState state) { |
497 | 461 |
Reference refGart = ReferenceFactory.newGeneric(); |
498 |
refGart.setTitleCache("GART"); |
|
462 |
refGart.setTitleCache("GART", true);
|
|
499 | 463 |
refGart.setUuid(uuidGartRef); |
500 | 464 |
getReferenceService().saveOrUpdate(refGart); |
501 | 465 |
super.doInvoke(state); |
502 | 466 |
} |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 | 467 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java | ||
---|---|---|
758 | 758 |
return specTypeDepositoryStr; |
759 | 759 |
} |
760 | 760 |
|
761 |
|
|
762 |
|
|
763 |
|
|
764 |
/** |
|
765 |
* @param fieldObservation |
|
766 |
* @return |
|
767 |
*/ |
|
768 | 761 |
protected DerivedUnit makeSingleTypeSpecimen(FieldUnit fieldObservation) { |
769 | 762 |
DerivationEvent derivEvent = DerivationEvent.NewInstance(); |
770 | 763 |
// derivEvent.setType(DerivationEventType.ACCESSIONING()); |
... | ... | |
774 | 767 |
return specimen; |
775 | 768 |
} |
776 | 769 |
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
/** |
|
781 |
* @param state |
|
782 |
* @return |
|
783 |
* @throws SQLException |
|
784 |
*/ |
|
785 | 770 |
protected FieldUnit makeTypeFieldObservation(GlobisImportState state, |
786 | 771 |
ResultSet rs) throws SQLException { |
787 | 772 |
|
... | ... | |
797 | 782 |
} |
798 | 783 |
|
799 | 784 |
|
800 |
|
|
801 |
|
|
802 |
/** |
|
803 |
* @param name |
|
804 |
* @param rs |
|
805 |
* @param status |
|
806 |
* @param specimen |
|
807 |
* @param specTaxId |
|
808 |
* @throws SQLException |
|
809 |
*/ |
|
810 | 785 |
protected void makeTypeDesignation(IZoologicalName name, ResultSet rs, DerivedUnit specimen, Integer specTaxId) throws SQLException { |
811 | 786 |
//type |
812 | 787 |
String specType = rs.getString("SpecType"); |
... | ... | |
819 | 794 |
name.addTypeDesignation(typeDesignation, true); |
820 | 795 |
} |
821 | 796 |
|
822 |
|
|
823 |
|
|
824 |
|
|
825 | 797 |
private SpecimenTypeDesignationStatus getTypeDesigType(String specType, Integer specTaxId) { |
826 | 798 |
if (isBlank(specType) ){ |
827 | 799 |
return null; |
... | ... | |
841 | 813 |
} |
842 | 814 |
} |
843 | 815 |
|
844 |
|
|
845 |
|
|
846 |
|
|
847 |
/** |
|
848 |
* @param state |
|
849 |
* @param referenceMap |
|
850 |
* @param rs |
|
851 |
* @param name |
|
852 |
* @param specTaxId |
|
853 |
* @return |
|
854 |
* @throws SQLException |
|
855 |
*/ |
|
856 | 816 |
private Reference handleNomRef(GlobisImportState state, Map<String, Reference> referenceMap, ResultSet rs, |
857 | 817 |
IZoologicalName name, Integer specTaxId) throws SQLException { |
858 | 818 |
//ref |
... | ... | |
875 | 835 |
return nomRef; |
876 | 836 |
} |
877 | 837 |
|
878 |
|
|
879 |
|
|
880 |
|
|
881 | 838 |
private void validateAcceptedTaxon(Taxon acceptedTaxon, ResultSet rs, Integer specTaxId, Integer acceptedTaxonId) throws SQLException { |
882 | 839 |
if (acceptedTaxon == null){ |
883 | 840 |
logger.warn("Accepted taxon is null for taxon taxon to validate. SpecTaxId " + specTaxId + ", accTaxonId: " + acceptedTaxonId); |
... | ... | |
894 | 851 |
//TODO |
895 | 852 |
} |
896 | 853 |
|
897 |
|
|
898 |
|
|
899 |
|
|
900 | 854 |
private Synonym getSynonym(GlobisImportState state, ResultSet rs, Integer specTaxId) throws SQLException { |
901 | 855 |
TaxonName name = (TaxonName)makeName(state, rs, specTaxId); |
902 | 856 |
|
... | ... | |
905 | 859 |
return synonym; |
906 | 860 |
} |
907 | 861 |
|
908 |
|
|
909 |
|
|
910 |
|
|
911 | 862 |
/** |
912 | 863 |
* @param state |
913 | 864 |
* @param rs |
... | ... | |
942 | 893 |
return name; |
943 | 894 |
} |
944 | 895 |
|
945 |
|
|
946 |
|
|
947 |
|
|
948 | 896 |
private void makeNamePartsAndCache(GlobisImportState state, ResultSet rs, String rank, IZoologicalName name) throws SQLException { |
949 | 897 |
String citedFamily = rs.getString("SpecCitedFamily"); |
950 | 898 |
String citedGenus = rs.getString("SpecCitedGenus"); |
... | ... | |
971 | 919 |
|
972 | 920 |
@Override |
973 | 921 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, GlobisImportState state) { |
974 |
String nameSpace; |
|
975 |
Class<?> cdmClass;
|
|
922 |
|
|
923 |
String nameSpace;
|
|
976 | 924 |
Set<String> idSet; |
977 | 925 |
|
978 |
Set<AgentBase> agents = state.getAgents(); |
|
926 |
@SuppressWarnings("rawtypes") |
|
927 |
Set<AgentBase> agents = state.getAgents(); |
|
979 | 928 |
getAgentService().saveOrUpdate(agents); |
980 | 929 |
|
981 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
930 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
982 | 931 |
try{ |
983 |
Set<String> taxonIdSet = new HashSet<String>();
|
|
984 |
Set<String> referenceIdSet = new HashSet<String>();
|
|
932 |
Set<String> taxonIdSet = new HashSet<>(); |
|
933 |
Set<String> referenceIdSet = new HashSet<>(); |
|
985 | 934 |
|
986 | 935 |
while (rs.next()){ |
987 | 936 |
handleForeignKey(rs, taxonIdSet, "SpecCurrspecID"); |
... | ... | |
990 | 939 |
|
991 | 940 |
//taxon map |
992 | 941 |
nameSpace = TAXON_NAMESPACE; |
993 |
cdmClass = Taxon.class; |
|
994 | 942 |
idSet = taxonIdSet; |
995 |
Map<String, Taxon> objectMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
943 |
Map<String, Taxon> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class, idSet, nameSpace);
|
|
996 | 944 |
result.put(nameSpace, objectMap); |
997 | 945 |
|
998 | 946 |
//reference map |
999 | 947 |
nameSpace = REFERENCE_NAMESPACE; |
1000 |
cdmClass = Reference.class; |
|
1001 | 948 |
idSet = referenceIdSet; |
1002 |
Map<String, Reference> referenceMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
949 |
Map<String, Reference> referenceMap = getCommonService().getSourcedObjectsByIdInSourceC(Reference.class, idSet, nameSpace);
|
|
1003 | 950 |
result.put(nameSpace, referenceMap); |
1004 | 951 |
|
1005 | 952 |
//collection map |
1006 | 953 |
nameSpace = COLLECTION_NAMESPACE; |
1007 | 954 |
List<Collection> listCollection = getCollectionService().list(Collection.class, null, null, null, null); |
1008 |
Map<String, Collection> collectionMap = new HashMap<String, Collection>();
|
|
955 |
Map<String, Collection> collectionMap = new HashMap<>(); |
|
1009 | 956 |
for (Collection collection : listCollection){ |
1010 | 957 |
if (isNotBlank(collection.getCode())){ |
1011 | 958 |
collectionMap.put(collection.getCode(), collection); |
... | ... | |
1023 | 970 |
return result; |
1024 | 971 |
} |
1025 | 972 |
|
1026 |
/* (non-Javadoc) |
|
1027 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
1028 |
*/ |
|
1029 | 973 |
@Override |
1030 | 974 |
protected boolean doCheck(GlobisImportState state){ |
1031 | 975 |
IOValidator<GlobisImportState> validator = new GlobisSpecTaxaImportValidator(); |
1032 | 976 |
return validator.validate(state); |
1033 | 977 |
} |
1034 | 978 |
|
1035 |
|
|
1036 |
/* (non-Javadoc) |
|
1037 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
1038 |
*/ |
|
1039 | 979 |
@Override |
1040 | 980 |
protected boolean isIgnore(GlobisImportState state){ |
1041 | 981 |
return ! state.getConfig().isDoSpecTaxa(); |
1042 | 982 |
} |
1043 | 983 |
|
1044 |
|
|
1045 |
|
|
1046 |
|
|
1047 | 984 |
@Override |
1048 | 985 |
public Reference createObject(ResultSet rs, GlobisImportState state) |
1049 | 986 |
throws SQLException { |
app-import/src/main/java/eu/etaxonomy/cdm/io/mexico/MexicoConabioCommonNamesImport.java | ||
---|---|---|
89 | 89 |
} |
90 | 90 |
} |
91 | 91 |
|
92 |
@SuppressWarnings("unchecked") |
|
93 | 92 |
private void initTaxa() { |
94 | 93 |
if (taxonIdMap == null){ |
95 | 94 |
Set<String> existingKeys = MexicoConabioTaxonImport.taxonIdMap.keySet(); |
96 |
taxonIdMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(Taxon.class,
|
|
95 |
taxonIdMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class,
|
|
97 | 96 |
existingKeys, MexicoConabioTaxonImport.TAXON_NAMESPACE); |
98 | 97 |
} |
99 | 98 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/mexico/MexicoConabioDistributionImport.java | ||
---|---|---|
59 | 59 |
return "DistribucionEstatal"; |
60 | 60 |
} |
61 | 61 |
|
62 |
@SuppressWarnings("unchecked") |
|
63 | 62 |
private void initTaxa() { |
64 | 63 |
if (taxonIdMap == null){ |
65 | 64 |
Set<String> existingKeys = MexicoConabioTaxonImport.taxonIdMap.keySet(); |
66 |
taxonIdMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(Taxon.class,
|
|
65 |
taxonIdMap = getCommonService().getSourcedObjectsByIdInSourceC(Taxon.class,
|
|
67 | 66 |
existingKeys, MexicoConabioTaxonImport.TAXON_NAMESPACE); |
68 | 67 |
} |
69 | 68 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java | ||
---|---|---|
348 | 348 |
e.printStackTrace(); |
349 | 349 |
} |
350 | 350 |
//add taxa and their parent taxa |
351 |
result.put(RedListUtil.TAXON_GESAMTLISTE_NAMESPACE, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE)); |
|
352 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_E, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_E)); |
|
353 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_W, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_W)); |
|
354 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_K, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_K)); |
|
355 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_AW, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_AW)); |
|
356 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_AO, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_AO)); |
|
357 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_R, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_R)); |
|
358 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_O, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_O)); |
|
359 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_S, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_S)); |
|
351 |
result.put(RedListUtil.TAXON_GESAMTLISTE_NAMESPACE, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE)); |
|
352 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_E, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_E)); |
|
353 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_W, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_W)); |
|
354 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_K, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_K)); |
|
355 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_AW, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_AW)); |
|
356 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_AO, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_AO)); |
|
357 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_R, getCommonService().getSourcedObjectsByIdInSourceC(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_R)); |
Also available in: Unified diff
adapt some classes to new CommonService.getSourcedObjectSByIdInSourceC and cleanup