Revision b313991f
Added by Andreas Müller over 4 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraTypeImport.java | ||
---|---|---|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
@Override |
113 |
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState bmState) { |
|
113 |
public boolean doPartition(@SuppressWarnings("rawtypes") ResultSetPartitioner partitioner, BerlinModelImportState bmState) {
|
|
114 | 114 |
boolean success = true; |
115 | 115 |
|
116 | 116 |
AlgaTerraImportState state = (AlgaTerraImportState)bmState; |
... | ... | |
128 | 128 |
|
129 | 129 |
Set<TaxonName> namesToSave = new HashSet<>(); |
130 | 130 |
|
131 |
Map<String, TaxonName> taxonNameMap = partitioner.getObjectMap(BerlinModelTaxonNameImport.NAMESPACE); |
|
132 |
Map<String, DerivedUnit> ecoFactMap = partitioner.getObjectMap(AlgaTerraEcoFactImport.ECO_FACT_FIELD_OBSERVATION_NAMESPACE); |
|
133 |
Map<String, DerivedUnit> typeSpecimenMap = partitioner.getObjectMap(TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE); |
|
134 |
Map<String, Reference> refMap = partitioner.getObjectMap(BerlinModelReferenceImport.REFERENCE_NAMESPACE); |
|
135 |
Map<String, Reference> refDetailMap = partitioner.getObjectMap(BerlinModelRefDetailImport.REFDETAIL_NAMESPACE); |
|
131 |
@SuppressWarnings("unchecked") |
|
132 |
Map<String, TaxonName> taxonNameMap = partitioner.getObjectMap(BerlinModelTaxonNameImport.NAMESPACE); |
|
133 |
@SuppressWarnings("unchecked") |
|
134 |
Map<String, DerivedUnit> ecoFactMap = partitioner.getObjectMap(AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE); |
|
135 |
@SuppressWarnings("unchecked") |
|
136 |
Map<String, DerivedUnit> typeSpecimenMap = partitioner.getObjectMap(TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE); |
|
137 |
@SuppressWarnings("unchecked") |
|
138 |
Map<String, Reference> refMap = partitioner.getObjectMap(BerlinModelReferenceImport.REFERENCE_NAMESPACE); |
|
139 |
@SuppressWarnings("unchecked") |
|
140 |
Map<String, Reference> refDetailMap = partitioner.getObjectMap(BerlinModelRefDetailImport.REFDETAIL_NAMESPACE); |
|
136 | 141 |
|
137 | 142 |
|
138 | 143 |
ResultSet rs = partitioner.getResultSet(); |
... | ... | |
330 | 335 |
return TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE; |
331 | 336 |
} |
332 | 337 |
|
333 |
/** |
|
334 |
* @param state |
|
335 |
* @param taxonNameMap |
|
336 |
* @param nameId |
|
337 |
* @return |
|
338 |
*/ |
|
339 | 338 |
private TaxonName getTaxonName(AlgaTerraImportState state, Map<String, TaxonName> taxonNameMap, int nameId) { |
340 | 339 |
TaxonName result; |
341 | 340 |
if (state.getConfig().isDoTaxonNames()){ |
... | ... | |
463 | 462 |
|
464 | 463 |
@Override |
465 | 464 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) { |
466 |
String nameSpace; |
|
467 |
Class<?> cdmClass;
|
|
465 |
|
|
466 |
String nameSpace;
|
|
468 | 467 |
Set<String> idSet; |
469 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
|
468 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>(); |
|
470 | 469 |
|
471 | 470 |
try{ |
472 |
Set<String> nameIdSet = new HashSet<String>();
|
|
473 |
Set<String> ecoFieldObservationIdSet = new HashSet<String>();
|
|
474 |
Set<String> typeSpecimenIdSet = new HashSet<String>();
|
|
475 |
// Set<String> termsIdSet = new HashSet<String>();
|
|
476 |
Set<String> collectionIdSet = new HashSet<String>();
|
|
477 |
Set<String> referenceIdSet = new HashSet<String>();
|
|
478 |
Set<String> refDetailIdSet = new HashSet<String>();
|
|
471 |
Set<String> nameIdSet = new HashSet<>(); |
|
472 |
Set<String> ecoFieldObservationIdSet = new HashSet<>(); |
|
473 |
Set<String> typeSpecimenIdSet = new HashSet<>(); |
|
474 |
// Set<String> termsIdSet = new HashSet<>(); |
|
475 |
Set<String> collectionIdSet = new HashSet<>(); |
|
476 |
Set<String> referenceIdSet = new HashSet<>(); |
|
477 |
Set<String> refDetailIdSet = new HashSet<>(); |
|
479 | 478 |
|
480 | 479 |
while (rs.next()){ |
481 | 480 |
handleForeignKey(rs, nameIdSet, "nameFk"); |
... | ... | |
489 | 488 |
|
490 | 489 |
//name map |
491 | 490 |
nameSpace = BerlinModelTaxonNameImport.NAMESPACE; |
492 |
cdmClass = TaxonName.class; |
|
493 | 491 |
idSet = nameIdSet; |
494 |
Map<String, TaxonName> objectMap = (Map<String, TaxonName>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
492 |
Map<String, TaxonName> objectMap = getCommonService().getSourcedObjectsByIdInSourceC(TaxonName.class, idSet, nameSpace);
|
|
495 | 493 |
result.put(nameSpace, objectMap); |
496 | 494 |
|
497 | 495 |
//eco fact field observation map |
498 |
nameSpace = AlgaTerraTypeImport.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
|
499 |
cdmClass = FieldUnit.class; |
|
496 |
nameSpace = AlgaTerraSpecimenImportBase.ECO_FACT_FIELD_OBSERVATION_NAMESPACE; |
|
500 | 497 |
idSet = ecoFieldObservationIdSet; |
501 |
Map<String, FieldUnit> fieldObservationMap = (Map<String, FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
498 |
Map<String, FieldUnit> fieldObservationMap = getCommonService().getSourcedObjectsByIdInSourceC(FieldUnit.class, idSet, nameSpace);
|
|
502 | 499 |
result.put(nameSpace, fieldObservationMap); |
503 | 500 |
|
504 | 501 |
//type specimen map |
505 |
nameSpace = AlgaTerraTypeImport.TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE; |
|
506 |
cdmClass = FieldUnit.class; |
|
502 |
nameSpace = AlgaTerraSpecimenImportBase.TYPE_SPECIMEN_FIELD_OBSERVATION_NAMESPACE; |
|
507 | 503 |
idSet = typeSpecimenIdSet; |
508 |
Map<String, FieldUnit> typeSpecimenMap = (Map<String, FieldUnit>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
504 |
Map<String, FieldUnit> typeSpecimenMap = getCommonService().getSourcedObjectsByIdInSourceC(FieldUnit.class, idSet, nameSpace);
|
|
509 | 505 |
result.put(nameSpace, typeSpecimenMap); |
510 | 506 |
|
511 | 507 |
|
512 | 508 |
//collections |
513 | 509 |
nameSpace = AlgaTerraCollectionImport.NAMESPACE_COLLECTION; |
514 |
cdmClass = Collection.class; |
|
515 | 510 |
idSet = collectionIdSet; |
516 |
Map<String, Collection> collectionMap = (Map<String, Collection>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
511 |
Map<String, Collection> collectionMap = getCommonService().getSourcedObjectsByIdInSourceC(Collection.class, idSet, nameSpace);
|
|
517 | 512 |
result.put(nameSpace, collectionMap); |
518 | 513 |
|
519 | 514 |
//sub-collections |
520 | 515 |
nameSpace = AlgaTerraCollectionImport.NAMESPACE_SUBCOLLECTION; |
521 |
cdmClass = Collection.class; |
|
522 | 516 |
idSet = collectionIdSet; |
523 |
Map<String, Collection> subCollectionMap = (Map<String, Collection>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
517 |
Map<String, Collection> subCollectionMap = getCommonService().getSourcedObjectsByIdInSourceC(Collection.class, idSet, nameSpace);
|
|
524 | 518 |
result.put(nameSpace, subCollectionMap); |
525 | 519 |
|
526 | 520 |
//reference map |
527 | 521 |
nameSpace = BerlinModelReferenceImport.REFERENCE_NAMESPACE; |
528 |
cdmClass = Reference.class; |
|
529 | 522 |
idSet = referenceIdSet; |
530 |
Map<String, Reference> referenceMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
523 |
Map<String, Reference> referenceMap = getCommonService().getSourcedObjectsByIdInSourceC(Reference.class, idSet, nameSpace);
|
|
531 | 524 |
result.put(nameSpace, referenceMap); |
532 | 525 |
|
533 | 526 |
//refDetail map |
534 | 527 |
nameSpace = BerlinModelRefDetailImport.REFDETAIL_NAMESPACE; |
535 |
cdmClass = Reference.class; |
|
536 | 528 |
idSet = refDetailIdSet; |
537 |
Map<String, Reference> refDetailMap= (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
|
529 |
Map<String, Reference> refDetailMap= getCommonService().getSourcedObjectsByIdInSourceC(Reference.class, idSet, nameSpace);
|
|
538 | 530 |
result.put(nameSpace, refDetailMap); |
539 | 531 |
|
540 |
|
|
541 |
|
|
542 | 532 |
} catch (SQLException e) { |
543 | 533 |
throw new RuntimeException(e); |
544 | 534 |
} |
545 | 535 |
return result; |
546 | 536 |
} |
547 | 537 |
|
548 |
/* (non-Javadoc) |
|
549 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
550 |
*/ |
|
551 | 538 |
@Override |
552 | 539 |
protected boolean doCheck(BerlinModelImportState state){ |
553 | 540 |
IOValidator<BerlinModelImportState> validator = new AlgaTerraTypeImportValidator(); |
554 | 541 |
return validator.validate(state); |
555 | 542 |
} |
556 | 543 |
|
557 |
|
|
558 |
/* (non-Javadoc) |
|
559 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
560 |
*/ |
|
561 | 544 |
@Override |
562 | 545 |
protected boolean isIgnore(BerlinModelImportState state){ |
563 | 546 |
return ! state.getConfig().isDoTypes(); |
564 | 547 |
} |
565 |
|
|
566 | 548 |
} |
Also available in: Unified diff
adapt some classes to new CommonService.getSourcedObjectSByIdInSource and cleanup