Project

General

Profile

Download (11.4 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.common.mapping;
11

    
12
import java.io.Serializable;
13
import java.util.UUID;
14

    
15
import org.apache.commons.lang3.StringUtils;
16
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.common.CdmUtils;
19
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
20
import eu.etaxonomy.cdm.model.common.ExtensionType;
21
import eu.etaxonomy.cdm.model.common.Language;
22
import eu.etaxonomy.cdm.model.common.MarkerType;
23
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
24
import eu.etaxonomy.cdm.model.description.Feature;
25
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
26
import eu.etaxonomy.cdm.model.description.State;
27
import eu.etaxonomy.cdm.model.location.NamedArea;
28
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
29
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
30
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
31
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
32
import eu.etaxonomy.cdm.model.name.Rank;
33
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
34
import eu.etaxonomy.cdm.model.term.DefinedTerm;
35

    
36
/**
37
 * @author a.mueller
38
 * @since 15.03.2010
39
 */
40
public class InputTransformerBase implements IInputTransformer, Serializable {
41
    private static final long serialVersionUID = 1824180329524647957L;
42
    @SuppressWarnings("unused")
43
	private static final Logger logger = LogManager.getLogger(InputTransformerBase.class);
44

    
45
	@Override
46
	public Feature getFeatureByKey(String key) throws UndefinedTransformerMethodException {
47
		String warning = "getFeatureByKey is not implemented in implementing transformer class";
48
		throw new UndefinedTransformerMethodException(warning);
49
	}
50

    
51
	@Override
52
	public UUID getFeatureUuid(String key) throws UndefinedTransformerMethodException {
53
		String warning = "getFeatureUuid is not implemented in implementing transformer class";
54
		throw new UndefinedTransformerMethodException(warning);
55
	}
56

    
57
	@Override
58
	public State getStateByKey(String key) throws UndefinedTransformerMethodException {
59
		String warning = "getStateByKey is not implemented in implementing transformer class";
60
		throw new UndefinedTransformerMethodException(warning);
61
	}
62

    
63
	@Override
64
	public UUID getStateUuid(String key) throws UndefinedTransformerMethodException {
65
		String warning = "getStateByKey is not implemented in implementing transformer class";
66
		throw new UndefinedTransformerMethodException(warning);
67
	}
68

    
69
	@Override
70
	public Language getLanguageByKey(String key) throws UndefinedTransformerMethodException {
71
		String warning = "getLanguageByKey is not implemented in implementing transformer class";
72
		throw new UndefinedTransformerMethodException(warning);
73
	}
74

    
75
	@Override
76
	public UUID getLanguageUuid(String key) throws UndefinedTransformerMethodException {
77
		String warning = "getLanguageByUuid is not implemented in implementing transformer class";
78
		throw new UndefinedTransformerMethodException(warning);
79
	}
80

    
81
	@Override
82
	public ExtensionType getExtensionTypeByKey(String key) throws UndefinedTransformerMethodException {
83
		String warning = "getExtensionTypeByKey is not implemented in implementing transformer class";
84
		throw new UndefinedTransformerMethodException(warning);
85
	}
86

    
87
	@Override
88
	public UUID getExtensionTypeUuid(String key) throws UndefinedTransformerMethodException {
89
		String warning = "getExtensionTypeUuid is not implemented in implementing transformer class";
90
		throw new UndefinedTransformerMethodException(warning);
91
	}
92

    
93
	@Override
94
	public MarkerType getMarkerTypeByKey(String key) throws UndefinedTransformerMethodException {
95
		String warning = "getMarkerTypeByKey is not implemented in implementing transformer class";
96
		throw new UndefinedTransformerMethodException(warning);
97
	}
98

    
99
	@Override
100
	public UUID getMarkerTypeUuid(String key) throws UndefinedTransformerMethodException {
101
		String warning = "getMarkerTypeUuid is not implemented in implementing transformer class";
102
		throw new UndefinedTransformerMethodException(warning);
103
	}
104

    
105
	@Override
106
	public NameTypeDesignationStatus getNameTypeDesignationStatusByKey(String key) throws UndefinedTransformerMethodException {
107
		String warning = "getNameTypeDesignationStatusByKey is not implemented in implementing transformer class";
108
		throw new UndefinedTransformerMethodException(warning);
109
	}
110

    
111
	@Override
112
	public UUID getNameTypeDesignationStatusUuid(String key) throws UndefinedTransformerMethodException {
113
		String warning = "getNameTypeDesignationStatusUuid is not implemented in implementing transformer class";
114
		throw new UndefinedTransformerMethodException(warning);
115
	}
116

    
117
	@Override
118
	public SpecimenTypeDesignationStatus getSpecimenTypeDesignationStatusByKey(String key) throws UndefinedTransformerMethodException {
119
		if (isBlank(key)){return null;
120
		}else if (key.matches("(?i)(T|Type)")){return SpecimenTypeDesignationStatus.TYPE();
121
		}else if (key.matches("(?i)(HT|Holotype)")){return SpecimenTypeDesignationStatus.HOLOTYPE();
122
		}else if (key.matches("(?i)(LT|Lectotype)")){return SpecimenTypeDesignationStatus.LECTOTYPE();
123
		}else if (key.matches("(?i)(NT|Neotype)")){return SpecimenTypeDesignationStatus.NEOTYPE();
124
		}else if (key.matches("(?i)(ST|Syntype)")){return SpecimenTypeDesignationStatus.SYNTYPE();
125
		}else if (key.matches("(?i)(ET|Epitype)")){return SpecimenTypeDesignationStatus.EPITYPE();
126
		}else if (key.matches("(?i)(IT|Isotype)")){return SpecimenTypeDesignationStatus.ISOTYPE();
127
		}else if (key.matches("(?i)(ILT|Isolectotype)")){return SpecimenTypeDesignationStatus.ISOLECTOTYPE();
128
		}else if (key.matches("(?i)(INT|Isoneotype)")){return SpecimenTypeDesignationStatus.ISONEOTYPE();
129
		}else if (key.matches("(?i)(IET|Isoepitype)")){return SpecimenTypeDesignationStatus.ISOEPITYPE();
130
		}else if (key.matches("(?i)(PT|Paratype)")){return SpecimenTypeDesignationStatus.PARATYPE();
131
		}else if (key.matches("(?i)(PLT|Paralectotype)")){return SpecimenTypeDesignationStatus.PARALECTOTYPE();
132
		}else if (key.matches("(?i)(PNT|Paraneotype)")){return SpecimenTypeDesignationStatus.PARANEOTYPE();
133
		}else if (key.matches("(?i)(unsp.|Unspecified)")){return SpecimenTypeDesignationStatus.UNSPECIFIC();
134
		}else if (key.matches("(?i)(2LT|Second Step Lectotype)")){return SpecimenTypeDesignationStatus.SECOND_STEP_LECTOTYPE();
135
		}else if (key.matches("(?i)(2NT|Second Step Neotype)")){return SpecimenTypeDesignationStatus.SECOND_STEP_NEOTYPE();
136
		}else if (key.matches("(?i)(OM|Original Material)")){return SpecimenTypeDesignationStatus.ORIGINAL_MATERIAL();
137
		}else if (key.matches("(?i)(IcT|Iconotype)")){return SpecimenTypeDesignationStatus.ICONOTYPE();
138
		}else if (key.matches("(?i)(PT|Phototype)")){return SpecimenTypeDesignationStatus.PHOTOTYPE();
139
		}else if (key.matches("(?i)(IST|Isosyntype)")){return SpecimenTypeDesignationStatus.ISOSYNTYPE();
140
		}else{
141
			return null;
142
		}
143
	}
144

    
145
	@Override
146
	public UUID getSpecimenTypeDesignationStatusUuid(String key) throws UndefinedTransformerMethodException {
147
		String warning = "getSpecimenTypeDesignationStatusUuid is not implemented in implementing transformer class";
148
		throw new UndefinedTransformerMethodException(warning);
149
	}
150

    
151
	@Override
152
	public PresenceAbsenceTerm getPresenceTermByKey(String key) throws UndefinedTransformerMethodException {
153
		String warning = "getPresenceTermByKey is not implemented in implementing transformer class";
154
		throw new UndefinedTransformerMethodException(warning);
155
	}
156

    
157
	@Override
158
	public UUID getPresenceTermUuid(String key) throws UndefinedTransformerMethodException {
159
		String warning = "getPresenceTermUuid is not implemented in implementing transformer class";
160
		throw new UndefinedTransformerMethodException(warning);
161
	}
162

    
163
	@Override
164
	public NamedArea getNamedAreaByKey(String key) throws UndefinedTransformerMethodException {
165
		String warning = "getNamedAreaByKey is not implemented in implementing transformer class";
166
		throw new UndefinedTransformerMethodException(warning);
167
	}
168

    
169
	@Override
170
	public UUID getNamedAreaUuid(String key) throws UndefinedTransformerMethodException {
171
		String warning = "getNamedAreaUuid is not implemented in implementing transformer class";
172
		throw new UndefinedTransformerMethodException(warning);
173
	}
174

    
175
	@Override
176
	public NamedAreaLevel getNamedAreaLevelByKey(String key) throws UndefinedTransformerMethodException {
177
		String warning = "getNamedAreaLevelByKey is not implemented in implementing transformer class";
178
		throw new UndefinedTransformerMethodException(warning);
179
	}
180

    
181
	@Override
182
	public UUID getNamedAreaLevelUuid(String key) throws UndefinedTransformerMethodException {
183
		String warning = "getNamedAreaLevelUuid is not implemented in implementing transformer class";
184
		throw new UndefinedTransformerMethodException(warning);
185
	}
186

    
187
	@Override
188
	public ReferenceSystem getReferenceSystemByKey(String key) throws UndefinedTransformerMethodException {
189
		if (CdmUtils.isBlank(key)){return null;
190
		}else if (key.matches("(?i)(wgs84)")){return ReferenceSystem.WGS84();
191
		}else if (key.matches("(?i)(googleearth)")){return ReferenceSystem.GOOGLE_EARTH();
192
		}else if (key.matches("(?i)(gazetteer)")){return ReferenceSystem.GAZETTEER();
193
		}else if (key.matches("(?i)(map)")){return ReferenceSystem.MAP();
194
		}else{
195
			String warning = "getReferenceSystemByKey is not implemented in implementing transformer class";
196
			throw new UndefinedTransformerMethodException(warning);
197
		}
198
	}
199

    
200
	@Override
201
	public UUID getReferenceSystemUuid(String key) throws UndefinedTransformerMethodException {
202

    
203
		String warning = "getReferenceSystemUuid is not implemented in implementing transformer class";
204
		throw new UndefinedTransformerMethodException(warning);
205
	}
206

    
207
	@Override
208
	public Rank getRankByKey(String key) throws UndefinedTransformerMethodException {
209
		String warning = "getRankByKey is not yet implemented in implementing transformer class";
210
		throw new UndefinedTransformerMethodException(warning);
211
	}
212

    
213
	@Override
214
	public NomenclaturalStatusType getNomenclaturalStatusByKey(String key) throws UndefinedTransformerMethodException {
215
	    String warning = "getNomenclaturalStatusByKey is not yet implemented in implementing transformer class";
216
	    throw new UndefinedTransformerMethodException(warning);
217
	}
218

    
219
	@Override
220
	public UUID getRankUuid(String key) throws UndefinedTransformerMethodException {
221
		String warning = "getRankUuid is not implemented in implementing transformer class";
222
		throw new UndefinedTransformerMethodException(warning);
223
	}
224

    
225
    @Override
226
    public DefinedTerm getIdentifierTypeByKey(String key) throws UndefinedTransformerMethodException {
227
        String warning = "getIdentifierTypeByKey is not implemented in implementing transformer class";
228
        throw new UndefinedTransformerMethodException(warning);
229
    }
230

    
231
    @Override
232
    public UUID getIdentifierTypeUuid(String key) throws UndefinedTransformerMethodException {
233
        String warning = "getIdentifierTypeUuid is not implemented in implementing transformer class";
234
        throw new UndefinedTransformerMethodException(warning);
235
    }
236

    
237
    protected boolean isBlank(String str){
238
        return StringUtils.isBlank(str);
239
    }
240
    protected boolean isNotBlank(String str){
241
        return StringUtils.isNotBlank(str);
242
    }
243

    
244
    @Override
245
    public RelationshipTermBase<?>[] getSynonymRelationTypesByKey(String key, DbImportStateBase<?,?> state) {
246
        String warning = "getSynonymRelationTypesByKey is not implemented in implementing transformer class";
247
        logger.warn(warning);
248
        return null;
249
    }
250

    
251
}
(51-51/53)