commit 308d3755458352c6f72b450c896ee27af92f4efe
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Jul 15 13:26:57 2016 +0200

    #5448 Import families

diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportConfigurator.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportConfigurator.java
index c5a6c357..f8482bc3 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportConfigurator.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportConfigurator.java
@@ -36,6 +36,7 @@ public class RedListGefaesspflanzenImportConfigurator extends
     @Override
     protected void makeIoClassList() {
         ioClassList = new Class[]{
+                RedListGefaesspflanzenImportFamily.class,
                 RedListGefaesspflanzenImportAuthor.class,
                 RedListGefaesspflanzenImportNames.class,
                 RedListGefaesspflanzenImportClassification.class,
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportFamily.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportFamily.java
new file mode 100644
index 00000000..8ffe8a7e
--- /dev/null
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportFamily.java
@@ -0,0 +1,110 @@
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+
+package eu.etaxonomy.cdm.io.redlist.gefaesspflanzen;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.io.common.DbImportBase;
+import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.name.BotanicalName;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ *
+ * @author pplitzner
+ * @date Mar 1, 2016
+ *
+ */
+
+@Component
+@SuppressWarnings("serial")
+public class RedListGefaesspflanzenImportFamily extends DbImportBase<RedListGefaesspflanzenImportState, RedListGefaesspflanzenImportConfigurator> {
+
+    private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportFamily.class);
+
+    private static final String tableName = "Rote Liste Gefäßpflanzen";
+
+    private static final String pluralString = "families";
+
+
+    public RedListGefaesspflanzenImportFamily() {
+        super(tableName, pluralString);
+    }
+
+    @Override
+    protected String getIdQuery(RedListGefaesspflanzenImportState state) {
+        return null;
+    }
+
+    @Override
+    protected String getRecordQuery(RedListGefaesspflanzenImportConfigurator config) {
+        return null;
+    }
+
+    @Override
+    protected void doInvoke(RedListGefaesspflanzenImportState state) {
+        try {
+            importFamilies(state);
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void importFamilies(RedListGefaesspflanzenImportState state) throws SQLException {
+        Map<String, UUID> familyMap = new HashMap<>();
+
+        String query = "SELECT DISTINCT f.FAMILIE "
+                + " FROM V_TAXATLAS_D20_FAMILIEN f";
+
+        ResultSet rs = state.getConfig().getSource().getResultSet(query);
+        while(rs.next()){
+            String familieStr = rs.getString("FAMILIE");
+            BotanicalName name = BotanicalName.NewInstance(Rank.FAMILY());
+            name.setGenusOrUninomial(familieStr);
+            Taxon family = Taxon.NewInstance(name, null);
+            familyMap.put(familieStr, family.getUuid());
+            getTaxonService().saveOrUpdate(family);
+        }
+        state.setFamilyMap(familyMap);
+    }
+
+    @Override
+    public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) {
+        return true;
+    }
+
+    @Override
+    public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs,
+            RedListGefaesspflanzenImportState state) {
+        Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
+        return result;
+    }
+
+    @Override
+    protected boolean doCheck(RedListGefaesspflanzenImportState state) {
+        return false;
+    }
+
+    @Override
+    protected boolean isIgnore(RedListGefaesspflanzenImportState state) {
+        return false;
+    }
+
+}
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportState.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportState.java
index c2c97257..8fff1f67 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportState.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportState.java
@@ -29,6 +29,7 @@ public class RedListGefaesspflanzenImportState extends DbImportStateBase<RedList
 	private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportState.class);
 
 	private final Map<String, UUID> authorMap = new HashMap<String, UUID>();
+	private Map<String, UUID> familyMap = new HashMap<String, UUID>();
 	private UUID checklistClassificationUuid;
 
     protected RedListGefaesspflanzenImportState(RedListGefaesspflanzenImportConfigurator config) {
@@ -47,4 +48,12 @@ public class RedListGefaesspflanzenImportState extends DbImportStateBase<RedList
         return checklistClassificationUuid;
     }
 
+    public Map<String, UUID> getFamilyMap() {
+        return familyMap;
+    }
+
+    public void setFamilyMap(Map<String, UUID> familyMap) {
+        this.familyMap = familyMap;
+    }
+
 }
