Revision 7d882578
Added by Andreas Müller about 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java | ||
---|---|---|
38 | 38 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
39 | 39 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
40 | 40 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
41 |
import eu.etaxonomy.cdm.model.name.CultivarPlantName; |
|
41 |
import eu.etaxonomy.cdm.model.name.ICultivarPlantName; |
|
42 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
|
43 |
import eu.etaxonomy.cdm.model.name.ITaxonNameBase; |
|
42 | 44 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
43 | 45 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
44 | 46 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
45 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
46 | 47 |
import eu.etaxonomy.cdm.model.name.Rank; |
47 | 48 |
import eu.etaxonomy.cdm.model.name.RankClass; |
48 | 49 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
... | ... | |
128 | 129 |
@Override |
129 | 130 |
public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) { |
130 | 131 |
ResultSet rs = partitioner.getResultSet(); |
131 |
Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
|
|
132 |
Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>();
|
|
132 |
Set<ITaxonNameBase> namesToSave = new HashSet<>();
|
|
133 |
Set<TaxonBase> taxaToSave = new HashSet<>(); |
|
133 | 134 |
try { |
134 | 135 |
while (rs.next()){ |
135 | 136 |
makeSingleNameAndTaxon(state, rs, namesToSave, taxaToSave); |
... | ... | |
139 | 140 |
e.printStackTrace(); |
140 | 141 |
} |
141 | 142 |
|
142 |
getNameService().saveOrUpdate(namesToSave);
|
|
143 |
getNameService().saveOrUpdate(TaxonNameBase.castAndDeproxy(namesToSave));
|
|
143 | 144 |
getTaxonService().saveOrUpdate(taxaToSave); |
144 | 145 |
return true; |
145 | 146 |
} |
146 | 147 |
|
147 |
private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave) |
|
148 |
private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<ITaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave)
|
|
148 | 149 |
throws SQLException { |
149 | 150 |
long id = rs.getLong(RedListUtil.NAMNR); |
150 | 151 |
String relationE = rs.getString(RedListUtil.E); |
... | ... | |
157 | 158 |
String relationS = rs.getString(RedListUtil.S); |
158 | 159 |
|
159 | 160 |
//---NAME--- |
160 |
NonViralName<?> name = importName(state, rs, namesToSave);
|
|
161 |
INonViralName name = importName(state, rs, namesToSave);
|
|
161 | 162 |
|
162 | 163 |
|
163 | 164 |
//--- AUTHORS --- |
... | ... | |
205 | 206 |
} |
206 | 207 |
} |
207 | 208 |
|
208 |
private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name, RedListGefaesspflanzenImportState state) throws SQLException {
|
|
209 |
private TaxonBase<?> importTaxon(ResultSet rs, INonViralName name, RedListGefaesspflanzenImportState state) throws SQLException {
|
|
209 | 210 |
|
210 | 211 |
long id = rs.getLong(RedListUtil.NAMNR); |
211 | 212 |
String taxNameString = rs.getString(RedListUtil.TAXNAME); |
... | ... | |
259 | 260 |
return taxonBase; |
260 | 261 |
} |
261 | 262 |
|
262 |
private void importAuthors(RedListGefaesspflanzenImportState state, ResultSet rs, NonViralName<?> name) throws SQLException {
|
|
263 |
private void importAuthors(RedListGefaesspflanzenImportState state, ResultSet rs, INonViralName name) throws SQLException {
|
|
263 | 264 |
|
264 | 265 |
long id = rs.getLong(RedListUtil.NAMNR); |
265 | 266 |
String nomZusatzString = rs.getString(RedListUtil.NOM_ZUSATZ); |
... | ... | |
322 | 323 |
checkNameConsistency(id, nomZusatzString, taxZusatzString, zusatzString, authorString, hybString, name); |
323 | 324 |
} |
324 | 325 |
|
325 |
private NonViralName<?> importName(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave) throws SQLException {
|
|
326 |
private INonViralName importName(RedListGefaesspflanzenImportState state, ResultSet rs, Set<ITaxonNameBase> namesToSave) throws SQLException {
|
|
326 | 327 |
|
327 | 328 |
long id = rs.getLong(RedListUtil.NAMNR); |
328 | 329 |
String taxNameString = rs.getString(RedListUtil.TAXNAME); |
... | ... | |
338 | 339 |
RedListUtil.logMessage(id, "No name found!", logger); |
339 | 340 |
} |
340 | 341 |
|
341 |
NonViralName<?> name = null;
|
|
342 |
INonViralName name = null;
|
|
342 | 343 |
Rank rank = makeRank(id, state, rangString, CdmUtils.isNotBlank(ep3String)); |
343 | 344 |
//cultivar |
344 | 345 |
if(rank!= null && rank.equals(Rank.CULTIVAR())){ |
345 |
CultivarPlantName cultivar = TaxonNameFactory.NewCultivarInstance(rank); |
|
346 |
ICultivarPlantName cultivar = TaxonNameFactory.NewCultivarInstance(rank);
|
|
346 | 347 |
cultivar.setGenusOrUninomial(ep1String); |
347 | 348 |
cultivar.setSpecificEpithet(ep2String); |
348 | 349 |
cultivar.setCultivarName(ep3String); |
... | ... | |
482 | 483 |
} |
483 | 484 |
|
484 | 485 |
private void checkNameConsistency(long id, String nomZusatzString, String taxZusatzString, |
485 |
String zusatzString, String authorString, String hybString, NonViralName<?> name) {
|
|
486 |
String zusatzString, String authorString, String hybString, INonViralName name) {
|
|
486 | 487 |
String authorshipCache = name.getAuthorshipCache(); |
487 | 488 |
//FIXME: remove split length check when name parser can parse multiple hybrid parents |
488 | 489 |
if(hybString.equals(RedListUtil.HYB_XF) && name.getTitleCache().split(RedListUtil.HYB_SIGN).length==2){ |
... | ... | |
526 | 527 |
return; |
527 | 528 |
} |
528 | 529 |
|
529 |
String nameCache = HibernateProxyHelper.deproxy(taxonBase.getName(), NonViralName.class).getNameCache().trim();
|
|
530 |
String nameCache = taxonBase.getName().getNameCache().trim();
|
|
530 | 531 |
taxNameString = taxNameString.trim(); |
531 | 532 |
taxNameString = taxNameString.replaceAll(" +", " "); |
532 | 533 |
|
Also available in: Unified diff
ref #6362, ref #6365 remove occurrences of NonViralName, BotanicalName and ZoologicalName in cdmlib-app