Project

General

Profile

Download (19.2 KB) Statistics
| Branch: | Revision:
1
package eu.etaxonomy.cdm.app.pesi.merging;
2

    
3
import java.util.ArrayList;
4
import java.util.HashSet;
5
import java.util.Iterator;
6
import java.util.List;
7
import java.util.Set;
8
import java.util.UUID;
9

    
10
import org.apache.log4j.Logger;
11

    
12
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
13
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
14
import eu.etaxonomy.cdm.api.service.pager.Pager;
15
import eu.etaxonomy.cdm.app.common.CdmDestinations;
16
import eu.etaxonomy.cdm.database.DbSchemaValidation;
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
19
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController;
20
import eu.etaxonomy.cdm.model.common.Annotation;
21
import eu.etaxonomy.cdm.model.common.Credit;
22
import eu.etaxonomy.cdm.model.common.Extension;
23
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
24
import eu.etaxonomy.cdm.model.common.Marker;
25
import eu.etaxonomy.cdm.model.description.Distribution;
26
import eu.etaxonomy.cdm.model.description.Feature;
27
import eu.etaxonomy.cdm.model.description.TaxonDescription;
28
import eu.etaxonomy.cdm.model.name.NameRelationship;
29
import eu.etaxonomy.cdm.model.name.Rank;
30
import eu.etaxonomy.cdm.model.reference.Reference;
31
import eu.etaxonomy.cdm.model.taxon.Classification;
32
import eu.etaxonomy.cdm.model.taxon.Synonym;
33
import eu.etaxonomy.cdm.model.taxon.Taxon;
34
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
36

    
37
public class FaunaEuErmsMergeActivator extends PesiMergeBase{
38

    
39
	static final ICdmDataSource faunaEuropaeaSource = CdmDestinations.localH2();
40

    
41
	static final int faunaEuUuid = 0;
42
	static final int ermsUuid = 9;
43
	static final int rankFaunaEu = 4;
44
	static final int rankErms = 13;
45
	private Classification faunaEuClassification;
46
	private Classification ermsClassification;
47

    
48
	private CdmApplicationController appCtrInit;
49

    
50
	private static final Logger logger = Logger.getLogger(FaunaEuErmsMergeActivator.class);
51

    
52
	//csv files starting with...
53
	static String sFileName = "c:\\test";
54

    
55
	private void initDb(ICdmDataSource db) {
56
		// Init source DB
57
		appCtrInit = CdmIoApplicationController.NewInstance(db, DbSchemaValidation.VALIDATE, false);
58
	}
59

    
60
	public static void main(String[] args) {
61

    
62
		FaunaEuErmsMergeActivator sc = new FaunaEuErmsMergeActivator();
63

    
64
		sc.initDb(faunaEuropaeaSource);
65
		//we also need to merge names completely identical!
66
		sc.mergeAuthors();
67

    
68
		//set the ranks of Agnatha and Gnathostomata to 50 instead of 45
69
		List<TaxonBase> taxaToChangeRank = new ArrayList<>();
70

    
71
		Pager<TaxonBase> agnatha = sc.appCtrInit.getTaxonService().findTaxaByName(TaxonBase.class, "Agnatha", null, null, null, "*", Rank.INFRAPHYLUM(), 10, 0, null);
72
		List<TaxonBase> agnathaList = agnatha.getRecords();
73
		taxaToChangeRank.addAll(agnathaList);
74

    
75
		Pager<TaxonBase> gnathostomata = sc.appCtrInit.getTaxonService().findTaxaByName(TaxonBase.class, "Gnathostomata", null, null, null, "*", Rank.INFRAPHYLUM(), 10, 0, null);
76
		List<TaxonBase> gnathostomataList = gnathostomata.getRecords();
77
		taxaToChangeRank.addAll(gnathostomataList);
78

    
79
		sc.setSpecificRank(taxaToChangeRank, Rank.SUPERCLASS());
80

    
81
		//ermsTaxon is accepted, faunaEu taxon is synonym
82
		//ermsTaxon is synonym, faunaEu is accepted
83

    
84
		sc.mergeDiffStatus();
85

    
86
		//erms is synonym, faunaEu as well
87

    
88
		// erms is accepted, faunaEu as well
89

    
90
	}
91

    
92
	private void mergeAuthors(){
93
		List<List<String>> authors = readCsvFile(sFileName + "_authors.csv");
94
		//authors: get firstAuthor if isFauEu = 1 otherwise get secondAuthor
95

    
96
		Iterator<List<String>> authorIterator = authors.iterator();
97
		List<TaxonBase<?>> taxaToSave = new ArrayList<>();  //TODO: needed?
98
		while (authorIterator.hasNext()){
99
		    List<String> row = authorIterator.next();
100
			UUID uuidFaunaEu = UUID.fromString(row.get(faunaEuUuid));
101
			UUID uuidErms = UUID.fromString(row.get(ermsUuid));
102
			TaxonBase<?> taxonFaunaEu = appCtrInit.getTaxonService().find(uuidFaunaEu);
103
			TaxonBase<?> taxonErms = appCtrInit.getTaxonService().find(uuidErms);
104
// which information should be used can be found in last row -> needs to be done manually
105
			if (Integer.parseInt(row.get(18)) == 1){
106
				//isFaunaEu = 1 -> copy the author of Fauna Europaea to Erms
107
				if (taxonFaunaEu.getName().getBasionymAuthorship()!= null){
108
					taxonErms.getName().setBasionymAuthorship(taxonFaunaEu.getName().getBasionymAuthorship());
109
				}
110
				if (taxonFaunaEu.getName().getCombinationAuthorship()!= null){
111
					taxonErms.getName().setCombinationAuthorship(taxonFaunaEu.getName().getCombinationAuthorship());
112
				}
113
				taxonErms.getName().generateAuthorship();
114
				taxaToSave.add(taxonErms);
115
			}else{
116
				if (taxonErms.getName().getBasionymAuthorship()!= null){
117
					taxonFaunaEu.getName().setBasionymAuthorship(taxonErms.getName().getBasionymAuthorship());
118
				}
119
				if (taxonErms.getName().getCombinationAuthorship()!= null){
120
					taxonFaunaEu.getName().setCombinationAuthorship(taxonErms.getName().getCombinationAuthorship());
121
				}
122
				taxonFaunaEu.getName().generateAuthorship();
123
				taxaToSave.add(taxonFaunaEu);
124
			}
125
		}
126
	}
127

    
128
	private void setSpecificRank(List<TaxonBase> taxa, Rank rank){
129
		for (TaxonBase<?> taxon: taxa){
130
			taxon.getName().setRank(rank);
131
		}
132
	}
133

    
134
	private void mergeDiffStatus(){
135
		List<List<String>> diffStatus = readCsvFile(sFileName + "_status.csv");
136

    
137
		//find all taxa accepted in erms, but synonyms in FauEu  and the same rank
138
		List<List<String>> accErmsSynFaunaEu = new ArrayList<>();
139
		for (List<String> rowList: diffStatus){
140
			if ((rowList.get(5).equals("synonym")) && (rowList.get(rankFaunaEu).equals(rowList.get(rankErms)))){
141
				//both conditions are true
142
				accErmsSynFaunaEu.add(rowList);
143
			}
144
		}
145
		mergeErmsAccFaunaEuSyn(accErmsSynFaunaEu);
146

    
147
		//find all taxa accepted in faunaEu, but synonyms in Erms and the same rank
148
		List<List<String>> synErmsAccFaunaEu = new ArrayList<>();
149
		for (List<String> rowList: diffStatus){
150
			if ((rowList.get(5).equals("accepted")) && (rowList.get(rankFaunaEu).equals(rowList.get(rankErms)))){
151
				//both conditions are true
152
				synErmsAccFaunaEu.add(rowList);
153
			}
154
		}
155
		mergeErmsSynFaunaEuAcc(synErmsAccFaunaEu);
156
	}
157

    
158
	private void mergeSameStatus(){
159
		List<List<String>> sameStatus = readCsvFile(sFileName + "_names.csv");
160

    
161
		TaxonBase<?> taxonFaunaEu;
162
		TaxonBase<?> taxonErms;
163
		List<String> propertyPaths = new ArrayList<>();
164
		propertyPaths.add("taxonBases.nodes.*");
165
		for (List<String> row: sameStatus){
166
			taxonFaunaEu = appCtrInit.getTaxonService().load(UUID.fromString(row.get(faunaEuUuid)), propertyPaths);
167
			taxonErms = appCtrInit.getTaxonService().load(UUID.fromString(row.get(ermsUuid)), propertyPaths);
168
			moveAllInformationsFromFaunaEuToErms(taxonFaunaEu, taxonErms);
169
			if (taxonErms instanceof Taxon){
170
				moveFaunaEuSynonymsToErmsTaxon((Taxon)taxonFaunaEu, (Taxon)taxonErms);
171
			}
172
		}
173
	}
174

    
175
	private void mergeErmsAccFaunaEuSyn(List<List<String>> ermsAccFaEuSyn){
176

    
177
		// update nameRelationships -> if the nameRelationship does not exist, then create a new one with ermsAcc as relatedTo TaxonName
178
		updateNameRelationships(ermsAccFaEuSyn);
179

    
180
		//delete all synonyms of FaunaEu Syn TODO: move sources and additional informations to erms taxon
181
		for (List<String> rowList: ermsAccFaEuSyn){
182
			UUID faunaUUID = UUID.fromString(rowList.get(faunaEuUuid));
183
			//UUID ermsUUID = UUID.fromString(rowList.get(ermsUuid));
184
			Synonym syn = (Synonym)appCtrInit.getTaxonService().find(faunaUUID);
185
			// remove synonym from taxon then delete
186
			appCtrInit.getTaxonService().deleteSynonym(syn, null);
187
		}
188

    
189
		//merge the infos of
190
	}
191

    
192
	private  void mergeErmsSynFaunaEuAcc (List<List<String>> ermsAccFaEuSyn){
193
		//occurence: connect instead of Fauna Europaea taxon the accepted taxon of the synonym with the occurrence (CDM -> distribution)
194
		//search distribution (via taxon of the taxon description), of which the taxon is the according Fauna Eu taxon and connect it with the accepted taxon of the ERMS syn
195
		for (List<String> row: ermsAccFaEuSyn){
196
		    Taxon taxonFaunaEu = (Taxon)appCtrInit.getTaxonService().find(UUID.fromString(row.get(faunaEuUuid)));
197
			Synonym synErms = (Synonym)appCtrInit.getTaxonService().find(UUID.fromString(row.get(ermsUuid)));
198
			synErms = HibernateProxyHelper.deproxy(synErms, Synonym.class);
199
			Taxon taxonErms = synErms.getAcceptedTaxon();
200

    
201
			if (taxonErms == null){
202
				logger.debug("There is no accepted taxon for the synonym" + synErms.getTitleCache());
203
			}
204

    
205
			Set<Feature> features = new HashSet<>();
206
			features.add(Feature.DISTRIBUTION());
207
			List<String> propertyPaths = new ArrayList<>();
208
			propertyPaths.add("inDescription.Taxon.*");
209
			List<Distribution> distributions = appCtrInit.getDescriptionService().getDescriptionElementsForTaxon(taxonFaunaEu, features, Distribution.class, 10, 0, null);
210

    
211

    
212
			for(Distribution distribution: distributions){
213
				TaxonDescription description = (TaxonDescription)distribution.getInDescription();
214
				TaxonDescription newDescription = TaxonDescription.NewInstance(taxonErms);
215
				newDescription.addElement(distribution);
216
				try{
217
					appCtrInit.getDescriptionService().delete(description);
218
				}catch (Exception e){
219
					logger.debug("The description of" + description.getTaxon().getTitleCache() + description.getTitleCache() + "can't be deleted because it is referenced.");
220
				}
221
			}
222

    
223
			//Child-Parent Relationship aktualisieren -> dem Child des Fauna Europaea Taxons als parent das akzeptierte Taxon von synErms
224
			Set<TaxonNode> nodesErms = taxonErms.getTaxonNodes();
225
			Set<TaxonNode> nodesFaunaEu =taxonFaunaEu.getTaxonNodes();
226
			if (nodesFaunaEu.size()>1 || nodesFaunaEu.isEmpty()){
227

    
228
			}else{
229
				Iterator<TaxonNode> iteratorNodesErms = nodesErms.iterator();
230

    
231
				Iterator<TaxonNode> iteratorNodesFaunaEu = nodesFaunaEu.iterator();
232
				TaxonNode node = iteratorNodesFaunaEu.next();
233
				List<TaxonNode> children = node.getChildNodes();
234
				Iterator<TaxonNode> childrenIterator = children.iterator();
235
				TaxonNode childNode;
236
				if (iteratorNodesErms.hasNext()){
237
					TaxonNode ermsNode = iteratorNodesErms.next();
238
					while (childrenIterator.hasNext()){
239
						childNode = childrenIterator.next();
240
						ermsNode.addChildNode(childNode, childNode.getReference(), childNode.getMicroReference());
241
					}
242
				}
243

    
244
			}
245
			//the fauna eu taxon should now only contain synonyms not existing in erms
246
			moveFaunaEuSynonymsToErmsTaxon(taxonFaunaEu, taxonErms);
247
			moveAllInformationsFromFaunaEuToErms(taxonFaunaEu, taxonErms);
248
			moveOriginalDbToErmsTaxon(taxonFaunaEu, taxonErms);
249
			//neue sec Referenz an das ErmsTaxon oder an das Synonym und Taxon oder nur Synonym??
250
			try{
251
				deleteFaunaEuTaxon(taxonFaunaEu);
252
			}catch(ReferencedObjectUndeletableException e){
253
				logger.debug("The taxon " + taxonFaunaEu.getTitleCache() + " can't be deleted because it is referenced.");
254
			}
255
		}
256

    
257
	}
258

    
259
	private void updateNameRelationships(List<List<String>> ermsAccFaEuSyn){
260
		//search all NameRelationships of FaunaEu and Erms, where (faunaEu)relatedFrom.name.titleCache = (erms)relatedFrom.name.titleCache and replace in faunaEu relationship the relatedTo.name by the relatedTo.name of the erms-relationship
261
		//if this relationship does not yet exist and the type is the same!!
262
		//if the relatedTo name belongs to an Erms taxon and to an FaunaEu synonym
263

    
264
		Synonym synFaunaEu;
265
		Taxon taxonErms;
266
		for (List<String> row: ermsAccFaEuSyn){
267
			synFaunaEu = (Synonym)appCtrInit.getTaxonService().find(UUID.fromString(row.get(faunaEuUuid)));
268
			taxonErms = (Taxon)appCtrInit.getTaxonService().find(UUID.fromString(row.get(ermsUuid)));
269
			List<NameRelationship> relSynFaunaEu = appCtrInit.getNameService().listToNameRelationships(synFaunaEu.getName(), null, 100, 0, null, null);
270
			List<NameRelationship> relTaxonErms = appCtrInit.getNameService().listToNameRelationships(taxonErms.getName(), null, 100, 0, null, null);
271

    
272
			List<NameRelationship> deleteRel = new ArrayList<>();
273
			for (NameRelationship relFauEu: relSynFaunaEu){
274
				boolean createNewRelationship = true;
275
				for (NameRelationship relErms: relTaxonErms){
276
					if ((relErms.getFromName().getTitleCache().equals(relFauEu.getFromName().getTitleCache())) && (relErms.getToName().getTitleCache().equals(relFauEu.getFromName().getTitleCache()))){
277
						//delete the faunaEu relationship because there exist an analogous relationship in erms
278
						deleteRel.add(relFauEu);
279
						createNewRelationship = false;
280
						break;
281
					}
282
				}
283
				if (createNewRelationship){
284
					//if relationship does not exist, create a new one with erms synonym
285
					taxonErms.getName().addRelationshipFromName(relFauEu.getFromName(), relFauEu.getType(), relFauEu.getRuleConsidered(), null);
286
				}
287
			}
288
		}
289
	}
290

    
291
	private void updateSynonymRelationships(List<List<String>> ermsSynFaEuAcc){
292
//		-- Update queries for RelTaxon (synonym relationships - move relationships to ERMS accepted taxon if not already existent or delete if already existent)
293
//		UPDATE RelTaxon_1 SET RelTaxon_1.TaxonFk2 = RT.TaxonFk2
294
//		FROM         Taxon AS ERMSSyn INNER JOIN
295
//		                      Taxon AS FaEuAcc ON ERMSSyn.RankFk = FaEuAcc.RankFk AND ERMSSyn.FullName = FaEuAcc.FullName AND
296
//		                      ERMSSyn.TaxonStatusFk <> ISNULL(FaEuAcc.TaxonStatusFk, 0) INNER JOIN
297
//		                      RelTaxon AS RT ON ERMSSyn.TaxonId = RT.TaxonFk1 INNER JOIN
298
//		                      RelTaxon AS RelTaxon_1 ON FaEuAcc.TaxonId = RelTaxon_1.TaxonFk2 INNER JOIN
299
//		                      Taxon AS FaEuSyn ON RelTaxon_1.TaxonFk1 = FaEuSyn.TaxonId LEFT OUTER JOIN
300
//		                      Taxon AS ERMSAllSyn ON RT.TaxonFk1 = ERMSAllSyn.TaxonId AND FaEuSyn.FullName <> ERMSAllSyn.FullName --(!!)
301
//		WHERE     (ERMSSyn.OriginalDB = N'ERMS') AND (RT.RelTaxonQualifierFk > 100) AND (ERMSSyn.TaxonStatusFk <> 1) AND (ERMSSyn.KingdomFk = 2) AND
302
//		                      (FaEuAcc.OriginalDB = N'FaEu') AND (RelTaxon_1.RelTaxonQualifierFk > 100)
303
		Taxon taxonFaunaEu;
304
		Synonym synErms;
305
		Taxon taxonErms;
306
		Set<Taxon> acceptedTaxa = new HashSet<>();
307
		for (List<String> row: ermsSynFaEuAcc){
308
			taxonFaunaEu = (Taxon)appCtrInit.getTaxonService().find(UUID.fromString(row.get(faunaEuUuid)));
309
			synErms = (Synonym)appCtrInit.getTaxonService().find(UUID.fromString(row.get(ermsUuid)));
310
			acceptedTaxa.clear();
311
			acceptedTaxa.add( synErms.getAcceptedTaxon());
312
			if (!acceptedTaxa.isEmpty()){
313
				taxonErms = acceptedTaxa.iterator().next();
314
				if (acceptedTaxa.size() > 1){
315
					logger.debug("There are more than one accepted taxon for synonym " + synErms.getTitleCache());
316
				}
317
			}else{
318
				taxonErms = null;
319
				logger.debug("There is no accepted taxon for synonym "  + synErms.getTitleCache());
320
			}
321

    
322
			if (taxonErms != null){
323
				Pager<Synonym> synsTaxonFaunaEuPager = appCtrInit.getTaxonService().getSynonyms(taxonFaunaEu, null, null, null, null, null);
324
				List<Synonym> synsTaxonFaunaEu = synsTaxonFaunaEuPager.getRecords();
325

    
326
				Pager<Synonym> synsTaxonErmsPager = appCtrInit.getTaxonService().getSynonyms(taxonErms, null, null, null, null, null);
327
				List<Synonym> synsTaxonErms = synsTaxonErmsPager.getRecords();
328

    
329
				List<Synonym> deleteRel = new ArrayList<>();
330
				for (Synonym synFauEu: synsTaxonFaunaEu){
331
					//TODO: wenn es noch keine SynonymRelationship gibt zu einem Synonym mit gleichem Namen,
332
				    //dann erzeuge die SynonymRelationship vom FaunaEuSyn (des FaunaEu Taxons, das
333
				    //identischen Namen hat) zum akzeptierten Taxon des Erms Syn
334
					boolean createNewRelationship = true;
335
					for (Synonym relErms: synsTaxonErms){
336
						if (relErms.getTitleCache().equals(synFauEu.getTitleCache())){
337
							//es gibt schon eine Relationship zu einem Synonym mit dem gleichen Namen wie das FaunaEu Synonym, also Relationship l�schen.
338
							createNewRelationship = false;
339
							break;
340
						}
341
					}
342
					if (createNewRelationship){
343
						taxonErms.addSynonym(synFauEu, synFauEu.getType());
344
					}
345
					deleteRel.add(synFauEu);
346
				}
347
			}
348
		}
349
	}
350

    
351
	private void deleteFaunaEuTaxon(Taxon taxonFaunaEu) throws ReferencedObjectUndeletableException {
352
		appCtrInit.getTaxonService().delete(taxonFaunaEu);
353
	}
354

    
355
	//wenn Name und Rang identisch sind und auch der Status gleich, dann alle Informationen vom Fauna Europaea Taxon/Synonym zum Erms Taxon/Synonym
356

    
357
	private void moveAllInformationsFromFaunaEuToErms(TaxonBase<?> faunaEu, TaxonBase<?> erms){
358
		Set<Annotation> annotations = faunaEu.getAnnotations();
359
		Set<Extension> extensions = faunaEu.getExtensions();
360
		Set<Marker> markers = faunaEu.getMarkers();
361
		List<Credit> credits = faunaEu.getCredits();
362
		if (faunaEu instanceof Taxon){
363
			Set<TaxonDescription> descriptions = ((Taxon)faunaEu).getDescriptions();
364
			Set<Taxon> misappliedNames = ((Taxon)faunaEu).getMisappliedNames(true);
365

    
366
			if (erms instanceof Taxon){
367
				Iterator<TaxonDescription> descriptionsIterator = descriptions.iterator();
368
				TaxonDescription description;
369
				while (descriptionsIterator.hasNext()){
370
					description = descriptionsIterator.next();
371
					((Taxon) erms).addDescription(description);
372
				}
373

    
374
				Iterator<Taxon> misappliedNamesIterator = misappliedNames.iterator();
375
				Taxon misappliedName;
376
				while (misappliedNamesIterator.hasNext()){
377
					misappliedName = misappliedNamesIterator.next();
378
					((Taxon) erms).addMisappliedName(misappliedName, null, null);
379
				}
380
			}
381
		}
382

    
383
		//move all these informations to the erms taxon
384
		Iterator<Annotation> annotationsIterator = annotations.iterator();
385
		Annotation annotation;
386
		while (annotationsIterator.hasNext()){
387
			annotation = annotationsIterator.next();
388
			erms.addAnnotation(annotation);
389
		}
390

    
391
		Iterator<Extension> extensionIterator = extensions.iterator();
392
		Extension extension;
393
		while (extensionIterator.hasNext()){
394
			extension = extensionIterator.next();
395
			erms.addExtension(extension);
396
		}
397

    
398
		Iterator<Marker> markerIterator = markers.iterator();
399
		Marker marker;
400
		while (markerIterator.hasNext()){
401
			marker = markerIterator.next();
402
			erms.addMarker(marker);
403
		}
404

    
405
		for (Credit credit: credits){
406
			erms.addCredit(credit);
407
		}
408
		//move children to erms taxon
409
		if (faunaEu instanceof Taxon && ((Taxon)faunaEu).getTaxonNode(faunaEuClassification).hasChildNodes()) {
410
			Taxon acceptedErmsTaxon;
411
			if (erms instanceof Synonym) {
412
				acceptedErmsTaxon = ((Synonym)erms).getAcceptedTaxon();
413
			}else {
414
				acceptedErmsTaxon = (Taxon)erms;
415
			}
416
			TaxonNode node = acceptedErmsTaxon.getTaxonNode(ermsClassification);
417
			for (TaxonNode child:((Taxon)faunaEu).getTaxonNode(faunaEuClassification).getChildNodes()) {
418
				//add pesi reference as reference??
419
				node.addChildNode(child, null, null);
420
			}
421
		}
422
	}
423

    
424
	//if name, rank, and status (accepted) are the same, then move the synonyms of faunaEu taxon to the erms taxon
425

    
426
	private void moveFaunaEuSynonymsToErmsTaxon(Taxon faunaEu, Taxon erms){
427
		Set<Synonym> syns =faunaEu.getSynonyms();
428
		Iterator<Synonym> synRelIterator = syns.iterator();
429
		while (synRelIterator.hasNext()){
430
			Synonym syn = synRelIterator.next();
431
			faunaEu.removeSynonym(syn);
432
			erms.addSynonym(syn, syn.getType());
433
		}
434
	}
435

    
436
	//after merging faunaEu taxon and erms taxon, the originalSource of the faunaEu taxon has to be moved to the erms taxon
437
	private void moveOriginalDbToErmsTaxon(TaxonBase<?> faunaEuTaxon, TaxonBase<?> ermsTaxon){
438
		Set<IdentifiableSource> sourcesFaunaEu = faunaEuTaxon.getSources();
439
		IdentifiableSource sourceFaunaEu = sourcesFaunaEu.iterator().next();
440
		ermsTaxon.addSource(sourceFaunaEu);
441
	}
442

    
443
	//merged taxon should have a new sec reference
444
	private void addNewSecForMergedTaxon(Taxon taxon, Reference sec){
445
		taxon.setSec(sec);
446
		//this does not work!!
447
		//taxon.setUuid(UUID.randomUUID());
448
	}
449

    
450
	// ----------- methods for merging Erms synonyms and Fauna Europaea Taxon
451

    
452
}
(1-1/4)