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
.redlist
.gefaesspflanzen
;
12 import java
.sql
.ResultSet
;
13 import java
.sql
.SQLException
;
14 import java
.util
.Collection
;
15 import java
.util
.HashMap
;
16 import java
.util
.HashSet
;
18 import java
.util
.UUID
;
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
.model
.common
.CdmBase
;
26 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
27 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
39 @SuppressWarnings("serial")
40 public class RedListGefaesspflanzenImportFamily
extends DbImportBase
<RedListGefaesspflanzenImportState
, RedListGefaesspflanzenImportConfigurator
> {
42 private static final Logger logger
= Logger
.getLogger(RedListGefaesspflanzenImportFamily
.class);
44 private static final String tableName
= "Rote Liste Gefäßpflanzen";
46 private static final String pluralString
= "families";
49 public RedListGefaesspflanzenImportFamily() {
50 super(tableName
, pluralString
);
54 protected String
getIdQuery(RedListGefaesspflanzenImportState state
) {
59 protected String
getRecordQuery(RedListGefaesspflanzenImportConfigurator config
) {
64 protected void doInvoke(RedListGefaesspflanzenImportState state
) {
66 Collection
<TaxonBase
> families
= importFamilies(state
);
67 getTaxonService().saveOrUpdate(families
);
68 } catch (SQLException e
) {
74 private Collection
<TaxonBase
> importFamilies(RedListGefaesspflanzenImportState state
) throws SQLException
{
75 Collection
<TaxonBase
> families
= new HashSet
<TaxonBase
>();
76 Map
<String
, UUID
> familyMapGL
= new HashMap
<>();
77 Map
<String
, UUID
> familyMapCL
= new HashMap
<>();
79 String query
= "SELECT DISTINCT f.FAMILIE "
80 + " FROM GATTUNG_FAMILIE f";
82 ResultSet rs
= state
.getConfig().getSource().getResultSet(query
);
84 String familieStr
= rs
.getString("FAMILIE");
85 BotanicalName name
= BotanicalName
.NewInstance(Rank
.FAMILY());
86 name
.setGenusOrUninomial(familieStr
);
87 Taxon familyGL
= Taxon
.NewInstance(name
, null);
88 familyMapGL
.put(familieStr
, familyGL
.getUuid());
89 //clone for checkliste
90 Taxon familyCL
= Taxon
.NewInstance(name
, null);
91 familyMapCL
.put(familieStr
, familyCL
.getUuid());
93 families
.add(familyGL
);
94 families
.add(familyCL
);
96 state
.setFamilyMapGesamtListe(familyMapGL
);
97 state
.setFamilyMapCheckliste(familyMapCL
);
102 public boolean doPartition(ResultSetPartitioner partitioner
, RedListGefaesspflanzenImportState state
) {
107 public Map
<Object
, Map
<String
, ?
extends CdmBase
>> getRelatedObjectsForPartition(ResultSet rs
,
108 RedListGefaesspflanzenImportState state
) {
109 Map
<Object
, Map
<String
, ?
extends CdmBase
>> result
= new HashMap
<>();
114 protected boolean doCheck(RedListGefaesspflanzenImportState state
) {
119 protected boolean isIgnore(RedListGefaesspflanzenImportState state
) {