Project

General

Profile

Download (65.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.io.berlinModel;
11

    
12
import java.sql.ResultSet;
13
import java.sql.SQLException;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.common.ResultWrapper;
19
import eu.etaxonomy.cdm.model.common.Language;
20
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
21
import eu.etaxonomy.cdm.model.common.RelationshipBase;
22
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
23
import eu.etaxonomy.cdm.model.description.Feature;
24
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
25
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
26
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
27
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
28
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
29
import eu.etaxonomy.cdm.model.name.Rank;
30
import eu.etaxonomy.cdm.model.name.RankClass;
31
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
32
import eu.etaxonomy.cdm.model.reference.ISection;
33
import eu.etaxonomy.cdm.model.reference.Reference;
34
import eu.etaxonomy.cdm.model.reference.ReferenceType;
35
import eu.etaxonomy.cdm.model.taxon.Synonym;
36
import eu.etaxonomy.cdm.model.taxon.SynonymType;
37
import eu.etaxonomy.cdm.model.taxon.Taxon;
38
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
39
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
40
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
41

    
42
/**
43
 * @author a.mueller
44
 * @since 20.03.2008
45
 */
46
public class BerlinModelTransformer {
47
	private static final Logger logger = Logger.getLogger(BerlinModelTransformer.class);
48

    
49
	//source Refs
50
	public static final UUID uuidSourceRefEuroMed = UUID.fromString("0603a84a-f024-4454-ab92-9e2ac0139126");
51

    
52
	//ranks
53
	public static UUID uuidRankCollSpecies = UUID.fromString("e14630ee-9446-4bb4-a7b7-4c3881bc5d94");
54
	public static UUID uuidRankProles = UUID.fromString("8810d1ba-6a34-4ae3-a355-919ccd1cd1a5");
55
	public static UUID uuidRankRace = UUID.fromString("196dee39-cfd8-4460-8bf0-88b83da27f62");
56
	public static UUID uuidRankSublusus = UUID.fromString("1fafa596-a8e7-4e62-a378-3cc8cb3627ca");
57

    
58
	//named areas
59
	public static UUID euroMedUuid = UUID.fromString("9fe09988-58c0-4c06-8474-f660a0c50014");
60

    
61
	public static UUID uuidEasternEuropeanRussia = UUID.fromString("3f013375-0e0a-40c3-8a14-84c0535fab40");
62
	public static UUID uuidSerbiaMontenegro = UUID.fromString("8926dbe6-863e-47a9-98a0-7dc9ed2c57f7");
63
	public static UUID uuidSerbia = UUID.fromString("4ffed197-3d7e-4cd9-8984-e64b8dee9512");
64
	public static UUID uuidLebanonSyria = UUID.fromString("0c45f250-99da-4b19-aa89-c3e56cfdf103");
65
	public static UUID uuidUssr = UUID.fromString("a512e00a-45f3-4be5-82fa-bba8d675696f");
66
	public static UUID uuidSicilyMalta = UUID.fromString("424d81ee-d272-4ae8-9600-0a334049cd72");
67

    
68
	public static UUID uuidDesertas = UUID.fromString("36f5e93e-34e8-45b5-a401-f0e0faad21cf");
69
	public static UUID uuidMadeira = UUID.fromString("086e27ee-78ff-4236-aca9-9850850cd355");
70
	public static UUID uuidPortoSanto = UUID.fromString("1f9ab6a0-a402-4dfe-8c5b-b1844eb4d8e5");
71
	//azores
72
	public static UUID uuidFlores = UUID.fromString("ef0067c2-8bbb-4e37-8462-97b03f51ba43");
73
	public static UUID uuidCorvo = UUID.fromString("b1e6117c-2be1-43a3-9233-227dd90bdee9");
74
	public static UUID uuidFaial = UUID.fromString("14f6dcdb-6524-4700-b80c-66424952ef2b");
75
	public static UUID uuidGraciosa = UUID.fromString("05f93a7b-d813-4833-864f-eedbba747133");
76
	public static UUID uuidSaoJorge = UUID.fromString("578e0ecd-b5e3-4c87-8ecc-0fc4c7e217d9");
77
	public static UUID uuidSaoMiguel = UUID.fromString("0e2f6ad8-7afb-4f01-b134-4f71991e877a");
78
	public static UUID uuidPico = UUID.fromString("98cc566f-4110-43d5-830f-68436a009f49");
79
	public static UUID uuidSantaMaria = UUID.fromString("bd5e5d4a-22b7-41aa-8e58-1d1d73a9954d");
80
	public static UUID uuidTerceira = UUID.fromString("6fc257c0-a131-41f0-b6c3-51ef9c4fa962");
81
	//Canyry islands
82
	public static UUID uuidGranCanaria = UUID.fromString("a0240c35-0e05-4157-8321-67ba8e31fdb9");
83
	public static UUID uuidFuerteventura = UUID.fromString("549ce2c1-6d49-4bf3-b75d-cf3f4b5a1398");
84
	public static UUID uuidGomera = UUID.fromString("895fab09-7478-4210-b42a-423d23c6f85e");
85
	public static UUID uuidHierro = UUID.fromString("d137b6a5-31bc-418c-9403-f042017dc04b");
86
	public static UUID uuidLanzaroteWithGraciosa = UUID.fromString("c9b08dc1-f301-4d9d-b447-b8744602c776");
87
	public static UUID uuidLaPalma = UUID.fromString("fdb3f2b2-f154-4f04-9f31-240a47a0e780");
88
	public static UUID uuidTenerife = UUID.fromString("73658c7e-a568-465e-bd84-4554fc93ca56");
89
	//Baleares
90
	public static UUID uuidIbizaWithFormentera = UUID.fromString("1cda2a33-3469-49d5-8e77-cb5451110519");
91
	public static UUID uuidMallorca = UUID.fromString("a10cba04-b4b5-4a4b-b69a-fcd4b3916fec");
92
	public static UUID uuidMenorca = UUID.fromString("9f6ede48-27f8-4270-bf4e-c97eaa86aab7");
93

    
94
	//russia
95
	public static UUID uuidRussiaNorthern = UUID.fromString("c23bc1c9-a775-4426-b883-07d4d7d47eed");
96
	public static UUID uuidRussiaBaltic = UUID.fromString("579dad44-9439-4b19-8716-ab90d8f27944");
97
	public static UUID uuidRussiaCentral = UUID.fromString("8bbc8c6a-2ef2-4024-ad51-66fe34c70092");
98
	public static UUID uuidRussiaSouthWest = UUID.fromString("daa5c207-5567-4690-8742-5e4d153b6a64");
99
	public static UUID uuidRussiaSouthEast = UUID.fromString("e8516598-b529-489e-9ee8-63bbbd295c1b");
100
	public static UUID uuidEastAegeanIslands = UUID.fromString("1c429593-c493-46e6-971a-0d70be690da8");
101
	public static UUID uuidTurkishEastAegeanIslands = UUID.fromString("ba35dba3-ac70-41ae-81c2-2070943f44f2");
102
	public static UUID uuidBalticStates = UUID.fromString("bf9d64f6-3183-4fa5-8e90-73090e7a2282");
103
	public static final UUID uuidTurkey = UUID.fromString("d344ee2c-14c8-438d-b03d-11538edb1268");
104
	public static final UUID uuidCaucasia = UUID.fromString("ebfd3fd1-3859-4e5e-95c7-f66010599d7e");
105

    
106

    
107

    
108
	//E+M areas
109
	public static UUID uuidVocEuroMedAreas = UUID.fromString("625a4962-c211-4597-816e-5804083efe26");
110
	public static UUID uuidEM = UUID.fromString("111BDF38-7A32-440A-9808-8AF1C9E54B51");
111
	public static UUID uuidEUR = UUID.fromString("80B3CEEE-2F78-45CE-B4F4-E473F5ED8343");
112
	public static UUID uuid14 = UUID.fromString("4FF83A35-97DE-4C39-BEDE-27EE9ECEFB45");
113
	public static UUID uuid20 = UUID.fromString("19D93AD1-59E7-49ED-B513-D7D493EDC4DE");
114
	public static UUID uuid21 = UUID.fromString("1B98DAF0-A709-4871-9A8B-CFDD09F41763");
115
	public static UUID uuid33 = UUID.fromString("6B719260-1E48-4D85-8BC3-320852E1B331");
116
	public static UUID uuidDa = UUID.fromString("867871C9-9931-47D0-AEF7-468B9519EBB2");
117
	public static UUID uuidFe = UUID.fromString("C4EF26AF-11E0-4888-9FC3-5E56F4422BB4");
118
	public static UUID uuidFa = UUID.fromString("70426E7E-2EAA-4987-95FB-5CB6E56980F3");
119
	public static UUID uuidBr = UUID.fromString("A22329C4-0B81-4E00-BCC3-2F44A6CA56D0");
120
	public static UUID uuidIs = UUID.fromString("3D2950E9-C2FD-462E-9697-DCB7241D514E");
121
	public static UUID uuidHb = UUID.fromString("65E405E7-B3D4-44B6-BE67-4881582EA274");
122
	public static UUID uuidNo = UUID.fromString("2D3F1181-6838-4034-96CB-F254A558572A");
123
	public static UUID uuidSb = UUID.fromString("BC847AF8-30C3-48B2-A881-2B2DEAC0A137");
124
	public static UUID uuidSu = UUID.fromString("F064AB9F-EDDB-47D8-8E54-B9E8AD19111D");
125
	public static UUID uuidAu = UUID.fromString("37C77C23-9673-4ABC-87C2-B29E9FA87FA8");
126
	public static UUID uuidBe = UUID.fromString("4840373B-F949-4630-B655-9B37F845CFDA");
127
	public static UUID uuidCz = UUID.fromString("02E67A70-C192-4A01-A311-99F8C42F9D51");
128
	public static UUID uuidGe = UUID.fromString("F617DDEA-51C9-4EF1-B7F4-ED22F871631D");
129
	public static UUID uuidHu = UUID.fromString("AD7EDDB1-C089-436F-88BA-BC9115BBD6E0");
130
	public static UUID uuidHo = UUID.fromString("00B8FE6D-D04B-4CAC-ADCE-32B44ABB385A");
131
	public static UUID uuidPo = UUID.fromString("F23864DF-DFD6-4ABC-B7D0-FD97408AE0A9");
132
	public static UUID uuidHe = UUID.fromString("7C28D878-F16D-4043-A94E-750BEF910064");
133
	public static UUID uuidBl = UUID.fromString("A4326211-3219-4655-83AD-599D635DB638");
134
	public static UUID uuidCo = UUID.fromString("3EE3CB3E-23DE-491F-94DF-35DB7A1D3AC0");
135
	public static UUID uuidGa = UUID.fromString("28591C04-60E3-432A-9D05-CBC945462D2E");
136
	public static UUID uuidLu = UUID.fromString("205512B0-AA22-4041-B92B-336FEB79FA4F");
137
	public static UUID uuidSa = UUID.fromString("11368A92-2362-4029-A26A-E35CEC0798C1");
138
	public static UUID uuidHs = UUID.fromString("6AD92C01-1442-4F2F-BD58-F73075B26C27");
139
	public static UUID uuidAl = UUID.fromString("635B63DA-0AAF-446C-843E-BEB52E2A1B90");
140
	public static UUID uuidBu = UUID.fromString("75F3CF66-B272-464E-9B1E-35B8E511936D");
141
	public static UUID uuidGr = UUID.fromString("34DF8B89-7DFA-4265-9A3E-D540DB72AA77");
142
	public static UUID uuidIt = UUID.fromString("06B8F41D-B9A8-4B55-8AAB-DE90EB3D0A9C");
143
	public static UUID uuidCr = UUID.fromString("20A8A822-1C87-43F0-A5EF-2AF1CC5DC0FC");
144
	public static UUID uuidRm = UUID.fromString("EAB29D40-E3B2-4920-BB1F-8757DFBC9E86");
145
	public static UUID uuidSi_S = UUID.fromString("DD861671-930F-4C9E-92D8-EADDC28EB6B7");
146
	public static UUID uuidTu_E = UUID.fromString("2B732609-55DB-4F25-BC73-618FFF515ADC");
147
	public static UUID uuidJu = UUID.fromString("BD5E6833-7E0E-41A8-83D6-149A31F2CE05");
148
	public static UUID uuidUk_K = UUID.fromString("40B7219D-E38C-44EB-9877-E311A2734022");
149
	public static UUID uuidUk = UUID.fromString("7A8DF5D0-3D18-4386-891E-96E11BDB6FEB");
150
	public static UUID uuidAg = UUID.fromString("548E583C-DBE7-463F-A01B-2A966F2B32D2");
151
	public static UUID uuidEg = UUID.fromString("9EDDDE2E-95B7-4443-89A8-C30D031E16A5");
152
	public static UUID uuidLi = UUID.fromString("2F506902-2A56-40C8-84CB-B436C84ED258");
153
	public static UUID uuidMa = UUID.fromString("D639A7AC-F873-414E-8869-73D10B9CF842");
154
	public static UUID uuidTn = UUID.fromString("AF4D86D4-2CA0-48A2-BA15-0D74454D1EAD");
155
	public static UUID uuidAz = UUID.fromString("CEC2EBD3-DFD0-4CE6-827F-BFF8FBAF5283");
156
	public static UUID uuidSg = UUID.fromString("BC4A0307-B81A-4233-B8BD-EFB9CEDFD530");
157
	public static UUID uuidAb = UUID.fromString("D3744C2D-2777-4E85-98BF-04D2FD589EBF");
158
	public static UUID uuidAr = UUID.fromString("535FED1E-3EC9-4563-AF55-E753AEFCFBFE");
159
	public static UUID uuidAb_A = UUID.fromString("0F4C98BF-AF7B-4CDA-B62C-AD6A1909BFA0");
160
	public static UUID uuidGg = UUID.fromString("DA1CCDA8-5867-4098-A709-100A66E2150A");
161
	public static UUID uuidAb_N = UUID.fromString("AA75B0CA-49C9-4F8E-8CC2-2A343EB2FFF4");
162
	public static UUID uuidCy = UUID.fromString("36EFDF69-09C0-4160-A502-9EEFBC22A984");
163
	public static UUID uuidAE_G = UUID.fromString("76F5F3F6-9C3E-47F5-8E85-55360C50273C");
164
	public static UUID uuidLe = UUID.fromString("639F5D97-EC9E-4EE2-ADFC-DFF73F7CC970");
165
	public static UUID uuidSn = UUID.fromString("5D8E0B00-96CE-4ACC-AF02-62A1B9866144");
166
	public static UUID uuidTu_A = UUID.fromString("F7B59D79-15C2-47C9-91B0-DEC1F388CB62");
167
	public static UUID uuidTu = UUID.fromString("DB98809B-EF22-413B-B1EA-A79C4E1C4903");
168
	public static UUID uuidAu_A = UUID.fromString("AE65867C-00F6-406C-A315-B3E4CC9A93D2");
169
	public static UUID uuidAu_L = UUID.fromString("78146B6E-E71A-46DA-8DBC-244CC648BBE7");
170
	public static UUID uuidAz_C = UUID.fromString("D35B8259-CC76-4FB0-AFC0-6A23D657EE3E");
171
	public static UUID uuidAz_F = UUID.fromString("0F8F470D-CA2A-4130-842A-0A0C6912A123");
172
	public static UUID uuidAz_G = UUID.fromString("CFF9FC6D-E3B2-45B1-87A9-6FEFB029A12F");
173
	public static UUID uuidAz_P = UUID.fromString("C8000982-19E8-492E-912D-59EB370E52C0");
174
	public static UUID uuidAz_S = UUID.fromString("BD852931-47B3-466C-A422-4F312B913CA2");
175
	public static UUID uuidAz_J = UUID.fromString("4A5CED9F-F078-44B3-94BF-F3EE79315236");
176
	public static UUID uuidAz_M = UUID.fromString("B8C76F37-6483-474F-85AB-96399219DE57");
177
	public static UUID uuidAz_T = UUID.fromString("7A52595F-DA5E-440A-B2BD-F63999CE979E");
178
	public static UUID uuidBe_B = UUID.fromString("9E263401-ACEC-4E2E-AA89-4AAF56AE7180");
179
	public static UUID uuidBe_L = UUID.fromString("AF71559C-7765-493C-8C9A-1248DFF28789");
180
	public static UUID uuidBl_I = UUID.fromString("121B07A0-8031-4F22-B9B7-C334FC3204CE");
181
	public static UUID uuidBl_M = UUID.fromString("E8E8EFDC-E9EB-4B26-9711-F986265AD114");
182
	public static UUID uuidBl_N = UUID.fromString("D96DD8A7-4BD8-4ADF-8CDB-05873686DB1A");
183
	public static UUID uuidBH = UUID.fromString("6A109EF5-3AC1-4C59-8599-08F944ABA499");
184
	public static UUID uuidBy = UUID.fromString("5D972AF7-6AE2-44D1-840B-EDB1DBE8B7AC");
185
	public static UUID uuidCa = UUID.fromString("CFA26682-B0AB-4FEB-9191-6AA098638382");
186
	public static UUID uuidCa_F = UUID.fromString("0D8ED2C4-0313-464C-A5B4-EC0A52E45ADF");
187
	public static UUID uuidCa_G = UUID.fromString("865D1319-B157-4D1A-BBF0-F56B7EB2ED96");
188
	public static UUID uuidCa_C = UUID.fromString("486FCBED-84C4-4673-8724-9A8A4A6613AD");
189
	public static UUID uuidCa_H = UUID.fromString("0B57C693-DB09-4D7F-9FA9-0DBBEFF3B3B6");
190
	public static UUID uuidCa_L = UUID.fromString("A88D6DF4-7924-4BEC-BFA6-071BDA82A4B3");
191
	public static UUID uuidCa_P = UUID.fromString("BBF04D1A-1FC0-4A7B-BF0B-7D7BF69D8392");
192
	public static UUID uuidCa_T = UUID.fromString("BBAD170B-285D-4BEA-8C3F-C43894FB75FF");
193
	public static UUID uuidCs = UUID.fromString("2ADA45F0-C7CC-4026-A8B1-B816971F0753");
194
	public static UUID uuidCt = UUID.fromString("09B5728A-4775-4530-B362-9B1EF4A9E8C3");
195
	public static UUID uuidEs = UUID.fromString("1011D427-401B-47EE-A42C-4C1698957D55");
196
	public static UUID uuidGa_C = UUID.fromString("3653A4DC-1ADE-4237-A62C-4F0AC11E576F");
197
	public static UUID uuidGa_F = UUID.fromString("860F92B6-5CDA-456B-964C-6162D1D08161");
198
	public static UUID uuidGg_A = UUID.fromString("5FAD859B-7929-4D5F-B92C-95E3E0469BB2");
199
	public static UUID uuidGg_D = UUID.fromString("6091C975-B946-4EF3-A18F-2E148EAE6A06");
200
	public static UUID uuidGg_G = UUID.fromString("048799B0-D7B9-44C6-B2D1-5CA2A49FA175");
201
	public static UUID uuidHs_A = UUID.fromString("EAED6C21-42E5-496D-B43E-C121F96FA672");
202
	public static UUID uuidHs_G = UUID.fromString("35350D75-6952-48BD-B265-C005BC1B2909");
203
	public static UUID uuidHs_S = UUID.fromString("264649F7-192D-4AE5-9840-81FC782F59F0");
204
	public static UUID uuidIr = UUID.fromString("A3B35528-5FFD-43B1-B605-711807C1EC9F");
205
	public static UUID uuidIt_I = UUID.fromString("E3BC327E-0B42-4439-811B-595BC55A8FF8");
206
	public static UUID uuidIt_S = UUID.fromString("57F35807-8CFA-4698-BB04-AAD3549C12EB");
207
	public static UUID uuidJo = UUID.fromString("567A537D-F2FA-43EF-A20A-AEC76723E269");
208
	public static UUID uuidKz = UUID.fromString("F8ABE715-D859-4B6F-B8F1-DB1A847DEAC4");
209
	public static UUID uuidLa = UUID.fromString("8E338882-2631-4AD6-BC53-799C698C807D");
210
	public static UUID uuidLt = UUID.fromString("ECF200B6-B1DF-414F-B215-EDAC503B1A65");
211
	public static UUID uuidMa_E = UUID.fromString("80980607-FBD8-46E3-BE56-05D997F2D331");
212
	public static UUID uuidMa_S = UUID.fromString("B743AE57-DC0B-4CCC-B4D9-7BF51E579E8E");
213
	public static UUID uuidMk = UUID.fromString("0CE83170-2FA7-4C72-81F7-7FFF17343E48");
214
	public static UUID uuidMd = UUID.fromString("2CFB90B1-0BA0-4578-AD11-AAD5AAB62899");
215
	public static UUID uuidMd_D = UUID.fromString("DBE1F3CA-4C7C-4062-AC1E-ADE0C17DCA52");
216
	public static UUID uuidMd_M = UUID.fromString("4658DADD-60FE-46D8-94E3-C6A6C4646105");
217
	public static UUID uuidMd_P = UUID.fromString("2C41EB67-A330-4214-B452-6E6741262CE5");
218
	public static UUID uuidSi_M = UUID.fromString("2920D738-54A1-49CE-AF3A-9CB742064587");
219
	public static UUID uuidMo = UUID.fromString("64F98B98-1050-42C6-B2C7-F72DA642E4D5");
220
	public static UUID uuidRf = UUID.fromString("4B6BDFEE-2BCB-4638-99CF-0F9612FA4787");
221
	public static UUID uuidRf_C = UUID.fromString("1FFAF0B5-6311-4BF6-977F-8940622C4986");
222
	public static UUID uuidRf_E = UUID.fromString("4280A0F6-298E-4B3C-8CE8-56A1208183F7");
223
	public static UUID uuidRf_K = UUID.fromString("D9559D9A-1798-4496-8671-DE667CC30EC0");
224
	public static UUID uuidRf_CS = UUID.fromString("6E886ACC-22C9-4C63-BEA5-A51AD84AF3D1");
225
	public static UUID uuidRf_N = UUID.fromString("B0D8F65E-B5A4-4C0B-A5EF-54CC9F378CC6");
226
	public static UUID uuidRf_NW = UUID.fromString("06CC9983-B444-4322-A03E-9A7A2AF1D4AD");
227
	public static UUID uuidRf_A = UUID.fromString("1786C13D-D26D-49E3-BA60-E3F3E7852713");
228
	public static UUID uuidRf_S = UUID.fromString("6AAB10D5-05E9-470A-8AF5-B6F8D48A71EC");
229
	public static UUID uuidSk = UUID.fromString("09267309-E771-4BD7-A67F-B6B4321546E0");
230
	public static UUID uuidSl = UUID.fromString("BC242D21-98CA-402C-BDB7-3ED347C7BDFD");
231
	public static UUID uuidSy = UUID.fromString("A5974D4B-F878-422C-A7A8-A1D8268109EF");
232
	public static UUID uuidUk_U = UUID.fromString("4A6C5155-154E-4B0D-AC73-550B51CCE374");
233
	public static UUID uuidSM = UUID.fromString("AC360FC1-30F4-444A-92EB-B55BF98B8E97");
234
	public static UUID uuidYu_K = UUID.fromString("F3F05E88-99AF-48FA-92EF-1A169BCC7ACF");
235
	public static UUID uuidCg = UUID.fromString("38A4FD15-40D6-43F4-9685-F87465FDBD3F");
236
	public static UUID uuidSr = UUID.fromString("468CFEA2-008F-40CF-B2C8-ADF5C09C0FA4");
237
	public static UUID uuidIJ = UUID.fromString("9351B972-0C0B-4A97-87B1-4CC11E67D21E");
238
	public static UUID uuidLS = UUID.fromString("F7BFDAE0-3DD9-4FC4-9B0B-0BF203B94031");
239
	public static UUID uuidRs = UUID.fromString("C4A898CE-0F32-44FE-A8A3-278E11A4BA53");
240
	public static UUID uuidSi = UUID.fromString("DB1FACF2-58A5-483E-9B2A-EB4290CA1B71");
241
	public static UUID uuidAz_L = UUID.fromString("F5AEF252-C4F8-4ECC-9B6E-4821DB7ADECF");
242
	public static UUID uuidHb_E = UUID.fromString("1D400E37-F39A-4CAE-8885-CF485B900CC5");
243
	public static UUID uuidHb_N = UUID.fromString("B1D514DA-B9E6-4F0E-ACE4-18FB061FC132");
244
	public static UUID uuidGa_M = UUID.fromString("E73942F0-292A-4F6A-8B2F-15AFE8634319");
245
	public static UUID uuidMa_M = UUID.fromString("D9F7DFFC-0E76-4790-9AAE-B7AEB5AD76ED");
246
	public static UUID uuidRs_N = UUID.fromString("44F262E3-5091-4D28-8081-440D3978FB0B");
247
	public static UUID uuidRs_B = UUID.fromString("A575D608-DD53-4C01-B2AF-5067D0711F64");
248
	public static UUID uuidRs_C = UUID.fromString("DA4E9CC3-B1CC-403A-81FF-BCC5D9FADBD1");
249
	public static UUID uuidRs_W = UUID.fromString("EFABC8FD-0B3C-475B-B532-E1CA0BA0BDBB");
250
	public static UUID uuidRs_E = UUID.fromString("7E0F8FA3-5DB9-48F0-9FA8-87FCAB3EAA53");
251
	public static UUID uuidAE = UUID.fromString("C8FCD4E0-E1A2-4A7D-8EE2-6F397F5C546C");
252
	public static UUID uuidAE_T = UUID.fromString("AF83B475-BB35-4594-8380-EA64B4313091");
253
	public static UUID uuidRs_K = UUID.fromString("2188E3A5-0446-47C8-B11B-B4B2B9A71C75");
254
	public static UUID uuidCc = UUID.fromString("05B0DD06-30F8-477D-BF4C-30D9DEF56320");
255
	public static UUID uuidBt = UUID.fromString("EE13FB74-F3AC-46B1-9F23-6A25AC504446");
256
	public static UUID uuidTcs = UUID.fromString("904C3980-B98D-422E-A195-95F4F41FC734");
257

    
258

    
259
	//salvador
260
	public static UUID uuidSalvadorAreas = UUID.fromString("8ef90ca3-77d7-4adc-8bbc-1eb354e61b65");
261

    
262

    
263

    
264
	//language areas
265
//	public static final UUID uuidUkraineAndCrimea = UUID.fromString("99d4d1c2-09f6-416e-86a3-bdde5cae52af");
266
	public static final UUID uuidAzerbaijanNakhichevan = UUID.fromString("232fbef0-9f4a-4cab-8ac1-e14c717e9de6");
267

    
268
	//Marker Types
269
	public static final UUID uuidMisappliedCommonName = UUID.fromString("25f5cfc3-16ab-4aba-a008-0db0f2cf7f9d");
270
	public static final UUID uuidEurArea = UUID.fromString("71dd0368-835c-4b53-889a-2bf316e10297");
271
	public static final UUID uuidEurMedArea = UUID.fromString("aa6a5b25-3ee3-4771-b4d1-b91918f23fa5");
272
	public static final UUID uuidHiddenArea = UUID.fromString("0318c67d-e323-4e9c-bffb-bc0c7f8f9f40");
273
	public static final UUID uuidTaxonomicallyValueless = UUID.fromString("e07060cc-5a51-471f-863b-01011e3142fb");
274
	public static final UUID uuidProbablyTaxonomicallyValueless = UUID.fromString("3b8b620e-986d-4a87-8070-1884a51c6bad");
275

    
276
	//Extension Types
277
	public static final UUID uuidSpeciesExpertName = UUID.fromString("2e8153d2-7412-49e4-87e1-5c38f4c5153a");
278
	public static final UUID uuidExpertName = UUID.fromString("24becb79-a90c-47d3-be35-efc87bb48fd3");
279

    
280
	public static final UUID DETAIL_EXT_UUID = UUID.fromString("c3959b4f-d876-4b7a-a739-9260f4cafd1c");
281
	public static final UUID ID_IN_SOURCE_EXT_UUID = UUID.fromString("23dac094-e793-40a4-bad9-649fc4fcfd44");
282
	public static final UUID uuidIsoCode = UUID.fromString("048b8153-e3ee-451c-a72c-f1c8bc291c3e");
283
	public static final UUID uuidTdwgAreaCode = UUID.fromString("73ad0288-b71b-4a14-9c2e-7f81f1e64a36");
284
	public static final UUID uuidMclCode = UUID.fromString("aa27083a-6a96-42aa-a2f8-5541cf057067");
285

    
286
	//Area Level
287
	public static final UUID uuidEuroMedAreaLevelTop = UUID.fromString("190d5758-4b96-4016-9412-6dc9c36ef5fd");
288
	public static final UUID uuidEuroMedAreaLevelFirst = UUID.fromString("d21503e3-875e-4abc-82ec-f812e3cfea84");
289
	public static final UUID uuidEuroMedAreaLevelSecond = UUID.fromString("97ac0bf5-b31c-487a-8ed5-a576f46c902c");
290

    
291
	//languages
292
	public static final UUID uuidLangMajorcan = UUID.fromString("82d696d7-cb4e-49de-ac89-63a0e12ca766");
293

    
294
	//REFERENCES
295
	public static int REF_ARTICLE = 1;
296
	public static int REF_PART_OF_OTHER_TITLE = 2;
297
	public static int REF_BOOK = 3;
298
	public static int REF_DATABASE = 4;
299
	public static int REF_INFORMAL = 5;
300
	public static int REF_NOT_APPLICABLE = 6;
301
	public static int REF_WEBSITE = 7;
302
	public static int REF_CD = 8;
303
	public static int REF_JOURNAL = 9;
304
	public static int REF_UNKNOWN = 10;
305
	public static int REF_PRINT_SERIES = 55;
306
	public static int REF_CONFERENCE_PROCEEDINGS = 56;
307
	public static int REF_JOURNAL_VOLUME = 57;
308

    
309

    
310

    
311
	//NameStatus
312
	public static int NAME_ST_NOM_INVAL = 1;
313
	public static int NAME_ST_NOM_ILLEG = 2;
314
	public static int NAME_ST_NOM_NUD = 3;
315
	public static int NAME_ST_NOM_REJ = 4;
316
	public static int NAME_ST_NOM_REJ_PROP = 5;
317
	public static int NAME_ST_NOM_UTIQUE_REJ = 6;
318
	public static int NAME_ST_NOM_UTIQUE_REJ_PROP = 7;
319
	public static int NAME_ST_NOM_CONS = 8;
320
	public static int NAME_ST_NOM_CONS_PROP = 9;
321
	public static int NAME_ST_ORTH_CONS = 10;
322
	public static int NAME_ST_ORTH_CONS_PROP = 11;
323
	public static int NAME_ST_NOM_SUPERFL = 12;
324
	public static int NAME_ST_NOM_AMBIG = 13;
325
	public static int NAME_ST_NOM_PROVIS = 14;
326
	public static int NAME_ST_NOM_DUB = 15;
327
	public static int NAME_ST_NOM_NOV = 16;
328
	public static int NAME_ST_NOM_CONFUS = 17;
329
	public static int NAME_ST_NOM_ALTERN = 18;
330
	public static int NAME_ST_COMB_INVAL = 19;
331

    
332

    
333
	//NameRelationShip
334
	public static int NAME_REL_IS_BASIONYM_FOR = 1;
335
	public static int NAME_REL_IS_LATER_HOMONYM_OF = 2;
336
	public static int NAME_REL_IS_REPLACED_SYNONYM_FOR = 3;
337
	public static int NAME_REL_IS_VALIDATION_OF = 4;
338
	public static int NAME_REL_IS_LATER_VALIDATION_OF = 5;
339
	public static int NAME_REL_IS_TYPE_OF = 6;
340
	public static int NAME_REL_IS_CONSERVED_TYPE_OF =7;
341
	public static int NAME_REL_IS_REJECTED_TYPE_OF = 8;
342
	public static int NAME_REL_IS_FIRST_PARENT_OF = 9;
343
	public static int NAME_REL_IS_SECOND_PARENT_OF = 10;
344
	public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;
345
	public static int NAME_REL_IS_MALE_PARENT_OF = 12;
346
	public static int NAME_REL_IS_CONSERVED_AGAINST =13;
347
	public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;
348
	public static int NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF = 15;
349
	public static int NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF = 16;
350
	public static int NAME_REL_IS_ALTERNATIVE_NAME_FOR = 17;
351
	public static int NAME_REL_HAS_SAME_TYPE_AS = 18;
352
	public static int NAME_REL_IS_LECTOTYPE_OF = 61;
353
	public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;
354

    
355
	//NameFacts
356
	public static String NAME_FACT_PROTOLOGUE = "Protologue";
357
	public static String NAME_FACT_ALSO_PUBLISHED_IN = "Also published in";
358
	public static String NAME_FACT_BIBLIOGRAPHY = "Bibliography";
359

    
360
	//TaxonRelationShip
361
	public static int TAX_REL_IS_INCLUDED_IN = 1;
362
	public static int TAX_REL_IS_SYNONYM_OF = 2;
363
	public static int TAX_REL_IS_MISAPPLIED_NAME_OF = 3;
364
	public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;
365
	public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;
366
	public static int TAX_REL_IS_HETEROTYPIC_SYNONYM_OF = 6;
367
	public static int TAX_REL_IS_HOMOTYPIC_SYNONYM_OF = 7;
368
	public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;
369
	public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;
370
	public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;
371
	public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;
372
	public static int TAX_REL_IS_PRO_PARTE_MISAPPLIED_NAME_OF = 110;  //does not really exist but as only used in BM export which is not in use anymore it serves as a placeholder for consistency
373

    
374

    
375

    
376
	//TaxonStatus
377
	public static int T_STATUS_ACCEPTED = 1;
378
	public static int T_STATUS_SYNONYM = 2;
379
	public static int T_STATUS_PARTIAL_SYN = 3;
380
	public static int T_STATUS_PRO_PARTE_SYN = 4;
381
	public static int T_STATUS_UNRESOLVED = 5;
382
	public static int T_STATUS_ORPHANED = 6;
383

    
384

    
385
	//Facts
386
	public static int FACT_DESCRIPTION = 1;
387
	public static int FACT_GROWTH_FORM = 2;
388
	public static int FACT_HARDINESS = 3;
389
	public static int FACT_ECOLOGY = 4;
390
	public static int FACT_PHENOLOGY = 5;
391
	public static int FACT_KARYOLOGY = 6;
392
	public static int FACT_ILLUSTRATION = 7;
393
	public static int FACT_IDENTIFICATION = 8;
394
	public static int FACT_OBSERVATION = 9;
395
	public static int FACT_DISTRIBUTION_EM = 10;
396
	public static int FACT_DISTRIBUTION_WORLD = 11;
397
	//E+M
398
	public static final UUID uuidFeatureMaps = UUID.fromString("8367730e-f3c3-4361-8360-a2057e4295ed");
399
	public static final UUID uuidFeatureConservationStatus = UUID.fromString("a32f33cd-1966-4a22-986c-94c5e688bbd1");
400
	public static final UUID uuidFeatureUse = UUID.fromString("199bbbd8-2db6-4335-b454-2e92ae02b699");
401
	public static final UUID uuidFeatureComments = UUID.fromString("31cc2b92-5cad-44e9-b50f-b8af591a527c");
402
	public static final UUID uuidFeatureDistrEM = UUID.fromString("a5ba7e7f-ca7f-4f50-afc7-73e76b3231d4");
403
	public static final UUID uuidFeatureDistrWorld = UUID.fromString("e4e24080-7017-47e6-924e-d2560fa68fb8");
404
	public static final UUID uuidFeatureEditorBrackets = UUID.fromString("b3b5bc1a-7ba8-4a39-9c0d-63ba599eb5d8");
405
	public static final UUID uuidFeatureEditorParenthesis = UUID.fromString("6ee10a2e-ff02-4cf4-a520-89630edc5b44");
406
	public static final UUID uuidFeatureInedited = UUID.fromString("c93e2968-bc52-4165-9755-ce37611faf01");
407
	public static final UUID uuidFeatureCommentsEditing = UUID.fromString("7a155021-158a-48bb-81d0-9a72b718e2de");
408

    
409
	//Salvador
410
	public static final UUID uuidFeatureDistributionGlobal = UUID.fromString("9bd09ada-7bb3-4fe5-be35-dc4564bdd161");
411
	public static final UUID uuidReporteParaElSalvador = UUID.fromString("1869a1a6-becb-468e-bc62-b2473f7d9391");
412
	public static final UUID uuidFeatureOtherReferences = UUID.fromString("f5dc30bd-a5b1-436d-8cc0-69a999e61590");
413
	public static final UUID uuidFeatureTaxonIllustrationReferences = UUID.fromString("6062122b-07c7-44e4-a9af-7daea0005819");
414
    public static final UUID uuidFeatureSpecimenNotes = UUID.fromString("3c657936-f51a-4bfa-9ea4-287926ac63e5");
415
    public static final UUID uuidFeatureEditorialNotes = UUID.fromString("5f971b66-1bc7-4b12-923e-2b4ee8b3737d");
416
    public static final UUID uuidFeatureHabitatSalvador = UUID.fromString("d03a5e2c-fd93-4fff-b0b3-e16cefbb9847");
417

    
418
	public static UUID uuidNomStatusCombIned = UUID.fromString("dde8a2e7-bf9e-42ec-b186-d5bde9c9c128");
419
	public static UUID uuidNomStatusSpNovIned = UUID.fromString("1a359ca1-9364-43bc-93e4-834bdcd52b72");
420
	public static UUID uuidNomStatusNomOrthCons = UUID.fromString("0f838183-ffa0-4014-928e-0e3a27eb3918");
421

    
422
	static NomenclaturalStatusType nomStatusCombIned;
423
	static NomenclaturalStatusType nomStatusSpNovIned;
424
	static NomenclaturalStatusType nomStatusNomOrthCons;
425

    
426
	public static NomenclaturalStatusType nomStatusTypeAbbrev2NewNomStatusType(String nomStatus){
427
		NomenclaturalStatusType result = null;
428
		if (nomStatus == null){
429
			return null;
430
		}else if (nomStatus.equalsIgnoreCase("comb. ined.")){
431
			if (nomStatusCombIned == null){
432
				nomStatusCombIned = NomenclaturalStatusType.NewInstance("comb. ined.", "comb. ined.", "comb. ined.", Language.LATIN());
433
				nomStatusCombIned.setUuid(uuidNomStatusCombIned);
434
				NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusCombIned);
435
			}
436
			result = nomStatusCombIned;
437
		}else if (nomStatus.equalsIgnoreCase("sp. nov. ined.")){
438
			if (nomStatusSpNovIned == null){
439
				nomStatusSpNovIned = NomenclaturalStatusType.NewInstance("sp. nov. ined.", "sp. nov. ined.", "sp. nov. ined.", Language.LATIN());
440
				nomStatusSpNovIned.setUuid(uuidNomStatusSpNovIned);
441
				NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusSpNovIned);
442
			}
443
			result = nomStatusSpNovIned;
444
		}else if (nomStatus.equalsIgnoreCase("nom. & orth. cons.")){
445
			if (nomStatusNomOrthCons == null){
446
				nomStatusNomOrthCons = NomenclaturalStatusType.NewInstance("nom. & orth. cons.", "nom. & orth. cons.", "nom. & orth. cons.", Language.LATIN());
447
				nomStatusNomOrthCons.setUuid(uuidNomStatusNomOrthCons);
448
				NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusNomOrthCons);
449
			}
450
			result = nomStatusNomOrthCons;
451
		}
