import eu.etaxonomy.cdm.model.common.AnnotationType;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.name.BotanicalName;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.name.RankClass;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
importAuthors(state, rs, name);
//---TAXON---
- TaxonBase<?> taxonBase = importTaxon(rs, name);
+ TaxonBase<?> taxonBase = importTaxon(rs, name, state);
if(taxonBase==null){
RedListUtil.logMessage(id, "Taxon for name "+name+" could not be created.", logger);
return;
}
}
- private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name) throws SQLException {
+ private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name, RedListGefaesspflanzenImportState state) throws SQLException {
long id = rs.getLong(RedListUtil.NAMNR);
String taxNameString = rs.getString(RedListUtil.TAXNAME);
addAnnotation(RedListUtil.WISSK+": "+wisskString, taxonBase);
//check taxon name consistency
- checkTaxonConsistency(id, taxNameString, hybString, taxonBase);
+ checkTaxonConsistency(id, taxNameString, hybString, taxonBase, state);
return taxonBase;
}
String hybridFormula1 = ep1String+" "+split[0].trim();
String hybridFormula2 = ep1String+" "+split[1].trim();
//check if the specific epithets are from the same genus or not like e.g. EPI2 = pratensis × Lolium multiflorum
- if(split[1].split(" ").length>1){
+ String[] secondHybrid = split[1].trim().split(" ");
+ if(secondHybrid.length>1 && secondHybrid[0].matches("[A-Z].*")){
hybridFormula2 = split[1];
}
if(CdmUtils.isNotBlank(ep3String)){
private void checkNameConsistency(long id, String nomZusatzString, String taxZusatzString,
String zusatzString, String authorString, String hybString, NonViralName<?> name) {
String authorshipCache = name.getAuthorshipCache();
- if(hybString.equals(RedListUtil.HYB_XF)){
+ //FIXME: remove split length check when name parser can parse multiple hybrid parents
+ if(hybString.equals(RedListUtil.HYB_XF) && name.getTitleCache().split(RedListUtil.HYB_SIGN).length==2){
if(name.getHybridChildRelations().isEmpty()){
RedListUtil.logMessage(id, "Hybrid formula but no hybrid child relations: "+name.getTitleCache(), logger);
return;
}
}
- private void checkTaxonConsistency(long id, String taxNameString, String hybString, TaxonBase<?> taxonBase) {
+ private void checkTaxonConsistency(long id, String taxNameString, String hybString, TaxonBase<?> taxonBase, RedListGefaesspflanzenImportState state) {
String nameCache = HibernateProxyHelper.deproxy(taxonBase.getName(), NonViralName.class).getNameCache().trim();
taxNameString = taxNameString.trim();
taxNameString = taxNameString.replaceAll(" +", " ");
}
taxNameString = taxNameString.replace("[ranglos]", "[unranked]");
- if(taxonBase.getName().getRank()!=null && taxonBase.getName().getRank().equals(Rank.PROLES())){
- taxNameString = taxNameString.replace("proles", "prol.");
+ if(taxonBase.getName().getRank()!=null){
+ if(taxonBase.getName().getRank().equals(Rank.PROLES())){
+ taxNameString = taxNameString.replace("proles", "prol.");
+ }
+ else if(taxonBase.getName().getRank().equals(state.getRank(RedListUtil.uuidRankCollectionSpecies))){
+ taxNameString = taxNameString.replace("\"Sammelart\"", "\"Coll. Species\"");
+ }
}
if(STRICT_TITLE_CHECK){
if(!taxNameString.trim().equals(nameCache)){
return Rank.UNRANKED_INFRAGENERIC();
}
}
+ else if(rankStr.equals("SAM")){
+ return getRank(state, RedListUtil.uuidRankCollectionSpecies, "Collective Species", "Collective Species", "\"Coll. Species\"", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.SpeciesGroup);
+ }
else{
rank = state.getTransformer().getRankByKey(rankStr);
}