Project

General

Profile

« Previous | Next » 

Revision 8f402cc0

Added by Andreas Müller over 4 years ago

ref #1444, ref #2871, ref #7976 improve authorship handling for MAN

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java
44 44
import eu.etaxonomy.cdm.model.common.ExtensionType;
45 45
import eu.etaxonomy.cdm.model.common.Language;
46 46
import eu.etaxonomy.cdm.model.common.MarkerType;
47
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
47 48
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
48 49
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
49 50
import eu.etaxonomy.cdm.model.name.Rank;
......
53 54
import eu.etaxonomy.cdm.model.taxon.Synonym;
54 55
import eu.etaxonomy.cdm.model.taxon.Taxon;
55 56
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
57
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
56 58
import eu.etaxonomy.cdm.strategy.cache.name.TaxonNameDefaultCacheStrategy;
57 59

  
58 60
/**
......
130 132
            MarkerType hasNoLastActionMarkerType = getMarkerType(DbLastActionMapper.uuidMarkerTypeHasNoLastAction, "has no last action", "No last action information available", "no last action");
131 133
            mapping.addMapper(DbImportAnnotationMapper.NewInstance("lastAction", lastActionType, hasNoLastActionMarkerType));
132 134

  
135
            //MAN authorshipCache => appendedPhrase
136
            mapping.addMapper(DbImportMethodMapper.NewDefaultInstance(this, "appendedPhraseForMisapplications", ErmsImportState.class));
137

  
133 138
            //titleCache compare
134 139
            mapping.addMapper(DbImportMethodMapper.NewDefaultInstance(this, "testTitleCache", ErmsImportState.class));
135 140

  
......
351 356
    }
352 357

  
353 358
    @SuppressWarnings("unused")  //used by MethodMapper
354
    private static TaxonBase<?> testTitleCache(ResultSet rs, ErmsImportState state) throws SQLException{
359
    private static TaxonBase<?> appendedPhraseForMisapplications(ResultSet rs, ErmsImportState state) throws SQLException{
355 360
        TaxonBase<?> taxon = (TaxonBase<?>)state.getRelatedObject(DbImportStateBase.CURRENT_OBJECT_NAMESPACE, DbImportStateBase.CURRENT_OBJECT_ID);
356 361
        TaxonName taxonName = taxon.getName();
357
         String displayName = rs.getString("tu_displayname");
358
         displayName = displayName == null ? null : displayName.trim();
359
         String titleCache = taxonName.resetTitleCache(); //calling titleCache should always be kept to have a computed titleCache in the CDM DB.
360
         String expectedTitleCache = getExpectedTitleCache(rs);
361
         //TODO check titleCache, but beware of autonyms
362
         if (!titleCache.equals(expectedTitleCache)){
363
             int pos = CdmUtils.diffIndex(titleCache, expectedTitleCache);
364
             logger.warn("Computed title cache differs at "+pos+".\n Computed             : " + titleCache + "\n DisplayName+Authority: " + expectedTitleCache);
365
             taxonName.setNameCache(displayName, true);
362
         String unacceptreason = rs.getString("tu_unacceptreason");
363
         RelationshipTermBase<?>[] rels = state.getTransformer().getSynonymRelationTypesByKey(unacceptreason, state);
364
         if (rels[1]!= null && rels[1].equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
365
             taxon.setAppendedPhrase(taxonName.getAuthorshipCache());
366
             taxon.setSec(null);
367
             taxonName.setAuthorshipCache(null, taxonName.isProtectedAuthorshipCache());
368
             //TODO maybe some further authorship handling is needed if authors get parsed, but not very likely for MAN authorship
366 369
         }
367 370
         return taxon;
368 371
     }
369 372

  
370
     //see also PesiErmsValidation.srcFullName()
371
     private static String getExpectedTitleCache(ResultSet srcRs) throws SQLException {
373
    @SuppressWarnings("unused")  //used by MethodMapper
374
    private static TaxonBase<?> testTitleCache(ResultSet rs, ErmsImportState state) throws SQLException{
375
        TaxonBase<?> taxon = (TaxonBase<?>)state.getRelatedObject(DbImportStateBase.CURRENT_OBJECT_NAMESPACE, DbImportStateBase.CURRENT_OBJECT_ID);
376
        TaxonName taxonName = taxon.getName();
377
        String displayName = rs.getString("tu_displayname");
378
        displayName = displayName == null ? null : displayName.trim();
379
        String titleCache = taxonName.resetTitleCache(); //calling titleCache should always be kept to have a computed titleCache in the CDM DB.
380
        String expectedTitleCache = getExpectedTitleCache(rs);
381
        //TODO check titleCache, but beware of autonyms
382
        if (!titleCache.equals(expectedTitleCache)){
383
            int pos = CdmUtils.diffIndex(titleCache, expectedTitleCache);
384
            logger.warn("Computed title cache differs at "+pos+".\n Computed             : " + titleCache + "\n DisplayName+Authority: " + expectedTitleCache);
385
            taxonName.setNameCache(displayName, true);
386
        }
387
        return taxon;
388
    }
389

  
390
    //see also PesiErmsValidation.srcFullName()
391
    private static String getExpectedTitleCache(ResultSet srcRs) throws SQLException {
372 392
        String result;
373 393
        String epi = srcRs.getString("tu_name");
374 394
        epi = " a" + epi;
......
382 402
        return result.trim();
383 403
    }
384 404

  
385
	private void handleNotAcceptedTaxon(Taxon taxon, int statusId, ErmsImportState state, ResultSet rs) throws SQLException {
405
    private void handleNotAcceptedTaxon(Taxon taxon, int statusId, ErmsImportState state, ResultSet rs) throws SQLException {
386 406
		ExtensionType notAccExtensionType = getExtensionType(state, ErmsTransformer.uuidErmsTaxonStatus, "ERMS taxon status", "ERMS taxon status", "status", null);
387 407
		String statusName = rs.getString("status_name");
388 408

  

Also available in: Unified diff