452
		return result;
453
	}
454

    
455

    
456
	public static NomenclaturalStatus nomStatusFkToNomStatus(int nomStatusFk, String nomStatusLabel)  throws UnknownCdmTypeException{
457
		if (nomStatusFk == NAME_ST_NOM_INVAL){
458
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.INVALID());
459
		}else if (nomStatusFk == NAME_ST_NOM_ILLEG){
460
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ILLEGITIMATE());
461
		}else if (nomStatusFk == NAME_ST_NOM_NUD){
462
			 return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NUDUM());
463
		}else if (nomStatusFk == NAME_ST_NOM_REJ){
464
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED());
465
		}else if (nomStatusFk == NAME_ST_NOM_REJ_PROP){
466
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.REJECTED_PROP());
467
		}else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ){
468
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED());
469
		}else if (nomStatusFk == NAME_ST_NOM_UTIQUE_REJ_PROP){
470
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.UTIQUE_REJECTED_PROP());
471
		}else if (nomStatusFk == NAME_ST_NOM_CONS){
472
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED());
473
		}else if (nomStatusFk == NAME_ST_NOM_CONS_PROP){
474
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED_PROP());
475
		}else if (nomStatusFk == NAME_ST_ORTH_CONS){
476
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED());
477
		}else if (nomStatusFk == NAME_ST_ORTH_CONS_PROP){
478
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP());
479
		}else if (nomStatusFk == NAME_ST_NOM_SUPERFL){
480
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.SUPERFLUOUS());
481
		}else if (nomStatusFk == NAME_ST_NOM_AMBIG){
482
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.AMBIGUOUS());
483
		}else if (nomStatusFk == NAME_ST_NOM_PROVIS){
484
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.PROVISIONAL());
485
		}else if (nomStatusFk == NAME_ST_NOM_DUB){
486
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.DOUBTFUL());
487
		}else if (nomStatusFk == NAME_ST_NOM_NOV){
488
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NOVUM());
489
		}else if (nomStatusFk == NAME_ST_NOM_CONFUS){
490
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONFUSUM());
491
		}else if (nomStatusFk == NAME_ST_NOM_ALTERN){
492
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE());
493
		}else if (nomStatusFk == NAME_ST_COMB_INVAL){
494
			return NomenclaturalStatus.NewInstance(NomenclaturalStatusType.COMBINATION_INVALID());
495
		}else {
496
			NomenclaturalStatusType statusType = nomStatusTypeAbbrev2NewNomStatusType(nomStatusLabel);
497
			NomenclaturalStatus result = NomenclaturalStatus.NewInstance(statusType);
498
			if (result != null){
499
				return result;
500
			}
501
			throw new UnknownCdmTypeException("Unknown NomenclaturalStatus (id=" + Integer.valueOf(nomStatusFk).toString() + ")");
502
		}
