Project

General

Profile

Download (25.3 KB) Statistics
| Branch: | 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.pesi.faunaEuropaea;
11

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

    
17
import org.apache.log4j.Logger;
18

    
19
import eu.etaxonomy.cdm.api.service.ITermService;
20
import eu.etaxonomy.cdm.model.common.DefinedTerm;
21
import eu.etaxonomy.cdm.model.common.Language;
22
import eu.etaxonomy.cdm.model.common.Representation;
23
import eu.etaxonomy.cdm.model.common.TermType;
24
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
25
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
26
import eu.etaxonomy.cdm.model.name.Rank;
27
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
28

    
29
/**
30
 * @author a.babadshanjan
31
 * @created 12.05.2009
32
 */
33

    
34
public final class FaunaEuropaeaTransformer {
35
	private static final Logger logger = Logger.getLogger(FaunaEuropaeaTransformer.class);
36

    
37
	public static final UUID uuidFauEuArea = UUID.fromString("16325043-e7da-4742-b012-9ce03362a124");
38

    
39
	// Query
40
	public static final int Q_NO_RESTRICTION = -1;
41

    
42
	// TaxonStatus
43
	public static final int T_STATUS_ACCEPTED = 1;
44
	public static final int T_STATUS_NOT_ACCEPTED = 0;
45

    
46
	// Author
47
	public static final int A_AUCT = 1;
48
	public static final String A_AUCTNAME = "auct.";
49

    
50
	// Parenthesis
51
	public static final int P_PARENTHESIS = 1;
52

    
53
	// User
54

    
55
	public static final int U_ACTIVE = 1;
56

    
57
	//new AbsencePresenceTermUUIDs
58

    
59
	// Rank
60
	public static final int R_KINGDOM = 1;
61
	public static final int R_SUBKINGDOM = 2;
62
	public static final int R_SUPERPHYLUM = 3;
63
	public static final int R_PHYLUM = 4;
64
	public static final int R_SUBPHYLUM = 5;
65
	public static final int R_INFRAPHYLUM = 6;
66
	public static final int R_CLASS = 7;
67
	public static final int R_SUBCLASS = 8;
68
	public static final int R_INFRACLASS = 9;
69
	public static final int R_SUPERORDER = 10;
70
	public static final int R_ORDER = 11;
71
	public static final int R_SUBORDER = 12;
72
	public static final int R_INFRAORDER = 13;
73
	public static final int R_SUPERFAMILY = 14;
74
	public static final int R_FAMILY = 15;
75
	public static final int R_SUBFAMILY = 16;
76
	public static final int R_TRIBE = 17;
77
	public static final int R_SUBTRIBE = 18;
78
	public static final int R_GENUS = 19;
79
	public static final int R_SUBGENUS = 20;
80
	public static final int R_SPECIES = 21;
81
	public static final int R_SUBSPECIES = 22;
82

    
83
	public static PresenceAbsenceTerm occStatus2PresenceAbsence(int occStatusId){
84

    
85
		if (Integer.valueOf(occStatusId) == null) {
86
			return PresenceAbsenceTerm.PRESENT();
87
		}
88
		switch (occStatusId){
89
    		case 0: return PresenceAbsenceTerm.PRESENT();
90
    		case 2: return PresenceAbsenceTerm.ABSENT();
91
    		case 1: return PresenceAbsenceTerm.PRESENT_DOUBTFULLY();
92
    		default: {
93
    		    return null;
94
    		}
95
		}
96
	}
97

    
98

    
99
	public static PresenceAbsenceTerm occStatus2PresenceAbsence_ (int occStatusId)  throws UnknownCdmTypeException{
100
		switch (occStatusId){
101
			case 0: return null;
102
			//case 110: return AbsenceTerm.CULTIVATED_REPORTED_IN_ERROR();
103
			case 120: return PresenceAbsenceTerm.CULTIVATED();
104
		//	case 210: return AbsenceTerm.INTRODUCED_REPORTED_IN_ERROR();
105
			case 220: return PresenceAbsenceTerm.INTRODUCED_PRESENCE_QUESTIONABLE();
106
			case 230: return PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED();
107
			case 240: return PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED();
108
			case 250: return PresenceAbsenceTerm.INTRODUCED();
109
			case 260: return PresenceAbsenceTerm.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();
110
			case 270: return PresenceAbsenceTerm.CASUAL();
111
			case 280: return PresenceAbsenceTerm.NATURALISED();
112
			//case 310: return AbsenceTerm.NATIVE_REPORTED_IN_ERROR();
113
			case 320: return PresenceAbsenceTerm.NATIVE_PRESENCE_QUESTIONABLE();
114
			case 330: return PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE();
115
			case 340: return PresenceAbsenceTerm.NATIVE_DOUBTFULLY_NATIVE();
116
			case 350: return PresenceAbsenceTerm.NATIVE();
117
			case 999: {
118
					logger.warn("endemic for EM can not be transformed in legal status");
119
					//TODO preliminary
120
					return PresenceAbsenceTerm.PRESENT();
121
				}
122
			default: {
123
				throw new UnknownCdmTypeException("Unknown occurrence status  (id=" + Integer.valueOf(occStatusId).toString() + ")");
124
			}
125
		}
126
	}
127

    
128

    
129
	public static Rank rankId2Rank (ResultSet rs, boolean useUnknown) throws UnknownCdmTypeException {
130
		Rank result;
131
		try {
132
			int rankId = rs.getInt("rnk_id");
133
			int parentRankId = rs.getInt("rnk_rnk_id");
134
			String rankName = rs.getString("rnk_name");
135
			String rankLatinName = rs.getString("rnk_latinname");
136
			int rankCategory = rs.getInt("rnk_category");
137

    
138
			if (logger.isDebugEnabled()) {
139
				logger.debug(rankId + ", " + parentRankId + ", " + rankName + ", " + rankCategory);
140
			}
141

    
142
			try {
143
				result = Rank.getRankByNameOrIdInVoc(rankName);
144
			} catch (UnknownCdmTypeException e1) {
145

    
146
				switch (rankId) {
147
				case 0: return null;
148
				case R_KINGDOM: return Rank.KINGDOM();
149
				case R_SUBKINGDOM: return Rank.SUBKINGDOM();
150
				case R_SUPERPHYLUM: return Rank.SUPERPHYLUM();
151
				case R_PHYLUM: return Rank.PHYLUM();
152
				case R_SUBPHYLUM: return Rank.SUBPHYLUM();
153
				case R_INFRAPHYLUM: return Rank.INFRAPHYLUM();
154
				case R_CLASS: return Rank.CLASS();
155
				case R_SUBCLASS: return Rank.SUBCLASS();
156
				case R_INFRACLASS: return Rank.INFRACLASS();
157
				case R_SUPERORDER: return Rank.SUPERORDER();
158
				case R_ORDER: return Rank.ORDER();
159
				case R_SUBORDER: return Rank.SUBORDER();
160
				case R_INFRAORDER: return Rank.INFRAORDER();
161
				case R_SUPERFAMILY: return Rank.SUPERFAMILY();
162
				case R_FAMILY: return Rank.FAMILY();
163
				case R_SUBFAMILY: return Rank.SUBFAMILY();
164
				case R_TRIBE: return Rank.TRIBE();
165
				case R_SUBTRIBE: return Rank.SUBTRIBE();
166
				case R_GENUS: return Rank.GENUS();
167
				case R_SUBGENUS: return Rank.SUBGENUS();
168
				case R_SPECIES: return Rank.SPECIES();
169
				case R_SUBSPECIES: return Rank.SUBSPECIES();
170

    
171
				default: {
172
					if (useUnknown){
173
						logger.error("Rank unknown. Created UNKNOWN_RANK");
174
						return Rank.UNKNOWN_RANK();
175
					}
176
					throw new UnknownCdmTypeException("Unknown Rank id" + Integer.valueOf(rankId).toString());
177
				}
178
				}
179
			}
180
			return result;
181
		} catch (SQLException e) {
182
			e.printStackTrace();
183
			logger.warn("Exception occurred. Created UNKNOWN_RANK instead");
184
			return Rank.UNKNOWN_RANK();
185
		}
186
	}
187

    
188

    
189
//	public static NamedArea areaId2TdwgArea (FaunaEuropaeaDistribution fauEuDistribution)
190
//	throws UnknownCdmTypeException {
191
//
192
//		NamedArea tdwgArea = null;
193
//
194
//		try {
195
//			int areaId = fauEuDistribution.getAreaId();
196
//			String areaName = fauEuDistribution.getAreaName();
197
//			String areaCode = fauEuDistribution.getAreaCode();
198
//			int extraLimital = fauEuDistribution.getExtraLimital();
199
//
200
//			//TODO: Verify mappings with comments. Those don't map to TDWG areas.
201
//
202
//			if (areaCode.equals("AD")) {
203
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SPA-AN");
204
//            } else if (areaCode.equals("AL")) {
205
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ALB-OO");
206
//            } else if (areaCode.equals("AT")) {
207
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("AUT-AU");
208
//            } else if (areaCode.equals("AUS")) {
209
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("AUS"); // Australian region - Australia
210
//            } else if (areaCode.equals("BA")) {
211
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("YUG-BH");
212
//            } else if (areaCode.equals("BE")) {
213
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BGM-BE");
214
//            } else if (areaCode.equals("BG")) {
215
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BUL-OO");
216
//            } else if (areaCode.equals("BY")) {
217
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BLR-OO");
218
//            } else if (areaCode.equals("CH")) {
219
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SWI-OO");
220
//            } else if (areaCode.equals("CY")) {
221
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("CYP-OO");
222
//            } else if (areaCode.equals("CZ")) {
223
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("CZE-CZ");
224
//            } else if (areaCode.equals("DE")) {
225
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("GER-OO");
226
//            } else if (areaCode.equals("DK-DEN")) {
227
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("DEN-OO");
228
//            } else if (areaCode.equals("DK-FOR")) {
229
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("FOR-OO");
230
//            } else if (areaCode.equals("EE")) {
231
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BLT-ES");
232
//            } else if (areaCode.equals("ES-BAL")) {
233
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BAL-OO");
234
//            } else if (areaCode.equals("ES-CNY")) {
235
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("CNY-OO");
236
//            } else if (areaCode.equals("ES-SPA")) {
237
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SPA-SP");
238
//            } else if (areaCode.equals("FI")) {
239
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("FIN-OO");
240
//            } else if (areaCode.equals("FR-COR")) {
241
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("COR-OO");
242
//            } else if (areaCode.equals("FR-FRA")) {
243
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("FRA-FR");
244
//            } else if (areaCode.equals("GB-CI")) {
245
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("FRA-CI");
246
//            } else if (areaCode.equals("GB-GI")) {
247
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SPA-GI");
248
//            } else if (areaCode.equals("GB-GRB")) {
249
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("GRB-OO");
250
//            } else if (areaCode.equals("GB-NI")) {
251
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("IRE-NI");
252
//            } else if (areaCode.equals("GR-GRC")) {
253
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("GRC-OO");
254
//            } else if (areaCode.equals("HR")) {
255
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("YUG-CR");
256
//            } else if (areaCode.equals("HU")) {
257
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("HUN-OO");
258
//            } else if (areaCode.equals("IE")) {
259
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("IRE-IR");
260
//            } else if (areaCode.equals("IS")) {
261
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ICE-OO");
262
//            } else if (areaCode.equals("IT-ITA")) {
263
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ITA-IT");
264
//            } else if (areaCode.equals("IT-SAR")) {
265
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SAR-OO");
266
//            } else if (areaCode.equals("IT-SI")) {
267
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SIC-SI");
268
//            } else if (areaCode.equals("LI")) {
269
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("AUT-LI");
270
//            } else if (areaCode.equals("LT")) {
271
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BLT-LI");
272
//            } else if (areaCode.equals("LU")) {
273
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BGM-LU");
274
//            } else if (areaCode.equals("LV")) {
275
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BLT-LA");
276
//            } else if (areaCode.equals("MC")) {
277
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("FRA-MO");
278
//            } else if (areaCode.equals("MD")) {
279
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("UKR-MO");
280
//            } else if (areaCode.equals("MK")) {
281
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("YUG-MA");
282
//            } else if (areaCode.equals("MT")) {
283
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SIC-MA");
284
//            } else if (areaCode.equals("NL")) {
285
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("NET-OO");
286
//            } else if (areaCode.equals("NO-NOR")) {
287
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("NOR-OO");
288
//            } else if (areaCode.equals("NO-SVA")) {
289
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SVA-OO");
290
//            } else if (areaCode.equals("PL")) {
291
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("POL-OO");
292
//            } else if (areaCode.equals("PT-AZO")) {
293
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("AZO-OO");
294
//            } else if (areaCode.equals("PT-MDR")) {
295
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("MDR-OO");
296
//            } else if (areaCode.equals("PT-POR")) {
297
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("POR-OO");
298
//            } else if (areaCode.equals("PT-SEL")) {
299
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SEL-OO");
300
//            } else if (areaCode.equals("RO")) {
301
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ROM-OO");
302
//            } else if (areaCode.equals("RU-KGD")) {
303
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("BLT-KA");
304
//            } else if (areaCode.equals("RU-RUC")) {
305
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("RUC-OO");
306
//            } else if (areaCode.equals("RU-RUE")) {
307
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("RUE-OO");
308
//            } else if (areaCode.equals("RU-RUN")) {
309
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("RUN-OO");
310
//            } else if (areaCode.equals("RU-RUS")) {
311
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("RUS-OO");
312
//            } else if (areaCode.equals("RU-RUW")) {
313
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("RUW-OO");
314
//            } else if (areaCode.equals("SE")) {
315
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("SWE-OO");
316
//            } else if (areaCode.equals("SI")) {
317
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("YUG-SL");
318
//            } else if (areaCode.equals("SK")) {
319
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("CZE-SK");
320
//            } else if (areaCode.equals("SM")) {
321
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ITA-SM");
322
//            } else if (areaCode.equals("TR-TUE")) {
323
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("TUE-OO");
324
//            }else if (areaCode.equals("UA")) {
325
//            	tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("UKR-UK"); //UKraine including Crimea
326
//            } else if (areaCode.equals("VA")) {
327
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("ITA-VC");
328
//            } else if (areaCode.equals("YU")) {
329
//                tdwgArea = TdwgAreaProvider.getAreaByTdwgAbbreviation("YUG");
330
//            } else {
331
//                throw new UnknownCdmTypeException("Unknown Area " + areaCode);
332
//            }
333
//
334
//			if (logger.isDebugEnabled()) {
335
//				logger.debug(areaId + ", " + areaName + ", " + areaCode + ", " + extraLimital);
336
//			}
337
//
338
//		} catch (Exception e) {
339
//			//e.printStackTrace();
340
//			logger.debug("Exception occurred. Area could not be mapped." + fauEuDistribution.getAreaName());
341
//			return null;
342
//		}
343
//
344
//		return tdwgArea;
345
//	}
346

    
347
//	public static UUID uuidAreaAUS = UUID.fromString("cf979ca8-8cb6-42df-b2ce-1f432ec7c26b");
348
//	public static UUID uuidAreaAFR = UUID.fromString("07ac5e75-9fc9-4aa0-938c-1324c9618b97");
349
//	public static UUID uuidAreaEPA = UUID.fromString("e83446d7-7379-4beb-be05-295f8da6f5ae");
350
//	public static UUID uuidAreaGR_AEG = UUID.fromString("6bd422aa-9911-4b80-8595-0f6d1ecd5eee");
351
//	public static UUID uuidAreaGR_CYC = UUID.fromString("8e7d7f1e-3e4d-4f7c-96ec-93ec91e528d6");
352
//	public static UUID uuidAreaGR_DOD = UUID.fromString("6d6f6842-924e-440b-9e7e-3df1922bf4a6");
353
//	public static UUID uuidAreaNAF = UUID.fromString("d2c54b1e-5f9f-455d-b308-6859cb153c7b");
354
//	public static UUID uuidAreaNEA = UUID.fromString("aa87f6b8-110b-44b5-a329-91a08f1a4cc9");
355
//	public static UUID uuidAreaNEO = UUID.fromString("0e6e0ce9-c6ab-46bc-80b9-aee4a0620e78");
356
//	public static UUID uuidAreaNRE = UUID.fromString("d51876c2-eaf6-4c7f-963e-337dd3e0d729");
357
//	public static UUID uuidAreaORR = UUID.fromString("04cab4f8-b316-4e21-9bcc-236a45e4e83d");
358
//	public static UUID uuidAreaGR_CR = UUID.fromString("2ef9fa6c-7c3f-431a-96c9-5980c55fc440");
359
//	public static UUID uuidAreaGR_GRC = UUID.fromString("b5d33c78-91e7-467a-9c2d-6c337b78d31a");
360
//	public static UUID uuidAreaUA = UUID.fromString("859cf055-a208-4f30-8e6e-361f165c6fa9");
361
//	public static UUID uuidAreaRU_FJL = UUID.fromString("84671068-2f18-40cb-933a-e7e1c0e37cc8");
362
//	public static UUID uuidAreaRU_NOZ = UUID.fromString("64cce0aa-0222-4740-8fa2-dbf0330e9266");
363

    
364

    
365

    
366
//	public final static HashMap<String, UUID> abbrToUUID = new HashMap<String,UUID>();
367
//	 	static
368
//	 	{
369
//	 		abbrToUUID.put("AUS", uuidAreaAUS);
370
//	 		abbrToUUID.put("AFR", uuidAreaAFR);
371
//	 		abbrToUUID.put("EPA", uuidAreaEPA);
372
//	 		abbrToUUID.put("GR-AEG", uuidAreaGR_AEG);
373
//	 		abbrToUUID.put("GR-CYC", uuidAreaGR_CYC);
374
//	 		abbrToUUID.put("GR-DOD", uuidAreaGR_DOD);
375
//	 		abbrToUUID.put("NAF", uuidAreaNAF);
376
//	 		abbrToUUID.put("NEA", uuidAreaNEA);
377
//	 		abbrToUUID.put("NEO", uuidAreaNEO);
378
//	 		abbrToUUID.put("NRE", uuidAreaNRE);
379
//	 		abbrToUUID.put("ORR", uuidAreaORR);
380
//	 		abbrToUUID.put("GR-KRI", uuidAreaGR_CR);
381
//	 		abbrToUUID.put("GR-GRC", uuidAreaGR_GRC);
382
//	 		abbrToUUID.put("UA", uuidAreaUA);
383
//	 		abbrToUUID.put("RU-FJL", uuidAreaRU_FJL);
384
//	 		abbrToUUID.put("RU-NOZ", uuidAreaRU_NOZ);
385
//
386
//
387
//	 	}
388

    
389

    
390
	 	public final static HashMap<Integer, Language> languageFK2Language  = new HashMap<>();
391

    
392
        static
393
	 	{
394
	 		languageFK2Language.put(1, Language.ALBANIAN());
395
	 		languageFK2Language.put(4, Language.AZERBAIJANI());
396
	 		languageFK2Language.put(6, Language.BULGARIAN());
397
	 		languageFK2Language.put(10, Language.DANISH());
398
	 		languageFK2Language.put(11, Language.DUTCH_MIDDLE());
399
	 		languageFK2Language.put(12, Language.ENGLISH());
400
	 		languageFK2Language.put(16, Language.FRENCH());
401

    
402
	 		languageFK2Language.put(18, Language.GERMAN());
403
	 		languageFK2Language.put(19, Language.GREEK_MODERN());
404
	 		languageFK2Language.put(23, Language.HEBREW());
405
	 		languageFK2Language.put(24, Language.ITALIAN());
406
	 		languageFK2Language.put(26, Language.LITHUANIAN());
407
	 		languageFK2Language.put(30, Language.NORWEGIAN());
408
	 		languageFK2Language.put(31, Language.POLISH());
409
	 		languageFK2Language.put(34, Language.RUSSIAN());
410
	 		languageFK2Language.put(54, Language.SLOVAK());
411
	 		languageFK2Language.put(55, Language.SLOVENIAN());
412
	 		languageFK2Language.put(57, Language.SWEDISH());
413
	 		languageFK2Language.put(58, Language.TURKISH());
414

    
415
	 		languageFK2Language.put(59, Language.UKRAINIAN());
416
	 		languageFK2Language.put(60, Language.WELSH());
417
	 		languageFK2Language.put(62, Language.GALICIAN());
418
	 		//languageFK2Language.put(83, getEnglishUS());
419
	 		languageFK2Language.put(97, Language.IRISH());
420

    
421

    
422
	 		languageFK2Language.put(100, Language.NORWEGIAN_BOKMOL());
423
	 		languageFK2Language.put(101, Language.NORWEGIAN_NYNORSK());
424

    
425
	 		languageFK2Language.put(102, Language.ARABIC());
426
	 		languageFK2Language.put(103, Language.ARMENIAN());
427

    
428
	 		languageFK2Language.put(104, Language.CATALAN_VALENCIAN());
429
	 		languageFK2Language.put(105, Language.CHINESE());
430
	 		languageFK2Language.put(106, Language.ESTONIAN());
431
	 		languageFK2Language.put(107, Language.FINNISH());
432

    
433
	 		languageFK2Language.put(108, Language.GAELIC_SCOTTISH_GAELIC());
434
	 		languageFK2Language.put(109, Language.JAPANESE());
435
	 		languageFK2Language.put(110, Language.KOREAN());
436
	 		languageFK2Language.put(111, Language.LATIN());
437
	 		languageFK2Language.put(112, Language.LATVIAN());
438
	 		languageFK2Language.put(113, Language.PERSIAN());
439
	 		languageFK2Language.put(114, Language.PORTUGUESE());
440
	 		languageFK2Language.put(115, Language.ROMANIAN());
441
	 		languageFK2Language.put(116, Language.GAELIC_SCOTTISH_GAELIC());
442
	 		languageFK2Language.put(117, Language.SWAHILI());
443
	 		languageFK2Language.put(118, Language.SPANISH_CASTILIAN());
444

    
445

    
446

    
447

    
448

    
449
	 	}
450
//	public static UUID getUUIDByAreaAbbr(String abbr){
451
//		return abbrToUUID.get(abbr);
452
//	}
453

    
454
	public static UUID uuidNomStatusTempNamed = UUID.fromString("aa6ada5a-ca21-4fef-b76f-9ae237e9c4ae");
455

    
456
	static NomenclaturalStatusType nomStatusTempNamed;
457

    
458
    private static DefinedTerm taxonomicSpecialistType;
459

    
460
    private static UUID uuidTaxonomicSpecialistType = UUID.fromString("006879e4-cf99-405a-a720-2e81d9cbc34c");
461

    
462
    private static DefinedTerm groupCoordinatorType;
463

    
464
    private static UUID uuidGroupCoordinatorType = UUID.fromString("3a827ebe-4410-40e5-a241-941b17028e11");
465

    
466
	private static DefinedTerm associateSpecialistType;
467

    
468
	private static UUID uuidAssociateSpecialistType = UUID.fromString("8258f73c-e0ad-4f87-a88c-53c58c08bba9");
469

    
470
	private static Language langEnglishUS;
471

    
472
	private static UUID uuidEnglishUS;
473

    
474

    
475

    
476
	public static NomenclaturalStatusType getNomStatusTempNamed(ITermService termService){
477
		if (nomStatusTempNamed == null){
478
			nomStatusTempNamed = (NomenclaturalStatusType)termService.find(uuidNomStatusTempNamed);
479
			if (nomStatusTempNamed == null){
480
				nomStatusTempNamed = NomenclaturalStatusType.NewInstance("temporary named", "temporary named", "temp. named", Language.ENGLISH());
481
				Representation repLatin = Representation.NewInstance("", "", "", Language.LATIN());
482
				nomStatusTempNamed.addRepresentation(repLatin);
483
				nomStatusTempNamed.setUuid(uuidNomStatusTempNamed);
484
				NomenclaturalStatusType.ALTERNATIVE().getVocabulary().addTerm(nomStatusTempNamed);
485
				termService.save(nomStatusTempNamed);
486
			}
487
		}
488
		return nomStatusTempNamed;
489
	}
490

    
491
	public static Language getEnglishUS(ITermService termService){
492
		if (langEnglishUS == null){
493
			langEnglishUS = (Language)termService.find(uuidEnglishUS);
494
            if (langEnglishUS == null){
495
            	logger.info("create language english-us");
496
            	langEnglishUS = Language.NewInstance("english-United States", "english-US", "eng-US");
497
    			langEnglishUS.setUuid(uuidEnglishUS);
498

    
499
                langEnglishUS = (Language)termService.save(langEnglishUS);
500
                languageFK2Language.put(83, langEnglishUS);
501
            }
502
        }
503
		return langEnglishUS;
504
	}
505
    /**
506
     * @return
507
     */
508
    public static DefinedTerm getTaxonomicSpecialistType(ITermService termService) {
509
        if (taxonomicSpecialistType == null){
510
            taxonomicSpecialistType = (DefinedTerm)termService.find(uuidTaxonomicSpecialistType);
511
            if (taxonomicSpecialistType == null){
512
            	logger.info("create taxonomic specialist type");
513
                taxonomicSpecialistType = DefinedTerm.NewInstance(TermType.TaxonNodeAgentRelationType, "taxonomic specialist", "taxonomic specialist", "TS");
514

    
515
                taxonomicSpecialistType.setUuid(uuidTaxonomicSpecialistType);
516

    
517
                termService.save(taxonomicSpecialistType);
518
            }
519
        }
520
        return taxonomicSpecialistType;
521
    }
522
    /**
523
     * @return
524
     */
525
    public static DefinedTerm getGroupCoordinatorType(ITermService termService) {
526
        if (groupCoordinatorType == null){
527
            groupCoordinatorType = (DefinedTerm)termService.find(uuidGroupCoordinatorType);
528
            if (groupCoordinatorType == null){
529
                groupCoordinatorType = DefinedTerm.NewInstance(TermType.TaxonNodeAgentRelationType, "group coordinator", "group coordinator", "GC");
530

    
531
                groupCoordinatorType.setUuid(uuidGroupCoordinatorType);
532

    
533
                termService.save(groupCoordinatorType);
534
            }
535
        }
536
        return groupCoordinatorType;
537
    }
538

    
539

    
540

    
541
    /**
542
     * @return
543
     */
544
    public static DefinedTerm getAssociateSpecialistType(ITermService termService) {
545
        if (associateSpecialistType == null){
546
        	associateSpecialistType = (DefinedTerm)termService.find(uuidAssociateSpecialistType);
547
            if (associateSpecialistType == null){
548
            	associateSpecialistType = DefinedTerm.NewInstance(TermType.TaxonNodeAgentRelationType, "associate specialist", "associate specialist", "AS");
549

    
550
            	associateSpecialistType.setUuid(uuidAssociateSpecialistType);
551

    
552
                termService.save(associateSpecialistType);
553
            }
554
        }
555
        return associateSpecialistType;
556
    }
557
	public static Language langFK2Language(
558
			Integer languageFk) {
559

    
560
		Language result = languageFK2Language.get(languageFk);
561

    
562
		return result;
563
	}
564

    
565

    
566
}
(16-16/20)