import org.springframework.stereotype.Component;\r
\r
import eu.etaxonomy.cdm.common.ResultWrapper;\r
+import eu.etaxonomy.cdm.model.description.AbsenceTerm;\r
import eu.etaxonomy.cdm.model.description.Feature;\r
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;\r
import eu.etaxonomy.cdm.model.description.PresenceTerm;\r
public final class FaunaEuropaeaTransformer {\r
private static final Logger logger = Logger.getLogger(FaunaEuropaeaTransformer.class);\r
\r
+ // Query\r
+ public static final int Q_NO_RESTRICTION = -1;\r
+ \r
// TaxonStatus\r
public static final int T_STATUS_ACCEPTED = 1;\r
public static final int T_STATUS_NOT_ACCEPTED = 0;\r
\r
// Author\r
public static final int A_AUCT = 1;\r
+ public static final String A_AUCTNAME = "auct.";\r
\r
// Parenthesis\r
public static final int P_PARENTHESIS = 1;\r
\r
private static Map<String, String> tdwgAreas = null;\r
\r
- public static PresenceAbsenceTermBase<?> occStatus2PresenceAbsence (int occStatusId) throws UnknownCdmTypeException{\r
+ public static PresenceAbsenceTermBase<?> occStatus2PresenceAbsence(int occStatusId) throws UnknownCdmTypeException{\r
+ switch (occStatusId){\r
+ case 0: return AbsenceTerm.ABSENT();\r
+ case 2: return PresenceTerm.INTRODUCED();\r
+ case 1: return PresenceTerm.NATIVE();\r
+ default: {\r
+ throw new UnknownCdmTypeException("Unknown presence status (id=" + Integer.valueOf(occStatusId).toString() + ")");\r
+ }\r
+ }\r
+ }\r
+\r
+ \r
+ public static PresenceAbsenceTermBase<?> occStatus2PresenceAbsence_ (int occStatusId) throws UnknownCdmTypeException{\r
switch (occStatusId){\r
case 0: return null;\r
case 110: return PresenceTerm.CULTIVATED_REPORTED_IN_ERROR();\r
}\r
\r
\r
- public static NamedArea areaId2TdwgArea (ResultSet rs) throws UnknownCdmTypeException {\r
+ public static NamedArea areaId2TdwgArea (FaunaEuropaeaDistribution fauEuDistribution) \r
+ throws UnknownCdmTypeException {\r
\r
NamedArea tdwgArea = null;\r
\r
try {\r
- int areaId = rs.getInt("ara_id");\r
- String areaName = rs.getString("ara_name");\r
- String areaCode = rs.getString("ara_code");\r
- int extraLimital = rs.getInt("ara_extralimital");\r
+ int areaId = fauEuDistribution.getAreaId();\r
+ String areaName = fauEuDistribution.getAreaName();\r
+ String areaCode = fauEuDistribution.getAreaCode();\r
+ int extraLimital = fauEuDistribution.getExtraLimital();\r
\r
- //TODO: Verify mappings with comments. Are those the best matches?\r
+ //TODO: Verify mappings with comments. Those don't map to TDWG areas.\r
\r
if (areaCode.equals("AD")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("SPA-AN");\r
else if (areaCode.equals("AFR")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("24"); // Afro-tropical region - Northeast Tropical Africa\r
else if (areaCode.equals("DK-DEN")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("DEN-OO");\r
else if (areaCode.equals("DK-FOR")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("FOR-OO");\r
else if (areaCode.equals("EE")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("BLT-ES");\r
- else if (areaCode.equals("EPA")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("Palaearctic");\r
+ else if (areaCode.equals("EPA")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("3"); // Palaearctic - Asia-Temperate\r
else if (areaCode.equals("ES-BAL")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("BLT-ES");\r
else if (areaCode.equals("ES-CNY")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("CNY-OO");\r
else if (areaCode.equals("ES-SPA")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("SPA-SP");\r
else if (areaCode.equals("MD")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("UKR-MO");\r
else if (areaCode.equals("MK")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("YUG-MA");\r
else if (areaCode.equals("MT")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("SIC-MA");\r
- else if (areaCode.equals("NAF")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("20"); // North Africa - Northern Africa\r
+ else if (areaCode.equals("NAF")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("20"); // North Africa - Northern Africa\r
else if (areaCode.equals("NEA")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("7"); // Nearctic region - Northern America\r
- else if (areaCode.equals("NEO")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("8"); // Neotropical region - Southern America\r
+ else if (areaCode.equals("NEO")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("8"); // Neotropical region - Southern America\r
else if (areaCode.equals("NL")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("NET-OO");\r
else if (areaCode.equals("NO-NOR")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("NOR-OO");\r
else if (areaCode.equals("NO-SVA")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("SVA-OO");\r
- else if (areaCode.equals("NRE")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("34"); // Near East - Western Asia\r
+ else if (areaCode.equals("NRE")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("34"); // Near East - Western Asia\r
else if (areaCode.equals("ORR")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("35"); // Oriental region - Arabian Peninsula\r
else if (areaCode.equals("PL")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("POL-OO");\r
else if (areaCode.equals("PT-AZO")) tdwgArea = TdwgArea.getAreaByTdwgAbbreviation("AZO-OO");\r
else \r
throw new UnknownCdmTypeException("Unknown Area " + areaCode);\r
\r
- \r
if (logger.isDebugEnabled()) {\r
logger.debug(areaId + ", " + areaName + ", " + areaCode + ", " + extraLimital);\r
}\r
\r
- } catch (SQLException e) {\r
+ } catch (Exception e) {\r
e.printStackTrace();\r
logger.warn("Exception occurred. Area could not be mapped.");\r
return null;\r