Project

General

Profile

Revision e1d0f581

IDe1d0f581d760e31388cd27d083536f5e5844b505
Parent 4133992a
Child d19ddd46

Added by Andreas Müller 12 months ago

ref #3992, ref #7713, ref #3990 Atomize last scrutiny references

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelImportConfigurator.java
66 66
	private boolean useSingleClassification = false;
67 67
	private boolean includeFlatClassifications = false;  //concepts with no taxon relationship (even no misapplied name or synonym rel)
68 68
	private boolean includeAllNonMisappliedRelatedClassifications = true;  //all concepts with any relationship except for misapplied name relationships
69
	private boolean useLastScrutinyAsSec = false;
70

  
71
	private boolean warnForDifferingSynonymReference = true;   //do not warn for E+M as it uses last scrutiny
69 72

  
70 73
	//occurrences
71 74
	private boolean isSplitTdwgCodes = true;
......
661 664
        this.featureTreeTitle = featureTreeTitle;
662 665
    }
663 666

  
667
    public boolean isUseLastScrutinyAsSec() {
668
        return useLastScrutinyAsSec;
669
    }
670
    public void setUseLastScrutinyAsSec(boolean useLastScrutinyAsSec) {
671
        this.useLastScrutinyAsSec = useLastScrutinyAsSec;
672
    }
664 673

  
665

  
674
    public boolean isWarnForDifferingSynonymReference() {
675
        return warnForDifferingSynonymReference;
676
    }
677
    public void setWarnForDifferingSynonymReference(boolean warnForDifferingSynonymReference) {
678
        this.warnForDifferingSynonymReference = warnForDifferingSynonymReference;
679
    }
666 680

  
667 681
}
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelReferenceImport.java
310 310
					if ((i++ % modCount) == 0 && i!= 1 ){ logger.info("References handled: " + (i-1) + " in round -" );}
311 311

  
312 312
					Integer refId = rs.getInt("refId");
313
					Integer inRefFk = rs.getInt("inRefFk");
313
					Integer inRefFk = nullSafeInt(rs, "inRefFk");
314 314

  
315 315
					if (inRefFk != null){
316 316

  
......
324 324
							}
325 325
							thisRef.setInReference(inRef);
326 326
							refToSave.put(refId, thisRef);
327
							thisRef.setTitleCache(null);
328
							thisRef.getTitleCache();
327
							if(!thisRef.isProtectedTitleCache()){
328
							    thisRef.setTitleCache(null);
329
							    thisRef.getTitleCache();
330
							}
331
						}
332
						if(inRefFk.equals(0)){
333
						    logger.warn("InRefFk is 0 for refId "+ refId);
329 334
						}
330 335
					}
331 336

  
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java
56 56
 */
57 57
@Component
58 58
public class BerlinModelTaxonImport  extends BerlinModelImportBase {
59
    /**
60
     *
61
     */
62
    private static final String LAST_SCRUTINY_FK = "lastScrutinyFk";
63

  
59 64
    private static final long serialVersionUID = -1186364983750790695L;
60 65

  
61 66
    private static final Logger logger = Logger.getLogger(BerlinModelTaxonImport.class);
......
106 111
		String sqlFrom = " FROM PTaxon pt ";
107 112
		if (config.isEuroMed()){
108 113
			sqlFrom = " FROM PTaxon AS pt " +
109
							" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier " +
110
							" LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId ";
111
			sqlSelect += " , em.MA, r.RefCache as LastScrutiny ";
114
							" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier ";
115
			if (!config.isUseLastScrutinyAsSec()){
116
			    sqlFrom += " LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId ";
117
			}
118
			sqlSelect += " , em.MA ";
119
			if (!config.isUseLastScrutinyAsSec()){
120
			    sqlSelect += ", r.RefCache as LastScrutiny ";
121
            }
112 122
		}
113 123

  
114 124

  
......
156 166
					uuid = rs.getString("UUID");
157 167
				}
158 168

  
169

  
159 170
				TaxonName taxonName = null;
160 171
				taxonName  = taxonNameMap.get(String.valueOf(nameFk));
161 172

  
162 173
				Reference reference = null;
163
				String refFk = String.valueOf(refFkInt);
164
				reference = refMap.get(refFk);
174
				String refFkStr = String.valueOf(refFkInt);
175
				reference = refMap.get(refFkStr);
176

  
177
				Reference lastScrutinyRef = null;
