2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.caryo
;
12 import java
.sql
.ResultSet
;
13 import java
.sql
.SQLException
;
14 import java
.util
.HashMap
;
15 import java
.util
.HashSet
;
19 import org
.apache
.commons
.lang
.StringUtils
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.springframework
.stereotype
.Component
;
23 import eu
.etaxonomy
.cdm
.io
.common
.DbImportBase
;
24 import eu
.etaxonomy
.cdm
.io
.common
.ResultSetPartitioner
;
25 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
26 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
27 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
29 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
30 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
31 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
32 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
33 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
34 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
35 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
36 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
37 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
38 import eu
.etaxonomy
.cdm
.model
.reference
.IArticle
;
39 import eu
.etaxonomy
.cdm
.model
.reference
.IBook
;
40 import eu
.etaxonomy
.cdm
.model
.reference
.IBookSection
;
41 import eu
.etaxonomy
.cdm
.model
.reference
.IJournal
;
42 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
43 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
44 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
45 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
46 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
47 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
48 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
49 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
50 import eu
.etaxonomy
.cdm
.strategy
.cache
.name
.BotanicNameDefaultCacheStrategy
;
51 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
52 import eu
.etaxonomy
.cdm
.strategy
.parser
.INonViralNameParser
;
53 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImpl
;
62 public class CaryoTaxonImport
extends DbImportBase
<CaryoImportState
, CaryoImportConfigurator
> {
63 private static final Logger logger
= Logger
.getLogger(CaryoTaxonImport
.class);
65 private int modCount
= 10000;
66 private static final String pluralString
= "taxa";
67 private static final String dbTableName
= "CARYOPHYLLALES";
71 private Map
<String
, Taxon
> familyMap
= new HashMap
<String
, Taxon
>();
72 private Map
<String
, Person
> personMap
= new HashMap
<String
, Person
>();
73 private Map
<String
, Team
> teamMap
= new HashMap
<String
, Team
>();
74 private Map
<String
, TeamOrPersonBase
> inAuthorMap
= new HashMap
<String
, TeamOrPersonBase
>();
75 private Map
<String
, IJournal
> journalMap
= new HashMap
<String
, IJournal
>();
76 private Map
<String
, IBook
> bookMap
= new HashMap
<String
, IBook
>();
79 private Classification classification
;
83 public CaryoTaxonImport(){
84 super(dbTableName
, pluralString
);
91 * @see eu.etaxonomy.cdm.io.common.DbImportBase#getIdQuery(eu.etaxonomy.cdm.io.common.DbImportStateBase)
94 protected String
getIdQuery(CaryoImportState state
) {
95 String strRecordQuery
=
97 " FROM " + dbTableName
+
99 return strRecordQuery
;
104 * @see eu.etaxonomy.cdm.io.common.DbImportBase#getRecordQuery(eu.etaxonomy.cdm.io.common.DbImportConfiguratorBase)
107 protected String
getRecordQuery(CaryoImportConfigurator config
) {
108 String strRecordQuery
=
110 " FROM " + getTableName() + " t " +
111 " WHERE ( t.ID IN (" + ID_LIST_TOKEN
+ ") )";
112 return strRecordQuery
;
118 * @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#doPartition(eu.etaxonomy.cdm.io.common.ResultSetPartitioner, eu.etaxonomy.cdm.io.globis.GlobisImportState)
121 public boolean doPartition(ResultSetPartitioner partitioner
, CaryoImportState state
) {
122 boolean success
= true;
124 Set
<TaxonBase
> objectsToSave
= new HashSet
<TaxonBase
>();
126 // Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE);
129 classification
= getClassification(state
);
138 ResultSet rs
= partitioner
.getResultSet();
141 Reference
<?
> sec
= state
.getTransactionalSourceReference();
146 if ((i
++ % modCount
) == 0 && i
!= 1 ){ logger
.info(pluralString
+ " handled: " + (i
-1));}
148 Integer id
= rs
.getInt("Id");
149 Integer taxonId
= rs
.getInt("NCUGenID");
150 String genus
= rs
.getString("Genus");
151 String family
= rs
.getString("Family");
152 String pages
= rs
.getString("Pages");
153 String autoren
= rs
.getString("Autoren");
154 String typeStr
= rs
.getString("Type");
155 String nomStatusStr
= rs
.getString("NomenclaturalStatus");
156 String basioStr
= rs
.getString("Basionym");
162 // ,[OriginalCitation]
165 BotanicalName name
= BotanicalName
.NewInstance(Rank
.GENUS());
166 name
.setGenusOrUninomial(genus
);
167 makeAuthors(name
, autoren
, id
);
168 INomenclaturalReference nomRef
= makeNomRef(state
, rs
, id
);
169 name
.setNomenclaturalReference(nomRef
);
170 name
.setNomenclaturalMicroReference(pages
);
171 makeStatus(name
, nomStatusStr
, id
);
174 Taxon taxon
= Taxon
.NewInstance(name
, state
.getTransactionalSourceReference());
175 handleTypes(state
, rs
, taxon
, typeStr
, id
);
176 handleBasionym(state
, rs
, taxon
, basioStr
, id
);
178 Taxon parent
= familyMap
.get(family
);
180 classification
.addParentChild(parent
, taxon
, sec
, null);
182 taxon
.addSource(String
.valueOf(taxonId
), "NCUGenID", sec
, null);
186 objectsToSave
.add(taxon
);
190 logger
.warn(pluralString
+ " to save: " + objectsToSave
.size());
191 getTaxonService().save(objectsToSave
);
194 } catch (SQLException e
) {
195 logger
.error("SQLException:" + e
);
200 private void handleBasionym(CaryoImportState state
, ResultSet rs
, Taxon taxon
, String basioStr
, Integer id
) {
201 if (StringUtils
.isNotBlank(basioStr
)){
202 BotanicalName name
= (BotanicalName
) taxon
.getName();
203 BotanicalName basionym
= BotanicalName
.PARSED_REFERENCE(basioStr
);
204 if (basionym
.hasProblem()){
205 logger
.warn("Problem when parsing basionym ("+id
+"): " + basioStr
);
207 name
.addBasionym(basionym
);
208 Synonym syn
= Synonym
.NewInstance(basionym
, state
.getTransactionalSourceReference());
209 taxon
.addSynonym(syn
, SynonymRelationshipType
.HOMOTYPIC_SYNONYM_OF());
210 getTaxonService().save(syn
);
218 private void handleTypes(CaryoImportState state
, ResultSet rs
, Taxon taxon
, String origType
, Integer id
) {
219 NameTypeDesignation desig
= NameTypeDesignation
.NewInstance();
220 String type
= origType
;
221 if (StringUtils
.isBlank(type
) || "to be designated".equalsIgnoreCase(type
)){
224 BotanicalName name
= (BotanicalName
)taxon
.getName();
225 BotanicalName typeName
= BotanicalName
.NewInstance(Rank
.SPECIES());
226 if ("not designated".equalsIgnoreCase(type
)){
227 desig
.setNotDesignated(true);
229 String genus
= name
.getGenusOrUninomial();
230 typeName
.setGenusOrUninomial(genus
);
231 if (! type
.startsWith(genus
.substring(0,1) + ". " )){
232 int i
= type
.indexOf(" ");
233 String genusOrig
= type
.substring(0, i
);
234 logger
.info("First genus letter not recognized: " + genusOrig
+ "-" + genus
+ ":"+ id
);
235 typeName
.setGenusOrUninomial(genusOrig
);
236 type
= type
.substring(i
+ 1).trim();
238 type
= type
.substring(3);
240 int i
= type
.indexOf(" ");
242 logger
.warn("No space: " + type
+"; " + id
);
244 String species
= type
.substring(0, i
);
245 typeName
.setSpecificEpithet(species
);
246 type
= type
.substring(i
+ 1).trim();
248 int posBracket
= type
.indexOf("(", 2);
250 String bracket
= type
.substring(posBracket
);
251 // logger.warn("Type has bracket("+id+"): " + bracket);
252 taxon
.addAnnotation(Annotation
.NewInstance("Type-bracket: " + bracket
, Language
.DEFAULT()));
253 type
= type
.substring(0, posBracket
).trim();
255 Taxon speciesTaxon
= Taxon
.NewInstance(typeName
, state
.getTransactionalSourceReference());
256 classification
.addParentChild(taxon
, speciesTaxon
, null, null);
258 type
= makeTypeNomStatus(typeName
, type
);
261 makeAuthors(typeName
, type
, id
);
264 desig
.setTypeName(typeName
);
266 name
.addTypeDesignation(desig
, true);
275 private String
makeTypeNomStatus(BotanicalName typeName
, String type
) {
276 if (type
.endsWith(", nom. illeg.")){
277 type
= type
.replaceAll(", nom. illeg.", "");
278 typeName
.addStatus(NomenclaturalStatus
.NewInstance(NomenclaturalStatusType
.ILLEGITIMATE()));
286 private void makeStatus(BotanicalName name
, String nomStatusStr
, Integer id
) throws SQLException
{
287 // ,[NomenclaturalStatus]
289 if (StringUtils
.isNotBlank(nomStatusStr
)){
290 NomenclaturalStatusType nomStatusType
;
292 nomStatusType
= NomenclaturalStatusType
.getNomenclaturalStatusTypeByAbbreviation(nomStatusStr
);
293 } catch (UnknownCdmTypeException e
) {
294 if (nomStatusStr
.startsWith("nom. rej. prop.")){
295 nomStatusType
= NomenclaturalStatusType
.REJECTED_PROP();
296 logger
.info("in favour not supported ("+id
+"): " + nomStatusStr
);
297 }else if (nomStatusStr
.startsWith("nom. rej. in favour")){
298 nomStatusType
= NomenclaturalStatusType
.REJECTED();
299 logger
.info("in favour not supported ("+id
+"): " + nomStatusStr
);
300 }else if (nomStatusStr
.startsWith("nom. cons. against")){
301 nomStatusType
= NomenclaturalStatusType
.CONSERVED();
302 logger
.info("against not supported ("+id
+"): " + nomStatusStr
);
303 }else if (nomStatusStr
.startsWith("nom. cons. prop. against")){
304 nomStatusType
= NomenclaturalStatusType
.CONSERVED_PROP();
305 logger
.info("against not supported ("+id
+"): " + nomStatusStr
);
307 logger
.warn("Unknown status type ("+id
+"): " + nomStatusStr
);
308 nomStatusType
= NomenclaturalStatusType
.DOUBTFUL();
312 NomenclaturalStatus status
= NomenclaturalStatus
.NewInstance(nomStatusType
);
313 name
.addStatus(status
);
321 private INomenclaturalReference
makeNomRef(CaryoImportState state
, ResultSet rs
, Integer id
) throws SQLException
{
322 INomenclaturalReference result
;
323 String periodicalTitle
= rs
.getString("PeriodicalTitle");
324 String volume
= rs
.getString("PeriodicalVolume");
325 String bookTitle
= rs
.getString("BookTitle");
326 String inAutorStr
= rs
.getString("InAutor");
327 String autorenStr
= rs
.getString("Autoren");
329 TeamOrPersonBase
<?
> author
= getNomRefAuthor(autorenStr
, id
);
330 if (StringUtils
.isNotBlank(periodicalTitle
)){
331 IJournal journal
= journalMap
.get(periodicalTitle
);
332 if (journal
== null){
333 logger
.warn("Journal not found: " + periodicalTitle
+ ";" + id
);
335 IArticle article
= ReferenceFactory
.newArticle();
336 article
.setInJournal(journal
);
337 article
.setVolume(volume
);
339 }else if (StringUtils
.isNotBlank(bookTitle
)){
340 IBook book
= bookMap
.get(bookTitle
);
341 if (inAutorStr
!= null){
342 IBookSection section
= ReferenceFactory
.newBookSection();
343 section
.setInBook(book
);
344 TeamOrPersonBase
<?
> inAuthor
= getInAuthor(inAutorStr
);
345 book
.setAuthorTeam(inAuthor
);
351 logger
.warn("No nomRef found: " + id
);
355 result
.setAuthorTeam(author
);
356 makeDate(state
, rs
, result
, id
);
361 private void makeDate(CaryoImportState state
, ResultSet rs
, INomenclaturalReference ref
, Integer id
) throws SQLException
{
362 TimePeriod tp
= TimePeriod
.NewInstance();
363 String pre1
= rs
.getString("DatePre1");
364 String pre2
= rs
.getString("DatePre2");
365 Float year1
= nullSafeFloat(rs
, "DateYear1");
366 Float year2
= nullSafeFloat(rs
, "DateYear2");
370 String modi1
= rs
.getString("DateModi1");
371 String modi2
= rs
.getString("DateModi2");
372 String date
= rs
.getString("Date");
374 tp
.setStartYear(year1
.intValue());
375 Integer
[] preDate1
= getDay(pre1
,id
);
376 // tp.setStartMonth(preDate1[1]);
377 // tp.setStartDay(preDate1[0]);
379 tp
.setEndYear(year2
.intValue());
381 Integer
[] preDate2
= getDay(pre2
, id
);
382 // tp.setEndMonth(preDate2[1]);
383 // tp.setEndDay(preDate2[0]);
385 // if (StringUtils.isNotBlank(modi1) || StringUtils.isNotBlank(modi2)){
386 // tp.setFreeText(date);
388 ref
.setDatePublished(tp
);
394 private Integer
[] getDay(String pre
, Integer id
) {
395 Integer
[] result
= new Integer
[2];
396 if (! StringUtils
.isBlank(pre
)){
398 String
[] split
= pre
.split("\\s");
400 if (split
.length
> 2){
401 logger
.warn("L > 2: " + pre
);
403 }else if(split
.length
== 2){
404 result
[0] = Integer
.valueOf(split
[0]);
410 if ("Jan".equalsIgnoreCase(monthStr
)){
412 }else if ("Feb".equalsIgnoreCase(monthStr
)){
414 }else if ("Mar".equalsIgnoreCase(monthStr
)){
416 }else if ("Apr".equalsIgnoreCase(monthStr
)){
418 }else if ("Mai".equalsIgnoreCase(monthStr
)){
420 }else if ("Jun".equalsIgnoreCase(monthStr
)){
422 }else if ("Jul".equalsIgnoreCase(monthStr
)){
424 }else if ("Aug".equalsIgnoreCase(monthStr
)){
426 }else if ("Sep".equalsIgnoreCase(monthStr
)){
428 }else if ("Oct".equalsIgnoreCase(monthStr
)){
430 }else if ("Nov".equalsIgnoreCase(monthStr
)){
432 }else if ("Dec".equalsIgnoreCase(monthStr
)){
435 logger
.warn("Unknown month ("+id
+"): " + monthStr
);
439 } catch (Exception e
) {
447 private TeamOrPersonBase
<?
> getInAuthor(String inAutorStr
) {
448 if (StringUtils
.isBlank(inAutorStr
)){
451 TeamOrPersonBase
<?
> inAuthor
= inAuthorMap
.get(inAutorStr
);
452 if (inAuthor
== null){
453 logger
.warn("Inauthor not found: " + inAutorStr
);
460 private void makeAuthors(BotanicalName name
, String autoren
, Integer id
) {
461 String
[] parsedAuthorTeams
= getParsedAuthors(autoren
);
462 name
.setBasionymAuthorTeam(getTeam(parsedAuthorTeams
[0], id
));
463 name
.setExBasionymAuthorTeam(getTeam(parsedAuthorTeams
[1], id
));
464 name
.setCombinationAuthorTeam(getTeam(parsedAuthorTeams
[2], id
));
465 name
.setExCombinationAuthorTeam(getTeam(parsedAuthorTeams
[3], id
));
469 private TeamOrPersonBase
<?
> getNomRefAuthor(String authorStr
, Integer id
) {
470 String
[] parsedAuthorTeams
= getParsedAuthors(authorStr
);
471 TeamOrPersonBase
<?
> team
= getTeam(parsedAuthorTeams
[2], id
);
476 private TeamOrPersonBase
<?
> getTeam(String author
, Integer id
) {
477 if (StringUtils
.isBlank(author
)){
480 TeamOrPersonBase
<?
> result
;
481 if (personMap
.get(author
) != null){
482 result
= personMap
.get(author
);
484 result
= teamMap
.get(author
);
487 logger
.warn("Team not found ("+id
+"): " + author
);
493 private void doInAuthors(CaryoImportState state
) throws SQLException
{
494 Source source
= state
.getConfig().getSource();
495 String sql
= "SELECT DISTINCT inAutor FROM " + getTableName() + " WHERE inAutor IS NOT NULL AND inAutor <> '' ";
496 ResultSet rs
= source
.getResultSet(sql
);
498 String inAutorStr
= rs
.getString("inAutor");
499 if (inAuthorMap
.get(inAutorStr
) == null){
500 Team team
= Team
.NewTitledInstance(inAutorStr
, inAutorStr
);
502 inAuthorMap
.put(inAutorStr
, team
);
503 getAgentService().save(team
);
510 private void doAuthors(CaryoImportState state
) throws SQLException
{
511 Source source
= state
.getConfig().getSource();
512 String sql
= "SELECT DISTINCT Autoren FROM " + getTableName() + " WHERE Autoren IS NOT NULL AND Autoren <> '' ";
513 ResultSet rs
= source
.getResultSet(sql
);
514 doTypeAuthors(state
);
516 String autorenStr
= rs
.getString("Autoren");
517 String
[] parsedAuthorTeams
= getParsedAuthors(autorenStr
);
518 for (String teamStr
: parsedAuthorTeams
){
527 private void doTypeAuthors(CaryoImportState state
) {
528 doTeam("Dinter & Derenb.");
534 doTeam("Dinter & A. Berger");
536 doTeam("Dinter & Berger");
538 doTeam("J. C. Wendl.");
539 doTeam("Baker & Clarke");
550 doTeam("Moq. & Coss.");
551 doTeam("Durieu & Moq.");
552 doTeam("Lag. & Rodrigues");
553 doTeam("M. Martens & Galeotti");
555 doTeam("Aitch. & Hemsl.");
556 doTeam("Ikonn.-Gal.");
572 doTeam("Werderm. & Backeb.");
577 doTeam("Rol.-Goss.");
579 doTeam("Andreae & Backeberg");
582 doTeam("Backeb. & Voll");
583 doTeam("Engelm. & Bigelow");
584 doTeam("Pfeiffer & Otto");
585 doTeam("Humb. & Bonpl.");
590 doTeam("Regel & Schmalh.");
592 doTeam("Pax & K. Hoff.");
597 doTeam("Schott, Nymann & Kotschy");
598 doTeam("Boiss. & Buhse");
600 doTeam("Coss. & Germ.");
602 doTeam("Pax & Hoffm.");
618 protected void doTeam(String teamStr
) {
619 if (StringUtils
.isBlank(teamStr
)){
622 String
[] parsedTeam
= parseTeam(teamStr
);
623 if (parsedTeam
.length
== 1){
624 savePerson(parsedTeam
[0]);
626 Team team
= teamMap
.get(teamStr
);
628 team
= Team
.NewInstance();
629 for (String member
: parsedTeam
){
630 Person person
= savePerson(member
);
631 team
.addTeamMember(person
);
633 teamMap
.put(teamStr
, team
);
634 getAgentService().saveOrUpdate(team
);
640 private String
[] parseTeam(String teamStr
) {
641 String
[] split
= teamStr
.split("[&,]");
642 for (int i
= 0; i
< split
.length
; i
++){
643 split
[i
] = split
[i
].trim();
648 private Person
savePerson(String personStr
) {
649 Person result
= personMap
.get(personStr
);
650 if (result
== null ){
651 Person person
= Person
.NewTitledInstance(personStr
);
652 personMap
.put(personStr
, person
);
653 getAgentService().save(person
);
662 private String
[] getParsedAuthors(String autorenStr
) {
663 String
[] result
= new String
[4];
664 String basioFull
= null;
667 String
[] split
= autorenStr
.split("\\)");
668 if (split
.length
> 1){
669 basioFull
= split
[0].replace("(", "").trim();
670 origFull
= split
[1].trim();
672 origFull
= split
[0].trim();
674 String
[] splitBasio
= splitExAuthors(basioFull
);
675 String
[] splitOrig
= splitExAuthors(origFull
);
676 result
[0] = splitBasio
[0];
677 result
[1] = splitBasio
[1];
678 result
[2] = splitOrig
[0];
679 result
[3] = splitOrig
[1];
687 private String
[] splitExAuthors(String author
) {
688 String
[] result
= new String
[2];
690 String
[] split
= author
.split("\\sex\\s");
691 if (split
.length
> 1){
692 result
[0] = split
[1].trim();
693 result
[1] = split
[0].trim();
695 result
[0] = split
[0].trim();
704 private void doBooks(CaryoImportState state
) throws SQLException
{
705 Source source
= state
.getConfig().getSource();
706 String sql
= "SELECT DISTINCT BookTitle FROM " + getTableName() + " WHERE BookTitle IS NOT NULL AND BookTitle <> '' ";
707 ResultSet rs
= source
.getResultSet(sql
);
709 String bookStr
= rs
.getString("BookTitle");
710 if (bookMap
.get(bookStr
) == null ){
712 IBook book
= ReferenceFactory
.newBook();
714 book
.setTitle(bookStr
);
716 bookMap
.put(bookStr
, book
);
717 getReferenceService().save((Reference
<?
>)book
);
725 private void doJournals(CaryoImportState state
) throws SQLException
{
726 Source source
= state
.getConfig().getSource();
727 String sqlPeriodical
= "SELECT DISTINCT PeriodicalTitle FROM " + getTableName() + " WHERE PeriodicalTitle IS NOT NULL AND PeriodicalTitle <> '' ";
728 ResultSet rs
= source
.getResultSet(sqlPeriodical
);
730 String periodical
= rs
.getString("PeriodicalTitle");
731 if (journalMap
.get(periodical
) == null ){
733 Reference
<?
> journal
= ReferenceFactory
.newJournal();
735 journal
.setTitle(periodical
);
737 journalMap
.put(periodical
, journal
);
738 getReferenceService().save(journal
);
746 private void doFamilies(CaryoImportState state
) throws SQLException
{
747 Source source
= state
.getConfig().getSource();
748 String sqlFamily
= "SELECT DISTINCT Family FROM " + getTableName() + " WHERE Family IS NOT NULL";
749 ResultSet rs
= source
.getResultSet(sqlFamily
);
751 String family
= rs
.getString("family");
752 if (familyMap
.get(family
) == null ){
754 BotanicalName name
= BotanicalName
.NewInstance(Rank
.FAMILY());
755 name
.setGenusOrUninomial(family
);
756 Taxon taxon
= Taxon
.NewInstance(name
, state
.getTransactionalSourceReference());
757 classification
.addChildTaxon(taxon
, null, null, null);
758 // taxon.addSource(id, idNamespace, citation, null);
760 familyMap
.put(family
, taxon
);
761 getTaxonService().save(taxon
);
767 private Classification
getClassification(CaryoImportState state
) {
768 if (this.classification
== null){
769 String name
= state
.getConfig().getClassificationName();
770 Reference
<?
> reference
= state
.getTransactionalSourceReference();
771 this.classification
= Classification
.NewInstance(name
, reference
, Language
.DEFAULT());
772 if (state
.getConfig().getClassificationUuid() != null){
773 classification
.setUuid(state
.getConfig().getClassificationUuid());
775 getClassificationService().save(classification
);
777 return this.classification
;
785 * @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet)
787 public Map
<Object
, Map
<String
, ?
extends CdmBase
>> getRelatedObjectsForPartition(ResultSet rs
) {
790 // Set<String> idSet;
791 Map
<Object
, Map
<String
, ?
extends CdmBase
>> result
= new HashMap
<Object
, Map
<String
, ?
extends CdmBase
>>();
793 // Set<String> taxonIdSet = new HashSet<String>();
795 // while (rs.next()){
796 //// handleForeignKey(rs, taxonIdSet, "taxonId");
800 // nameSpace = TAXON_NAMESPACE;
801 // cdmClass = Taxon.class;
802 // idSet = taxonIdSet;
803 // Map<String, Taxon> objectMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
804 // result.put(nameSpace, objectMap);
807 // } catch (SQLException e) {
808 // throw new RuntimeException(e);
814 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator)
817 protected boolean doCheck(CaryoImportState state
){
823 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
825 protected boolean isIgnore(CaryoImportState state
){
826 return ! state
.getConfig().isDoTaxa();