503
	}
504

    
505
	public static UUID getEMAreaUuid(String areaId){
506
		if (areaId == null){
507
			logger.warn("No AreaId given");
508
			return null;
509
		}else if (areaId.equals("EM")){return uuidEM;
510
		}else if (areaId.equals("EUR")){return uuidEUR;
511
		}else if (areaId.equals("14")){return uuid14;
512
		}else if (areaId.equals("20")){return uuid20;
513
		}else if (areaId.equals("21")){return uuid21;
514
		}else if (areaId.equals("33")){return uuid33;
515
		}else if (areaId.equals("Da")){return uuidDa;
516
		}else if (areaId.equals("Fe")){return uuidFe;
517
		}else if (areaId.equals("Fa")){return uuidFa;
518
		}else if (areaId.equals("Br")){return uuidBr;
519
		}else if (areaId.equals("Is")){return uuidIs;
520
		}else if (areaId.equals("Hb")){return uuidHb;
521
		}else if (areaId.equals("No")){return uuidNo;
522
		}else if (areaId.equals("Sb")){return uuidSb;
523
		}else if (areaId.equals("Su")){return uuidSu;
524
		}else if (areaId.equals("Au")){return uuidAu;
525
		}else if (areaId.equals("Be")){return uuidBe;
526
		}else if (areaId.equals("Cz")){return uuidCz;
527
		}else if (areaId.equals("Ge")){return uuidGe;
528
		}else if (areaId.equals("Hu")){return uuidHu;
529
		}else if (areaId.equals("Ho")){return uuidHo;
530
		}else if (areaId.equals("Po")){return uuidPo;
531
		}else if (areaId.equals("He")){return uuidHe;
532
		}else if (areaId.equals("Bl")){return uuidBl;
533
		}else if (areaId.equals("Co")){return uuidCo;
534
		}else if (areaId.equals("Ga")){return uuidGa;
535
		}else if (areaId.equals("Lu")){return uuidLu;
536
		}else if (areaId.equals("Sa")){return uuidSa;
537
		}else if (areaId.equals("Hs")){return uuidHs;
538
		}else if (areaId.equals("Al")){return uuidAl;
539
		}else if (areaId.equals("Bu")){return uuidBu;
540
		}else if (areaId.equals("Gr")){return uuidGr;
541
		}else if (areaId.equals("It")){return uuidIt;
542
		}else if (areaId.equals("Cr")){return uuidCr;
543
		}else if (areaId.equals("Rm")){return uuidRm;
544
		}else if (areaId.equals("Si(S)")){return uuidSi_S;
545
		}else if (areaId.equals("Tu(E)")){return uuidTu_E;
546
		}else if (areaId.equals("Ju")){return uuidJu;
547
		}else if (areaId.equals("Uk(K)")){return uuidUk_K;
548
		}else if (areaId.equals("Uk")){return uuidUk;
549
		}else if (areaId.equals("Ag")){return uuidAg;
550
		}else if (areaId.equals("Eg")){return uuidEg;
551
		}else if (areaId.equals("Li")){return uuidLi;
552
		}else if (areaId.equals("Ma")){return uuidMa;
553
		}else if (areaId.equals("Tn")){return uuidTn;
554
		}else if (areaId.equals("Az")){return uuidAz;
555
		}else if (areaId.equals("Sg")){return uuidSg;
556
		}else if (areaId.equals("Ab")){return uuidAb;
557
		}else if (areaId.equals("Ar")){return uuidAr;
558
		}else if (areaId.equals("Ab(A)")){return uuidAb_A;
559
		}else if (areaId.equals("Gg")){return uuidGg;
560
		}else if (areaId.equals("Ab(N)")){return uuidAb_N;
561
		}else if (areaId.equals("Cy")){return uuidCy;
562
		}else if (areaId.equals("AE(G)")){return uuidAE_G;
563
		}else if (areaId.equals("Le")){return uuidLe;
564
		}else if (areaId.equals("Sn")){return uuidSn;
565
		}else if (areaId.equals("Tu(A)")){return uuidTu_A;
566
		}else if (areaId.equals("Tu")){return uuidTu;
567
		}else if (areaId.equals("Au(A)")){return uuidAu_A;
568
		}else if (areaId.equals("Au(L)")){return uuidAu_L;
569
		}else if (areaId.equals("Az(C)")){return uuidAz_C;
570
		}else if (areaId.equals("Az(F)")){return uuidAz_F;
571
		}else if (areaId.equals("Az(G)")){return uuidAz_G;
572
		}else if (areaId.equals("Az(P)")){return uuidAz_P;
573
		}else if (areaId.equals("Az(S)")){return uuidAz_S;
574
		}else if (areaId.equals("Az(J)")){return uuidAz_J;
575
		}else if (areaId.equals("Az(M)")){return uuidAz_M;
576
		}else if (areaId.equals("Az(T)")){return uuidAz_T;
577
		}else if (areaId.equals("Be(B)")){return uuidBe_B;
578
		}else if (areaId.equals("Be(L)")){return uuidBe_L;
579
		}else if (areaId.equals("Bl(I)")){return uuidBl_I;
580
		}else if (areaId.equals("Bl(M)")){return uuidBl_M;
581
		}else if (areaId.equals("Bl(N)")){return uuidBl_N;
582
		}else if (areaId.equals("BH")){return uuidBH;
583
		}else if (areaId.equals("By")){return uuidBy;
584
		}else if (areaId.equals("Ca")){return uuidCa;
585
		}else if (areaId.equals("Ca(F)")){return uuidCa_F;
586
		}else if (areaId.equals("Ca(G)")){return uuidCa_G;
587
		}else if (areaId.equals("Ca(C)")){return uuidCa_C;
588
		}else if (areaId.equals("Ca(H)")){return uuidCa_H;
589
		}else if (areaId.equals("Ca(L)")){return uuidCa_L;
590
		}else if (areaId.equals("Ca(P)")){return uuidCa_P;
591
		}else if (areaId.equals("Ca(T)")){return uuidCa_T;
592
		}else if (areaId.equals("Cs")){return uuidCs;
593
		}else if (areaId.equals("Ct")){return uuidCt;
594
		}else if (areaId.equals("Es")){return uuidEs;
595
		}else if (areaId.equals("Ga(C)")){return uuidGa_C;
596
		}else if (areaId.equals("Ga(F)")){return uuidGa_F;
597
		}else if (areaId.equals("Gg(A)")){return uuidGg_A;
598
		}else if (areaId.equals("Gg(D)")){return uuidGg_D;
599
		}else if (areaId.equals("Gg(G)")){return uuidGg_G;
600
		}else if (areaId.equals("Hs(A)")){return uuidHs_A;
601
		}else if (areaId.equals("Hs(G)")){return uuidHs_G;
602
		}else if (areaId.equals("Hs(S)")){return uuidHs_S;
603
		}else if (areaId.equals("Ir")){return uuidIr;
604
		}else if (areaId.equals("It(I)")){return uuidIt_I;
605
		}else if (areaId.equals("It(S)")){return uuidIt_S;
606
		}else if (areaId.equals("Jo")){return uuidJo;
607
		}else if (areaId.equals("Kz")){return uuidKz;
608
		}else if (areaId.equals("La")){return uuidLa;
609
		}else if (areaId.equals("Lt")){return uuidLt;
610
		}else if (areaId.equals("Ma(E)")){return uuidMa_E;
611
		}else if (areaId.equals("Ma(S)")){return uuidMa_S;
612
		}else if (areaId.equals("Mk")){return uuidMk;
613
		}else if (areaId.equals("Md")){return uuidMd;
614
		}else if (areaId.equals("Md(D)")){return uuidMd_D;
615
		}else if (areaId.equals("Md(M)")){return uuidMd_M;
616
		}else if (areaId.equals("Md(P)")){return uuidMd_P;
617
		}else if (areaId.equals("Si(M)")){return uuidSi_M;
618
		}else if (areaId.equals("Mo")){return uuidMo;
619
		}else if (areaId.equals("Rf")){return uuidRf;
620
		}else if (areaId.equals("Rf(C)")){return uuidRf_C;
621
		}else if (areaId.equals("Rf(E)")){return uuidRf_E;
622
		}else if (areaId.equals("Rf(K)")){return uuidRf_K;
623
		}else if (areaId.equals("Rf(CS)")){return uuidRf_CS;
624
		}else if (areaId.equals("Rf(N)")){return uuidRf_N;
625
		}else if (areaId.equals("Rf(NW)")){return uuidRf_NW;
626
		}else if (areaId.equals("Rf(A)")){return uuidRf_A;
627
		}else if (areaId.equals("Rf(S)")){return uuidRf_S;
628
		}else if (areaId.equals("Sk")){return uuidSk;
629
		}else if (areaId.equals("Sl")){return uuidSl;
630
		}else if (areaId.equals("Sy")){return uuidSy;
631
		}else if (areaId.equals("Uk(U)")){return uuidUk_U;
632
		}else if (areaId.equals("SM")){return uuidSM;
633
		}else if (areaId.equals("Yu(K)")){return uuidYu_K;
634
		}else if (areaId.equals("Cg")){return uuidCg;
635
		}else if (areaId.equals("Sr")){return uuidSr;
636
		}else if (areaId.equals("IJ")){return uuidIJ;
637
		}else if (areaId.equals("LS")){return uuidLS;
638
		}else if (areaId.equals("Rs")){return uuidRs;
639
		}else if (areaId.equals("Si")){return uuidSi;
640
		}else if (areaId.equals("Az(L)")){return uuidAz_L;
641
		}else if (areaId.equals("Hb(E)")){return uuidHb_E;
642
		}else if (areaId.equals("Hb(N)")){return uuidHb_N;
643
		}else if (areaId.equals("Ga(M)")){return uuidGa_M;
644
		}else if (areaId.equals("Ma(M)")){return uuidMa_M;
645
		}else if (areaId.equals("Rs(N)")){return uuidRs_N;
646
		}else if (areaId.equals("Rs(B)")){return uuidRs_B;
647
		}else if (areaId.equals("Rs(C)")){return uuidRs_C;
648
		}else if (areaId.equals("Rs(W)")){return uuidRs_W;
649
		}else if (areaId.equals("Rs(E)")){return uuidRs_E;
650
		}else if (areaId.equals("AE")){return uuidAE;
651
		}else if (areaId.equals("AE(T)")){return uuidAE_T;
652
		}else if (areaId.equals("Rs(K)")){return uuidRs_K;
653
		}else if (areaId.equals("Cc")){return uuidCc;
654
		}else if (areaId.equals("Bt")){return uuidBt;
655
		}else if (areaId.equals("Tcs")){return uuidTcs;
656
        }else if (areaId.equals("Azores")){return null;  //these are duplicates and are handled differently
657
        }else if (areaId.equals("Canary Is.")){return null; //these are duplicates and are handled differently
658
        }else{
659
		    logger.warn("Area not found: " + areaId);
660
			return null;
661
		}
662

    
663
	}
