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
.OriginalSourceType
;
33 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
34 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
35 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
36 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
37 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
38 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
39 import eu
.etaxonomy
.cdm
.model
.reference
.IArticle
;
40 import eu
.etaxonomy
.cdm
.model
.reference
.IBook
;
41 import eu
.etaxonomy
.cdm
.model
.reference
.IBookSection
;
42 import eu
.etaxonomy
.cdm
.model
.reference
.IJournal
;
43 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
44 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
45 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
46 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
47 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
48 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
49 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
50 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
51 import eu
.etaxonomy
.cdm
.strategy
.cache
.name
.BotanicNameDefaultCacheStrategy
;
52 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
53 import eu
.etaxonomy
.cdm
.strategy
.parser
.INonViralNameParser
;
54 import eu
.etaxonomy
.cdm
.strategy
.parser
.NonViralNameParserImpl
;
63 public class CaryoTaxonImport
extends DbImportBase
<CaryoImportState
, CaryoImportConfigurator
> {
64 private static final Logger logger
= Logger
.getLogger(CaryoTaxonImport
.class);
66 private int modCount
= 10000;
67 private static final String pluralString
= "taxa";
68 private static final String dbTableName
= "CARYOPHYLLALES";
72 private Map
<String
, Taxon
> familyMap
= new HashMap
<String
, Taxon
>();
73 private Map
<String
, Person
> personMap
= new HashMap
<String
, Person
>();
74 private Map
<String
, Team
> teamMap
= new HashMap
<String
, Team
>();
75 private Map
<String
, TeamOrPersonBase
> inAuthorMap
= new HashMap
<String
, TeamOrPersonBase
>();
76 private Map
<String
, IJournal
> journalMap
= new HashMap
<String
, IJournal
>();
77 private Map
<String
, IBook
> bookMap
= new HashMap
<String
, IBook
>();
80 private Classification classification
;
84 public CaryoTaxonImport(){
85 super(dbTableName
, pluralString
);
92 * @see eu.etaxonomy.cdm.io.common.DbImportBase#getIdQuery(eu.etaxonomy.cdm.io.common.DbImportStateBase)
95 protected String
getIdQuery(CaryoImportState state
) {
96 String strRecordQuery
=
98 " FROM " + dbTableName
+
100 return strRecordQuery
;
105 * @see eu.etaxonomy.cdm.io.common.DbImportBase#getRecordQuery(eu.etaxonomy.cdm.io.common.DbImportConfiguratorBase)
108 protected String
getRecordQuery(CaryoImportConfigurator config
) {
109 String strRecordQuery
=
111 " FROM " + getTableName() + " t " +
112 " WHERE ( t.ID IN (" + ID_LIST_TOKEN
+ ") )";
113 return strRecordQuery
;
119 * @see eu.etaxonomy.cdm.io.globis.GlobisImportBase#doPartition(eu.etaxonomy.cdm.io.common.ResultSetPartitioner, eu.etaxonomy.cdm.io.globis.GlobisImportState)
122 public boolean doPartition(ResultSetPartitioner partitioner
, CaryoImportState state
) {
123 boolean success
= true;
125 Set
<TaxonBase
> objectsToSave
= new HashSet
<TaxonBase
>();
127 // Map<String, Taxon> taxonMap = (Map<String, Taxon>) partitioner.getObjectMap(TAXON_NAMESPACE);
130 classification
= getClassification(state
);
139 ResultSet rs
= partitioner
.getResultSet();
142 Reference
<?
> sec
= state
.getTransactionalSourceReference();
147 if ((i
++ % modCount
) == 0 && i
!= 1 ){ logger
.info(pluralString
+ " handled: " + (i
-1));}
149 Integer id
= rs
.getInt("Id");
150 Integer taxonId
= rs
.getInt("NCUGenID");
151 String genus
= rs
.getString("Genus");
152 String family
= rs
.getString("Family");
153 String pages
= rs
.getString("Pages");
154 String autoren
= rs
.getString("Autoren");
155 String typeStr
= rs
.getString("Type");
156 String nomStatusStr
= rs
.getString("NomenclaturalStatus");
157 String basioStr
= rs
.getString("Basionym");
163 // ,[OriginalCitation]
166 BotanicalName name
= BotanicalName
.NewInstance(Rank
.GENUS());
167 name
.setGenusOrUninomial(genus
);
168 makeAuthors(name
, autoren
, id
);
169 INomenclaturalReference nomRef
= makeNomRef(state
, rs
, id
);
170 name
.setNomenclaturalReference(nomRef
);
171 name
.setNomenclaturalMicroReference(pages
);
172 makeStatus(name
, nomStatusStr
, id
);
175 Taxon taxon
= Taxon
.NewInstance(name
, state
.getTransactionalSourceReference());
176 handleTypes(state
, rs
, taxon
, typeStr
, id
);
177 handleBasionym(state
, rs
, taxon
, basioStr
, id
);
179 Taxon parent
= familyMap
.get(family
);
181 classification
.addParentChild(parent
, taxon
, sec
, null);
183 taxon
.addSource(OriginalSourceType
.Import
, String
.valueOf(taxonId
), "NCUGenID", sec
, null);
187 objectsToSave
.add(taxon
);
191 logger
.warn(pluralString
+ " to save: " + objectsToSave
.size());
192 getTaxonService().save(objectsToSave
);
195 } catch (SQLException e
) {
196 logger
.error("SQLException:" + e
);
201 private void handleBasionym(CaryoImportState state
, ResultSet rs
, Taxon taxon
, String basioStr
, Integer id
) {
202 if (StringUtils
.isNotBlank(basioStr
)){
203 BotanicalName name
= (BotanicalName
) taxon
.getName();
204 BotanicalName basionym
= BotanicalName
.PARSED_REFERENCE(basioStr
);
205 if (basionym
.hasProblem()){
206 logger
.warn("Problem when parsing basionym ("+id
+"): " + basioStr
);
208 name
.addBasionym(basionym
);
209 Synonym syn
= Synonym
.NewInstance(basionym
, state
.getTransactionalSourceReference());
210 taxon
.addSynonym(syn
, SynonymRelationshipType
.HOMOTYPIC_SYNONYM_OF());
211 getTaxonService().save(syn
);
219 private void handleTypes(CaryoImportState state
, ResultSet rs
, Taxon taxon
, String origType
, Integer id
) {
220 NameTypeDesignation desig
= NameTypeDesignation
.NewInstance();
221 String type
= origType
;
222 if (StringUtils
.isBlank(type
) || "to be designated".equalsIgnoreCase(type
)){
225 BotanicalName name
= (BotanicalName
)taxon
.getName();
226 BotanicalName typeName
= BotanicalName
.NewInstance(Rank
.SPECIES());
227 if ("not designated".equalsIgnoreCase(type
)){
228 desig
.setNotDesignated(true);
230 String genus
= name
.getGenusOrUninomial();
231 typeName
.setGenusOrUninomial(genus
);
232 if (! type
.startsWith(genus
.substring(0,1) + ". " )){
233 int i
= type
.indexOf(" ");
234 String genusOrig
= type
.substring(0, i
);
235 logger
.info("First genus letter not recognized: " + genusOrig
+ "-" + genus
+ ":"+ id
);
236 typeName
.setGenusOrUninomial(genusOrig
);
237 type
= type
.substring(i
+ 1).trim();
239 type
= type
.substring(3);
241 int i
= type
.indexOf(" ");
243 logger
.warn("No space: " + type
+"; " + id
);
245 String species
= type
.substring(0, i
);
246 typeName
.setSpecificEpithet(species
);
247 type
= type
.substring(i
+ 1).trim();
249 int posBracket
= type
.indexOf("(", 2);
251 String bracket
= type
.substring(posBracket
);
252 // logger.warn("Type has bracket("+id+"): " + bracket);
253 taxon
.addAnnotation(Annotation
.NewInstance("Type-bracket: " + bracket
, Language
.DEFAULT()));
254 type
= type
.substring(0, posBracket
).trim();
256 Taxon speciesTaxon
= Taxon
.NewInstance(typeName
, state
.getTransactionalSourceReference());
257 classification
.addParentChild(taxon
, speciesTaxon
, null, null);
259 type
= makeTypeNomStatus(typeName
, type
);
262 makeAuthors(typeName
, type
, id
);
265 desig
.setTypeName(typeName
);
267 name
.addTypeDesignation(desig
, true);
276 private String
makeTypeNomStatus(BotanicalName typeName
, String type
) {
277 if (type
.endsWith(", nom. illeg.")){
278 type
= type
.replaceAll(", nom. illeg.", "");
279 typeName
.addStatus(NomenclaturalStatus
.NewInstance(NomenclaturalStatusType
.ILLEGITIMATE()));
287 private void makeStatus(BotanicalName name
, String nomStatusStr
, Integer id
) throws SQLException
{
288 // ,[NomenclaturalStatus]
290 if (StringUtils
.isNotBlank(nomStatusStr
)){
291 NomenclaturalStatusType nomStatusType
;
293 nomStatusType
= NomenclaturalStatusType
.getNomenclaturalStatusTypeByAbbreviation(nomStatusStr
);
294 } catch (UnknownCdmTypeException e
) {
295 if (nomStatusStr
.startsWith("nom. rej. prop.")){
296 nomStatusType
= NomenclaturalStatusType
.REJECTED_PROP();
297 logger
.info("in favour not supported ("+id
+"): " + nomStatusStr
);
298 }else if (nomStatusStr
.startsWith("nom. rej. in favour")){
299 nomStatusType
= NomenclaturalStatusType
.REJECTED();
300 logger
.info("in favour not supported ("+id
+"): " + nomStatusStr
);
301 }else if (nomStatusStr
.startsWith("nom. cons. against")){
302 nomStatusType
= NomenclaturalStatusType
.CONSERVED();
303 logger
.info("against not supported ("+id
+"): " + nomStatusStr
);
304 }else if (nomStatusStr
.startsWith("nom. cons. prop. against")){
305 nomStatusType
= NomenclaturalStatusType
.CONSERVED_PROP();
306 logger
.info("against not supported ("+id
+"): " + nomStatusStr
);
308 logger
.warn("Unknown status type ("+id
+"): " + nomStatusStr
);
309 nomStatusType
= NomenclaturalStatusType
.DOUBTFUL();
313 NomenclaturalStatus status
= NomenclaturalStatus
.NewInstance(nomStatusType
);
314 name
.addStatus(status
);
322 private INomenclaturalReference
makeNomRef(CaryoImportState state
, ResultSet rs
, Integer id
) throws SQLException
{
323 INomenclaturalReference result
;
324 String periodicalTitle
= rs
.getString("PeriodicalTitle");
325 String volume
= rs
.getString("PeriodicalVolume");
326 String bookTitle
= rs
.getString("BookTitle");
327 String inAutorStr
= rs
.getString("InAutor");
328 String autorenStr
= rs
.getString("Autoren");
330 TeamOrPersonBase
<?
> author
= getNomRefAuthor(autorenStr
, id
);
331 if (StringUtils
.isNotBlank(periodicalTitle
)){
332 IJournal journal
= journalMap
.get(periodicalTitle
);
333 if (journal
== null){
334 logger
.warn("Journal not found: " + periodicalTitle
+ ";" + id
);
336 IArticle article
= ReferenceFactory
.newArticle();
337 article
.setInJournal(journal
);
338 article
.setVolume(volume
);
340 }else if (StringUtils
.isNotBlank(bookTitle
)){
341 IBook book
= bookMap
.get(bookTitle
);
342 if (inAutorStr
!= null){
343 IBookSection section
= ReferenceFactory
.newBookSection();
344 section
.setInBook(book
);
345 TeamOrPersonBase
<?
> inAuthor
= getInAuthor(inAutorStr
);
346 book
.setAuthorTeam(inAuthor
);
352 logger
.warn("No nomRef found: " + id
);
356 result
.setAuthorTeam(author
);
357 makeDate(state
, rs
, result
, id
);
362 private void makeDate(CaryoImportState state
, ResultSet rs
, INomenclaturalReference ref
, Integer id
) throws SQLException
{
363 TimePeriod tp
= TimePeriod
.NewInstance();
364 String pre1
= rs
.getString("DatePre1");
365 String pre2
= rs
.getString("DatePre2");
366 Float year1
= nullSafeFloat(rs
, "DateYear1");
367 Float year2
= nullSafeFloat(rs
, "DateYear2");
371 String modi1
= rs
.getString("DateModi1");
372 String modi2
= rs
.getString("DateModi2");
373 String date
= rs
.getString("Date");
375 tp
.setStartYear(year1
.intValue());
376 Integer
[] preDate1
= getDay(pre1
,id
);
377 // tp.setStartMonth(preDate1[1]);
378 // tp.setStartDay(preDate1[0]);
380 tp
.setEndYear(year2
.intValue());
382 Integer
[] preDate2
= getDay(pre2
, id
);
383 // tp.setEndMonth(preDate2[1]);
384 // tp.setEndDay(preDate2[0]);
386 // if (StringUtils.isNotBlank(modi1) || StringUtils.isNotBlank(modi2)){
387 // tp.setFreeText(date);
389 ref
.setDatePublished(tp
);
395 private Integer
[] getDay(String pre
, Integer id
) {
396 Integer
[] result
= new Integer
[2];
397 if (! StringUtils
.isBlank(pre
)){
399 String
[] split
= pre
.split("\\s");
401 if (split
.length
> 2){
402 logger
.warn("L > 2: " + pre
);
404 }else if(split
.length
== 2){
405 result
[0] = Integer
.valueOf(split
[0]);
411 if ("Jan".equalsIgnoreCase(monthStr
)){
413 }else if ("Feb".equalsIgnoreCase(monthStr
)){
415 }else if ("Mar".equalsIgnoreCase(monthStr
)){
417 }else if ("Apr".equalsIgnoreCase(monthStr
)){
419 }else if ("Mai".equalsIgnoreCase(monthStr
)){
421 }else if ("Jun".equalsIgnoreCase(monthStr
)){
423 }else if ("Jul".equalsIgnoreCase(monthStr
)){
425 }else if ("Aug".equalsIgnoreCase(monthStr
)){
427 }else if ("Sep".equalsIgnoreCase(monthStr
)){
429 }else if ("Oct".equalsIgnoreCase(monthStr
)){
431 }else if ("Nov".equalsIgnoreCase(monthStr
)){
433 }else if ("Dec".equalsIgnoreCase(monthStr
)){
436 logger
.warn("Unknown month ("+id
+"): " + monthStr
);
440 } catch (Exception e
) {
448 private TeamOrPersonBase
<?
> getInAuthor(String inAutorStr
) {
449 if (StringUtils
.isBlank(inAutorStr
)){
452 TeamOrPersonBase
<?
> inAuthor
= inAuthorMap
.get(inAutorStr
);
453 if (inAuthor
== null){
454 logger
.warn("Inauthor not found: " + inAutorStr
);
461 private void makeAuthors(BotanicalName name
, String autoren
, Integer id
) {
462 String
[] parsedAuthorTeams
= getParsedAuthors(autoren
);
463 name
.setBasionymAuthorTeam(getTeam(parsedAuthorTeams
[0], id
));
464 name
.setExBasionymAuthorTeam(getTeam(parsedAuthorTeams
[1], id
));
465 name
.setCombinationAuthorTeam(getTeam(parsedAuthorTeams
[2], id
));
466 name
.setExCombinationAuthorTeam(getTeam(parsedAuthorTeams
[3], id
));
470 private TeamOrPersonBase
<?
> getNomRefAuthor(String authorStr
, Integer id
) {
471 String
[] parsedAuthorTeams
= getParsedAuthors(authorStr
);
472 TeamOrPersonBase
<?
> team
= getTeam(parsedAuthorTeams
[2], id
);
477 private TeamOrPersonBase
<?
> getTeam(String author
, Integer id
) {
478 if (StringUtils
.isBlank(author
)){
481 TeamOrPersonBase
<?
> result
;
482 if (personMap
.get(author
) != null){
483 result
= personMap
.get(author
);
485 result
= teamMap
.get(author
);
488 logger
.warn("Team not found ("+id
+"): " + author
);
494 private void doInAuthors(CaryoImportState state
) throws SQLException
{
495 Source source
= state
.getConfig().getSource();
496 String sql
= "SELECT DISTINCT inAutor FROM " + getTableName() + " WHERE inAutor IS NOT NULL AND inAutor <> '' ";
497 ResultSet rs
= source
.getResultSet(sql
);
499 String inAutorStr
= rs
.getString("inAutor");
500 if (inAuthorMap
.get(inAutorStr
) == null){
501 Team team
= Team
.NewTitledInstance(inAutorStr
, inAutorStr
);
503 inAuthorMap
.put(inAutorStr
, team
);
504 getAgentService().save(team
);
511 private void doAuthors(CaryoImportState state
) throws SQLException
{
512 Source source
= state
.getConfig().getSource();
513 String sql
= "SELECT DISTINCT Autoren FROM " + getTableName() + " WHERE Autoren IS NOT NULL AND Autoren <> '' ";
514 ResultSet rs
= source
.getResultSet(sql
);
515 doTypeAuthors(state
);
517 String autorenStr
= rs
.getString("Autoren");
518 String
[] parsedAuthorTeams
= getParsedAuthors(autorenStr
);
519 for (String teamStr
: parsedAuthorTeams
){
528 private void doTypeAuthors(CaryoImportState state
) {
529 doTeam("Dinter & Derenb.");
535 doTeam("Dinter & A. Berger");
537 doTeam("Dinter & Berger");
539 doTeam("J. C. Wendl.");
540 doTeam("Baker & Clarke");
551 doTeam("Moq. & Coss.");
552 doTeam("Durieu & Moq.");
553 doTeam("Lag. & Rodrigues");
554 doTeam("M. Martens & Galeotti");
556 doTeam("Aitch. & Hemsl.");
557 doTeam("Ikonn.-Gal.");
573 doTeam("Werderm. & Backeb.");
578 doTeam("Rol.-Goss.");
580 doTeam("Andreae & Backeberg");
583 doTeam("Backeb. & Voll");
584 doTeam("Engelm. & Bigelow");
585 doTeam("Pfeiffer & Otto");
586 doTeam("Humb. & Bonpl.");
591 doTeam("Regel & Schmalh.");
593 doTeam("Pax & K. Hoff.");
598 doTeam("Schott, Nymann & Kotschy");
599 doTeam("Boiss. & Buhse");
601 doTeam("Coss. & Germ.");
603 doTeam("Pax & Hoffm.");
619 protected void doTeam(String teamStr
) {
620 if (StringUtils
.isBlank(teamStr
)){
623 String
[] parsedTeam
= parseTeam(teamStr
);
624 if (parsedTeam
.length
== 1){
625 savePerson(parsedTeam
[0]);
627 Team team
= teamMap
.get(teamStr
);
629 team
= Team
.NewInstance();
630 for (String member
: parsedTeam
){
631 Person person
= savePerson(member
);
632 team
.addTeamMember(person
);
634 teamMap
.put(teamStr
, team
);
635 getAgentService().saveOrUpdate(team
);
641 private String
[] parseTeam(String teamStr
) {
642 String
[] split
= teamStr
.split("[&,]");
643 for (int i
= 0; i
< split
.length
; i
++){
644 split
[i
] = split
[i
].trim();
649 private Person
savePerson(String personStr
) {
650 Person result
= personMap
.get(personStr
);
651 if (result
== null ){
652 Person person
= Person
.NewTitledInstance(personStr
);
653 personMap
.put(personStr
, person
);
654 getAgentService().save(person
);
663 private String
[] getParsedAuthors(String autorenStr
) {
664 String
[] result
= new String
[4];
665 String basioFull
= null;
668 String
[] split
= autorenStr
.split("\\)");
669 if (split
.length
> 1){
670 basioFull
= split
[0].replace("(", "").trim();
671 origFull
= split
[1].trim();
673 origFull
= split
[0].trim();
675 String
[] splitBasio
= splitExAuthors(basioFull
);
676 String
[] splitOrig
= splitExAuthors(origFull
);
677 result
[0] = splitBasio
[0];
678 result
[1] = splitBasio
[1];
679 result
[2] = splitOrig
[0];
680 result
[3] = splitOrig
[1];
688 private String
[] splitExAuthors(String author
) {
689 String
[] result
= new String
[2];
691 String
[] split
= author
.split("\\sex\\s");
692 if (split
.length
> 1){
693 result
[0] = split
[1].trim();
694 result
[1] = split
[0].trim();
696 result
[0] = split
[0].trim();
705 private void doBooks(CaryoImportState state
) throws SQLException
{
706 Source source
= state
.getConfig().getSource();
707 String sql
= "SELECT DISTINCT BookTitle FROM " + getTableName() + " WHERE BookTitle IS NOT NULL AND BookTitle <> '' ";
708 ResultSet rs
= source
.getResultSet(sql
);
710 String bookStr
= rs
.getString("BookTitle");
711 if (bookMap
.get(bookStr
) == null ){
713 IBook book
= ReferenceFactory
.newBook();
715 book
.setTitle(bookStr
);
717 bookMap
.put(bookStr
, book
);
718 getReferenceService().save((Reference
<?
>)book
);
726 private void doJournals(CaryoImportState state
) throws SQLException
{
727 Source source
= state
.getConfig().getSource();
728 String sqlPeriodical
= "SELECT DISTINCT PeriodicalTitle FROM " + getTableName() + " WHERE PeriodicalTitle IS NOT NULL AND PeriodicalTitle <> '' ";
729 ResultSet rs
= source
.getResultSet(sqlPeriodical
);
731 String periodical
= rs
.getString("PeriodicalTitle");
732 if (journalMap
.get(periodical
) == null ){
734 Reference
<?
> journal
= ReferenceFactory
.newJournal();
736 journal
.setTitle(periodical
);
738 journalMap
.put(periodical
, journal
);
739 getReferenceService().save(journal
);
747 private void doFamilies(CaryoImportState state
) throws SQLException
{
748 Source source
= state
.getConfig().getSource();
749 String sqlFamily
= "SELECT DISTINCT Family FROM " + getTableName() + " WHERE Family IS NOT NULL";
750 ResultSet rs
= source
.getResultSet(sqlFamily
);
752 String family
= rs
.getString("family");
753 if (familyMap
.get(family
) == null ){
755 BotanicalName name
= BotanicalName
.NewInstance(Rank
.FAMILY());
756 name
.setGenusOrUninomial(family
);
757 Taxon taxon
= Taxon
.NewInstance(name
, state
.getTransactionalSourceReference());
758 classification
.addChildTaxon(taxon
, null, null);
759 // taxon.addSource(id, idNamespace, citation, null);
761 familyMap
.put(family
, taxon
);
762 getTaxonService().save(taxon
);
768 private Classification
getClassification(CaryoImportState state
) {
769 if (this.classification
== null){
770 String name
= state
.getConfig().getClassificationName();
771 Reference
<?
> reference
= state
.getTransactionalSourceReference();
772 this.classification
= Classification
.NewInstance(name
, reference
, Language
.DEFAULT());
773 if (state
.getConfig().getClassificationUuid() != null){
774 classification
.setUuid(state
.getConfig().getClassificationUuid());
776 getClassificationService().save(classification
);
778 return this.classification
;
786 * @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet)
788 public Map
<Object
, Map
<String
, ?
extends CdmBase
>> getRelatedObjectsForPartition(ResultSet rs
) {
791 // Set<String> idSet;
792 Map
<Object
, Map
<String
, ?
extends CdmBase
>> result
= new HashMap
<Object
, Map
<String
, ?
extends CdmBase
>>();
794 // Set<String> taxonIdSet = new HashSet<String>();
796 // while (rs.next()){
797 //// handleForeignKey(rs, taxonIdSet, "taxonId");
801 // nameSpace = TAXON_NAMESPACE;
802 // cdmClass = Taxon.class;
803 // idSet = taxonIdSet;
804 // Map<String, Taxon> objectMap = (Map<String, Taxon>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
805 // result.put(nameSpace, objectMap);
808 // } catch (SQLException e) {
809 // throw new RuntimeException(e);
815 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator)
818 protected boolean doCheck(CaryoImportState state
){
824 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
826 protected boolean isIgnore(CaryoImportState state
){
827 return ! state
.getConfig().isDoTaxa();