Project

General

Profile

Revision 1d5daa79

ID1d5daa794c2002ff487d9f0b5a3925eb9e8f49e3
Parent 48003e9f
Child 933eee97

Added by Patrick Plitzner about 4 years ago

#5448 Import rank "SAM"

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
34 34
import eu.etaxonomy.cdm.model.common.AnnotationType;
35 35
import eu.etaxonomy.cdm.model.common.CdmBase;
36 36
import eu.etaxonomy.cdm.model.common.Language;
37
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
37 38
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
38 39
import eu.etaxonomy.cdm.model.description.TaxonDescription;
39 40
import eu.etaxonomy.cdm.model.name.BotanicalName;
......
43 44
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
44 45
import eu.etaxonomy.cdm.model.name.NonViralName;
45 46
import eu.etaxonomy.cdm.model.name.Rank;
47
import eu.etaxonomy.cdm.model.name.RankClass;
46 48
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
47 49
import eu.etaxonomy.cdm.model.taxon.Synonym;
48 50
import eu.etaxonomy.cdm.model.taxon.Taxon;
......
136 138
        importAuthors(state, rs, name);
137 139

  
138 140
        //---TAXON---
139
        TaxonBase<?> taxonBase = importTaxon(rs, name);
141
        TaxonBase<?> taxonBase = importTaxon(rs, name, state);
140 142
        if(taxonBase==null){
141 143
            RedListUtil.logMessage(id, "Taxon for name "+name+" could not be created.", logger);
142 144
            return;
......
189 191
        }
190 192
    }
191 193

  
192
    private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name) throws SQLException {
194
    private TaxonBase<?> importTaxon(ResultSet rs, NonViralName<?> name, RedListGefaesspflanzenImportState state) throws SQLException {
193 195

  
194 196
        long id = rs.getLong(RedListUtil.NAMNR);
195 197
        String taxNameString = rs.getString(RedListUtil.TAXNAME);
......
235 237
        addAnnotation(RedListUtil.WISSK+": "+wisskString, taxonBase);
236 238

  
237 239
        //check taxon name consistency
238
        checkTaxonConsistency(id, taxNameString, hybString, taxonBase);
240
        checkTaxonConsistency(id, taxNameString, hybString, taxonBase, state);
239 241
        return taxonBase;
240 242
    }
241 243

  
......
500 502
        }
501 503
    }
502 504

  
503
    private void checkTaxonConsistency(long id, String taxNameString, String hybString, TaxonBase<?> taxonBase) {
505
    private void checkTaxonConsistency(long id, String taxNameString, String hybString, TaxonBase<?> taxonBase, RedListGefaesspflanzenImportState state) {
504 506
        String nameCache = HibernateProxyHelper.deproxy(taxonBase.getName(), NonViralName.class).getNameCache().trim();
505 507
        taxNameString = taxNameString.trim();
506 508
        taxNameString = taxNameString.replaceAll(" +", " ");
......
528 530
        }
529 531

  
530 532
        taxNameString = taxNameString.replace("[ranglos]", "[unranked]");
531
        if(taxonBase.getName().getRank()!=null && taxonBase.getName().getRank().equals(Rank.PROLES())){
532
            taxNameString = taxNameString.replace("proles", "prol.");
533
        if(taxonBase.getName().getRank()!=null){
534
            if(taxonBase.getName().getRank().equals(Rank.PROLES())){
535
                taxNameString = taxNameString.replace("proles", "prol.");
536
            }
537
            else if(taxonBase.getName().getRank().equals(state.getRank(RedListUtil.uuidRankCollectionSpecies))){
538
                taxNameString = taxNameString.replace("\"Sammelart\"", "\"Coll. Species\"");
539
            }
533 540
        }
534 541
        if(STRICT_TITLE_CHECK){
535 542
            if(!taxNameString.trim().equals(nameCache)){
......
555 562
                    return Rank.UNRANKED_INFRAGENERIC();
556 563
                }
557 564
            }
565
            else if(rankStr.equals("SAM")){
566
                return getRank(state, RedListUtil.uuidRankCollectionSpecies, "Collective Species", "Collective Species", "\"Coll. Species\"", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.SpeciesGroup);
567
            }
558 568
            else{
559 569
                rank = state.getTransformer().getRankByKey(rankStr);
560 570
            }
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenTransformer.java
10 10

  
11 11
package eu.etaxonomy.cdm.io.redlist.gefaesspflanzen;
12 12

  
13
import java.util.UUID;
14

  
13 15
import org.apache.log4j.Logger;
14 16

  
15 17
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
......
31 33
	private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenTransformer.class);
32 34

  
33 35
    @Override
36
    public UUID getRankUuid(String key) throws UndefinedTransformerMethodException {
37
        if (key == null){return null;}
38
        if (key.equals("SAM")){return RedListUtil.uuidRankCollectionSpecies;}
39
        return null;
40
    }
41

  
42
    @Override
34 43
    public Rank getRankByKey(String key) throws UndefinedTransformerMethodException {
35 44
        if (key == null){return null;}
36 45
        if (key.equals("GAT")){return Rank.GENUS();}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java
45 45
    public static final UUID uuidClassificationO = UUID.fromString("e19bb2e6-d898-4793-8cd4-d866eeb1f872");
46 46
    public static final UUID uuidClassificationS = UUID.fromString("53e81162-5c2d-425b-bbe6-6e8d12e85790");
47 47

  
48
    public static final UUID uuidRankCollectionSpecies = UUID.fromString("6056e143-4efe-4632-b532-27699ed62884");
49

  
48 50
    public static final String NAME_NAMESPACE = "name";
49 51
    public static final String AUTHOR_NAMESPACE = "author";
50 52
    public static final String TAXON_GESAMTLISTE_NAMESPACE = "taxon_gesamt_liste";

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)