664

    
665

    
666
	//TypeDesignation
667
	public static SpecimenTypeDesignationStatus typeStatusId2TypeStatus (int typeStatusId)  throws UnknownCdmTypeException{
668
		switch (typeStatusId){
669
			case 0: return null;
670
			case 1: return SpecimenTypeDesignationStatus.HOLOTYPE();
671
			case 2: return SpecimenTypeDesignationStatus.LECTOTYPE();
672
			case 3: return SpecimenTypeDesignationStatus.NEOTYPE();
673
			case 4: return SpecimenTypeDesignationStatus.EPITYPE();
674
			case 5: return SpecimenTypeDesignationStatus.ISOLECTOTYPE();
675
			case 6: return SpecimenTypeDesignationStatus.ISONEOTYPE();
676
			case 7: return SpecimenTypeDesignationStatus.ISOTYPE();
677
			case 8: return SpecimenTypeDesignationStatus.PARANEOTYPE();
678
			case 9: return SpecimenTypeDesignationStatus.PARATYPE();
679
			case 10: return SpecimenTypeDesignationStatus.SECOND_STEP_LECTOTYPE();
680
			case 11: return SpecimenTypeDesignationStatus.SECOND_STEP_NEOTYPE();
681
			case 12: return SpecimenTypeDesignationStatus.SYNTYPE();
682
			case 21: return SpecimenTypeDesignationStatus.ICONOTYPE();
683
			case 22: return SpecimenTypeDesignationStatus.PHOTOTYPE();
684
			default: {
685
				throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(typeStatusId).toString() + ")");
686
			}
687
		}
