Revision e138a102
Added by Patrick Plitzner almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java | ||
---|---|---|
117 | 117 |
throws SQLException { |
118 | 118 |
long id = rs.getLong(RedListUtil.NAMNR); |
119 | 119 |
String clTaxonString = rs.getString(RedListUtil.CL_TAXON); |
120 |
String relationE = rs.getString(RedListUtil.E); |
|
121 |
String relationW = rs.getString(RedListUtil.W); |
|
122 |
String relationK = rs.getString(RedListUtil.K); |
|
123 |
String relationAW = rs.getString(RedListUtil.AW); |
|
124 |
String relationAO = rs.getString(RedListUtil.AO); |
|
125 |
String relationR = rs.getString(RedListUtil.R); |
|
126 |
String relationO = rs.getString(RedListUtil.O); |
|
127 |
String relationS = rs.getString(RedListUtil.S); |
|
120 | 128 |
|
121 | 129 |
//---NAME--- |
122 | 130 |
NonViralName<?> name = importName(state, rs, namesToSave); |
... | ... | |
133 | 141 |
} |
134 | 142 |
|
135 | 143 |
//---CONCEPT RELATIONSHIPS--- |
144 |
//E, W, K, AW, AO, R, O, S |
|
145 |
cloneTaxon(taxonBase, relationE, RedListUtil.CLASSIFICATION_NAMESPACE_E, taxaToSave, id, state); |
|
146 |
cloneTaxon(taxonBase, relationW, RedListUtil.CLASSIFICATION_NAMESPACE_W, taxaToSave, id, state); |
|
147 |
cloneTaxon(taxonBase, relationK, RedListUtil.CLASSIFICATION_NAMESPACE_K, taxaToSave, id, state); |
|
148 |
cloneTaxon(taxonBase, relationAW, RedListUtil.CLASSIFICATION_NAMESPACE_AW, taxaToSave, id, state); |
|
149 |
cloneTaxon(taxonBase, relationAO, RedListUtil.CLASSIFICATION_NAMESPACE_AO, taxaToSave, id, state); |
|
150 |
cloneTaxon(taxonBase, relationR, RedListUtil.CLASSIFICATION_NAMESPACE_R, taxaToSave, id, state); |
|
151 |
cloneTaxon(taxonBase, relationO, RedListUtil.CLASSIFICATION_NAMESPACE_O, taxaToSave, id, state); |
|
152 |
cloneTaxon(taxonBase, relationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, taxaToSave, id, state); |
|
136 | 153 |
//checklist |
137 | 154 |
TaxonBase<?> checklistTaxon = null; |
138 | 155 |
if(CdmUtils.isNotBlank(clTaxonString) && !clTaxonString.trim().equals("-")){ |
... | ... | |
145 | 162 |
ImportHelper.setOriginalSource(checklistTaxon, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_CHECKLISTE_NAMESPACE); |
146 | 163 |
taxaToSave.add(checklistTaxon); |
147 | 164 |
} |
148 |
//E, W, K, AW, AO, R, O, S |
|
149 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_E, taxaToSave, id, state); |
|
150 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_W, taxaToSave, id, state); |
|
151 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_K, taxaToSave, id, state); |
|
152 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_AW, taxaToSave, id, state); |
|
153 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_AO, taxaToSave, id, state); |
|
154 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_R, taxaToSave, id, state); |
|
155 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_O, taxaToSave, id, state); |
|
156 |
cloneTaxon(taxonBase, RedListUtil.CLASSIFICATION_NAMESPACE_S, taxaToSave, id, state); |
|
157 | 165 |
|
158 | 166 |
//NOTE: the source has to be added after cloning or otherwise the clone would also get the source |
159 | 167 |
ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE); |
160 | 168 |
taxaToSave.add(taxonBase); |
161 | 169 |
} |
162 | 170 |
|
163 |
private Taxon cloneTaxon(final TaxonBase<?> gesamtListeTaxon, String sourceNameSpace, Set<TaxonBase> taxaToSave, long id, RedListGefaesspflanzenImportState state){ |
|
164 |
Taxon clonedTaxon = null; |
|
171 |
private void cloneTaxon(final TaxonBase<?> gesamtListeTaxon, String relationString, String sourceNameSpace, Set<TaxonBase> taxaToSave, long id, RedListGefaesspflanzenImportState state){ |
|
172 |
if(CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){ |
|
173 |
Taxon clonedTaxon = null; |
|
165 | 174 |
|
166 |
if(gesamtListeTaxon.isInstanceOf(Taxon.class)){ |
|
167 |
clonedTaxon = HibernateProxyHelper.deproxy(gesamtListeTaxon.clone(), Taxon.class); |
|
168 |
} |
|
169 |
else if(gesamtListeTaxon.isInstanceOf(Synonym.class)){ |
|
170 |
clonedTaxon = Taxon.NewInstance(gesamtListeTaxon.getName(), gesamtListeTaxon.getSec()); |
|
171 |
} |
|
172 |
else{ |
|
173 |
RedListUtil.logMessage(id, "Taxon base "+gesamtListeTaxon+" is neither taxon nor synonym! Taxon could not be cloned", logger); |
|
174 |
return null; |
|
175 |
if(gesamtListeTaxon.isInstanceOf(Taxon.class)){ |
|
176 |
clonedTaxon = HibernateProxyHelper.deproxy(gesamtListeTaxon.clone(), Taxon.class); |
|
177 |
} |
|
178 |
else if(gesamtListeTaxon.isInstanceOf(Synonym.class)){ |
|
179 |
clonedTaxon = Taxon.NewInstance(gesamtListeTaxon.getName(), gesamtListeTaxon.getSec()); |
|
180 |
} |
|
181 |
else{ |
|
182 |
RedListUtil.logMessage(id, "Taxon base "+gesamtListeTaxon+" is neither taxon nor synonym! Taxon could not be cloned", logger); |
|
183 |
return; |
|
184 |
} |
|
185 |
ImportHelper.setOriginalSource(clonedTaxon, state.getTransactionalSourceReference(), id, sourceNameSpace); |
|
186 |
taxaToSave.add(clonedTaxon); |
|
175 | 187 |
} |
176 |
|
|
177 |
ImportHelper.setOriginalSource(clonedTaxon, state.getTransactionalSourceReference(), id, sourceNameSpace); |
|
178 |
taxaToSave.add(clonedTaxon); |
|
179 |
return clonedTaxon; |
|
180 | 188 |
} |
181 | 189 |
|
182 | 190 |
private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name) throws SQLException { |
Also available in: Unified diff
#5448 Avoid clonig of all taxa for all classifications