Revision e1d0f581
Added by Andreas Müller over 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java | ||
---|---|---|
56 | 56 |
*/ |
57 | 57 |
@Component |
58 | 58 |
public class BerlinModelTaxonImport extends BerlinModelImportBase { |
59 |
/** |
|
60 |
* |
|
61 |
*/ |
|
62 |
private static final String LAST_SCRUTINY_FK = "lastScrutinyFk"; |
|
63 |
|
|
59 | 64 |
private static final long serialVersionUID = -1186364983750790695L; |
60 | 65 |
|
61 | 66 |
private static final Logger logger = Logger.getLogger(BerlinModelTaxonImport.class); |
... | ... | |
106 | 111 |
String sqlFrom = " FROM PTaxon pt "; |
107 | 112 |
if (config.isEuroMed()){ |
108 | 113 |
sqlFrom = " FROM PTaxon AS pt " + |
109 |
" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier " + |
|
110 |
" LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId "; |
|
111 |
sqlSelect += " , em.MA, r.RefCache as LastScrutiny "; |
|
114 |
" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier "; |
|
115 |
if (!config.isUseLastScrutinyAsSec()){ |
|
116 |
sqlFrom += " LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId "; |
|
117 |
} |
|
118 |
sqlSelect += " , em.MA "; |
|
119 |
if (!config.isUseLastScrutinyAsSec()){ |
|
120 |
sqlSelect += ", r.RefCache as LastScrutiny "; |
|
121 |
} |
|
112 | 122 |
} |
113 | 123 |
|
114 | 124 |
|
... | ... | |
156 | 166 |
uuid = rs.getString("UUID"); |
157 | 167 |
} |
158 | 168 |
|
169 |
|
|
159 | 170 |
TaxonName taxonName = null; |
160 | 171 |
taxonName = taxonNameMap.get(String.valueOf(nameFk)); |
161 | 172 |
|
162 | 173 |
Reference reference = null; |
163 |
String refFk = String.valueOf(refFkInt); |
|
164 |
reference = refMap.get(refFk); |
|
174 |
String refFkStr = String.valueOf(refFkInt); |
|
175 |
reference = refMap.get(refFkStr); |
|
176 |
|
|
177 |
Reference lastScrutinyRef = null; |
|
178 |
if (state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs,LAST_SCRUTINY_FK)){ |
|
179 |
Integer lastScrutinyFk = nullSafeInt(rs,LAST_SCRUTINY_FK); |
|
180 |
if (lastScrutinyFk != null){ |
|
181 |
String lastScrutinyFkStr = String.valueOf(lastScrutinyFk); |
|
182 |
if (lastScrutinyFkStr != null){ |
|
183 |
lastScrutinyRef = refMap.get(lastScrutinyFkStr); |
|
184 |
if (lastScrutinyRef == null){ |
|
185 |
logger.warn("Last scrutiny reference "+lastScrutinyFkStr+" could not be found " |
|
186 |
+ "for taxon " + taxonId); |
|
187 |
} |
|
188 |
if(!StringUtils.right(refFkStr, 5).equals("00000")){ |
|
189 |
logger.warn("Unexpected secFk " + refFkStr + " for taxon with last scrutiny. Taxon id " + taxonId); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
165 | 194 |
|
166 | 195 |
if(! config.isIgnoreNull()){ |
167 | 196 |
if (taxonName == null ){ |
... | ... | |
169 | 198 |
success = false; |
170 | 199 |
continue; //next taxon |
171 | 200 |
}else if (reference == null ){ |
172 |
logger.warn("Reference belonging to taxon could not be found in store. Taxon will not be imported"); |
|
201 |
logger.warn("Sec Reference belonging to taxon could not be found in store. Taxon will not be imported");
|
|
173 | 202 |
success = false; |
174 | 203 |
continue; //next taxon |
175 | 204 |
} |
... | ... | |
177 | 206 |
TaxonBase<?> taxonBase; |
178 | 207 |
Synonym synonym; |
179 | 208 |
Taxon taxon; |
209 |
Reference sec = lastScrutinyRef != null? lastScrutinyRef: reference; |
|
180 | 210 |
try { |
181 | 211 |
logger.debug(statusFk); |
182 | 212 |
if (statusFk == T_STATUS_ACCEPTED || statusFk == T_STATUS_UNRESOLVED |
183 | 213 |
|| statusFk == T_STATUS_PRO_PARTE_SYN || statusFk == T_STATUS_PARTIAL_SYN ){ |
184 |
taxon = Taxon.NewInstance(taxonName, reference);
|
|
214 |
taxon = Taxon.NewInstance(taxonName, sec);
|
|
185 | 215 |
taxonBase = taxon; |
186 | 216 |
if (statusFk == T_STATUS_UNRESOLVED){ |
187 | 217 |
taxon.setTaxonStatusUnknown(true); |
188 | 218 |
} |
189 | 219 |
//TODO marker for pp and partial? |
190 | 220 |
}else if (statusFk == T_STATUS_SYNONYM ){ |
191 |
synonym = Synonym.NewInstance(taxonName, reference);
|
|
221 |
synonym = Synonym.NewInstance(taxonName, sec);
|
|
192 | 222 |
taxonBase = synonym; |
193 | 223 |
// if (statusFk == T_STATUS_PRO_PARTE_SYN){ |
194 | 224 |
// synonym.setProParte(true); |
... | ... | |
250 | 280 |
} |
251 | 281 |
} |
252 | 282 |
|
253 |
// |
|
254 |
if (resultSetHasColumn(rs, "LastScrutiny")){ |
|
283 |
// does not exist anymore as we use last scrutiny now as sec ref
|
|
284 |
if (!state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs, "LastScrutiny")){
|
|
255 | 285 |
String lastScrutiny = rs.getString("LastScrutiny"); |
256 | 286 |
//TODO strange, why not Extension last scrutiny? To match PESI? Is there a difference |
257 | 287 |
//to LastScrutinyFK and SpeciesExpertFK? |
... | ... | |
345 | 375 |
while (rs.next()){ |
346 | 376 |
handleForeignKey(rs, nameIdSet, "PTNameFk"); |
347 | 377 |
handleForeignKey(rs, referenceIdSet, "PTRefFk"); |
378 |
if (state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs, LAST_SCRUTINY_FK)){ |
|
379 |
handleForeignKey(rs, referenceIdSet, LAST_SCRUTINY_FK); |
|
380 |
} |
|
348 | 381 |
} |
349 | 382 |
|
350 | 383 |
//name map |
... | ... | |
382 | 415 |
return ! state.getConfig().isDoTaxa(); |
383 | 416 |
} |
384 | 417 |
|
385 |
|
|
386 |
|
|
387 | 418 |
} |
Also available in: Unified diff
ref #3992, ref #7713, ref #3990 Atomize last scrutiny references