688
	}
689

    
690
	//TypeDesignation
691
	public static TaxonRelationshipType taxonRelId2TaxonRelType (int relTaxonTypeId, ResultWrapper<Boolean> isInverse, ResultWrapper<Boolean> isDoubtful)  throws UnknownCdmTypeException{
692
		isInverse.setValue(false);
693
		switch (relTaxonTypeId){
694
			case 0: return null;
695
			case 11: return TaxonRelationshipType.CONGRUENT_TO();
696
			case 12: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES();
697
			case 13: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();
698
			case 14: return TaxonRelationshipType.INCLUDES();
699
			case 15: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES();
700
			case 16: return TaxonRelationshipType.INCLUDED_OR_INCLUDES();
701
			case 17: return TaxonRelationshipType.CONGRUENT_OR_INCLUDED_OR_INCLUDES();
702
			case 18: return TaxonRelationshipType.OVERLAPS();
703
			case 19: return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();
704
			case 20: isInverse.setValue(true); return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();
705
			case 21: isInverse.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();
706
			case 22: return TaxonRelationshipType.INCLUDES_OR_OVERLAPS();
707
			case 23: return TaxonRelationshipType.CONGRUENT_OR_INCLUDES_OR_OVERLAPS();
708
			case 24: return TaxonRelationshipType.INCLUDED_OR_INCLUDES_OR_OVERLAPS();
709

    
710
			case 26: return TaxonRelationshipType.EXCLUDES();
711

    
712
			//TODO other relationshipTypes
713

    
714
			case 40: return TaxonRelationshipType.NOT_CONGRUENT_TO();
715

    
716
			//how to implement this, what is a purely doubtful relationship ??
717
//			case 42: isDoubtful.setValue(true); return TaxonRelationshipType.();
718

    
719
			case 43: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_TO();
720
			case 44: isInverse.setValue(true);isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();
721
			case 46: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDES();
722
			case 48: isDoubtful.setValue(true); return TaxonRelationshipType.INCLUDED_OR_INCLUDES();
723
			case 50: isDoubtful.setValue(true); return TaxonRelationshipType.OVERLAPS();
724
			case 51: isDoubtful.setValue(true); return TaxonRelationshipType.CONGRUENT_OR_OVERLAPS();
725
			case 58: isDoubtful.setValue(true); return TaxonRelationshipType.EXCLUDES();
726

    
727

    
728
			default: {
729
				throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(relTaxonTypeId).toString() + ")");
730
			}
731
		}
