Project

General

Profile

« Previous | Next » 

Revision 67426b79

Added by Andreas Müller over 4 years ago

ref #2717 adapt PesiExport to EuroMed requirements and adapt PesiExportActivatorEM

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiDestinations.java
23 23

  
24 24
	public static Source pesi_test_local_CDM_EM2PESI(){
25 25
		String dbms = Source.SQL_SERVER_2008;
26
		String strServer = "localhost";
26
		String strServer = "pesiimport3";
27 27
		String strDB = "CDM_EM2PESI";
28 28
		int port = 1433;
29
		String userName =  "pesiexport";// "pesiexport3";
29
		String userName =  "pesi2019";// "pesiexport3";
30 30
		return makeSource(dbms, strServer, strDB, port, userName, null);
31 31
	}
32 32

  
33
	public static Source pesi_test_local_CDM_EM2PESI_tmp(){
33
	public static Source pesi_test_local_CDM_EM2PESI_2(){
34 34
		String dbms = Source.SQL_SERVER_2008;
35
		String strServer = "localhost";
36
		String strDB = "CDMTMP_EM2PESI";
35
		String strServer = "pesiimport3";
36
		String strDB = "CDM_EM2PESI_2";
37 37
		int port = 1433;
38
		String userName = "pesiexport";
38
		String userName = "pesi2019";
39 39
		return makeSource(dbms, strServer, strDB, port, userName, null);
40 40
	}
41 41

  
cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/PesiExportActivatorEM.java
19 19
import eu.etaxonomy.cdm.io.common.Source;
20 20
import eu.etaxonomy.cdm.io.pesi.out.PesiExportConfigurator;
21 21
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
22
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
23 22

  
24 23
/**
25 24
 * @author a.mueller
......
30 29
	@SuppressWarnings("unused")
31 30
	private static final Logger logger = Logger.getLogger(PesiExportActivatorEM.class);
32 31

  
33
	static final ICdmDataSource cdmSource = CdmDestinations.test_cdm_pesi_euroMed();
32
//	static final ICdmDataSource cdmSource = CdmDestinations.test_cdm_pesi_euroMed();
33
	static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_mysql_euromed();
34 34

  
35 35
	//database validation status (create, update, validate ...)
36 36
	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_EM2PESI();
37
//	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_FE2PESI();
38
//	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI();
39

  
40
	//Taxon names can't be mapped to their CDM ids as PESI Taxon table mainly holds taxa and there IDs. We ad nameIdStart to the TaxonName id to get a unique id
41
	static final int nameIdStart = 10000000;
42
	static final IdType idType = IdType.CDM_ID_WITH_EXCEPTIONS;
43

  
44
	static final int partitionSize = 1000;
45

  
46
	//check - export
47
	static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
48

  
49
	//NomenclaturalCode
50
	static final NomenclaturalCode nomenclaturalCode  = NomenclaturalCode.ICNAFP;
51

  
52
	static final boolean deleteAll = true;
53

  
37
//	static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_EM2PESI_2();
54 38

  
55 39
// ****************** ALL *****************************************
56 40

  
57
	//references
58
	static final DO_REFERENCES doReferences =  DO_REFERENCES.ALL;
41
	boolean deleteAll = false;
42
	DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
43
	boolean doTaxa = true;
44
	boolean doTaxaPhase1 = true;   //better do not use, Phase1 is needed in Phase3
45
	boolean doPureNames = true;
46
	boolean doTreeIndex = true;
47
	boolean doParentAndBiota = true;
48
	boolean doInferredSynonyms = false;   //no inferred synonyms in E+M
49
	boolean doRelTaxa = true;
50
	boolean doAdditionalTaxonSource = true;
51
    boolean doDescriptions = true;
52
	boolean doEcologyAndLink = true;
59 53

  
60
	//taxa
61
	static final boolean doTaxa = true;
62
	static final boolean doPureNames = true;
63
	static final boolean doTreeIndex = true;
64
	static final boolean doParentAndBiota = true;
65
	static final boolean doRank = true;
66
	static final boolean doInferredSynonyms = false;   //no inferred synonyms in E+M
67
	static final boolean doRelTaxa = true;
68
	static final boolean doDescriptions = true;
54
// ************************ NONE **************************************** //
69 55

  
70
	static final boolean doNotes = true;
71
	static final boolean doNoteSources = true;
72
	static final boolean doAdditionalTaxonSource = true;
73
	static final boolean doOccurrence = true;
74
	static final boolean doOccurrenceSource = true;
75
	static final boolean doImage = true;
56
//    boolean deleteAll = false;
57
//    DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
58
//    boolean doTaxa = false;
59
//    boolean doPureNames = false;
60
//    boolean doTreeIndex = false;
61
//    boolean doParentAndBiota = false;
62
//    boolean doInferredSynonyms = false;   //no inferred synonyms in E+M
63
//    boolean doRelTaxa = false;
64
//    boolean doAdditionalTaxonSource = false;
65
//    boolean doDescriptions = false;
66
//    boolean doEcologyAndLink = false;
76 67

  
77 68

  
78
// ************************ NONE **************************************** //
69
    //check - export
70
    static final CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
79 71

  
80
//	//references
81
//	static final DO_REFERENCES doReferences =  DO_REFERENCES.NONE;
82
//
83
//	//taxa
84
//	static final boolean doTaxa = false;
85
//	static final boolean doPureNames = false;
86
//	static final boolean doRelTaxa = false;
87
//	static final boolean doNotes = false;
88
//	static final boolean doNoteSources = false;
89
//	static final boolean doAdditionalTaxonSource = false;
90
//	static final boolean doOccurrence = false;
91
//	static final boolean doOccurrenceSource = false;
92
//	static final boolean doImage = false;
93
//	static final boolean doTreeIndex = false;
94
//	static final boolean doRank = true;
95
//	static final boolean doInferredSynonyms = true;
72
    //Taxon names can't be mapped to their CDM ids as PESI Taxon table mainly holds taxa and there IDs. We ad nameIdStart to the TaxonName id to get a unique id
73
    static final int nameIdStart = 10000000;
74
    static final IdType idType = IdType.CDM_ID_WITH_EXCEPTIONS;
96 75

  
76
    static final int partitionSize = 1000;
97 77

  
98 78
	public boolean 	doExport(ICdmDataSource source){
99
		System.out.println("Start export to PESI ("+ pesiDestination.getDatabase() + ") ...");
79
	    System.out.println("Start export from " + source.getDatabase() + " to PESI ("+ pesiDestination.getDatabase() + ") ...");
100 80

  
101 81
		//make PESI Source
102 82
		Source destination = pesiDestination;
......
106 86

  
107 87
		config.setDoTaxa(doTaxa);
108 88
		config.setDoPureNames(doPureNames);
89
		config.setDoTaxaPhase1(doTaxaPhase1);
109 90
		config.setDoRelTaxa(doRelTaxa);
110
		config.setDoOccurrence(doOccurrence);
111 91
		config.setDoReferences(doReferences);
112
		config.setDoImages(doImage);
113
		config.setDoNotes(doNotes);
114
		config.setDoNoteSources(doNoteSources);
115
		config.setDoOccurrenceSource(doOccurrenceSource);
116 92
		config.setDoTreeIndex(doTreeIndex);
117
		config.setDoTreeIndex(doParentAndBiota);
93
		config.setDoParentAndBiota(doParentAndBiota);
118 94
		config.setDoInferredSynonyms(doInferredSynonyms);
119 95
		config.setDoDescription(doDescriptions);
96
		config.setDoAdditionalTaxonSource(doAdditionalTaxonSource);
97
		config.setDoEcologyAndLink(doEcologyAndLink);
120 98

  
121 99
		config.setCheck(check);
122 100
		config.setLimitSave(partitionSize);
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java
643 643
    }
644 644

  
645 645
    // return all sources with a PESI reference
646
    private static Set<IdentifiableSource> filterPesiSources(Set<? extends IdentifiableSource> sources) {
646
    protected static Set<IdentifiableSource> filterPesiSources(Set<? extends IdentifiableSource> sources) {
647 647
        Set<IdentifiableSource> result = new HashSet<>();
648 648
        for (IdentifiableSource source : sources){
649 649
            Reference ref = source.getCitation();
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportConfigurator.java
45 45
	private boolean doParentAndBiota = true;
46 46
	private boolean doInferredSynonyms = true;
47 47
	private boolean doPureNames = true;
48
	private boolean doTaxaPhase1 = true;
48 49
	private boolean doDescription = true;
49 50
	private boolean doEcologyAndLink = true;
50 51

  
......
197 198
		this.doPureNames = doPureNames;
198 199
	}
199 200

  
200
	public boolean isDoDescription() {
201
	public boolean isDoTaxaPhase1() {
202
        return doTaxaPhase1;
203
    }
204
    public void setDoTaxaPhase1(boolean doTaxaPhase1) {
205
        this.doTaxaPhase1 = doTaxaPhase1;
206
    }
207

  
208
    public boolean isDoDescription() {
201 209
		return doDescription;
202 210
	}
203 211
	public void setDoDescription(boolean doDescription) {
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiSourceExport.java
11 11
import java.sql.SQLException;
12 12
import java.util.ArrayList;
13 13
import java.util.EnumSet;
14
import java.util.HashSet;
15 14
import java.util.List;
16 15
import java.util.Set;
17 16

  
......
35 34
import eu.etaxonomy.cdm.model.common.ExtensionType;
36 35
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
37 36
import eu.etaxonomy.cdm.model.reference.Reference;
38
import eu.etaxonomy.cdm.model.reference.ReferenceType;
39 37

  
40 38
/**
41 39
 * The export class for {@link eu.etaxonomy.cdm.model.reference.Reference References}.<p>
......
299 297
		String result = null;
300 298

  
301 299
		try {
302
		if (reference != null) {
303
			Set<IdentifiableSource> sourceAll = reference.getSources();
304
			Set<IdentifiableSource> sourceCandidates = filterOriginalPesiDbSources(sourceAll);
305

  
306
			if (sourceCandidates.size() == 1) {
307
				result = sourceCandidates.iterator().next().getIdInSource();
308
			} else if (sourceCandidates.size() > 1) {
309
				logger.warn("Reference for RefIdInSource has multiple IdentifiableSources which are candidates for a PESI originalDbSource. RefIdInSource can't be determined correctly and will be left out: " + reference.getUuid() + " (" + reference.getTitleCache() + ")");
310
				int count = 1;
311
//				for (IdentifiableSource source : sources) {
312
//					result += source.getIdInSource();
313
//					if (count < sources.size()) {
314
//						result += "; ";
315
//					}
316
//					count++;
317
//				}
318
			}
319
		}
300
    		if (reference != null) {
301
    			Set<IdentifiableSource> sourceAll = reference.getSources();
302
    			Set<IdentifiableSource> sourceCandidates = filterPesiSources(sourceAll);
303

  
304
    			if (sourceCandidates.size() == 1) {
305
    				result = sourceCandidates.iterator().next().getIdInSource();
306
    			} else if (sourceCandidates.size() > 1) {
307
    				logger.warn("Reference for RefIdInSource has multiple IdentifiableSources which are candidates for a PESI originalDbSource. RefIdInSource can't be determined correctly and will be left out: " + reference.getUuid() + " (" + reference.getTitleCache() + ")");
308
    				int count = 1;
309
    //				for (IdentifiableSource source : sources) {
310
    //					result += source.getIdInSource();
311
    //					if (count < sources.size()) {
312
    //						result += "; ";
313
    //					}
314
    //					count++;
315
    //				}
316
    			}
317
    		}
320 318
		} catch (Exception e) {
321 319
			e.printStackTrace();
322 320
		}
......
324 322
		return result;
325 323
	}
326 324

  
327
	private static Set<IdentifiableSource> filterOriginalPesiDbSources(
328
			Set<IdentifiableSource> sourceAll) {
329
		Set<IdentifiableSource> sourceCandidates = new HashSet<>();
330
		for (IdentifiableSource source : sourceAll){
331
			if (isOriginalPesiDbSource(source)){
332
				sourceCandidates.add(source);
333
			}
334
		}
335
		return sourceCandidates;
336
	}
337

  
338
	private static boolean isOriginalPesiDbSource(IdentifiableSource source) {
339
		return (source.getCitation() != null) &&
340
				source.getCitation().getType().equals(ReferenceType.Database);
341
	}
325
//	private static Set<IdentifiableSource> filterOriginalPesiDbSources(
326
//			Set<IdentifiableSource> sourceAll) {
327
//		Set<IdentifiableSource> sourceCandidates = new HashSet<>();
328
//		for (IdentifiableSource source : sourceAll){
329
//			if (isOriginalPesiDbSource(source)){
330
//				sourceCandidates.add(source);
331
//			}
332
//		}
333
//		return sourceCandidates;
334
//	}
335
//
336
//	private static boolean isOriginalPesiDbSource(IdentifiableSource source) {
337
//		return (source.getCitation() != null) &&
338
//				source.getCitation().getType().equals(ReferenceType.Database);
339
//	}
342 340

  
343 341
	/**
344 342
	 * Returns the <code>OriginalDB</code> attribute.
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java
34 34

  
35 35
import eu.etaxonomy.cdm.api.service.TaxonServiceImpl;
36 36
import eu.etaxonomy.cdm.common.CdmUtils;
37
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer;
38 37
import eu.etaxonomy.cdm.io.common.Source;
39 38
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
40 39
import eu.etaxonomy.cdm.io.common.mapping.out.DbConstantMapper;
......
104 103

  
105 104
	private static final String pluralString = "Taxa";
106 105
	private static final String parentPluralString = "Taxa";
106
	private static final String pluralStringNames = "Names";
107 107

  
108 108
	private PreparedStatement parentTaxonFk_TreeIndex_KingdomFkStmt;
109 109
	private PreparedStatement parentTaxonFkStmt;
110 110
	private PreparedStatement rankTypeExpertsUpdateStmt;
111 111
	private PreparedStatement rankUpdateStmt;
112 112
	private Integer kingdomFk;
113
	private AnnotationType treeIndexAnnotationType;
113

  
114 114
	private static ExtensionType lastActionExtensionType;
115 115
	private static ExtensionType lastActionDateExtensionType;
116 116
	private static ExtensionType expertNameExtensionType;
117 117
	private static ExtensionType speciesExpertNameExtensionType;
118 118
	private static ExtensionType cacheCitationExtensionType;
119

  
119 120
	public static TaxonNameDefaultCacheStrategy zooNameStrategy = ZooNameNoMarkerCacheStrategy.NewInstance();
120 121
	public static TaxonNameDefaultCacheStrategy nonViralNameStrategy = TaxonNameDefaultCacheStrategy.NewInstance();
121 122
	private static int currentTaxonId;
122 123

  
123
	protected AnnotationType getTreeIndexAnnotationType() {
124
		return treeIndexAnnotationType;
125
	}
126

  
127
	protected void setTreeIndexAnnotationType(AnnotationType treeIndexAnnotationType) {
128
		this.treeIndexAnnotationType = treeIndexAnnotationType;
129
	}
130

  
131 124
	enum NamePosition {
132 125
		beginning,
133 126
		end,
......
247 240
	}
248 241

  
249 242
	private boolean doPhase01(PesiExportState state, PesiExportMapping mapping, PesiExportMapping additionalSourceMapping){
250
		int count = 0;
243
		if (!state.getConfig().isDoTaxaPhase1()){
244
		    return true;
245
		}
246
	    int count = 0;
251 247
		int pastCount = 0;
252 248
		boolean success = true;
253 249
		// Get the limit for objects to save within a single transaction.
......
294 290
    				    }else{
295 291
    				        logger.warn("Kingdom taxon is not of class Taxon but " + taxon.getClass().getSimpleName() + ": " + nvn.getGenusOrUninomial());
296 292
    				    }
293
    				}else if (taxon.getUuid().equals(PesiTransformer.uuidTaxonValuelessEuroMed)){
294
    				    String treeIndex = ((Taxon)taxon).getTaxonNodes().iterator().next().treeIndex();
295
                        Integer kingdomId = PesiTransformer.pesiKingdomMap.get("Plantae");
296
                        state.getTreeIndexKingdomMap().put(treeIndex, kingdomId);
297 297
    				}
298 298
				}catch(NullPointerException e){
299 299
				    logger.error(nvn.getTitleCache() + " has no Rank!");
......
425 425
				for (TaxonNode node : taxon.getTaxonNodes()){
426 426
					doCount(count++, modCount, pluralString);
427 427
					TaxonNode parentNode = node.getParent();
428
					if (parentNode != null && parentNode.getTaxon() != null){  //new root node handling requires has root taxon with taxon == null
428
					if (parentNode != null && isPesiTaxon(parentNode.getTaxon())){//exclude root taxa and unpublished parents (relevant for "Valueless" parent for E+M Rubus taxa). Usually a parent should not be unpublished
429 429
						int childId = state.getDbId( taxon);
430 430
						int parentId = state.getDbId(parentNode.getTaxon());
431 431
						success &= invokeParentTaxonFk(parentId, childId);
......
555 555
        return success;
556 556
    }
557 557

  
558
    private static Integer findKingdomIdFromTreeIndex(TaxonBase<?> taxonBase,PesiExportState state) {
558
    private static Integer findKingdomIdFromTreeIndex(TaxonBase<?> taxonBase, PesiExportState state) {
559 559
        Taxon taxon;
560 560
        if (taxonBase instanceof Synonym){
561 561
            taxon = ((Synonym) taxonBase).getAcceptedTaxon();
......
584 584
                if(matcher.find()) {
585 585
                    String treeIndexKingdom = matcher.group(0);
586 586
                    kingdomID = state.getTreeIndexKingdomMap().get(treeIndexKingdom);
587
                }else{
587
                }
588
                if (kingdomID == null){
588 589
                    pattern = Pattern.compile("#t[0-9]+#([0-9]+#){2}");
589 590
                    matcher = pattern.matcher(treeIndex);
590 591
                    if(matcher.find()) {
......
901 902
			List<TaxonName> list;
902 903
			while ((list = getNextPureNamePartition(null, limit, partitionCount++)) != null   ) {
903 904

  
904
				logger.info("Fetched " + list.size() + " names without taxa. Exporting...");
905
				logger.debug("Fetched " + list.size() + pluralStringNames + " without taxa. Exporting...");
905 906
				for (TaxonName taxonName : list) {
906 907
					doCount(count++, modCount, pluralString);
907 908
					success &= mapping.invoke(taxonName);
......
914 915
				// Commit transaction
915 916
				commitTransaction(txStatus);
916 917
				logger.debug("Committed transaction.");
917
				logger.info("Exported " + (count - pastCount) + " " + pluralString + ". Total: " + count);
918
				logger.info("Exported " + (count - pastCount) + " " + pluralStringNames + ". Total: " + count + ". Partition: " + partitionCount);
918 919
				pastCount = count;
919 920

  
920 921
				// Start transaction
921 922
				txStatus = startTransaction(true);
922
				logger.info("Started new transaction for PureNames. Fetching some " + pluralString + " (max: " + limit + ") ...");
923
				logger.debug("Started new transaction for PureNames. Fetching some " + pluralString + " (max: " + limit + ") ...");
923 924
			}
924
			logger.info("No " + pluralString + " left to fetch.");
925
			logger.debug("No " + pluralString + " left to fetch.");
925 926

  
926 927
			// Commit transaction
927 928
			commitTransaction(txStatus);
......
1172 1173
	 * @return Whether the delete operation was successful or not.
1173 1174
	 */
1174 1175
	protected boolean doDelete(PesiExportState state) {
1175
		PesiExportConfigurator pesiConfig = state.getConfig();
1176

  
1177
		String sql;
1178
		Source destination =  pesiConfig.getDestination();
1176
	    if (!state.getConfig().isDoTaxaPhase1()){
1177
	        return true;
1178
	    }
1179
		Source destination =  state.getConfig().getDestination();
1179 1180

  
1180
		// Clear Taxon
1181
		sql = "DELETE FROM " + dbTableName;
1182
		destination.update(sql);
1181
		String[] tables = new String[]{"AdditionalTaxonSource","CommonNameSource","CommonName",
1182
		        "Image","NoteSource","Note","OccurrenceSource","Occurrence","RelTaxon","Taxon"};
1183 1183

  
1184
		//TODO due to foreign keys we should also delete all tables linking to Taxon table
1184
		for(String table : tables){
1185
		    String sql = "DELETE FROM " + table;
1186
		    destination.update(sql);
1187
		}
1185 1188

  
1186 1189
		return true;
1187 1190
	}
......
1217 1220
		return result;
1218 1221
	}
