\r
import java.sql.ResultSet;\r
import java.sql.SQLException;\r
+import java.util.ArrayList;\r
import java.util.HashSet;\r
+import java.util.List;\r
import java.util.Map;\r
import java.util.Set;\r
\r
int countDescriptions = 0;\r
int countDistributions = 0;\r
//for each reference\r
- while (rs.next()){\r
- \r
- if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("Facts handled: " + (i-1));}\r
- \r
- int occurrenceId = rs.getInt("OccurrenceId");\r
- int newTaxonId = rs.getInt("RIdentifier");\r
- String tdwgCode = rs.getString("TDWGCode");\r
- Integer emStatusId = (Integer)rs.getObject("emOccurSumCatId");\r
- \r
- try {\r
- \r
- PresenceAbsenceTermBase<?> status = null;\r
- if (emStatusId != null){\r
- status = BerlinModelTransformer.occStatus2PresenceAbsence(emStatusId);\r
- }\r
- \r
- NamedArea tdwgArea = null;\r
- if (tdwgCode != null){\r
- tdwgArea = TdwgArea.getAreaByTdwgAbbreviation(tdwgCode.trim());\r
- }\r
- \r
- TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId);\r
- if (tdwgArea != null){\r
- Distribution distribution = Distribution.NewInstance(tdwgArea, status);\r
- if (taxonDescription != null) {\r
- taxonDescription.addElement(distribution);\r
- countDistributions++;\r
- if (taxonDescription != oldDescription){\r
- taxonStore.add(taxonDescription.getTaxon());\r
- oldDescription = taxonDescription;\r
- countDescriptions++;\r
- }\r
- } else {\r
- logger.warn("Distribution " + tdwgArea.toString() + " ignored");\r
- }\r
- }\r
- } catch (UnknownCdmTypeException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
+ while (rs.next()){\r
+ \r
+ if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("Facts handled: " + (i-1));}\r
+ \r
+ int occurrenceId = rs.getInt("OccurrenceId");\r
+ int newTaxonId = rs.getInt("RIdentifier");\r
+ String tdwgCodeString = rs.getString("TDWGCode");\r
+ Integer emStatusId = (Integer)rs.getObject("emOccurSumCatId");\r
+ \r
+ try {\r
+ //status\r
+ PresenceAbsenceTermBase<?> status = null;\r
+ if (emStatusId != null){\r
+ status = BerlinModelTransformer.occStatus2PresenceAbsence(emStatusId);\r
+ }\r
+ \r
+ //Create area list\r
+ List<NamedArea> tdwgAreas = new ArrayList<NamedArea>();\r
+ if (tdwgCodeString != null){\r
+ String[] tdwgCodes = tdwgCodeString.split(";");\r
+ for (String tdwgCode : tdwgCodes){\r
+ NamedArea tdwgArea = TdwgArea.getAreaByTdwgAbbreviation(tdwgCode.trim());\r
+ if (tdwgArea != null){\r
+ tdwgAreas.add(tdwgArea);\r
+ }\r
+ }\r
+ }\r
+ \r
+ //create description(elements)\r
+ TaxonDescription taxonDescription = getTaxonDescription(newTaxonId, oldTaxonId, oldDescription, taxonMap, occurrenceId);\r
+ for (NamedArea tdwgArea : tdwgAreas){\r
+ Distribution distribution = Distribution.NewInstance(tdwgArea, status);\r
+ if (taxonDescription != null) { \r
+ taxonDescription.addElement(distribution); \r
+ countDistributions++; \r
+ if (taxonDescription != oldDescription){ \r
+ taxonStore.add(taxonDescription.getTaxon()); \r
+ oldDescription = taxonDescription; \r
+ countDescriptions++; \r
+ } \r
+ } else { \r
+ logger.warn("Distribution " + tdwgArea.toString() + " ignored"); \r
+ }\r
+ }\r
+ } catch (UnknownCdmTypeException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+\r
+// TODO\r
+// sources\r
+// references\r
+ }\r
\r
-// TODO\r
-// sources\r
-// references\r
- }\r
logger.info("Distributions: " + countDistributions + ", Descriptions: " + countDescriptions );\r
logger.warn("Unmatched occurrences: " + (i - countDescriptions));\r
logger.info("Taxa to save: " + taxonStore.size());\r