732
	}
733

    
734
	//TypeDesignation
735
	public static HybridRelationshipType relNameId2HybridRel (int relNameId)  throws UnknownCdmTypeException{
736
		switch (relNameId){
737
			case 0: return null;
738
			case 9: return HybridRelationshipType.FIRST_PARENT();
739
			case 10: return HybridRelationshipType.SECOND_PARENT();
740
			case 11: return HybridRelationshipType.FEMALE_PARENT();
741
			case 12: return HybridRelationshipType.MALE_PARENT();
742
			default: {
743
				throw new UnknownCdmTypeException("Unknown HybridRelationshipType (id=" + Integer.valueOf(relNameId).toString() + ")");
744
			}
745
		}
746
	}
747

    
748
	//OccStatus
749
	public static PresenceAbsenceTerm occStatus2PresenceAbsence (int occStatusId)  throws UnknownCdmTypeException{
750
		switch (occStatusId){
751
			case 0: return null;
752
			case 110: return PresenceAbsenceTerm.CULTIVATED_REPORTED_IN_ERROR();
753
			case 120: return PresenceAbsenceTerm.CULTIVATED();
754
			case 210: return PresenceAbsenceTerm.INTRODUCED_REPORTED_IN_ERROR();
755
			case 220: return PresenceAbsenceTerm.INTRODUCED_PRESENCE_QUESTIONABLE();
756
			case 230: return PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED();
757
			case 240: return PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED();
758
			case 250: return PresenceAbsenceTerm.INTRODUCED();
759
			case 260: return PresenceAbsenceTerm.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();
760
			case 270: return PresenceAbsenceTerm.CASUAL();
761
			case 280: return PresenceAbsenceTerm.NATURALISED();
762
			case 310: return PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR();
763
			case 320: return PresenceAbsenceTerm.NATIVE_PRESENCE_QUESTIONABLE();
764
			case 330: return PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE();
765
			case 340: return PresenceAbsenceTerm.NATIVE_DOUBTFULLY_NATIVE();
766
			case 350: return PresenceAbsenceTerm.NATIVE();
767
			case 999: {
768
					logger.info("endemic for EM can not be transformed in legal status. Used 'PRESENT' instead");
769
					//TODO preliminary
770
					return PresenceAbsenceTerm.PRESENT();
771
				}
772
			default: {
773
				throw new UnknownCdmTypeException("Unknown occurrence status  (id=" + Integer.valueOf(occStatusId).toString() + ")");
774
			}
775
		}
776
	}
777

    
778

    
779
	//FactCategory
780
	public static Feature factCategory2Feature (int factCategoryId)  throws UnknownCdmTypeException{
781
		switch (factCategoryId){
782
			case 0: return null;
783
			case 1: return Feature.DESCRIPTION();
784
			case 4: return Feature.ECOLOGY();
785
			case 5: return Feature.PHENOLOGY();
786
			case 12: return Feature.COMMON_NAME();
787
			case 13: return Feature.OCCURRENCE();
788
			case 99: return Feature.CITATION();
789
			default: {
790
				throw new UnknownCdmTypeException("Unknown FactCategory (id=" + Integer.valueOf(factCategoryId).toString() + ")");
791
			}
792
		}
793
	}
794

    
795
	public static UUID getFeatureUuid(String key) {
796
		if (key == null){
797
			return null;
798
		}else if (key.equalsIgnoreCase("14-Maps")){ return uuidFeatureMaps;
799
		}else if (key.equalsIgnoreCase("301-Conservation Status")){ return uuidFeatureConservationStatus;
800
		}else if (key.equalsIgnoreCase("302-Use")){ return uuidFeatureUse;
801
		}else if (key.equalsIgnoreCase("303-Comments")){ return uuidFeatureComments;
802

    
803
		}else if (key.equalsIgnoreCase("10-general distribution (Euro+Med)")){ return uuidFeatureDistrEM;
804
		}else if (key.equalsIgnoreCase("11-general distribution (world)")){ return uuidFeatureDistrWorld;
805
		}else if (key.equalsIgnoreCase("250-Editor_Brackets")){ return uuidFeatureEditorBrackets;
806
		}else if (key.equalsIgnoreCase("251-Editor_Parenthesis")){ return uuidFeatureEditorParenthesis;
807
		}else if (key.equalsIgnoreCase("252-Inedited")){ return uuidFeatureInedited;
808
		}else if (key.equalsIgnoreCase("253-Comments on editing process")){ return uuidFeatureCommentsEditing;
809

    
810
		//salvador
811
		}else if (key.equalsIgnoreCase("302-Usos")){ return Feature.uuidUses;
812
		}else if (key.equalsIgnoreCase("303-Distribución global")){ return uuidFeatureDistributionGlobal;
813
		}else if (key.equalsIgnoreCase("306-Nombre(s) común(es)")){ return Feature.uuidCommonName;
814
		}else if (key.equalsIgnoreCase("307-Muestras de herbario")){ return Feature.uuidSpecimen;
815
        }else if (key.equalsIgnoreCase("309-Reporte para El Salvador")){ return uuidReporteParaElSalvador;
816
        }else if (key.equalsIgnoreCase("310-Otras referencias")){ return uuidFeatureOtherReferences;
817
        }else if (key.equalsIgnoreCase("311-Ilustración(es)")){ return uuidFeatureTaxonIllustrationReferences;
818
        }else if (key.equalsIgnoreCase("312-Imágen")){ return Feature.uuidImage;
819
        }else if (key.equalsIgnoreCase("350-Descripción*")){ return Feature.uuidDescription;
820
        }else if (key.equalsIgnoreCase("1800-Notas de muestras*")){ return uuidFeatureSpecimenNotes;
821
        }else if (key.equalsIgnoreCase("1900-Notas editoriales*")){ return uuidFeatureEditorialNotes;
822
        }else if (key.equalsIgnoreCase("2000-Habitat en El Salvador*")){ return uuidFeatureHabitatSalvador;
823

    
824

    
825

    
826

    
827

    
828

    
829

    
830
		}else{
831
			return null;
832
		}
833
	}
834

    
835

    
836
	static Rank collSpeciesRank;
837
	/**
838
	 * @param i
839
	 * @return
840
	 */
841
	private static Rank rankId2NewRank(Integer rankId, boolean switchRank) {
842
		Rank result = null;
843
		if (rankId == null){
844
			return null;
845
		}else if (rankId == 57){
846

    
847
			if (collSpeciesRank == null){
848
				collSpeciesRank = Rank.NewInstance(RankClass.SpeciesGroup, "Collective species", "Coll. species", "coll.");
849
				collSpeciesRank.setUuid(uuidRankCollSpecies);
850
				OrderedTermVocabulary<Rank> voc = (OrderedTermVocabulary<Rank>)Rank.SPECIES().getVocabulary();
851
				voc.addTermBelow(collSpeciesRank, Rank.SPECIESGROUP());
852
			}
853
			result = collSpeciesRank;
854
		}
855
		return result;
856
	}
