Revision 495cebda
Added by Andreas Müller almost 11 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java | ||
---|---|---|
29 | 29 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
30 | 30 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
31 | 31 |
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport; |
32 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
|
32 | 33 |
import eu.etaxonomy.cdm.io.globis.validation.GlobisSpecTaxaImportValidator; |
33 | 34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
34 | 35 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
35 | 36 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
36 | 37 |
import eu.etaxonomy.cdm.model.common.Marker; |
37 | 38 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
38 |
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry; |
|
39 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
40 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
39 | 41 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
40 | 42 |
import eu.etaxonomy.cdm.model.name.Rank; |
41 | 43 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
... | ... | |
67 | 69 |
private static final String pluralString = "taxa"; |
68 | 70 |
private static final String dbTableName = "specTax"; |
69 | 71 |
private static final Class cdmTargetClass = Reference.class; |
70 |
public static final String SPEC_TAX_NAMESPACE = dbTableName; |
|
71 |
public static final String TYPE_NAMESPACE = dbTableName + ".SpecTypeDepository"; |
|
72 | 72 |
|
73 | 73 |
private static UUID uuidCitedTypeLocality = UUID.fromString("ca431e0a-84ec-4828-935f-df4c8f5cf880"); |
74 | 74 |
private static UUID uuidCitedTypeMaterial = UUID.fromString("8395021a-e596-4a55-9794-8c03aaad9e16"); |
... | ... | |
137 | 137 |
Integer acceptedTaxonId = nullSafeInt(rs, "SpecCurrspecID"); |
138 | 138 |
String specSystaxRank = rs.getString("SpecSystaxRank"); |
139 | 139 |
|
140 |
//ignore: CountryDummy, currentSpecies, DepositoryDisplay, DepositoryDummy, ReferenceDisplay, SpecDescriptionImageFile, all *Valid* |
|
141 |
|
|
140 | 142 |
try { |
141 | 143 |
|
142 | 144 |
//source ref |
... | ... | |
189 | 191 |
objectsToSave.add(acceptedTaxon); |
190 | 192 |
} |
191 | 193 |
|
194 |
//makeMarker1(state, rs, name); //ignore! |
|
195 |
|
|
196 |
makeNotAvailable(state, rs, name); |
|
197 |
|
|
192 | 198 |
//SpecCitedTypeLocality |
193 | 199 |
String citedTypeLocality = rs.getString("SpecCitedTypeLocality"); |
194 | 200 |
if (isNotBlank(citedTypeLocality)){ |
195 |
ExtensionType exTypeCitedTypeLoc = getExtensionType(state, uuidCitedTypeLocality, "Type locality as cited in original description", "Type locality as cited in original description", null, ExtensionType.DOI().getVocabulary()); |
|
196 |
name.addExtension(citedTypeLocality, exTypeCitedTypeLoc); |
|
201 |
// ExtensionType exTypeCitedTypeLoc = getExtensionType(state, uuidCitedTypeLocality, "Type locality as cited in original description", "Type locality as cited in original description", null, ExtensionType.DOI().getVocabulary()); |
|
202 |
// name.addExtension(citedTypeLocality, exTypeCitedTypeLoc); |
|
203 |
addNameDescription(state, name, uuidCitedTypeLocality, citedTypeLocality, "Type locality as cited in original description"); |
|
197 | 204 |
} |
198 | 205 |
|
199 | 206 |
//SpecCitedTypeMaterial |
200 | 207 |
String citedTypeMaterial = rs.getString("SpecCitedTypeMaterial"); |
201 | 208 |
if (isNotBlank(citedTypeMaterial)){ |
202 |
ExtensionType exTypeCitedTypeLoc = getExtensionType(state, uuidCitedTypeMaterial, "Type material as cited in original description", "Type locality as cited in original description", null, ExtensionType.DOI().getVocabulary());
|
|
209 |
ExtensionType exTypeCitedTypeLoc = getExtensionType(state, uuidCitedTypeMaterial, "Type material as cited in original description", "Type material as cited in original description", null, ExtensionType.DOI().getVocabulary());
|
|
203 | 210 |
name.addExtension(citedTypeLocality, exTypeCitedTypeLoc); |
204 | 211 |
} |
205 | 212 |
|
213 |
name.addSource(String.valueOf(specTaxId), SPEC_TAX_NAMESPACE, state.getTransactionalSourceReference(), null); |
|
206 | 214 |
|
207 | 215 |
namesToSave.add(name); |
208 | 216 |
|
... | ... | |
226 | 234 |
} |
227 | 235 |
|
228 | 236 |
|
237 |
private void makeNotAvailable(GlobisImportState state, ResultSet rs, ZoologicalName name) throws SQLException { |
|
238 |
String notAvailableStr = rs.getString("SpecNotAvailable"); |
|
239 |
try { |
|
240 |
if (isNotBlank(notAvailableStr)){ |
|
241 |
if (notAvailableStr.contains("not available") ){ |
|
242 |
UUID uuidNotAvailableMarkerType = state.getTransformer().getMarkerTypeUuid("not available"); |
|
243 |
|
|
244 |
MarkerType markerType = getMarkerType(state, uuidNotAvailableMarkerType, "not available", "not available", null); |
|
245 |
name.addMarker(Marker.NewInstance(markerType, true)); |
|
246 |
} |
|
247 |
} |
|
248 |
} catch (UndefinedTransformerMethodException e) { |
|
249 |
e.printStackTrace(); |
|
250 |
} |
|
251 |
//Not available reason |
|
252 |
//TODO make it a vocabulary |
|
253 |
String notAvailableReason = rs.getString("SpecNotAvailableReason"); |
|
254 |
if (isNotBlank(notAvailableReason)){ |
|
255 |
UUID uuidNotAvailableReason; |
|
256 |
try { |
|
257 |
uuidNotAvailableReason = state.getTransformer().getExtensionTypeUuid("not available reason"); |
|
258 |
ExtensionType notAvailableReasonExtType = getExtensionType(state, uuidNotAvailableReason, "Not available reason", "Not available reason", null, null); |
|
259 |
name.addExtension(notAvailableReason, notAvailableReasonExtType); |
|
260 |
} catch (UndefinedTransformerMethodException e) { |
|
261 |
e.printStackTrace(); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 |
} |
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
/** |
|
272 |
* This method is not used anymore as according to Alexander Marker1 should be ignored. |
|
273 |
* @param state |
|
274 |
* @param rs |
|
275 |
* @param name |
|
276 |
* @throws SQLException |
|
277 |
*/ |
|
278 |
private void makeMarker1(GlobisImportState state, ResultSet rs, ZoologicalName name) throws SQLException { |
|
279 |
String marker1Str = rs.getString("Marker1"); |
|
280 |
try { |
|
281 |
if (isNotBlank(marker1Str)){ |
|
282 |
marker1Str = marker1Str.trim(); |
|
283 |
if (marker1Str.contains("checked") || marker1Str.contains("berpr") ){ //überprüft |
|
284 |
UUID uuidCheckedMarkerType; |
|
285 |
uuidCheckedMarkerType = state.getTransformer().getMarkerTypeUuid("checked"); |
|
286 |
|
|
287 |
MarkerType markerType = getMarkerType(state, uuidCheckedMarkerType, "checked", "checked", null); |
|
288 |
name.addMarker(Marker.NewInstance(markerType, true)); |
|
289 |
} |
|
290 |
if (marker1Str.contains("old record") || marker1Str.contains("alte Angabe") ){ |
|
291 |
UUID uuidOldRecordMarkerType = state.getTransformer().getMarkerTypeUuid("old record"); |
|
292 |
MarkerType markerType = getMarkerType(state, uuidOldRecordMarkerType, "checked", "checked", null); |
|
293 |
name.addMarker(Marker.NewInstance(markerType, true)); |
|
294 |
} |
|
295 |
} |
|
296 |
} catch (UndefinedTransformerMethodException e) { |
|
297 |
e.printStackTrace(); |
|
298 |
} |
|
299 |
|
|
300 |
} |
|
301 |
|
|
302 |
|
|
303 |
private void addNameDescription(GlobisImportState state, ZoologicalName name, UUID featureUuid, |
|
304 |
String citedTypeLocality, String featureLabel) { |
|
305 |
Feature feature = getFeature(state, featureUuid,featureLabel,featureLabel, null, null); |
|
306 |
getTaxonNameDescription(name, false, true); |
|
307 |
|
|
308 |
} |
|
309 |
|
|
310 |
|
|
229 | 311 |
private Pattern patternAll = Pattern.compile("(.+,\\s.+)(\\(.+\\))"); |
230 | 312 |
|
231 | 313 |
|
... | ... | |
248 | 330 |
//TODO several issues |
249 | 331 |
if (specTypeDepositories.length == 0){ |
250 | 332 |
Specimen specimen = makeSingleTypeSpecimen(fieldObservation); |
251 |
makeTypeDesignation(name, rs, specimen); |
|
333 |
makeTypeDesignation(name, rs, specimen, specTaxId);
|
|
252 | 334 |
makeTypeIdInSource(state, specimen, "null", specTaxId); |
253 | 335 |
} |
254 | 336 |
for (String specTypeDepositoryStr : specTypeDepositories){ |
... | ... | |
278 | 360 |
} |
279 | 361 |
|
280 | 362 |
//type Designation |
281 |
makeTypeDesignation(name, rs, specimen); |
|
363 |
makeTypeDesignation(name, rs, specimen, specTaxId);
|
|
282 | 364 |
} |
283 | 365 |
|
284 | 366 |
|
... | ... | |
470 | 552 |
DerivedUnitType unitType = DerivedUnitType.Specimen; |
471 | 553 |
DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(unitType); |
472 | 554 |
|
473 |
WaterbodyOrCountry typeCountry = getCountry(state, countryString);
|
|
555 |
NamedArea typeCountry = getCountry(state, countryString);
|
|
474 | 556 |
facade.setCountry(typeCountry); |
475 | 557 |
FieldObservation fieldObservation = facade.innerFieldObservation(); |
476 | 558 |
return fieldObservation; |
... | ... | |
484 | 566 |
* @param rs |
485 | 567 |
* @param status |
486 | 568 |
* @param specimen |
569 |
* @param specTaxId |
|
487 | 570 |
* @throws SQLException |
488 | 571 |
*/ |
489 |
protected void makeTypeDesignation(ZoologicalName name, ResultSet rs, Specimen specimen) throws SQLException { |
|
572 |
protected void makeTypeDesignation(ZoologicalName name, ResultSet rs, Specimen specimen, Integer specTaxId) throws SQLException {
|
|
490 | 573 |
//type |
491 | 574 |
String specType = rs.getString("SpecType"); |
492 |
SpecimenTypeDesignationStatus status = getTypeDesigType(specType); |
|
575 |
SpecimenTypeDesignationStatus status = getTypeDesigType(specType, specTaxId);
|
|
493 | 576 |
|
494 | 577 |
SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance(); |
495 | 578 |
typeDesignation.setTypeStatus(status); |
... | ... | |
501 | 584 |
|
502 | 585 |
|
503 | 586 |
|
504 |
private SpecimenTypeDesignationStatus getTypeDesigType(String specType) { |
|
587 |
private SpecimenTypeDesignationStatus getTypeDesigType(String specType, Integer specTaxId) {
|
|
505 | 588 |
if (isBlank(specType) ){ |
506 | 589 |
return null; |
507 |
}else if (specType.matches("Holotype(Holotypus)?")){ |
|
590 |
}else if (specType.matches("Holotype(.*Holotypus)?")){
|
|
508 | 591 |
return SpecimenTypeDesignationStatus.HOLOTYPE(); |
509 | 592 |
}else if (specType.matches("Neotype")){ |
510 | 593 |
return SpecimenTypeDesignationStatus.NEOTYPE(); |
... | ... | |
513 | 596 |
}else if (specType.matches("Lectotype")){ |
514 | 597 |
return SpecimenTypeDesignationStatus.LECTOTYPE(); |
515 | 598 |
}else{ |
516 |
logger.warn("SpecimenTypeDesignationStatus does not match: " + specType); |
|
599 |
logger.warn("SpecimenTypeDesignationStatus does not match: " + specType + " in specTaxId " + specTaxId);
|
|
517 | 600 |
return null; |
518 | 601 |
} |
519 | 602 |
} |
... | ... | |
613 | 696 |
String authorStr = rs.getString("SpecAuthor"); |
614 | 697 |
String yearStr = rs.getString("SpecYear"); |
615 | 698 |
String authorAndYearStr = CdmUtils.concat(", ", authorStr, yearStr); |
616 |
handleAuthorAndYear(authorAndYearStr, name); |
|
699 |
handleAuthorAndYear(authorAndYearStr, name, specTaxId);
|
|
617 | 700 |
|
618 |
name.addSource(String.valueOf(specTaxId), SPEC_TAX_NAMESPACE, state.getTransactionalSourceReference(), null); |
|
619 | 701 |
return name; |
620 | 702 |
} |
621 | 703 |
|
... | ... | |
717 | 799 |
|
718 | 800 |
|
719 | 801 |
@Override |
720 |
public Reference createObject(ResultSet rs, GlobisImportState state) |
|
802 |
public Reference<?> createObject(ResultSet rs, GlobisImportState state)
|
|
721 | 803 |
throws SQLException { |
722 | 804 |
// not needed |
723 | 805 |
return null; |
724 | 806 |
} |
725 | 807 |
|
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 | 808 |
} |
Also available in: Unified diff
updates to globis import