Revision bb38665e
Added by Andreas Müller over 10 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java | ||
---|---|---|
24 | 24 |
import org.springframework.stereotype.Component; |
25 | 25 |
|
26 | 26 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
27 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType; |
|
28 | 27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
29 | 28 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
30 | 29 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
... | ... | |
36 | 35 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
37 | 36 |
import eu.etaxonomy.cdm.model.common.Marker; |
38 | 37 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
38 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
39 | 39 |
import eu.etaxonomy.cdm.model.description.Feature; |
40 | 40 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
41 | 41 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
... | ... | |
46 | 46 |
import eu.etaxonomy.cdm.model.name.ZoologicalName; |
47 | 47 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
48 | 48 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
49 |
import eu.etaxonomy.cdm.model.occurrence.FieldObservation; |
|
50 |
import eu.etaxonomy.cdm.model.occurrence.Specimen; |
|
49 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
50 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
51 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
51 | 52 |
import eu.etaxonomy.cdm.model.reference.Reference; |
52 | 53 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
53 | 54 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
... | ... | |
210 | 211 |
name.addExtension(citedTypeLocality, exTypeCitedTypeLoc); |
211 | 212 |
} |
212 | 213 |
|
213 |
name.addSource(String.valueOf(specTaxId), SPEC_TAX_NAMESPACE, state.getTransactionalSourceReference(), null); |
|
214 |
name.addSource(OriginalSourceType.Import, String.valueOf(specTaxId), SPEC_TAX_NAMESPACE, state.getTransactionalSourceReference(), null);
|
|
214 | 215 |
|
215 | 216 |
namesToSave.add(name); |
216 | 217 |
|
... | ... | |
316 | 317 |
return; |
317 | 318 |
} |
318 | 319 |
|
319 |
FieldObservation fieldObservation = makeTypeFieldObservation(state, rs);
|
|
320 |
FieldUnit fieldObservation = makeTypeFieldObservation(state, rs);
|
|
320 | 321 |
|
321 | 322 |
//typeDepository |
322 | 323 |
String specTypeDepositoriesStr = rs.getString("SpecTypeDepository"); |
... | ... | |
329 | 330 |
|
330 | 331 |
//TODO several issues |
331 | 332 |
if (specTypeDepositories.length == 0){ |
332 |
Specimen specimen = makeSingleTypeSpecimen(fieldObservation);
|
|
333 |
DerivedUnit specimen = makeSingleTypeSpecimen(fieldObservation);
|
|
333 | 334 |
makeTypeDesignation(name, rs, specimen, specTaxId); |
334 | 335 |
makeTypeIdInSource(state, specimen, "null", specTaxId); |
335 | 336 |
} |
... | ... | |
337 | 338 |
specTypeDepositoryStr = specTypeDepositoryStr.trim(); |
338 | 339 |
|
339 | 340 |
//Specimen |
340 |
Specimen specimen = makeSingleTypeSpecimen(fieldObservation);
|
|
341 |
DerivedUnit specimen = makeSingleTypeSpecimen(fieldObservation);
|
|
341 | 342 |
|
342 | 343 |
if (specTypeDepositoryStr.equals("??")){ |
343 | 344 |
//unknown |
... | ... | |
367 | 368 |
} |
368 | 369 |
|
369 | 370 |
|
370 |
private void makeTypeIdInSource(GlobisImportState state, Specimen specimen, String collectionCode, Integer specTaxId) {
|
|
371 |
private void makeTypeIdInSource(GlobisImportState state, DerivedUnit specimen, String collectionCode, Integer specTaxId) {
|
|
371 | 372 |
String namespace = TYPE_NAMESPACE; |
372 | 373 |
String id = getTypeId(specTaxId, collectionCode); |
373 |
IdentifiableSource source = IdentifiableSource.NewInstance(id, namespace, state.getTransactionalSourceReference(), null); |
|
374 |
IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Import, id, namespace, state.getTransactionalSourceReference(), null);
|
|
374 | 375 |
specimen.addSource(source); |
375 | 376 |
} |
376 | 377 |
|
... | ... | |
403 | 404 |
* @param specimen |
404 | 405 |
* @param specTaxId |
405 | 406 |
*/ |
406 |
protected Collection makeCollection(GlobisImportState state, String specTypeDepositoryStr, Specimen specimen, Integer specTaxId) {
|
|
407 |
protected Collection makeCollection(GlobisImportState state, String specTypeDepositoryStr, DerivedUnit specimen, Integer specTaxId) {
|
|
407 | 408 |
|
408 | 409 |
//Collection |
409 | 410 |
specTypeDepositoryStr = specTypeDepositoryStr.replace("Washington, D.C.", "Washington@ D.C."); |
... | ... | |
489 | 490 |
* @param specTaxId |
490 | 491 |
* @return |
491 | 492 |
*/ |
492 |
protected String makeAdditionalSpecimenInformation( String specTypeDepositoryStr, Specimen specimen, Integer specTaxId) {
|
|
493 |
protected String makeAdditionalSpecimenInformation( String specTypeDepositoryStr, DerivedUnit specimen, Integer specTaxId) {
|
|
493 | 494 |
//doubful |
494 | 495 |
if (specTypeDepositoryStr.endsWith("?")){ |
495 | 496 |
Marker.NewInstance(specimen, true, MarkerType.IS_DOUBTFUL()); |
... | ... | |
527 | 528 |
* @param fieldObservation |
528 | 529 |
* @return |
529 | 530 |
*/ |
530 |
protected Specimen makeSingleTypeSpecimen(FieldObservation fieldObservation) {
|
|
531 |
protected DerivedUnit makeSingleTypeSpecimen(FieldUnit fieldObservation) {
|
|
531 | 532 |
DerivationEvent derivEvent = DerivationEvent.NewInstance(); |
532 | 533 |
// derivEvent.setType(DerivationEventType.ACCESSIONING()); |
533 | 534 |
fieldObservation.addDerivationEvent(derivEvent); |
534 |
Specimen specimen = Specimen.NewInstance();
|
|
535 |
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance();
|
|
535 | 536 |
specimen.setDerivedFrom(derivEvent); |
536 | 537 |
return specimen; |
537 | 538 |
} |
... | ... | |
544 | 545 |
* @return |
545 | 546 |
* @throws SQLException |
546 | 547 |
*/ |
547 |
protected FieldObservation makeTypeFieldObservation(GlobisImportState state,
|
|
548 |
protected FieldUnit makeTypeFieldObservation(GlobisImportState state,
|
|
548 | 549 |
ResultSet rs) throws SQLException { |
549 | 550 |
|
550 | 551 |
String countryString = rs.getString("SpecTypeCountry"); |
551 | 552 |
|
552 |
DerivedUnitType unitType = DerivedUnitType.Specimen;
|
|
553 |
SpecimenOrObservationType unitType = SpecimenOrObservationType.PreservedSpecimen;
|
|
553 | 554 |
DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(unitType); |
554 | 555 |
|
555 | 556 |
NamedArea typeCountry = getCountry(state, countryString); |
556 | 557 |
facade.setCountry(typeCountry); |
557 |
FieldObservation fieldObservation = facade.innerFieldObservation();
|
|
558 |
FieldUnit fieldObservation = facade.innerFieldUnit();
|
|
558 | 559 |
return fieldObservation; |
559 | 560 |
} |
560 | 561 |
|
... | ... | |
569 | 570 |
* @param specTaxId |
570 | 571 |
* @throws SQLException |
571 | 572 |
*/ |
572 |
protected void makeTypeDesignation(ZoologicalName name, ResultSet rs, Specimen specimen, Integer specTaxId) throws SQLException {
|
|
573 |
protected void makeTypeDesignation(ZoologicalName name, ResultSet rs, DerivedUnit specimen, Integer specTaxId) throws SQLException {
|
|
573 | 574 |
//type |
574 | 575 |
String specType = rs.getString("SpecType"); |
575 | 576 |
SpecimenTypeDesignationStatus status = getTypeDesigType(specType, specTaxId); |
... | ... | |
681 | 682 |
Rank rank = null; |
682 | 683 |
if (isNotBlank(rankStr)){ |
683 | 684 |
try { |
684 |
rank = Rank.getRankByNameOrAbbreviation(rankStr, NomenclaturalCode.ICZN, true);
|
|
685 |
rank = Rank.getRankByNameOrIdInVoc(rankStr, NomenclaturalCode.ICZN, true);
|
|
685 | 686 |
} catch (UnknownCdmTypeException e) { |
686 | 687 |
e.printStackTrace(); |
687 | 688 |
} |
Also available in: Unified diff
reintegrate cdmlib-app-3.3 branch into trunk