import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
-import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
import eu.etaxonomy.cdm.model.common.Annotation;
import eu.etaxonomy.cdm.model.common.AnnotationType;
import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.ExtensionType;
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.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
/**
private static final boolean STRICT_TITLE_CHECK = false;
+ private ExtensionType extensionTypeFlor;
+
+ private ExtensionType extensionTypeAtlasIdx;
+
+ private ExtensionType extensionTypeKart;
+
+ private ExtensionType extensionTypeRl2015;
+
+ private ExtensionType extensionTypeEhrd;
+
+ private ExtensionType extensionTypeWissk;
+
public RedListGefaesspflanzenImportNames() {
super(tableName, pluralString);
}
@Override
protected void doInvoke(RedListGefaesspflanzenImportState state) {
+ makeExtensionTypes();
super.doInvoke(state);
}
+ private void makeExtensionTypes() {
+ extensionTypeFlor = ExtensionType.NewInstance(RedListUtil.FLOR, RedListUtil.FLOR, "");
+ extensionTypeAtlasIdx = ExtensionType.NewInstance(RedListUtil.ATLAS_IDX, RedListUtil.ATLAS_IDX, "");
+ extensionTypeKart = ExtensionType.NewInstance(RedListUtil.KART, RedListUtil.KART, "");
+ extensionTypeRl2015 = ExtensionType.NewInstance(RedListUtil.RL2015, RedListUtil.RL2015, "");
+ extensionTypeEhrd = ExtensionType.NewInstance(RedListUtil.EHRD, RedListUtil.EHRD, "");
+ extensionTypeWissk = ExtensionType.NewInstance(RedListUtil.WISSK, RedListUtil.WISSK, "");
+ getTermService().saveOrUpdate(extensionTypeFlor);
+ getTermService().saveOrUpdate(extensionTypeAtlasIdx);
+ getTermService().saveOrUpdate(extensionTypeKart);
+ getTermService().saveOrUpdate(extensionTypeRl2015);
+ getTermService().saveOrUpdate(extensionTypeEhrd);
+ getTermService().saveOrUpdate(extensionTypeWissk);
+ }
+
@Override
public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) {
ResultSet rs = partitioner.getResultSet();
private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave)
throws SQLException {
long id = rs.getLong(RedListUtil.NAMNR);
- String clTaxonString = rs.getString(RedListUtil.CL_TAXON);
String relationE = rs.getString(RedListUtil.E);
String relationW = rs.getString(RedListUtil.W);
String relationK = rs.getString(RedListUtil.K);
//---TAXON---
TaxonBase<?> taxonBase = importTaxon(rs, name, state);
if(taxonBase==null){
- RedListUtil.logMessage(id, "Taxon for name "+name+" could not be created.", logger);
+ RedListUtil.logMessage(id, "!SERIOUS ERROR! Taxon for name "+name+" could not be created!", logger);
return;
}
cloneTaxon(taxonBase, relationR, RedListUtil.CLASSIFICATION_NAMESPACE_R, taxaToSave, id, state);
cloneTaxon(taxonBase, relationO, RedListUtil.CLASSIFICATION_NAMESPACE_O, taxaToSave, id, state);
cloneTaxon(taxonBase, relationS, RedListUtil.CLASSIFICATION_NAMESPACE_S, taxaToSave, id, state);
- //checklist
- TaxonBase<?> checklistTaxon = null;
- if(CdmUtils.isNotBlank(clTaxonString) && !clTaxonString.trim().equals("-")){
- checklistTaxon = (TaxonBase<?>) taxonBase.clone();
- if(checklistTaxon.isInstanceOf(Taxon.class)){
- TaxonRelationship relation = HibernateProxyHelper.deproxy(checklistTaxon, Taxon.class).addTaxonRelation(HibernateProxyHelper.deproxy(taxonBase, Taxon.class), TaxonRelationshipType.CONGRUENT_TO(), null, null);
- relation.setDoubtful(true);
- }
-
- ImportHelper.setOriginalSource(checklistTaxon, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_CHECKLISTE_NAMESPACE);
- taxaToSave.add(checklistTaxon);
- }
//NOTE: the source has to be added after cloning or otherwise the clone would also get the source
ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, RedListUtil.TAXON_GESAMTLISTE_NAMESPACE);
taxonBase = Synonym.NewInstance(name, null);
}
else{
+ RedListUtil.logMessage(id, "Taxon was not created!! Unknown value for "+RedListUtil.GUELT+"!", logger);
return null;
}
}
//add annotations
- addAnnotation(RedListUtil.FLOR+": "+florString, taxonBase);
- addAnnotation(RedListUtil.ATLAS_IDX+": "+atlasIdxString, taxonBase);
- addAnnotation(RedListUtil.KART+": "+kartString, taxonBase);
- addAnnotation(RedListUtil.RL2015+": "+rl2015String, taxonBase);
- addAnnotation(RedListUtil.EHRD+": "+ehrdString, taxonBase);
- addAnnotation(RedListUtil.WISSK+": "+wisskString, taxonBase);
+ taxonBase.addExtension(florString, extensionTypeFlor);
+ taxonBase.addExtension(atlasIdxString, extensionTypeAtlasIdx);
+ taxonBase.addExtension(kartString, extensionTypeKart);
+ taxonBase.addExtension(rl2015String, extensionTypeRl2015);
+ taxonBase.addExtension(ehrdString, extensionTypeEhrd);
+ taxonBase.addExtension(wisskString, extensionTypeWissk);
//check taxon name consistency
checkTaxonConsistency(id, taxNameString, hybString, epi1String, epi2String, epi3String, taxonBase, state);
return taxonBase;
}
- private void addAnnotation(String string, AnnotatableEntity entity) {
- if(CdmUtils.isNotBlank(string)){
- entity.addAnnotation(Annotation.NewInstance(string, AnnotationType.TECHNICAL(), Language.GERMAN()));
- }
- }
-
private void importAuthors(RedListGefaesspflanzenImportState state, ResultSet rs, NonViralName<?> name) throws SQLException {
long id = rs.getLong(RedListUtil.NAMNR);
taxNameString = taxNameString.replaceAll(" +", " ");
- if(hybString.equals(RedListUtil.HYB_X) || hybString.equals(RedListUtil.HYB_N)){
+ if((hybString.equals(RedListUtil.HYB_X) || hybString.equals(RedListUtil.HYB_N))
+ && nameCache.matches(".*\\s"+RedListUtil.HYB_SIGN+"\\w.*")){
taxNameString = taxNameString.replace(" "+RedListUtil.HYB_SIGN+" ", " "+RedListUtil.HYB_SIGN);//hybrid sign has no space after it in titleCache for binomial hybrids
taxNameString = taxNameString.replace(" x ", " "+RedListUtil.HYB_SIGN);//in some cases a standard 'x' is used
}
else if(rankStr.equals("KMB")){
return getRank(state, RedListUtil.uuidRankCombination, "Combination", "Combination", "", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.Infraspecific);
}
+ else if(rankStr.equals("'FO")){
+ return getRank(state, RedListUtil.uuidRankForme, "Forme'", "Forme'", "", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.Infraspecific);
+ }
else{
rank = state.getTransformer().getRankByKey(rankStr);
}