Project

General

Profile

Revision ad6b62ca

IDad6b62ca819ea76abe2c010bf6bc0251842487df
Parent b2ce7834
Child 100e8ed6

Added by Patrick Plitzner over 5 years ago

Fix ClassCastException, improve taxon name check, fix rank evaluation
#5448

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
91 91
    @Override
92 92
    public boolean doPartition(ResultSetPartitioner partitioner, RedListGefaesspflanzenImportState state) {
93 93
        ResultSet rs = partitioner.getResultSet();
94
        Set<TaxonNameBase<?,?>> namesToSave = new HashSet<TaxonNameBase<?,?>>();
95
        Set<TaxonBase<?>> taxaToSave = new HashSet<TaxonBase<?>>();
94
        Set<TaxonNameBase> namesToSave = new HashSet<TaxonNameBase>();
95
        Set<TaxonBase> taxaToSave = new HashSet<TaxonBase>();
96 96
        try {
97 97
            while (rs.next()){
98 98
                makeSingleNameAndTaxon(state, rs, namesToSave, taxaToSave);
......
102 102
            e.printStackTrace();
103 103
        }
104 104

  
105
        getNameService().saveOrUpdate((TaxonNameBase) namesToSave);
106
        getTaxonService().saveOrUpdate((TaxonBase) taxaToSave);
105
        getNameService().saveOrUpdate(namesToSave);
106
        getTaxonService().saveOrUpdate(taxaToSave);
107 107
        return true;
108 108
    }
109 109

  
110
    private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase<?,?>> namesToSave, Set<TaxonBase<?>> taxaToSave)
110
    private void makeSingleNameAndTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave, Set<TaxonBase> taxaToSave)
111 111
            throws SQLException {
112 112
        long id = rs.getLong(RedListUtil.NAMNR);
113 113
        String clTaxonString = rs.getString(RedListUtil.CL_TAXON);
......
139 139
        TaxonBase<?> checklistTaxon = null;
140 140
        if(CdmUtils.isNotBlank(clTaxonString) && !clTaxonString.trim().equals("-")){
141 141
            checklistTaxon = (TaxonBase<?>) taxonBase.clone();
142
            //TODO what to do with synonyms?
143 142
            if(checklistTaxon.isInstanceOf(Taxon.class)){
144 143
                TaxonRelationship relation = HibernateProxyHelper.deproxy(checklistTaxon, Taxon.class).addTaxonRelation(HibernateProxyHelper.deproxy(taxonBase, Taxon.class), TaxonRelationshipType.CONGRUENT_TO(), null, null);
145 144
                relation.setDoubtful(true);
......
163 162
        taxaToSave.add(taxonBase);
164 163
    }
165 164

  
166
    private void addConceptRelation(String relationString, String classificationNamespace, TaxonBase<?> gesamtListeTaxon, TaxonBase<?> checkListenTaxon, Set<TaxonBase<?>> taxaToSave, long id, RedListGefaesspflanzenImportState state){
165
    private void addConceptRelation(String relationString, String classificationNamespace, TaxonBase<?> gesamtListeTaxon, TaxonBase<?> checkListenTaxon, Set<TaxonBase> taxaToSave, long id, RedListGefaesspflanzenImportState state){
167 166
        if(CdmUtils.isNotBlank(relationString) && !relationString.equals(".")){
168 167
            String substring = relationString.substring(relationString.length()-1, relationString.length());
169 168
            TaxonRelationshipType taxonRelationshipTypeByKey = new RedListGefaesspflanzenTransformer().getTaxonRelationshipTypeByKey(substring);
......
189 188
     * This can be changed with parameter <i>reverseRelation</i>
190 189
     * @return cloned taxon
191 190
     */
192
    private Taxon cloneTaxon(final TaxonBase<?> gesamtListeTaxon, final TaxonBase<?> checklisteTaxon, TaxonRelationshipType relationFromCloneToTaxon, Set<TaxonBase<?>> taxaToSave, long id, String sourceNameSpace, boolean reverseRelation, boolean doubtful, RedListGefaesspflanzenImportState state){
191
    private Taxon cloneTaxon(final TaxonBase<?> gesamtListeTaxon, final TaxonBase<?> checklisteTaxon, TaxonRelationshipType relationFromCloneToTaxon, Set<TaxonBase> taxaToSave, long id, String sourceNameSpace, boolean reverseRelation, boolean doubtful, RedListGefaesspflanzenImportState state){
193 192
        Taxon acceptedGesamtListeTaxon = getAcceptedTaxon(gesamtListeTaxon);
194 193
        Taxon acceptedChecklistTaxon = getAcceptedTaxon(checklisteTaxon);
195 194
        Taxon clonedTaxon = null;
......
346 345
        checkAuthorShipConsistency(id, nomZusatzString, taxZusatzString, zusatzString, authorString, authorshipCache);
347 346
    }
348 347

  
349
    private NonViralName<?> importName(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase<?,?>> namesToSave) throws SQLException {
348
    private NonViralName<?> importName(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonNameBase> namesToSave) throws SQLException {
350 349

  
351 350
        long id = rs.getLong(RedListUtil.NAMNR);
352 351
        String taxNameString = rs.getString(RedListUtil.TAXNAME);
......
370 369
        }
371 370
        name.setGenusOrUninomial(ep1String);
372 371
        if(CdmUtils.isNotBlank(ep2String)){
373
            name.setSpecificEpithet(ep2String);
372
            if(rank!=null && rank.isInfraGeneric()){
373
                name.setInfraGenericEpithet(ep2String);
374
            }
375
            else{
376
                name.setSpecificEpithet(ep2String);
377
            }
374 378
        }
375 379
        if(CdmUtils.isNotBlank(ep3String)){
376 380
            name.setInfraSpecificEpithet(ep3String);
......
480 484
            taxNameString = taxNameString.replace(RedListUtil.HYB_SIGN+" ", RedListUtil.HYB_SIGN);//hybrid sign has no space after it in titleCache for binomial hybrids
481 485
        }
482 486
        if(taxNameString.endsWith("- Gruppe")){
483
            taxNameString.replaceAll("- Gruppe", "species group");
487
            taxNameString = taxNameString.replaceAll("- Gruppe", "species group");
484 488
        }
485 489
        if(taxNameString.endsWith("- group")){
486
            taxNameString.replaceAll("- group", "species group");
490
            taxNameString = taxNameString.replaceAll("- group", "species group");
487 491
        }
488 492
        taxNameString = taxNameString.replace("[ranglos]", "[unranked]");
489 493
        if(!taxNameString.trim().equals(nameCache)){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)