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.taxonx;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
|
15
|
import eu.etaxonomy.cdm.model.description.Feature;
|
16
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
17
|
import eu.etaxonomy.cdm.model.name.Rank;
|
18
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
19
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
21
|
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @since 29.07.2008
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public final class TaxonXTransformer {
|
29
|
@SuppressWarnings("unused")
|
30
|
private static final Logger logger = Logger.getLogger(TaxonXTransformer.class);
|
31
|
|
32
|
//Facts
|
33
|
public static int FACT_DESCRIPTION = 1;
|
34
|
public static int FACT_GROWTH_FORM = 2;
|
35
|
public static int FACT_HARDINESS = 3;
|
36
|
public static int FACT_ECOLOGY = 4;
|
37
|
public static int FACT_PHENOLOGY = 5;
|
38
|
public static int FACT_KARYOLOGY = 6;
|
39
|
public static int FACT_ILLUSTRATION = 7;
|
40
|
public static int FACT_IDENTIFICATION = 8;
|
41
|
public static int FACT_OBSERVATION = 9;
|
42
|
public static int FACT_DISTIRBUTION_EM = 10;
|
43
|
public static int FACT_DISTIRBUTION_WORLD = 11;
|
44
|
|
45
|
//TypeDesignation
|
46
|
public static SpecimenTypeDesignationStatus typeStatusId2TypeStatus (int typeStatusId) throws UnknownCdmTypeException{
|
47
|
switch (typeStatusId){
|
48
|
case 1: return SpecimenTypeDesignationStatus.HOLOTYPE();
|
49
|
case 2: return SpecimenTypeDesignationStatus.LECTOTYPE();
|
50
|
case 3: return SpecimenTypeDesignationStatus.NEOTYPE();
|
51
|
case 4: return SpecimenTypeDesignationStatus.EPITYPE();
|
52
|
case 5: return SpecimenTypeDesignationStatus.ISOLECTOTYPE();
|
53
|
case 6: return SpecimenTypeDesignationStatus.ISONEOTYPE();
|
54
|
case 7: return SpecimenTypeDesignationStatus.ISOTYPE();
|
55
|
case 8: return SpecimenTypeDesignationStatus.PARANEOTYPE();
|
56
|
case 9: return SpecimenTypeDesignationStatus.PARATYPE();
|
57
|
case 10: return SpecimenTypeDesignationStatus.SECOND_STEP_LECTOTYPE();
|
58
|
case 11: return SpecimenTypeDesignationStatus.SECOND_STEP_NEOTYPE();
|
59
|
case 12: return SpecimenTypeDesignationStatus.SYNTYPE();
|
60
|
case 21: return SpecimenTypeDesignationStatus.ICONOTYPE();
|
61
|
case 22: return SpecimenTypeDesignationStatus.PHOTOTYPE();
|
62
|
default: {
|
63
|
throw new UnknownCdmTypeException("Unknown TypeDesignationStatus (id=" + Integer.valueOf(typeStatusId).toString() + ")");
|
64
|
}
|
65
|
}
|
66
|
}
|
67
|
|
68
|
|
69
|
|
70
|
|
71
|
/** Creates an cdm-Rank by the tcs rank
|
72
|
*/
|
73
|
public static Rank rankString2Rank (String strRank) throws UnknownCdmTypeException{
|
74
|
String tcsRoot = "http://rs.tdwg.org/ontology/voc/TaxonRank#";
|
75
|
String tcsGenus = tcsRoot + "Genus";
|
76
|
String tcsSpecies = tcsRoot + "Species";
|
77
|
// String tcsGenus = tcsRoot + "Genus";
|
78
|
|
79
|
if (strRank == null){return null;
|
80
|
}else if (tcsGenus.equals(strRank)){return Rank.GENUS();
|
81
|
}else if (tcsSpecies.equals(strRank)){return Rank.SPECIES();
|
82
|
}
|
83
|
else {
|
84
|
throw new UnknownCdmTypeException("Unknown Rank " + strRank);
|
85
|
}
|
86
|
}
|
87
|
|
88
|
/** Creates an cdm-NomenclaturalCode by the tcs NomenclaturalCode
|
89
|
*/
|
90
|
public static Feature descriptionType2feature (String descriptionType) throws UnknownCdmTypeException{
|
91
|
if (descriptionType == null){ return null;
|
92
|
// }else if ("abstract".equals(descriptionType)){return Feature.XX();
|
93
|
// }else if ("acknowledgments".equals(descriptionType)){return Feature.ICZN();
|
94
|
}else if ("biology_ecology".equals(descriptionType)){return Feature.BIOLOGY_ECOLOGY();
|
95
|
}else if ("description".equals(descriptionType)){return Feature.DESCRIPTION();
|
96
|
}else if ("cultivation".equals(descriptionType)){return Feature.CULTIVATION();
|
97
|
}else if ("conservation".equals(descriptionType)){return Feature.CONSERVATION();
|
98
|
}else if ("diagnosis".equals(descriptionType)){return Feature.DIAGNOSIS();
|
99
|
}else if ("Description".equals(descriptionType)){return Feature.DESCRIPTION();
|
100
|
}else if ("discussion".equals(descriptionType)){return Feature.DISCUSSION();
|
101
|
}else if ("distribution".equals(descriptionType)){return Feature.DISTRIBUTION();
|
102
|
}else if ("etymology".equals(descriptionType)){return Feature.ETYMOLOGY();
|
103
|
}else if ("key".equals(descriptionType)){return Feature.KEY();
|
104
|
}else if ("introduction".equals(descriptionType)){return Feature.INTRODUCTION();
|
105
|
}else if ("materials_examined".equals(descriptionType)){return Feature.MATERIALS_EXAMINED();
|
106
|
}else if ("materials_methods".equals(descriptionType)){return Feature.MATERIALS_METHODS();
|
107
|
// }else if ("multiple".equals(descriptionType)){return Feature.multi;
|
108
|
// }else if ("synopsis".equals(descriptionType)){return Feature.synopsis;
|
109
|
}else if ("uses".equals(descriptionType)){return Feature.USES();
|
110
|
}else if ("vernacular".equals(descriptionType)){return Feature.COMMON_NAME();
|
111
|
}else if ("anatomy".equals(descriptionType)){return Feature.ANATOMY();
|
112
|
}else {
|
113
|
throw new UnknownCdmTypeException("Unknown Description Type: " + descriptionType);
|
114
|
}
|
115
|
}
|
116
|
|
117
|
public static boolean isReverseRelationshipCategory (String tcsRelationshipCategory){
|
118
|
String str = tcsRelationshipCategory.replace("http://rs.tdwg.org/ontology/voc/TaxonConcept#", "");
|
119
|
if ("HasSynonym".equalsIgnoreCase(str)
|
120
|
|| "IsParentTaxonOf".equalsIgnoreCase(str)
|
121
|
|| "IsIncludedIn".equalsIgnoreCase(str)
|
122
|
|| "DoesNotInclude".equalsIgnoreCase(str)
|
123
|
){
|
124
|
|
125
|
return true;
|
126
|
}
|
127
|
return false;
|
128
|
}
|
129
|
|
130
|
/** Creates an cdm-RelationshipTermBase by the tcsRelationshipCategory
|
131
|
*/
|
132
|
public static RelationshipTermBase tcsRelationshipCategory2Relationship (String tcsRelationshipCategory) throws UnknownCdmTypeException{
|
133
|
String tcsRoot = "http://rs.tdwg.org/ontology/voc/TaxonConcept#";
|
134
|
String doesNotInclude = tcsRoot + "DoesNotInclude";
|
135
|
String doesNotOverlap = tcsRoot + "DoesNotOverlap";
|
136
|
String excludes = tcsRoot + "Excludes";
|
137
|
String hasSynonym = tcsRoot + "HasSynonym";
|
138
|
String hasVernacular = tcsRoot + "HasVernacular";
|
139
|
String includes = tcsRoot + "Includes";
|
140
|
String isAmbiregnalOf = tcsRoot + "IsAmbiregnalOf";
|
141
|
String isAnamorphOf = tcsRoot + "IsAnamorphOf";
|
142
|
String isChildTaxonOf = tcsRoot + "IsChildTaxonOf";
|
143
|
String isCongruentTo = tcsRoot + "IsCongruentTo";
|
144
|
String isFemaleParentOf = tcsRoot + "IsFemaleParentOf";
|
145
|
String isFirstParentOf = tcsRoot + "IsFirstParentOf";
|
146
|
String isHybridChildOf = tcsRoot + "IsHybridChildOf";
|
147
|
String isHybridParentOf = tcsRoot + "IsHybridParentOf";
|
148
|
String isIncludedIn = tcsRoot + "IsIncludedIn";
|
149
|
String isMaleParentOf = tcsRoot + "IsMaleParentOf";
|
150
|
String isNotCongruentTo = tcsRoot + "IsNotCongruentTo";
|
151
|
String isNotIncludedIn = tcsRoot + "IsNotIncludedIn";
|
152
|
String isParentTaxonOf = tcsRoot + "IsParentTaxonOf";
|
153
|
String isSecondParentOf = tcsRoot + "IsSecondParentOf";
|
154
|
String isSynonymFor = tcsRoot + "IsSynonymFor";
|
155
|
String isTeleomorphOf = tcsRoot + "IsTeleomorphOf";
|
156
|
String isVernacularFor = tcsRoot + "IsVernacularFor";
|
157
|
String overlaps = tcsRoot + "Overlaps";
|
158
|
|
159
|
if (tcsRelationshipCategory == null){ return null;
|
160
|
|
161
|
//Synonym relationships
|
162
|
}else if (isSynonymFor.equals(tcsRelationshipCategory)){return SynonymType.SYNONYM_OF();
|
163
|
}else if (hasSynonym.equals(tcsRelationshipCategory)){/*isReverse = true; */ return SynonymType.SYNONYM_OF();
|
164
|
|
165
|
//Taxon relationships
|
166
|
}else if (isChildTaxonOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN();
|
167
|
}else if (isParentTaxonOf.equals(tcsRelationshipCategory)){/*isReverse = true; */ return TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN();
|
168
|
|
169
|
//concept relationships
|
170
|
}else if (doesNotOverlap.equals(tcsRelationshipCategory)){return TaxonRelationshipType.DOES_NOT_OVERLAP();
|
171
|
}else if (excludes.equals(tcsRelationshipCategory)){return TaxonRelationshipType.EXCLUDES();
|
172
|
}else if (includes.equals(tcsRelationshipCategory)){return TaxonRelationshipType.INCLUDES();
|
173
|
}else if (isCongruentTo.equals(tcsRelationshipCategory)){return TaxonRelationshipType.CONGRUENT_TO();
|
174
|
}else if (isNotCongruentTo.equals(tcsRelationshipCategory)){return TaxonRelationshipType.NOT_CONGRUENT_TO();
|
175
|
}else if (isNotIncludedIn.equals(tcsRelationshipCategory)){return TaxonRelationshipType.NOT_INCLUDED_IN();
|
176
|
}else if (overlaps.equals(tcsRelationshipCategory)){return TaxonRelationshipType.OVERLAPS();
|
177
|
//reverse concept relationships
|
178
|
}else if (isIncludedIn.equals(tcsRelationshipCategory)){/*isReverse = true; */ return TaxonRelationshipType.INCLUDES();
|
179
|
}else if (doesNotInclude.equals(tcsRelationshipCategory)){/*isReverse = true; */ return TaxonRelationshipType.NOT_INCLUDED_IN();
|
180
|
|
181
|
//TODO
|
182
|
// }else if (hasVernacular.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
183
|
// }else if (isAmbiregnalOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
184
|
// }else if (isAnamorphOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
185
|
// }else if (isFemaleParentOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
186
|
// }else if (isFirstParentOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
187
|
// }else if (isHybridChildOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
188
|
// }else if (isHybridParentOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
189
|
// }else if (isMaleParentOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
190
|
// }else if (isSecondParentOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
191
|
// }else if (isTeleomorphOf.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
192
|
// }else if (isVernacularFor.equals(tcsRelationshipCategory)){return TaxonRelationshipType.X;
|
193
|
|
194
|
}else {
|
195
|
throw new UnknownCdmTypeException("Unknown RelationshipCategory " + tcsRelationshipCategory);
|
196
|
}
|
197
|
}
|
198
|
|
199
|
|
200
|
/** Creates an cdm-NomenclaturalCode by the tcs NomenclaturalCode
|
201
|
*/
|
202
|
public static NomenclaturalStatusType nomStatusString2NomStatus (String nomStatus) throws UnknownCdmTypeException{
|
203
|
|
204
|
if (nomStatus == null){ return null;
|
205
|
}else if ("Valid".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.VALID();
|
206
|
|
207
|
}else if ("Alternative".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ALTERNATIVE();
|
208
|
}else if ("nom. altern.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ALTERNATIVE();
|
209
|
|
210
|
}else if ("Ambiguous".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.AMBIGUOUS();
|
211
|
|
212
|
}else if ("Doubtful".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.DOUBTFUL();
|
213
|
|
214
|
}else if ("Confusum".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.CONFUSUM();
|
215
|
|
216
|
}else if ("Illegitimate".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ILLEGITIMATE();
|
217
|
}else if ("nom. illeg.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ILLEGITIMATE();
|
218
|
|
219
|
}else if ("Superfluous".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.SUPERFLUOUS();
|
220
|
}else if ("nom. superfl.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.SUPERFLUOUS();
|
221
|
|
222
|
}else if ("Rejected".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.REJECTED();
|
223
|
}else if ("nom. rej.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.REJECTED();
|
224
|
|
225
|
}else if ("Utique Rejected".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.UTIQUE_REJECTED();
|
226
|
|
227
|
}else if ("Conserved Prop".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.CONSERVED_PROP();
|
228
|
|
229
|
}else if ("Orthography Conserved Prop".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP();
|
230
|
|
231
|
}else if ("Legitimate".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.LEGITIMATE();
|
232
|
|
233
|
}else if ("Novum".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.NOVUM();
|
234
|
}else if ("nom. nov.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.NOVUM();
|
235
|
|
236
|
}else if ("Utique Rejected Prop".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.UTIQUE_REJECTED_PROP();
|
237
|
|
238
|
}else if ("Orthography Conserved".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED();
|
239
|
|
240
|
}else if ("Rejected Prop".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.REJECTED_PROP();
|
241
|
|
242
|
}else if ("Conserved".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.CONSERVED();
|
243
|
}else if ("nom. cons.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.CONSERVED();
|
244
|
|
245
|
}else if ("Sanctioned".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.SANCTIONED();
|
246
|
|
247
|
}else if ("Invalid".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.INVALID();
|
248
|
}else if ("nom. inval.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.INVALID();
|
249
|
|
250
|
}else if ("Nudum".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.NUDUM();
|
251
|
}else if ("nom. nud.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.NUDUM();
|
252
|
|
253
|
}else if ("Combination Invalid".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.COMBINATION_INVALID();
|
254
|
|
255
|
}else if ("Provisional".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.PROVISIONAL();
|
256
|
}else if ("nom. provis.".equalsIgnoreCase(nomStatus)){return NomenclaturalStatusType.PROVISIONAL();
|
257
|
}
|
258
|
else {
|
259
|
throw new UnknownCdmTypeException("Unknown Nomenclatural status type " + nomStatus);
|
260
|
}
|
261
|
}
|
262
|
|
263
|
}
|