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.in;
|
11
|
|
12
|
import java.sql.ResultSet;
|
13
|
import java.sql.SQLException;
|
14
|
import java.util.HashMap;
|
15
|
import java.util.HashSet;
|
16
|
import java.util.Map;
|
17
|
import java.util.Set;
|
18
|
import java.util.UUID;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.springframework.stereotype.Component;
|
22
|
|
23
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
24
|
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
|
25
|
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelTaxonNameImportValidator;
|
26
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
27
|
import eu.etaxonomy.cdm.io.common.IOValidator;
|
28
|
import eu.etaxonomy.cdm.io.common.ImportHelper;
|
29
|
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
|
30
|
import eu.etaxonomy.cdm.io.common.Source;
|
31
|
import eu.etaxonomy.cdm.model.agent.Person;
|
32
|
import eu.etaxonomy.cdm.model.agent.Team;
|
33
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
34
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
35
|
import eu.etaxonomy.cdm.model.common.Extension;
|
36
|
import eu.etaxonomy.cdm.model.common.ExtensionType;
|
37
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
38
|
import eu.etaxonomy.cdm.model.name.CultivarPlantName;
|
39
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
40
|
import eu.etaxonomy.cdm.model.name.Rank;
|
41
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
42
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
43
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
44
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
45
|
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
|
46
|
|
47
|
/**
|
48
|
* @author a.mueller
|
49
|
* @created 20.03.2008
|
50
|
* @version 1.0
|
51
|
*/
|
52
|
@Component
|
53
|
public class BerlinModelTaxonNameImport extends BerlinModelImportBase {
|
54
|
private static final Logger logger = Logger.getLogger(BerlinModelTaxonNameImport.class);
|
55
|
|
56
|
public static final String NAMESPACE = "TaxonName";
|
57
|
|
58
|
public static final UUID SOURCE_ACC_UUID = UUID.fromString("c3959b4f-d876-4b7a-a739-9260f4cafd1c");
|
59
|
|
60
|
private static int modCount = 5000;
|
61
|
private static final String pluralString = "TaxonNames";
|
62
|
private static final String dbTableName = "Name";
|
63
|
|
64
|
|
65
|
public BerlinModelTaxonNameImport(){
|
66
|
super();
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery()
|
71
|
*/
|
72
|
@Override
|
73
|
protected String getRecordQuery(BerlinModelImportConfigurator config) {
|
74
|
Source source = config.getSource();
|
75
|
|
76
|
String facultativCols = "";
|
77
|
String strFacTable = "RefDetail";
|
78
|
String strFacColumn = "IdInSource";
|
79
|
String strColAlias = null;
|
80
|
if (checkSqlServerColumnExists(source, strFacTable, strFacColumn)){
|
81
|
facultativCols += ", " + strFacTable + "." + strFacColumn ;
|
82
|
if (! CdmUtils.Nz(strColAlias).equals("") ){
|
83
|
facultativCols += " AS " + strColAlias;
|
84
|
}
|
85
|
}
|
86
|
|
87
|
String strRecordQuery =
|
88
|
"SELECT Name.* , RefDetail.RefDetailId, RefDetail.RefFk, " +
|
89
|
" RefDetail.FullRefCache, RefDetail.FullNomRefCache, RefDetail.PreliminaryFlag AS RefDetailPrelim, RefDetail.Details, " +
|
90
|
" RefDetail.SecondarySources, Rank.RankAbbrev, Rank.Rank " +
|
91
|
facultativCols +
|
92
|
" FROM Name LEFT OUTER JOIN RefDetail ON Name.NomRefDetailFk = RefDetail.RefDetailId AND " +
|
93
|
" Name.NomRefFk = RefDetail.RefFk " +
|
94
|
" LEFT OUTER JOIN Rank ON Name.RankFk = Rank.rankID " +
|
95
|
" WHERE name.nameId IN ("+ID_LIST_TOKEN+") ";
|
96
|
//strQuery += " AND RefDetail.PreliminaryFlag = 1 ";
|
97
|
//strQuery += " AND Name.Created_When > '03.03.2004' ";
|
98
|
return strRecordQuery;
|
99
|
}
|
100
|
|
101
|
|
102
|
/* (non-Javadoc)
|
103
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#doPartition(eu.etaxonomy.cdm.io.berlinModel.in.ResultSetPartitioner, eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportState)
|
104
|
*/
|
105
|
public boolean doPartition(ResultSetPartitioner partitioner, BerlinModelImportState state) {
|
106
|
String dbAttrName;
|
107
|
String cdmAttrName;
|
108
|
boolean success = true ;
|
109
|
BerlinModelImportConfigurator config = state.getConfig();
|
110
|
Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
|
111
|
Map<String, Team> teamMap = (Map<String, Team>) partitioner.getObjectMap(BerlinModelAuthorTeamImport.NAMESPACE);
|
112
|
|
113
|
ResultSet rs = partitioner.getResultSet();
|
114
|
|
115
|
try {
|
116
|
int i = 0;
|
117
|
//for each reference
|
118
|
while (rs.next()){
|
119
|
|
120
|
if ((i++ % modCount) == 0 && i != 1 ){ logger.info("Names handled: " + (i-1));}
|
121
|
|
122
|
//create TaxonName element
|
123
|
int nameId = rs.getInt("nameId");
|
124
|
Object authorFk = rs.getObject("AuthorTeamFk");
|
125
|
Object exAuthorFk = rs.getObject("ExAuthorTeamFk");
|
126
|
Object basAuthorFk = rs.getObject("BasAuthorTeamFk");
|
127
|
Object exBasAuthorFk = rs.getObject("ExBasAuthorTeamFk");
|
128
|
String strCultivarGroupName = rs.getString("CultivarGroupName");
|
129
|
String strCultivarName = rs.getString("CultivarName");
|
130
|
|
131
|
try {
|
132
|
boolean useUnknownRank = true;
|
133
|
Rank rank = BerlinModelTransformer.rankId2Rank(rs, useUnknownRank);
|
134
|
|
135
|
TaxonNameBase taxonNameBase;
|
136
|
if (config.getNomenclaturalCode() != null){
|
137
|
taxonNameBase = config.getNomenclaturalCode().getNewTaxonNameInstance(rank);
|
138
|
//check cultivar
|
139
|
if (taxonNameBase instanceof BotanicalName){
|
140
|
if (CdmUtils.isNotEmpty(strCultivarGroupName) && CdmUtils.isNotEmpty(strCultivarName)){
|
141
|
taxonNameBase = CultivarPlantName.NewInstance(rank);
|
142
|
}
|
143
|
}
|
144
|
}else{
|
145
|
taxonNameBase = NonViralName.NewInstance(rank);
|
146
|
}
|
147
|
|
148
|
if (rank == null){
|
149
|
//TODO rank should never be null or a more sophisticated algorithm has to be implemented for genus/supraGenericName
|
150
|
logger.warn("Rank is null. Genus epethiton was imported. May be wrong");
|
151
|
success = false;
|
152
|
}
|
153
|
if (rank != null && rank.isSupraGeneric()){
|
154
|
dbAttrName = "supraGenericName";
|
155
|
}else{
|
156
|
dbAttrName = "genus";
|
157
|
}
|
158
|
cdmAttrName = "genusOrUninomial";
|
159
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
160
|
|
161
|
dbAttrName = "genusSubdivisionEpi";
|
162
|
cdmAttrName = "infraGenericEpithet";
|
163
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
164
|
|
165
|
dbAttrName = "speciesEpi";
|
166
|
cdmAttrName = "specificEpithet";
|
167
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
168
|
|
169
|
|
170
|
dbAttrName = "infraSpeciesEpi";
|
171
|
cdmAttrName = "infraSpecificEpithet";
|
172
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
173
|
|
174
|
dbAttrName = "unnamedNamePhrase";
|
175
|
cdmAttrName = "appendedPhrase";
|
176
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
177
|
|
178
|
//Details
|
179
|
dbAttrName = "details";
|
180
|
cdmAttrName = "nomenclaturalMicroReference";
|
181
|
success &= ImportHelper.addStringValue(rs, taxonNameBase, dbAttrName, cdmAttrName);
|
182
|
|
183
|
//nomRef
|
184
|
success &= makeNomenclaturalReference(config, taxonNameBase, nameId, rs, partitioner);
|
185
|
|
186
|
//Source_Acc
|
187
|
String sourceAcc = rs.getString("Source_Acc");
|
188
|
if (CdmUtils.isNotEmpty(sourceAcc)){
|
189
|
ExtensionType sourceAccExtensionType = getExtensionType(state, SOURCE_ACC_UUID, "Source_Acc","Source_Acc","Source_Acc");
|
190
|
Extension datesExtension = Extension.NewInstance(taxonNameBase, sourceAcc, sourceAccExtensionType);
|
191
|
}
|
192
|
|
193
|
//created, notes
|
194
|
success &= doIdCreatedUpdatedNotes(state, taxonNameBase, rs, nameId, NAMESPACE);
|
195
|
|
196
|
//NonViralName
|
197
|
if (taxonNameBase instanceof NonViralName){
|
198
|
NonViralName nonViralName = (NonViralName)taxonNameBase;
|
199
|
|
200
|
//authorTeams
|
201
|
if (teamMap != null ){
|
202
|
nonViralName.setCombinationAuthorTeam(getAuthorTeam(teamMap, authorFk, nameId, config));
|
203
|
nonViralName.setExCombinationAuthorTeam(getAuthorTeam(teamMap, exAuthorFk, nameId, config));
|
204
|
nonViralName.setBasionymAuthorTeam(getAuthorTeam(teamMap, basAuthorFk, nameId, config));
|
205
|
nonViralName.setExBasionymAuthorTeam(getAuthorTeam(teamMap, exBasAuthorFk, nameId, config));
|
206
|
}else{
|
207
|
logger.warn("TeamMap is null");
|
208
|
success = false;
|
209
|
}
|
210
|
}//nonviralName
|
211
|
|
212
|
|
213
|
|
214
|
|
215
|
|
216
|
//zoologicalName
|
217
|
if (taxonNameBase instanceof ZoologicalName){
|
218
|
ZoologicalName zooName = (ZoologicalName)taxonNameBase;
|
219
|
makeZoologialName(rs, zooName, nameId);
|
220
|
}
|
221
|
//botanicalName
|
222
|
else if (taxonNameBase instanceof BotanicalName){
|
223
|
BotanicalName botName = (BotanicalName)taxonNameBase;
|
224
|
success &= makeBotanicalNamePart(rs, botName) ;
|
225
|
|
226
|
}
|
227
|
|
228
|
// dbAttrName = "preliminaryFlag";
|
229
|
Boolean preliminaryFlag = rs.getBoolean("PreliminaryFlag");
|
230
|
if (preliminaryFlag == true){
|
231
|
//Computes all caches and sets
|
232
|
taxonNameBase.setFullTitleCache(taxonNameBase.getFullTitleCache(), true);
|
233
|
taxonNameBase.setTitleCache(taxonNameBase.getTitleCache(), true);
|
234
|
if (taxonNameBase instanceof NonViralName){
|
235
|
NonViralName nvn = (NonViralName)taxonNameBase;
|
236
|
nvn.setNameCache(nvn.getNameCache(), true);
|
237
|
nvn.setAuthorshipCache(nvn.getAuthorshipCache(), true);
|
238
|
}
|
239
|
}
|
240
|
namesToSave.add(taxonNameBase);
|
241
|
|
242
|
}
|
243
|
catch (UnknownCdmTypeException e) {
|
244
|
logger.warn("Name with id " + nameId + " has unknown rankId " + " and could not be saved.");
|
245
|
success = false;
|
246
|
}
|
247
|
|
248
|
} //while rs.hasNext()
|
249
|
} catch (SQLException e) {
|
250
|
logger.error("SQLException:" + e);
|
251
|
return false;
|
252
|
}
|
253
|
|
254
|
|
255
|
// logger.info( i + " names handled");
|
256
|
getNameService().save(namesToSave);
|
257
|
return success;
|
258
|
}
|
259
|
|
260
|
/* (non-Javadoc)
|
261
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet)
|
262
|
*/
|
263
|
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) {
|
264
|
String nameSpace;
|
265
|
Class cdmClass;
|
266
|
Set<String> idSet;
|
267
|
|
268
|
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>();
|
269
|
|
270
|
try{
|
271
|
Set<String> teamIdSet = new HashSet<String>();
|
272
|
Set<String> referenceIdSet = new HashSet<String>();
|
273
|
Set<String> refDetailIdSet = new HashSet<String>();
|
274
|
while (rs.next()){
|
275
|
handleForeignKey(rs, teamIdSet, "AuthorTeamFk");
|
276
|
handleForeignKey(rs, teamIdSet, "ExAuthorTeamFk");
|
277
|
handleForeignKey(rs, teamIdSet, "BasAuthorTeamFk");
|
278
|
handleForeignKey(rs, teamIdSet, "ExBasAuthorTeamFk");
|
279
|
handleForeignKey(rs, referenceIdSet, "nomRefFk");
|
280
|
handleForeignKey(rs, refDetailIdSet, "nomRefDetailFk");
|
281
|
}
|
282
|
|
283
|
//team map
|
284
|
nameSpace = BerlinModelAuthorTeamImport.NAMESPACE;
|
285
|
cdmClass = Team.class;
|
286
|
idSet = teamIdSet;
|
287
|
Map<String, Person> teamMap = (Map<String, Person>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
288
|
result.put(nameSpace, teamMap);
|
289
|
|
290
|
//nom reference map
|
291
|
nameSpace = BerlinModelReferenceImport.NOM_REFERENCE_NAMESPACE;
|
292
|
cdmClass = ReferenceBase.class;
|
293
|
idSet = referenceIdSet;
|
294
|
Map<String, ReferenceBase> nomReferenceMap = (Map<String, ReferenceBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
295
|
result.put(nameSpace, nomReferenceMap);
|
296
|
|
297
|
//biblio reference map
|
298
|
nameSpace = BerlinModelReferenceImport.BIBLIO_REFERENCE_NAMESPACE;
|
299
|
cdmClass = ReferenceBase.class;
|
300
|
idSet = referenceIdSet;
|
301
|
Map<String, ReferenceBase> biblioReferenceMap = (Map<String, ReferenceBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
302
|
result.put(nameSpace, biblioReferenceMap);
|
303
|
|
304
|
//nom refDetail map
|
305
|
nameSpace = BerlinModelRefDetailImport.NOM_REFDETAIL_NAMESPACE;
|
306
|
cdmClass = ReferenceBase.class;
|
307
|
idSet = refDetailIdSet;
|
308
|
Map<String, ReferenceBase> nomRefDetailMap= (Map<String, ReferenceBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
309
|
result.put(nameSpace, nomRefDetailMap);
|
310
|
|
311
|
//biblio refDetail map
|
312
|
nameSpace = BerlinModelRefDetailImport.BIBLIO_REFDETAIL_NAMESPACE;
|
313
|
cdmClass = ReferenceBase.class;
|
314
|
idSet = refDetailIdSet;
|
315
|
Map<String, ReferenceBase> biblioRefDetailMap= (Map<String, ReferenceBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
316
|
result.put(nameSpace, biblioRefDetailMap);
|
317
|
|
318
|
} catch (SQLException e) {
|
319
|
throw new RuntimeException(e);
|
320
|
}
|
321
|
return result;
|
322
|
}
|
323
|
|
324
|
private boolean makeZoologialName(ResultSet rs, ZoologicalName zooName, int nameId)
|
325
|
throws SQLException{
|
326
|
boolean success = true;
|
327
|
//publicationYear
|
328
|
String authorTeamYear = rs.getString("authorTeamYear");
|
329
|
try {
|
330
|
if (! "".equals(CdmUtils.Nz(authorTeamYear).trim())){
|
331
|
Integer publicationYear = Integer.valueOf(authorTeamYear.trim());
|
332
|
zooName.setPublicationYear(publicationYear);
|
333
|
}
|
334
|
} catch (NumberFormatException e) {
|
335
|
logger.warn("authorTeamYear could not be parsed for taxonName: "+ nameId);
|
336
|
}
|
337
|
//original publication year
|
338
|
String basAuthorTeamYear = rs.getString("basAuthorTeamYear");
|
339
|
try {
|
340
|
if (! "".equals(CdmUtils.Nz(basAuthorTeamYear).trim())){
|
341
|
Integer OriginalPublicationYear = Integer.valueOf(basAuthorTeamYear.trim());
|
342
|
zooName.setOriginalPublicationYear(OriginalPublicationYear);
|
343
|
}
|
344
|
} catch (NumberFormatException e) {
|
345
|
logger.warn("basAuthorTeamYear could not be parsed for taxonName: "+ nameId);
|
346
|
}
|
347
|
return success;
|
348
|
}
|
349
|
|
350
|
private boolean makeBotanicalNamePart(ResultSet rs, BotanicalName botanicalName)throws SQLException{
|
351
|
boolean success = true;
|
352
|
String dbAttrName;
|
353
|
String cdmAttrName;
|
354
|
|
355
|
dbAttrName = "HybridFormulaFlag";
|
356
|
cdmAttrName = "isHybridFormula";
|
357
|
success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
|
358
|
|
359
|
dbAttrName = "MonomHybFlag";
|
360
|
cdmAttrName = "isMonomHybrid";
|
361
|
success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
|
362
|
|
363
|
dbAttrName = "BinomHybFlag";
|
364
|
cdmAttrName = "isBinomHybrid";
|
365
|
success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
|
366
|
|
367
|
dbAttrName = "TrinomHybFlag";
|
368
|
cdmAttrName = "isTrinomHybrid";
|
369
|
success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
|
370
|
|
371
|
try {
|
372
|
String strCultivarGroupName = rs.getString("CultivarGroupName");
|
373
|
String strCultivarName = rs.getString("CultivarName");
|
374
|
if (botanicalName instanceof CultivarPlantName){
|
375
|
CultivarPlantName cultivarName = (CultivarPlantName)botanicalName;
|
376
|
String concatCultivarName = CdmUtils.concat("-", strCultivarName, strCultivarGroupName);
|
377
|
if (CdmUtils.isNotEmpty(strCultivarGroupName) && CdmUtils.isNotEmpty(strCultivarName)){
|
378
|
logger.warn("CDM does not support cultivarGroupName and CultivarName together: " + concatCultivarName);
|
379
|
}
|
380
|
cultivarName.setCultivarName(strCultivarGroupName);
|
381
|
}
|
382
|
} catch (SQLException e) {
|
383
|
throw e;
|
384
|
}
|
385
|
return success;
|
386
|
}
|
387
|
|
388
|
|
389
|
private boolean makeNomenclaturalReference(IImportConfigurator config, TaxonNameBase taxonNameBase,
|
390
|
int nameId, ResultSet rs, ResultSetPartitioner partitioner) throws SQLException{
|
391
|
Map<String, ReferenceBase> biblioRefMap = partitioner.getObjectMap(BerlinModelReferenceImport.BIBLIO_REFERENCE_NAMESPACE);
|
392
|
Map<String, ReferenceBase> nomRefMap = partitioner.getObjectMap(BerlinModelReferenceImport.NOM_REFERENCE_NAMESPACE);
|
393
|
Map<String, ReferenceBase> biblioRefDetailMap = partitioner.getObjectMap(BerlinModelRefDetailImport.BIBLIO_REFDETAIL_NAMESPACE);
|
394
|
Map<String, ReferenceBase> nomRefDetailMap = partitioner.getObjectMap(BerlinModelRefDetailImport.NOM_REFDETAIL_NAMESPACE);
|
395
|
|
396
|
Object nomRefFkObj = rs.getObject("NomRefFk");
|
397
|
Object nomRefDetailFkObj = rs.getObject("NomRefDetailFk");
|
398
|
boolean refDetailPrelim = rs.getBoolean("RefDetailPrelim");
|
399
|
|
400
|
boolean success = true;
|
401
|
//nomenclatural Reference
|
402
|
if (biblioRefMap != null){
|
403
|
if (nomRefFkObj != null){
|
404
|
String nomRefFk = String.valueOf(nomRefFkObj);
|
405
|
String nomRefDetailFk = String.valueOf(nomRefDetailFkObj);
|
406
|
//get nomRef
|
407
|
ReferenceBase nomReference =
|
408
|
getReferenceFromMaps(nomRefDetailMap, biblioRefDetailMap,
|
409
|
nomRefMap, biblioRefMap, nomRefDetailFk, nomRefFk);
|
410
|
|
411
|
|
412
|
//setNomRef
|
413
|
if (nomReference == null ){
|
414
|
//TODO
|
415
|
if (! config.isIgnoreNull()){
|
416
|
logger.warn("Nomenclatural reference (nomRefFk = " + nomRefFk + ") for TaxonName (nameId = " + nameId + ")"+
|
417
|
" was not found in reference store. Nomenclatural reference was not set!!");
|
418
|
}
|
419
|
}else{
|
420
|
if (! INomenclaturalReference.class.isAssignableFrom(nomReference.getClass())){
|
421
|
logger.warn("Nomenclatural reference (nomRefFk = " + nomRefFk + ") for TaxonName (nameId = " + nameId + ")"+
|
422
|
" is not assignable from INomenclaturalReference. (Class = " + nomReference.getClass()+ ")");
|
423
|
}
|
424
|
nomReference.setNomenclaturallyRelevant(true);
|
425
|
taxonNameBase.setNomenclaturalReference(nomReference);
|
426
|
}
|
427
|
}
|
428
|
}
|
429
|
return success;
|
430
|
}
|
431
|
|
432
|
private static TeamOrPersonBase getAuthorTeam(Map<String, Team> teamMap, Object teamIdObject, int nameId, BerlinModelImportConfigurator bmiConfig){
|
433
|
if (teamIdObject == null){
|
434
|
return null;
|
435
|
}else {
|
436
|
String teamId = String.valueOf(teamIdObject);
|
437
|
TeamOrPersonBase author = teamMap.get(teamId);
|
438
|
if (author == null){
|
439
|
//TODO
|
440
|
if (!bmiConfig.isIgnoreNull() && ! (teamId.equals(0) && bmiConfig.isIgnore0AuthorTeam()) ){
|
441
|
logger.warn("AuthorTeam (teamId = " + teamId + ") for TaxonName (nameId = " + nameId + ")"+
|
442
|
" was not found in authorTeam store. Relation was not set!!");}
|
443
|
return null;
|
444
|
}else{
|
445
|
return author;
|
446
|
}
|
447
|
}
|
448
|
}
|
449
|
|
450
|
/* (non-Javadoc)
|
451
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator)
|
452
|
*/
|
453
|
@Override
|
454
|
protected boolean doCheck(BerlinModelImportState state){
|
455
|
IOValidator<BerlinModelImportState> validator = new BerlinModelTaxonNameImportValidator();
|
456
|
return validator.validate(state);
|
457
|
}
|
458
|
|
459
|
/* (non-Javadoc)
|
460
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getTableName()
|
461
|
*/
|
462
|
@Override
|
463
|
protected String getTableName() {
|
464
|
return dbTableName;
|
465
|
}
|
466
|
|
467
|
/* (non-Javadoc)
|
468
|
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getPluralString()
|
469
|
*/
|
470
|
@Override
|
471
|
public String getPluralString() {
|
472
|
return pluralString;
|
473
|
}
|
474
|
|
475
|
/* (non-Javadoc)
|
476
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
|
477
|
*/
|
478
|
protected boolean isIgnore(BerlinModelImportState state){
|
479
|
return ! state.getConfig().isDoTaxonNames();
|
480
|
}
|
481
|
|
482
|
|
483
|
|
484
|
|
485
|
|
486
|
|
487
|
//FOR FUTURE USE , DONT DELETE
|
488
|
// new CdmStringMapper("nameId", "nameId"),
|
489
|
// new CdmStringMapper("rankFk", "rankFk"),
|
490
|
// new CdmStringMapper("nameCache", "nameCache"),
|
491
|
// new CdmStringMapper("unnamedNamePhrase", "unnamedNamePhrase"),
|
492
|
// new CdmStringMapper("fullNameCache", "fullNameCache"),
|
493
|
// new CdmStringMapper("preliminaryFlag", "preliminaryFlag"),
|
494
|
// new CdmStringMapper("supragenericName", "supragenericName"),
|
495
|
// new CdmStringMapper("genus", "genus"),
|
496
|
// new CdmStringMapper("genusSubdivisionEpi", "genusSubdivisionEpi"),
|
497
|
// new CdmStringMapper("speciesEpi", "speciesEpi"),
|
498
|
// new CdmStringMapper("infraSpeciesEpi", "infraSpeciesEpi"),
|
499
|
// new CdmStringMapper("authorTeamFk", "authorTeamFk"),
|
500
|
// new CdmStringMapper("exAuthorTeamFk", "exAuthorTeamFk"),
|
501
|
// new CdmStringMapper("basAuthorTeamFk", "basAuthorTeamFk"),
|
502
|
// new CdmStringMapper("exBasAuthorTeamFk", "exBasAuthorTeamFk"),
|
503
|
// new CdmStringMapper("hybridFormulaFlag", "hybridFormulaFlag"),
|
504
|
// new CdmStringMapper("monomHybFlag", "monomHybFlag"),
|
505
|
// new CdmStringMapper("binomHybFlag", "binomHybFlag"),
|
506
|
// new CdmStringMapper("trinomHybFlag", "trinomHybFlag"),
|
507
|
// new CdmStringMapper("cultivarGroupName", "cultivarGroupName"),
|
508
|
// new CdmStringMapper("cultivarName", "cultivarName"),
|
509
|
// new CdmStringMapper("nomRefFk", "nomRefFk"),
|
510
|
// new CdmStringMapper("nomRefDetailFk", "nomRefDetailFk"),
|
511
|
// new CdmStringMapper("nameSourceRefFk", "nameSourceRefFk"),
|
512
|
// new CdmStringMapper("source_Acc", "source_Acc"),
|
513
|
// new CdmStringMapper("created_When", "created_When"),
|
514
|
// new CdmStringMapper("created_Who", "created_Who"),
|
515
|
// new CdmStringMapper("notes", "notes"),
|
516
|
// new CdmStringMapper("parsingComments", "parsingComments"),
|
517
|
// new CdmStringMapper("oldNomRefFk", "oldNomRefFk"),
|
518
|
// new CdmStringMapper("oldNomRefDetailFk", "oldNomRefDetailFk"),
|
519
|
// new CdmStringMapper("updated_Who", "updated_Who"),
|
520
|
// new CdmStringMapper("orthoProjection", "orthoProjection"),
|
521
|
|
522
|
|
523
|
}
|