Revision 892efc69
Added by Andreas Kohlbecker almost 14 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java | ||
---|---|---|
30 | 30 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
31 | 31 |
import eu.etaxonomy.cdm.model.taxon.TaxonomicTree; |
32 | 32 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
33 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
33 | 34 |
|
34 | 35 |
/** |
35 | 36 |
* @author a.babadshanjan |
... | ... | |
151 | 152 |
// Create the taxon name object depending on the setting of the nomenclatural code |
152 | 153 |
// in the configurator (botanical code, zoological code, etc.) |
153 | 154 |
NomenclaturalCode nc = getConfigurator().getNomenclaturalCode(); |
154 |
TaxonNameBase taxonNameBase;
|
|
155 |
NonViralName taxonNameBase;
|
|
155 | 156 |
if (nc == NomenclaturalCode.ICVCN){ |
156 | 157 |
logger.warn("ICVCN not yet supported"); |
157 | 158 |
return false; |
158 | 159 |
}else{ |
159 |
taxonNameBase = nc.getNewTaxonNameInstance(rank); |
|
160 |
NonViralName nonViralName = (NonViralName)taxonNameBase; |
|
160 |
taxonNameBase =(NonViralName) nc.getNewTaxonNameInstance(rank);
|
|
161 |
//NonViralName nonViralName = (NonViralName)taxonNameBase;
|
|
161 | 162 |
//TODO parse name |
162 |
nonViralName.setNameCache(taxonNameStr); |
|
163 |
NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance(); |
|
164 |
taxonNameBase = parser.parseFullName(taxonNameStr, nc, rank); |
|
165 |
|
|
166 |
taxonNameBase.setNameCache(taxonNameStr); |
|
163 | 167 |
|
164 | 168 |
// Create the author |
165 | 169 |
if (CdmUtils.isNotEmpty(authorStr)) { |
166 | 170 |
//TODO parse authors |
167 | 171 |
//if (state.getAuthor(authorStr)!= null) { |
168 |
nonViralName.setAuthorshipCache(authorStr);
|
|
172 |
taxonNameBase.setAuthorshipCache(authorStr);
|
|
169 | 173 |
// } else { |
170 | 174 |
// state.putAuthor(authorStr, null); |
171 | 175 |
// Person author = Person.NewTitledInstance(authorStr); |
... | ... | |
203 | 207 |
Integer childId = state.getTaxonLight().getId(); |
204 | 208 |
|
205 | 209 |
Taxon parentTaxon = (Taxon)state.getTaxonBase(parentId); |
206 |
|
|
210 |
Taxon taxon = (Taxon)state.getTaxonBase(childId); |
|
207 | 211 |
if (CdmUtils.isNotEmpty(taxonNameStr)) { |
208 | 212 |
if (nameStatus != null && nameStatus.equalsIgnoreCase("invalid")){ |
209 | 213 |
//add synonym relationship |
... | ... | |
213 | 217 |
// Add the parent relationship |
214 | 218 |
if (state.getTaxonLight().getParentId() != 0) { |
215 | 219 |
if (parentTaxon != null) { |
216 |
Taxon taxon = (Taxon)state.getTaxonBase(childId); |
|
220 |
//Taxon taxon = (Taxon)state.getTaxonBase(childId);
|
|
217 | 221 |
|
218 | 222 |
ReferenceBase citation = state.getConfig().getSourceReference(); |
219 | 223 |
String microCitation = null; |
... | ... | |
228 | 232 |
//do nothing (parent == 0) no parent exists |
229 | 233 |
} |
230 | 234 |
} |
231 |
} else { |
|
232 |
// add common name to parent taxon |
|
235 |
} |
|
236 |
if (CdmUtils.isNotEmpty(commonNameStr)) |
|
237 |
{ // add common name to taxon |
|
233 | 238 |
|
234 | 239 |
Language language = getTermService().getLanguageByIso(state.getTaxonLight().getLanguage()); |
235 | 240 |
if (language == null && CdmUtils.isNotEmpty(state.getTaxonLight().getLanguage()) ){ |
... | ... | |
239 | 244 |
} |
240 | 245 |
CommonTaxonName commonTaxonName = CommonTaxonName.NewInstance(commonNameStr, language); |
241 | 246 |
try { |
242 |
TaxonDescription taxonDescription = getDescription(parentTaxon);
|
|
247 |
TaxonDescription taxonDescription = getDescription(taxon);
|
|
243 | 248 |
taxonDescription.addElement(commonTaxonName); |
244 |
logger.info("Common name " + commonNameStr + " added to " + parentTaxon.getTitleCache());
|
|
249 |
logger.info("Common name " + commonNameStr + " added to " + taxon.getTitleCache());
|
|
245 | 250 |
} catch (ClassCastException ex) { |
246 | 251 |
logger.error(taxonNameStr + " is not a taxon instance."); |
247 | 252 |
} |
... | ... | |
274 | 279 |
if (tree == null){ |
275 | 280 |
tree = makeTree(state, sec); |
276 | 281 |
} |
277 |
success = tree.addParentChild(parentTaxon, childTaxon, citation, microCitation);
|
|
282 |
success &= (null != tree.addParentChild(parentTaxon, childTaxon, citation, microCitation));
|
|
278 | 283 |
return success; |
279 | 284 |
} |
280 | 285 |
|
Also available in: Unified diff
merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk