Project

General

Profile

Revision 59d588d3

ID59d588d3618128a6980f1d9bbf10e840f23e049c
Parent 91f5b910
Child 4b241d73

Added by Andreas Müller 11 months ago

fix #7769 implement postulated parental species as extension

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java
30 30
import org.apache.log4j.Logger;
31 31
import org.springframework.stereotype.Component;
32 32

  
33
import eu.etaxonomy.cdm.common.CdmUtils;
33 34
import eu.etaxonomy.cdm.database.update.DatabaseTypeNotSupportedException;
34 35
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
35 36
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelTaxonImportValidator;
......
109 110

  
110 111
	@Override
111 112
	protected String getRecordQuery(BerlinModelImportConfigurator config) {
112
		String sqlSelect = " SELECT pt.*  ";
113
		String sqlSelect = " SELECT pt.* , n.notes nameNotes";
113 114
		String sqlFrom = " FROM PTaxon pt ";
114 115
		if (config.isEuroMed()){
115
			sqlFrom = " FROM PTaxon AS pt " +
116
							" INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier ";
116
			sqlFrom = " FROM PTaxon AS pt "
117
			                + " INNER JOIN v_cdm_exp_taxaAll AS em ON pt.RIdentifier = em.RIdentifier "
118
							+ " LEFT OUTER JOIN Name n ON pt.PTNameFk = n.nameId ";
117 119
			if (!config.isUseLastScrutinyAsSec()){
118 120
			    sqlFrom += " LEFT OUTER JOIN Reference r ON pt.LastScrutinyFk = r.RefId ";
119 121
			}
......
319 321

  
320 322
					//Notes
321 323
					boolean excludeNotes = state.getConfig().isTaxonNoteAsFeature() && taxonBase.isInstanceOf(Taxon.class);
322
					doIdCreatedUpdatedNotes(state, taxonBase, rs, taxonId, NAMESPACE, false, excludeNotes);
323
					if (excludeNotes){
324
					String notes = rs.getString("Notes");
325
					if (state.getConfig().isEuroMed()){
326
					    if (isNotBlank(notes) && notes.startsWith("non ")){
327
					        taxonBase.setAppendedPhrase(CdmUtils.concat("; ", taxonBase.getAppendedPhrase(), notes));
328
					        notes = null;
329
					    }
330
					    String nameNotes = rs.getString("nameNotes");
331
					    nameNotes = BerlinModelTaxonNameImport.filterNotes(nameNotes, 900000000 + taxonId);
332
					    if (BerlinModelTaxonNameImport.isPostulatedParentalSpeciesNote(nameNotes)){
333
					        nameNotes = nameNotes.replace("{", "").replace("}", "");
334
					        String text = "For intermediate, so-called \"collective\" species in the genus Pilosella, a combination of the postulated parental basic species is given.";
335
					        UUID parSpecUuid = BerlinModelTransformer.PARENTAL_SPECIES_EXT_UUID;
336
					        ExtensionType parentalSpeciesExtType = getExtensionType(state, parSpecUuid, " Postulated parental species", text, "par. spec.");
337
					        Extension.NewInstance(taxonBase, nameNotes, parentalSpeciesExtType);
338
					    }
339
					}
340

  
341
					doIdCreatedUpdatedNotes(state, taxonBase, rs, taxonId, NAMESPACE, false, excludeNotes || notes == null);
342
					if (excludeNotes && notes != null){
324 343
					    makeTaxonomicNote(state, CdmBase.deproxy(taxonBase, Taxon.class), rs.getString("Notes"));
325 344
					}
326 345

  
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonNameImport.java
338 338
    private void handleNameNotes(BerlinModelImportState state, TaxonName taxonName, ResultSet rs, int nameId) throws SQLException {
339 339
        String notesOrig = rs.getString("notes");
340 340
        String notes = filterNotes(notesOrig, nameId);
341
        if (isNotBlank(notes) && taxonName != null ){
341
        boolean isParentalSpecies = state.getConfig().isEuroMed() && isPostulatedParentalSpeciesNote(notes);
342
        if (isNotBlank(notes) && taxonName != null && !isParentalSpecies ){
342 343
            String notesString = String.valueOf(notes);
343 344
            if (notesString.length() > 65530 ){
344 345
                notesString = notesString.substring(0, 65530) + "...";
......
356 357
    /**
357 358
     * @param notes
358 359
     */
359
    private String filterNotes(String notes, int nameId) {
360
    protected static String filterNotes(String notes, int nameId) {
360 361
        String result;
361 362
        if (isBlank(notes)){
362 363
            result = null;
......
393 394
    }
394 395

  
395 396

  
397
    /**
398
     * @param nameNotes
399
     * @return
400
     */
401
    protected static boolean isPostulatedParentalSpeciesNote(String nameNotes) {
402
        if (nameNotes == null){
403
            return false;
404
        }else{
405
            return nameNotes.matches(".*<>.*");
406
        }
407
    }
408

  
409

  
396 410
    private Rank handleProlesAndRaceSublusus(BerlinModelImportState state, ResultSet rs, Rank rank) throws SQLException {
397 411
		Rank result;
398 412
		String rankAbbrev = rs.getString("RankAbbrev");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)