857

    
858

    
859
	public static Rank rankId2Rank (ResultSet rs, boolean useUnknown, boolean switchSpeciesGroup) throws UnknownCdmTypeException{
860
		Rank result;
861
		try {
862
			int rankId = rs.getInt("rankFk");
863

    
864
			String abbrev = rs.getString("rankAbbrev");
865
			String rankName = rs.getString("rank");
866
			if (logger.isDebugEnabled()){logger.debug(rankId);}
867
			if (logger.isDebugEnabled()){logger.debug(abbrev);}
868
			if (logger.isDebugEnabled()){logger.debug(rankName);}
869

    
870
			if (switchSpeciesGroup){
871
				if (rankId == 59){
872
					rankId = 57;
873
				}else if (rankId == 57){
874
					rankId = 59;
875
				}
876
			}
877
			try {
878
				result = Rank.getRankByNameOrIdInVoc(abbrev);
879
			} catch (UnknownCdmTypeException e) {
880
				try {
881
					result = Rank.getRankByNameOrIdInVoc(rankName);
882
				} catch (UnknownCdmTypeException e1) {
883
					switch (rankId){
884
						case 0: return null;
885
						case 1: return Rank.KINGDOM();
886
						case 3: return Rank.SUBKINGDOM();
887
						case 5: return Rank.PHYLUM();
888
						case 7: return Rank.SUBPHYLUM();
889
						case 8: return Rank.DIVISION();
890
						case 9: return Rank.SUBDIVISION();
891
						case 10: return Rank.CLASS();
892
						case 13: return Rank.SUBCLASS();
893
						case 16: return Rank.SUPERORDER();
894
						case 18: return Rank.ORDER();
895
						case 19: return Rank.SUBORDER();
896
						case 20: return Rank.FAMILY();
897
						case 25: return Rank.SUBFAMILY();
898
						case 30: return Rank.TRIBE();
899
						case 35: return Rank.SUBTRIBE();
900
						case 40: return Rank.GENUS();
901
						case 42: return Rank.SUBGENUS();
902
						case 45: return Rank.SECTION_BOTANY();
903
						case 47: return Rank.SUBSECTION_BOTANY();
904
						case 50: return Rank.SERIES();
905
						case 52: return Rank.SUBSERIES();
906
						case 58: return Rank.SPECIESAGGREGATE();
907
						case 59: return Rank.SPECIESGROUP();
908
						case 60: return Rank.SPECIES();
909
						case 61: return Rank.GREX();
910
						case 65: return Rank.SUBSPECIES();
911
						case 66: {System.out.println("Rank 66 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}
912
						case 67: {System.out.println("Rank 67 not yet implemented"); throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());}
913
						case 68: return Rank.CONVAR();
914
						case 70: return Rank.VARIETY();
915
						case 73: return Rank.SUBVARIETY();
916
						case 80: return Rank.FORM();
917
						case 82: return Rank.SUBFORM();
918
						case 84: return Rank.SPECIALFORM();
919
						case 98: return Rank.INFRAGENERICTAXON();
920
						case 99: return Rank.INFRASPECIFICTAXON();
921

    
922
						case 750: return Rank.SUPERCLASS();
923
						case 780: return Rank.INFRACLASS();
924
						case 820: return Rank.INFRAORDER();
925

    
926
						case 830: return Rank.SUPERFAMILY();
927

    
928
						default: {
929
							Rank rank = rankId2NewRank(57, switchSpeciesGroup);
930
							if (rank != null){
931
								return rank;
932
							}
933
							if (useUnknown){
934
								logger.error("Rank unknown: " + rankId + ". Created UNKNOWN_RANK");
935
								return Rank.UNKNOWN_RANK();
936
							}
937
							throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());
938
						}
939
					}
940
				}
941
			}
942
			return result;
943
		} catch (SQLException e) {
944
			e.printStackTrace();
945
			logger.warn("Exception occurred. Created UNKNOWN_RANK instead");
946
			return Rank.UNKNOWN_RANK();
947
		}
948
	}
949

    
950

    
951
	public static Integer rank2RankId (Rank rank){
952
		if (rank == null){
953
			return null;
954
		}
955
		else if (rank.equals(Rank.KINGDOM())){		return 1;}
956
		else if (rank.equals(Rank.SUBKINGDOM())){	return 3;}
957
		else if (rank.equals(Rank.PHYLUM())){		return 5;}
958
		else if (rank.equals(Rank.SUBPHYLUM())){	return 7;}
959
		else if (rank.equals(Rank.DIVISION())){		return 8;}
960
		else if (rank.equals(Rank.SUBDIVISION())){	return 9;}
961

    
962
		else if (rank.equals(Rank.CLASS())){		return 10;}
963
		else if (rank.equals(Rank.SUBCLASS())){		return 13;}
964
		else if (rank.equals(Rank.SUPERORDER())){	return 16;}
965
		else if (rank.equals(Rank.ORDER())){		return 18;}
966
		else if (rank.equals(Rank.SUBORDER())){		return 19;}
967
		else if (rank.equals(Rank.FAMILY())){		return 20;}
968
		else if (rank.equals(Rank.SUBFAMILY())){	return 25;}
969
		else if (rank.equals(Rank.TRIBE())){		return 30;}
970
		else if (rank.equals(Rank.SUBTRIBE())){		return 35;}
971
		else if (rank.equals(Rank.GENUS())){		return 40;}
972
		else if (rank.equals(Rank.SUBGENUS())){		return 42;}
973
		else if (rank.equals(Rank.SECTION_BOTANY())){		return 45;}
974
		else if (rank.equals(Rank.SUBSECTION_BOTANY())){	return 47;}
975
		else if (rank.equals(Rank.SERIES())){		return 50;}
976
		else if (rank.equals(Rank.SUBSERIES())){	return 52;}
977
		else if (rank.equals(Rank.SPECIESAGGREGATE())){	return 58;}
978
		//TODO
979
		//		else if (rank.equals(Rank.XXX())){	return 59;}
980
		else if (rank.equals(Rank.SPECIES())){		return 60;}
981
		else if (rank.equals(Rank.SUBSPECIES())){	return 65;}
982
		else if (rank.equals(Rank.CONVAR())){		return 68;}
983
		else if (rank.equals(Rank.VARIETY())){		return 70;}
984
		else if (rank.equals(Rank.SUBVARIETY())){	return 73;}
985
		else if (rank.equals(Rank.FORM())){			return 80;}
986
		else if (rank.equals(Rank.SUBFORM())){		return 82;}
987
		else if (rank.equals(Rank.SPECIALFORM())){	return 84;}
988
		else if (rank.equals(Rank.INFRAGENERICTAXON())){	return 98;}
989
		else if (rank.equals(Rank.INFRASPECIFICTAXON())){	return 99;}
990

    
991
		else if (rank.equals(Rank.SUPERCLASS())){	return 750;}
992
		else if (rank.equals(Rank.INFRACLASS())){	return 780;}
993
		else if (rank.equals(Rank.INFRAORDER())){	return 820;}
994
		else if (rank.equals(Rank.SUPERFAMILY())){	return 830;}
995

    
996
		else {
997
			//TODO Exception
998
			logger.warn("Rank not yet supported in Berlin Model: "+ rank.getLabel());
999
			return null;
1000
		}
1001
	}
1002

    
1003
	public static Integer textData2FactCategoryFk (Feature feature){
1004
		if (feature == null){return null;}
1005
		if (feature.equals(Feature.DESCRIPTION())){
1006
			return 1;
1007
		}else if (feature.equals(Feature.ECOLOGY())){
1008
			return 4;
1009
		}else if (feature.equals(Feature.PHENOLOGY())){
1010
			return 5;
1011
		}else if (feature.equals(Feature.COMMON_NAME())){
1012
			return 12;
1013
		}else if (feature.equals(Feature.OCCURRENCE())){
1014
			return 13;
1015
		}else if (feature.equals(Feature.CITATION())){
1016
			return 99;
1017
		}else{
1018
			logger.debug("Unknown Feature.");
1019
			return null;
1020
		}
1021
	}
1022

    
1023

    
1024
	public static Integer taxonBase2statusFk (TaxonBase<?> taxonBase){
1025
		if (taxonBase == null){return null;}
1026
		if (taxonBase.isInstanceOf(Taxon.class)){
1027
			return T_STATUS_ACCEPTED;
1028
		}else if (taxonBase.isInstanceOf(Synonym.class)){
1029
			return T_STATUS_SYNONYM;
1030
		}else{
1031
			logger.warn("Unknown ");
1032
			return T_STATUS_UNRESOLVED;
1033
		}
1034
		//TODO
1035
//		public static int T_STATUS_PARTIAL_SYN = 3;
1036
//		public static int T_STATUS_PRO_PARTE_SYN = 4;
1037
//		public static int T_STATUS_UNRESOLVED = 5;
1038
//		public static int T_STATUS_ORPHANED = 6;
1039
	}
1040

    
1041
	public static Integer ref2refCategoryId (Reference ref){
1042
		if (ref == null){
1043
			return null;
1044
		}
1045
		else if (ref.getType().equals(ReferenceType.Article)){		return REF_ARTICLE;}
1046
		else if (ref instanceof ISection){	return REF_PART_OF_OTHER_TITLE;}
1047
		else if (ref.getType().equals(ReferenceType.Book)){	return REF_BOOK;}
1048
		else if (ref.getType().equals(ReferenceType.Database)){	return REF_DATABASE;}
1049
//		else if (ref instanceof SectionBas){	return REF_INFORMAL;}
1050
//		else if (ref instanceof SectionBas){	return REF_NOT_APPLICABLE;}
1051
		else if (ref.getType().equals(ReferenceType.WebPage)){	return REF_WEBSITE;}
1052
		else if (ref.getType().equals(ReferenceType.CdDvd)){	return REF_CD;}
1053
		else if (ref.getType().equals(ReferenceType.Journal)){	return REF_JOURNAL;}
1054
		else if (ref.getType().equals(ReferenceType.Generic)){	return REF_UNKNOWN;}
1055
		else if (ref.getType().equals(ReferenceType.PrintSeries)){
1056
			logger.warn("Print Series is not a standard Berlin Model category");
1057
			return REF_PRINT_SERIES;
1058
		}
1059
		else if (ref.getType().equals(ReferenceType.Proceedings)){
1060
			logger.warn("Proceedings is not a standard Berlin Model category");
1061
			return REF_CONFERENCE_PROCEEDINGS;
1062
		}
1063
//		else if (ref instanceof ){	return REF_JOURNAL_VOLUME;}
1064
		else if (ref.getType().equals(ReferenceType.Patent)){	return REF_NOT_APPLICABLE;}
1065
		else if (ref.getType().equals(ReferenceType.PersonalCommunication)){	return REF_INFORMAL;}
1066
		else if (ref.getType().equals(ReferenceType.Report)){	return REF_NOT_APPLICABLE;}
1067
		else if (ref.getType().equals(ReferenceType.Thesis)){	return REF_NOT_APPLICABLE;}
1068
		else if (ref.getType().equals(ReferenceType.Report)){	return REF_NOT_APPLICABLE;}
1069

    
1070
		else {
1071
			//TODO Exception
1072
			logger.warn("Reference type not yet supported in Berlin Model: "+ ref.getClass().getSimpleName());
1073
			return null;
1074
		}
1075
	}