1219 1222

  
1220
	private static String getRankCache(TaxonName taxonName, PesiExportState state) {
1223
	@SuppressWarnings("unused")
1224
    private static String getRankCache(TaxonName taxonName, PesiExportState state) {
1221 1225
	    List<TaxonNode> nodes = getTaxonNodes(taxonName);
1222
        Integer kingdomId = findKingdomIdFromTreeIndex(nodes.iterator().next().getTaxon(), state);
1226
	    Integer kingdomId;
1227
	    if (nodes == null||nodes.isEmpty()){
1228
	        kingdomId = getKingdomFk(taxonName);
1229
	    }else{
1230
	        kingdomId = findKingdomIdFromTreeIndex(nodes.iterator().next().getTaxon(), state);
1231
	    }
1223 1232
        return getRankCache(taxonName, kingdomId, state);
1224 1233
	}
1225 1234

  
1226

  
1227
	/**
1228
	 * Returns the <code>RankCache</code> attribute.
1229
	 * @param taxonName The {@link TaxonNameBase TaxonName}.
1230
	 * @param nomenclaturalCode The {@link NomenclaturalCode NomenclaturalCode}.
1231
	 * @param state
1232
	 * @return The <code>RankCache</code> attribute.
1233
	 * @see MethodMapper
1234
	 */
1235 1235
	private static String getRankCache(TaxonName taxonName, Integer kingdomFk, PesiExportState state) {
1236 1236
	    if (Rank.DOMAIN().equals(taxonName.getRank())){
1237 1237
            return state.getTransformer().getCacheByRankAndKingdom(Rank.DOMAIN(), null);
......
1255 1255
            }else{
1256 1256
                taxon = CdmBase.deproxy(tb, Synonym.class).getAcceptedTaxon();
1257 1257
            }
1258
            if (taxon != null){
1258
            if (isPesiTaxon(taxon)){
1259 1259
                for (TaxonNode node : taxon.getTaxonNodes()){
1260 1260
                    result.add(node);
1261 1261
                }
......
1264 1264
        return result;
1265 1265
    }
1266 1266

  
1267
//    @SuppressWarnings("unused")  //used by pure name mapper and by getRankFk
1268
    private static Integer getKingdomFk(TaxonName taxonName){
1269
        EnumSet<PesiSource> origin = getSources(taxonName);
1270
        if (origin.size() == 1 && origin.contains(PesiSource.EM)){
1271
            //maybe simply replace by
1272
            //return PesiTransformer.KINGDOM_PLANTAE;
1273
            return PesiTransformer.nomenclaturalCode2Kingdom(taxonName.getNameType());
1274
        }else{
1275
            logger.warn("getKingdomFk not yet implemented for non-EuroMed pure names");
1276
            return null;
1277
        }
1278
    }
1279

  
1280
    /**
1281
     * Returns the rankFk for the taxon name based on the names nomenclatural code.
1282
     * You may not use this method for kingdoms other then Animalia, Plantae and Bacteria.
1283
     */
1284
    @SuppressWarnings("unused")  //used by pure name mapper
1285
    private static Integer getRankFk(TaxonName taxonName) {
1286
        EnumSet<PesiSource> origin = getSources(taxonName);
1287
        if (origin.size() == 1 && origin.contains(PesiSource.EM)){
1288
            return getRankFk(taxonName, getKingdomFk(taxonName));
1289
        }else{
1290
            logger.warn("getRankFk not yet implemented for non-EuroMed pure names");
1291
            return null;
1292
        }
1293
    }
1294

  
1267 1295
    /**
1268 1296
	 * Returns the <code>DisplayName</code> attribute.
1269 1297
	 * @param taxon The {@link TaxonBase Taxon}.
......
1470 1498
	/**
1471 1499
	 * Returns the nomenclatural reference which is the reference
1472 1500
	 * including the detail (microreference).
1473
	 * @param taxonName The {@link TaxonNameBase TaxonName}.
1474
	 * @return The <code>AuthorString</code> attribute.
1501
	 * @param taxonName The {@link TaxonName taxon name}.
1475 1502
	 * @see MethodMapper
1476 1503
	 */
1477 1504
	@SuppressWarnings("unused")
......
1690 1717
	 * @return The <code>TypeDesignationStatusFk</code> attribute.
1691 1718
	 * @see MethodMapper
1692 1719
	 */
1693
	@SuppressWarnings("unused")
1720
	//TODO seems not to be used
1694 1721
	private static Integer getTypeDesignationStatusFk(TaxonName taxonName) {
1695 1722
		Integer result = null;
1696 1723

  
1697 1724
		try {
1698
		if (taxonName != null) {
1699
			Set<NameTypeDesignation> typeDesignations = taxonName.getNameTypeDesignations();
1700
			if (typeDesignations.size() == 1) {
1701
				Object obj = typeDesignations.iterator().next().getTypeStatus();
1702
				NameTypeDesignationStatus designationStatus = CdmBase.deproxy(obj, NameTypeDesignationStatus.class);
1703
				result = PesiTransformer.nameTypeDesignationStatus2TypeDesignationStatusId(designationStatus);
1704
			} else if (typeDesignations.size() > 1) {
1705
				logger.error("Found a TaxonName with more than one NameTypeDesignation: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")");
1706
			}
1707
		}
1708

  
1725
    		if (taxonName != null) {
1726
    			Set<NameTypeDesignation> typeDesignations = taxonName.getNameTypeDesignations();
1727
    			if (typeDesignations.size() == 1) {
1728
    				Object obj = typeDesignations.iterator().next().getTypeStatus();
1729
    				NameTypeDesignationStatus designationStatus = CdmBase.deproxy(obj, NameTypeDesignationStatus.class);
1730
    				result = PesiTransformer.nameTypeDesignationStatus2TypeDesignationStatusId(designationStatus);
1731
    			} else if (typeDesignations.size() > 1) {
1732
    				logger.error("Found a TaxonName with more than one NameTypeDesignation: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")");
1733
    			}
1734
    		}
1709 1735
		} catch (Exception e) {
1710 1736
			e.printStackTrace();
1711 1737
		}
......
1718 1744
	 * @return The <code>TypeDesignationStatusCache</code> attribute.
1719 1745
	 * @see MethodMapper
1720 1746
	 */
1721
	@SuppressWarnings("unused")
1747
	//TODO seems not to be used
1722 1748
	private static String getTypeDesignationStatusCache(TaxonName taxonName) {
1723 1749
		String result = null;
1724 1750

  
1725 1751
		try {
1726
		if (taxonName != null) {
1727
			Set<NameTypeDesignation> typeDesignations = taxonName.getNameTypeDesignations();
1728
			if (typeDesignations.size() == 1) {
1729
				Object obj = typeDesignations.iterator().next().getTypeStatus();
1730
				NameTypeDesignationStatus designationStatus = CdmBase.deproxy(obj, NameTypeDesignationStatus.class);
1731
				result = PesiTransformer.nameTypeDesignationStatus2TypeDesignationStatusCache(designationStatus);
1732
			} else if (typeDesignations.size() > 1) {
1733
				logger.error("Found a TaxonName with more than one NameTypeDesignation: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")");
1734
			}
1735
		}
1736

  
1752
    		if (taxonName != null) {
1753
    			Set<NameTypeDesignation> typeDesignations = taxonName.getNameTypeDesignations();
1754
    			if (typeDesignations.size() == 1) {
1755
    				Object obj = typeDesignations.iterator().next().getTypeStatus();
1756
    				NameTypeDesignationStatus designationStatus = CdmBase.deproxy(obj, NameTypeDesignationStatus.class);
1757
    				result = PesiTransformer.nameTypeDesignationStatus2TypeDesignationStatusCache(designationStatus);
1758
    			} else if (typeDesignations.size() > 1) {
1759
    				logger.error("Found a TaxonName with more than one NameTypeDesignation: " + taxonName.getUuid() + " (" + taxonName.getTitleCache() + ")");
1760
    			}
1761
    		}
1737 1762
		} catch (Exception e) {
1738 1763
			e.printStackTrace();
1739 1764
		}
......
1803 1828
				Reference ref = source.getCitation();
1804 1829
				UUID refUuid = ref.getUuid();
1805 1830
				String idInSource = source.getIdInSource();
1806
				if (refUuid.equals(BerlinModelTransformer.uuidSourceRefEuroMed)){
1831
				if (refUuid.equals(PesiTransformer.uuidSourceRefEuroMed)){
1807 1832
					result = idInSource != null ? ("NameId: " + source.getIdInSource()) : null;
1808 1833
				}else if (refUuid.equals(PesiTransformer.uuidSourceRefFaunaEuropaea)){
1809 1834
					result = idInSource != null ? ("TAX_ID: " + source.getIdInSource()) : null;
......
1993 2018
	 * @return The <code>LastAction</code> attribute.
1994 2019
	 * @see MethodMapper
1995 2020
	 */
1996
	@SuppressWarnings("unused")
2021
	//TODO still in use?
1997 2022
	private static String getLastAction(IdentifiableEntity<?> identEntity) {
1998 2023
		String result = null;
1999 2024
		try {
2000
		Set<Extension> extensions = identEntity.getExtensions();
2001
		for (Extension extension : extensions) {
2002
			if (extension.getType().equals(lastActionExtensionType)) {
2003
				result = extension.getValue();
2004
			}
2005
		}
2025
    		Set<Extension> extensions = identEntity.getExtensions();
2026
    		for (Extension extension : extensions) {
2027
    			if (extension.getType().equals(lastActionExtensionType)) {
2028
    				result = extension.getValue();
2029
    			}
2030
    		}
2006 2031
		} catch (Exception e) {
2007 2032
			e.printStackTrace();
2008 2033
		}
......
2015 2040
	 * @return The <code>LastActionDate</code> attribute.
2016 2041
	 * @see MethodMapper
2017 2042
	 */
2018
	@SuppressWarnings({ "unused" })
2043
	//TODO still in use?
2019 2044
	private static DateTime getLastActionDate(IdentifiableEntity<?> identEntity) {
2020 2045
		DateTime result = null;
2021 2046
		try {
......
2041 2066
	 * @return The <code>ExpertName</code> attribute.
2042 2067
	 * @see MethodMapper
2043 2068
	 */
2044
	@SuppressWarnings("unused")
2069
	@SuppressWarnings("unused")  //for some reason it is also called by getCacheCitation
2045 2070
	private static String getExpertName(TaxonBase<?> taxonName) {
2046
		String result = null;
2071
	    String result = null;
2047 2072
		try {
2048
		Set<Extension> extensions = taxonName.getExtensions();
2049
		for (Extension extension : extensions) {
2050
			if (extension.getType().equals(expertNameExtensionType)) {
2051
				result = extension.getValue();
2052
			}
2053
		}
2073
    		if(expertNameExtensionType!=null){  //some databases do not have this extension type
2074
    		    Set<Extension> extensions = taxonName.getExtensions();
2075
    		    for (Extension extension : extensions) {
2076
    		        if (extension.getType().equals(expertNameExtensionType)) {
2077
    		            result = extension.getValue();
2078
    		        }
2079
    		    }
2080
    		}
2054 2081
		} catch (Exception e) {
2055 2082
			e.printStackTrace();
2056 2083
		}
......
2075 2102
	 * @return The <code>SpeciesExpertName</code> attribute.
2076 2103
	 * @see MethodMapper
2077 2104
	 */
2078
	@SuppressWarnings("unused")
2105
	//TODO still in use?
2079 2106
	private static String getSpeciesExpertName(TaxonBase<?> taxonName) {
2080 2107
		String result = null;
2081 2108
		try {
2082
		Set<Extension> extensions = taxonName.getExtensions();
2083
		for (Extension extension : extensions) {
2084
			if (extension.getType().equals(speciesExpertNameExtensionType)) {
2085
				result = extension.getValue();
2086
			}
2087
		}
2109
    		Set<Extension> extensions = taxonName.getExtensions();
2110
    		for (Extension extension : extensions) {
2111
    			if (extension.getType().equals(speciesExpertNameExtensionType)) {
2112
    				result = extension.getValue();
2113
    			}
2114
    		}
2088 2115
		} catch (Exception e) {
2089 2116
			e.printStackTrace();
2090 2117
		}
......
2132 2159
		return PesiTransformer.taxonRelation2RelTaxonQualifierFk(relationship);
2133 2160
	}
2134 2161

  
2135
    @SuppressWarnings("unused")
2162
    //TODO still in use?
2136 2163
    private static String getSynonymTypeCache(Synonym synonym, PesiExportState state) {
2137 2164
        String result = null;
2138 2165
        NomenclaturalCode code = null;
......
2208 2235
		mapping.addMapper(MethodMapper.NewInstance("KingdomFk", this, TaxonName.class));
2209 2236
		mapping.addMapper(MethodMapper.NewInstance("RankFk", this, TaxonName.class));
2210 2237
		mapping.addMapper(MethodMapper.NewInstance("RankCache", this, TaxonName.class, PesiExportState.class));
2211
		mapping.addMapper(DbConstantMapper.NewInstance("TaxonStatusFk", Types.INTEGER , PesiTransformer.T_STATUS_UNACCEPTED));
2212
		mapping.addMapper(DbConstantMapper.NewInstance("TaxonStatusCache", Types.VARCHAR , state.getTransformer().getTaxonStatusCacheByKey( PesiTransformer.T_STATUS_UNACCEPTED)));
2238
		mapping.addMapper(DbConstantMapper.NewInstance("TaxonStatusFk", Types.INTEGER, PesiTransformer.T_STATUS_UNACCEPTED));
2239
		mapping.addMapper(DbConstantMapper.NewInstance("TaxonStatusCache", Types.VARCHAR, state.getTransformer().getTaxonStatusCacheByKey( PesiTransformer.T_STATUS_UNACCEPTED)));
2213 2240
		mapping.addMapper(DbStringMapper.NewInstance("AuthorshipCache", "AuthorString").setBlankToNull(true));
2214 2241
		mapping.addMapper(MethodMapper.NewInstance("WebShowName", this, TaxonName.class));
2215 2242
		mapping.addMapper(MethodMapper.NewInstance("GUID", this, TaxonName.class));
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java
74 74
	public static final UUID uuidSourceRefIndexFungorum = UUID.fromString("8de25d27-7d40-47f4-af3b-59d64935a843");
75 75
	public static final UUID uuidSourceRefAuct = UUID.fromString("5f79f96c-c100-4cd8-b78e-2b2dacf09a23");
76 76

  
77
    public static final UUID uuidTaxonValuelessEuroMed = UUID.fromString("f0a9322b-a57e-447b-9a75-a909f2f2a994");
78

  
77 79
	public static final String SOURCE_STR_EM = "E+M";
78 80
	public static final String SOURCE_STR_FE = "FaEu";
79 81
	public static final String SOURCE_STR_IF = "IF";

Also available in: Unified diff