178
                if (state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs,LAST_SCRUTINY_FK)){
179
                    Integer lastScrutinyFk = nullSafeInt(rs,LAST_SCRUTINY_FK);
180
                    if (lastScrutinyFk != null){
181
                        String lastScrutinyFkStr = String.valueOf(lastScrutinyFk);
182
                        if (lastScrutinyFkStr != null){
183
                            lastScrutinyRef = refMap.get(lastScrutinyFkStr);
184
                            if (lastScrutinyRef == null){
185
                                logger.warn("Last scrutiny reference "+lastScrutinyFkStr+" could not be found "
186
                                        + "for taxon " + taxonId);
187
                            }
188
                            if(!StringUtils.right(refFkStr, 5).equals("00000")){
189
                                logger.warn("Unexpected secFk " + refFkStr + " for taxon with last scrutiny. Taxon id " + taxonId);
190
                            }
191
                        }
192
                    }
193
                }
165 194

  
166 195
				if(! config.isIgnoreNull()){
167 196
					if (taxonName == null ){
......
169 198
						success = false;
170 199
						continue; //next taxon
171 200
					}else if (reference == null ){
172
						logger.warn("Reference belonging to taxon could not be found in store. Taxon will not be imported");
201
						logger.warn("Sec Reference belonging to taxon could not be found in store. Taxon will not be imported");
173 202
						success = false;
174 203
						continue; //next taxon
175 204
					}
......
177 206
				TaxonBase<?> taxonBase;
178 207
				Synonym synonym;
179 208
				Taxon taxon;
209
				Reference sec = lastScrutinyRef != null? lastScrutinyRef: reference;
180 210
				try {
181 211
					logger.debug(statusFk);
182 212
					if (statusFk == T_STATUS_ACCEPTED || statusFk == T_STATUS_UNRESOLVED
183 213
					        || statusFk == T_STATUS_PRO_PARTE_SYN || statusFk == T_STATUS_PARTIAL_SYN ){
184
						taxon = Taxon.NewInstance(taxonName, reference);
214
						taxon = Taxon.NewInstance(taxonName, sec);
185 215
						taxonBase = taxon;
186 216
						if (statusFk == T_STATUS_UNRESOLVED){
187 217
							taxon.setTaxonStatusUnknown(true);
188 218
						}
189 219
						//TODO marker for pp and partial?
190 220
					}else if (statusFk == T_STATUS_SYNONYM ){
191
						synonym = Synonym.NewInstance(taxonName, reference);
221
						synonym = Synonym.NewInstance(taxonName, sec);
192 222
						taxonBase = synonym;
193 223
//						if (statusFk == T_STATUS_PRO_PARTE_SYN){
194 224
//						    synonym.setProParte(true);
......
250 280
						}
251 281
					}
252 282

  
253
					//
254
					if (resultSetHasColumn(rs, "LastScrutiny")){
283
					//  does not exist anymore as we use last scrutiny now as sec ref
284
					if (!state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs, "LastScrutiny")){
255 285
						String lastScrutiny = rs.getString("LastScrutiny");
256 286
						//TODO strange, why not Extension last scrutiny? To match PESI? Is there a difference
257 287
						//to LastScrutinyFK and SpeciesExpertFK?
......
345 375
			while (rs.next()){
346 376
				handleForeignKey(rs, nameIdSet, "PTNameFk");
347 377
				handleForeignKey(rs, referenceIdSet, "PTRefFk");
378
				if (state.getConfig().isUseLastScrutinyAsSec() && resultSetHasColumn(rs, LAST_SCRUTINY_FK)){
379
				    handleForeignKey(rs, referenceIdSet, LAST_SCRUTINY_FK);
380
				}
348 381
			}
349 382

  
350 383
			//name map
......
382 415
		return ! state.getConfig().isDoTaxa();
383 416
	}
384 417

  
385

  
386

  
387 418
}
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java
320 320
							    logger.warn("RelID: " + relPTaxonId + ". Synonym ("+taxon1Id +") already has an accepted taxon. Create clone.");
321 321
							    synonym = (Synonym)synonym.clone();
322 322
							}
323
							makeSynRel(relQualifierFk, toTaxon, synonym, citation, microcitation);
323
							makeSynRel(state, relQualifierFk, toTaxon, synonym, citation, microcitation);
324 324

  
325 325
							if (relQualifierFk == TAX_REL_IS_SYNONYM_OF ||
326 326
									relQualifierFk == TAX_REL_IS_HOMOTYPIC_SYNONYM_OF ||
......
572 572
	}
573 573

  
574 574

  
575
	private void makeSynRel (int relQualifierFk, Taxon toTaxon, Synonym synonym, Reference citation, String microcitation){
576
		if (citation != null && !citation.equals(synonym.getSec())){
575
	private void makeSynRel (BerlinModelImportState state, int relQualifierFk, Taxon toTaxon, Synonym synonym, Reference citation, String microcitation){
576
		if (state.getConfig().isWarnForDifferingSynonymReference() && citation != null && !citation.equals(synonym.getSec())){
577 577
		    logger.warn("A synonym relationship citation is given and differs from synonym secundum. This can not be handled in CDM");
578 578
		}
579 579
		if (isNotBlank(microcitation)  && !microcitation.equals(synonym.getSecMicroReference())){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)