1076

    
1077

    
1078
	public static Integer taxRelation2relPtQualifierFk (RelationshipBase<?,?,?> rel){
1079
		if (rel == null){
1080
			return null;
1081
		}
1082
//		else if (rel instanceof SynonymRelationship){
1083
//			return ;
1084
//		}else if (rel instanceof TaxonRelationship){
1085
			RelationshipTermBase<?> type = rel.getType();
1086
			if (type.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {return TAX_REL_IS_INCLUDED_IN;
1087
			}else if (type.equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())) {return TAX_REL_IS_MISAPPLIED_NAME_OF;
1088
			}else if (type.equals(TaxonRelationshipType.PRO_PARTE_MISAPPLIED_NAME_FOR())) {return TAX_REL_IS_PRO_PARTE_MISAPPLIED_NAME_OF;
1089
            }else if (type.equals(SynonymType.SYNONYM_OF())) {return TAX_REL_IS_SYNONYM_OF;
1090
			}else if (type.equals(SynonymType.HOMOTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HOMOTYPIC_SYNONYM_OF;
1091
			}else if (type.equals(SynonymType.HETEROTYPIC_SYNONYM_OF())) {return TAX_REL_IS_HETEROTYPIC_SYNONYM_OF;
1092
			}else if (type.equals(TaxonRelationshipType.CONGRUENT_TO())) {return 11;
1093
//			public static int TAX_REL_IS_PROPARTE_SYN_OF = 4;
1094
//			public static int TAX_REL_IS_PARTIAL_SYN_OF = 5;
1095
//			public static int TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF = 101;
1096
//			public static int TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF = 102;
1097
//			public static int TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF = 103;
1098
//			public static int TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF = 104;
1099

    
1100
			}else {
1101
				//TODO Exception
1102
				logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());
1103
				return null;
1104
		}
1105
	}
1106

    
1107
	public static Integer nomStatus2nomStatusFk (NomenclaturalStatusType status){
1108
		if (status == null){
1109
			return null;
1110
		}
1111
		if (status.equals(NomenclaturalStatusType.INVALID())) {return NAME_ST_NOM_INVAL;
1112
		}else if (status.equals(NomenclaturalStatusType.ILLEGITIMATE())) {return NAME_ST_NOM_ILLEG;
1113
		}else if (status.equals(NomenclaturalStatusType.NUDUM())) {return NAME_ST_NOM_NUD;
1114
		}else if (status.equals(NomenclaturalStatusType.REJECTED())) {return NAME_ST_NOM_REJ;
1115
		}else if (status.equals(NomenclaturalStatusType.REJECTED_PROP())) {return NAME_ST_NOM_REJ_PROP;
1116
		}else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED())) {return NAME_ST_NOM_UTIQUE_REJ;
1117
		}else if (status.equals(NomenclaturalStatusType.UTIQUE_REJECTED_PROP())) {return NAME_ST_NOM_UTIQUE_REJ_PROP;
1118
		}else if (status.equals(NomenclaturalStatusType.CONSERVED())) {return NAME_ST_NOM_CONS;
1119

    
1120
		}else if (status.equals(NomenclaturalStatusType.CONSERVED_PROP())) {return NAME_ST_NOM_CONS_PROP;
1121
		}else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED())) {return NAME_ST_ORTH_CONS;
1122
		}else if (status.equals(NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP())) {return NAME_ST_ORTH_CONS_PROP;
1123
		}else if (status.equals(NomenclaturalStatusType.SUPERFLUOUS())) {return NAME_ST_NOM_SUPERFL;
1124
		}else if (status.equals(NomenclaturalStatusType.AMBIGUOUS())) {return NAME_ST_NOM_AMBIG;
1125
		}else if (status.equals(NomenclaturalStatusType.PROVISIONAL())) {return NAME_ST_NOM_PROVIS;
1126
		}else if (status.equals(NomenclaturalStatusType.DOUBTFUL())) {return NAME_ST_NOM_DUB;
1127
		}else if (status.equals(NomenclaturalStatusType.NOVUM())) {return NAME_ST_NOM_NOV;
1128

    
1129
		}else if (status.equals(NomenclaturalStatusType.CONFUSUM())) {return NAME_ST_NOM_CONFUS;
1130
		}else if (status.equals(NomenclaturalStatusType.ALTERNATIVE())) {return NAME_ST_NOM_ALTERN;
1131
		}else if (status.equals(NomenclaturalStatusType.COMBINATION_INVALID())) {return NAME_ST_COMB_INVAL;
1132
		//TODO
1133
		}else {
1134
			//TODO Exception
1135
			logger.warn("NomStatus type not yet supported by Berlin Model export: "+ status);
1136
			return null;
1137
		}
1138
	}
1139

    
1140

    
1141

    
1142
	public static Integer nameRel2RelNameQualifierFk (RelationshipBase<?,?,?> rel){
1143
		if (rel == null){
1144
			return null;
1145
		}
1146
		RelationshipTermBase<?> type = rel.getType();
1147
		if (type.equals(NameRelationshipType.BASIONYM())) {return NAME_REL_IS_BASIONYM_FOR;
1148
		}else if (type.equals(NameRelationshipType.LATER_HOMONYM())) {return NAME_REL_IS_LATER_HOMONYM_OF;
1149
		}else if (type.equals(NameRelationshipType.REPLACED_SYNONYM())) {return NAME_REL_IS_REPLACED_SYNONYM_FOR;
1150
		//TODO
1151
		}else if (type.equals(NameRelationshipType.VALIDATED_BY_NAME())) {return NAME_REL_IS_VALIDATION_OF;
1152
		}else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_LATER_VALIDATION_OF;
1153
		}else if (type.equals(NameRelationshipType.CONSERVED_AGAINST())) {return NAME_REL_IS_CONSERVED_AGAINST;
1154

    
1155

    
1156
		}else if (type.equals(NameRelationshipType.TREATED_AS_LATER_HOMONYM())) {return NAME_REL_IS_TREATED_AS_LATER_HOMONYM_OF;
1157
		}else if (type.equals(NameRelationshipType.ORTHOGRAPHIC_VARIANT())) {return NAME_REL_IS_ORTHOGRAPHIC_VARIANT_OF;
1158
		}else {
1159
			//TODO Exception
1160
			logger.warn("Relationship type not yet supported by Berlin Model export: "+ rel.getType());
1161
			return null;
1162
	}
1163

    
1164
			//NameRelationShip
1165

    
1166
//	}else if (type.equals(NameRelationshipType.())) {return NAME_REL_IS_REJECTED_IN_FAVOUR_OF;
1167

    
1168
//			public static int NAME_REL_IS_FIRST_PARENT_OF = 9;
1169
//			public static int NAME_REL_IS_SECOND_PARENT_OF = 10;
1170
//			public static int NAME_REL_IS_FEMALE_PARENT_OF = 11;
1171
//			public static int NAME_REL_IS_MALE_PARENT_OF = 12;
1172
//
1173
//			public static int NAME_REL_IS_REJECTED_IN_FAVOUR_OF = 14;
1174
//	}else if (type.equals(NameRelationshipType.)) {return NAME_REL_IS_REJECTED_TYPE_OF;
1175
//
1176
//			public static int NAME_REL_HAS_SAME_TYPE_AS = 18;
1177
//			public static int NAME_REL_IS_LECTOTYPE_OF = 61;
1178
//			public static int NAME_REL_TYPE_NOT_DESIGNATED = 62;
1179

    
1180
		//	}else if (type.equals(NameRelationshipType.LATER_VALIDATED_BY_NAME())) {return NAME_REL_IS_TYPE_OF;
1181

    
1182

    
1183
	}
1184

    
1185
	public static UUID getWebMarkerUuid (int markerCategoryId){
1186
		if (markerCategoryId == 1){
1187
			return UUID.fromString("d8554418-d1ae-471d-a1bd-a0cbc7ab860c");  //any as not to find in cichorieae
1188
		}else if (markerCategoryId == 2){
1189
			return UUID.fromString("7f189c48-8632-4870-9ec8-e4d2489f324e");
1190
		}else if (markerCategoryId == 3){
1191
			return UUID.fromString("9a115e6b-8210-4dd3-825a-6fed11016c63");
1192
		}else if (markerCategoryId == 4){
1193
			return UUID.fromString("1d287011-2054-41c5-a919-17ac1d0a9270");
1194
		}else if (markerCategoryId == 9){
1195
			return UUID.fromString("cc5eca5c-1ae5-4feb-9a95-507fc167b0c9");
1196
		//Salvador
1197
		}else if (markerCategoryId == 5){
1198
			return UUID.fromString("7d8875b3-107c-4189-97e5-cadb470e543a");
1199
		}else if (markerCategoryId == 20){
1200
			return UUID.fromString("3574e2b0-6431-4d71-b456-bc967c80f622");
1201
		}else if (markerCategoryId == 30){
1202
			return UUID.fromString("9924b27e-0dbe-4d95-ae9b-096fbbc3edcb");
1203
		}else if (markerCategoryId == 40){
1204
			return UUID.fromString("69241b97-f4d2-4f60-9aed-1c4ccb5bced5");
1205
		}else if (markerCategoryId == 50){
1206
			return UUID.fromString("f3b62ce3-0212-4542-a74c-0c68d08859b1");
1207
		}else if (markerCategoryId == 55){
1208
			return UUID.fromString("bec822f2-8242-425f-ad46-f11f0b82f69b");
1209
		}else if (markerCategoryId == 60){
1210
			return UUID.fromString("722fca60-0416-4bf0-aa4b-a07400f9710d");
1211
		}else if (markerCategoryId == 70){
1212
			return UUID.fromString("ed57857b-1001-4b09-b48e-d88ab146bb2b");
1213
		}else if (markerCategoryId == 80){
1214
			return UUID.fromString("637e8b77-1202-462b-9d77-1023f3c192d9");
1215
		}else if (markerCategoryId == 90){
1216
			return UUID.fromString("c769c231-6e76-46df-88f7-2c459342a3c2");
1217
		}else if (markerCategoryId == 93){
1218
			return UUID.fromString("075ee97e-246f-4f3d-aa96-16930df6268c");
1219
		}else if (markerCategoryId == 100){
1220
			return UUID.fromString("e17065bf-3e44-417a-b05c-f82929f680c3");
1221
		}else if (markerCategoryId == 110){
1222
			return UUID.fromString("e2b8de07-770e-4fda-b445-c4735f4e95c8");
1223
		}else if (markerCategoryId == 900){
1224
			return UUID.fromString("d029c3c9-944a-4bb9-bba6-12c95da94a04");
1225
		}else if (markerCategoryId == 920){
1226
			return UUID.fromString("98af97b1-e5e3-4ee4-902e-15032316bfc3");
1227
		}else if (markerCategoryId == 930){
1228
			return UUID.fromString("4b6c3130-4e50-4f45-8461-d2698cf5f80b");
1229
		}else if (markerCategoryId == 950){
1230
			return UUID.fromString("1e53f58c-6528-42c6-99ae-0f75a3c3c264");
1231
		}else if (markerCategoryId == 960){
1232
			return UUID.fromString("1903d460-94cc-4fc4-b2a8-a3fb0cfd69a0");
1233
		}else{
1234
			logger.warn("Unknown webMarker category: " + markerCategoryId);
1235
			return null;
1236
		}
1237

    
1238
	}
1239

    
1240
}
(1-1/2)