Project

General

Profile

Download (37.4 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.editor;
11

    
12
import java.util.Arrays;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Set;
16
import java.util.UUID;
17

    
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.ui.IEditorInput;
20
import org.eclipse.ui.IMemento;
21
import org.eclipse.ui.IPersistableElement;
22

    
23
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
24
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
25
import eu.etaxonomy.cdm.api.service.IClassificationService;
26
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
27
import eu.etaxonomy.cdm.api.service.ITaxonService;
28
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
29
import eu.etaxonomy.cdm.model.taxon.ITreeNode;
30
import eu.etaxonomy.cdm.model.taxon.Synonym;
31
import eu.etaxonomy.cdm.model.taxon.Taxon;
32
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
33
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
35
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
36
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
37
import eu.etaxonomy.taxeditor.model.DataChangeBridge;
38
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
39
import eu.etaxonomy.taxeditor.store.CdmStore;
40

    
41
/**
42
 * <p>TaxonEditorInput class.</p>
43
 *
44
 * @author n.hoffmann
45
 * @created 19.03.2009
46
 * @version 1.0
47
 */
48
public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPersistableElement {
49
	
50
	private ConversationHolder conversation;
51
	
52
	private TaxonNode taxonNode;
53

    
54
	private TaxonEditorInputDataChangeBehaviour dataChangeBehavior;
55
	
56
	private TaxonBase initiallySelectedTaxonBase;
57

    
58
	private Taxon taxon;
59
	
60
	private TaxonEditorInput(TaxonNode taxonNode, ConversationHolder conversation){
61
		this.conversation = conversation;
62
		this.taxonNode = taxonNode;
63
	}
64
	
65

    
66
	
67
	/**
68
	 * <p>NewInstance</p>
69
	 *
70
	 * @param taxonNodeUuid a {@link java.util.UUID} object.
71
	 * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
72
	 * @throws java.lang.Exception if any.
73
	 */
74
	public static TaxonEditorInput NewInstance(UUID taxonNodeUuid) throws Exception{
75
		try{
76
			ConversationHolder conversation = CdmStore.createConversation();
77
			return NewInstance(taxonNodeUuid, conversation);
78
		}catch(Exception e){
79
			throw e;
80
		}
81
	}
82
	
83
    /**
84
     * 
85
     * @param taxonNodeUuid
86
     * @param conversation
87
     * @return
88
     */
89
    private static TaxonEditorInput NewInstance(UUID taxonNodeUuid, ConversationHolder conversation){
90
 	
91
    	TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid);
92
		
93
		if(taxonNode == null){
94
			EditorUtil.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
95
			return null;
96
		}	
97
		
98
    	return new TaxonEditorInput(taxonNode, conversation);
99
    }
100
    
101
    /**
102
     * <p>NewInstanceFromTaxonBase</p>
103
     *
104
     * @param taxonBaseUuid a {@link java.util.UUID} object.
105
     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
106
     */
107
    public static TaxonEditorInput NewInstanceFromTaxonBase(UUID taxonBaseUuid){
108
    	ConversationHolder conversation = CdmStore.createConversation();
109
    	
110
    	TaxonEditorInput input = null;
111
    	
112
    	TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
113
    	
114
    	if(taxonBase instanceof Taxon){
115
    		Taxon taxon = (Taxon) taxonBase;
116
    		
117
    		if (taxon.isMisapplication()){
118
    			// TODO get accepted taxon
119
    			EditorUtil.info("trying to open Mispplied Name ");
120
    			
121
    			Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
122
    			Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
123
    			for(TaxonRelationship relation : relations){
124
    				if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
125
    					acceptedTaxa.add(relation.getToTaxon());
126
    				}
127
    			}
128
    			input =  getInputForMultipleTaxa(conversation, acceptedTaxa);
129
    			
130
    		}else{
131
    			input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
132
    		}
133
    	}else if(taxonBase instanceof Synonym){
134
    		Synonym synonym = (Synonym) taxonBase;
135
    		
136
    		Set<Taxon> taxa = synonym.getAcceptedTaxa();
137
    		input = getInputForMultipleTaxa(conversation, taxa);
138
    	}
139
    	
140
    	input.setInitiallySelectedTaxonBase(taxonBase);
141
    	
142
    	return input;
143
    }
144
    
145
	private static TaxonEditorInput getInputForMultipleNodes(ConversationHolder conversation, Set<TaxonNode> taxonNodes){
146
    	if(taxonNodes.size() == 1){
147
    		TaxonNode taxonNode = taxonNodes.iterator().next();
148
    		return NewInstance(taxonNode.getUuid(), conversation);
149
    	}else if(taxonNodes.size() > 1){
150
			TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(taxonNodes);
151
			if(taxonNode != null){
152
				return NewInstance(taxonNode.getUuid(), conversation);			
153
			}
154
		}else if(taxonNodes.size() == 0){
155
			// this is an undesired state
156
			EditorUtil.warningDialog("Incorrect state", TaxonEditorInput.class, "The accepted taxon is not part of any classification. This should not have happened.");
157
		}
158
    	return null;
159
    }
160
    
161
    private static TaxonEditorInput getInputForMultipleTaxa(ConversationHolder conversation, Set<Taxon> taxa){
162
    	if(taxa.size() == 1){
163
    		Taxon taxon = taxa.iterator().next();
164
    		Set<TaxonNode> nodes = taxon.getTaxonNodes();
165
    		return getInputForMultipleNodes(conversation, nodes);
166
    	}else if(taxa.size() > 1){
167
			// FIXME implement a dialog that shows all possible taxa and let the user choose which he wants to open.
168
			EditorUtil.warningDialog("Not implemented yet", TaxonEditorInput.class, "There are multiple accepted taxa for the current selection. We currently do not know which one you want to open." +
169
					" This case is not handled yet by the software.");
170
		}else if(taxa.size() == 0){
171
			// this is an undesired state
172
			EditorUtil.warningDialog("Incorrect state", TaxonEditorInput.class, "Trying to open accepted taxon for a synonym or misapplication but" +
173
					" no accepted taxa are present. This should not have happened.");
174
		}
175
    	return null;
176
    }
177
    
178
    /**
179
     * <p>NewEmptyInstance</p>
180
     *
181
     * @param parentNodeUuid a {@link java.util.UUID} object.
182
     * @return a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} object.
183
     */
184
    public static TaxonEditorInput NewEmptyInstance(UUID parentNodeUuid){
185
    	ConversationHolder conversation = CdmStore.createConversation();
186
		
187
		TaxonNameBase<?, ?> name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
188
		ITreeNode parentNode = CdmStore.getService(IClassificationService.class).getTreeNodeByUuid(parentNodeUuid);
189
		
190
		Taxon newTaxon = Taxon.NewInstance(name, parentNode.getReference());
191
		TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference(), null);
192
		
193
		// add the new taxon to the editors persistence context
194
		UUID newTaxonNodeUuid = CdmStore.getService(ITaxonNodeService.class).save(newTaxonNode);
195
		
196
		return new TaxonEditorInput(newTaxonNode, conversation);
197
    }
198
	
199
	/* (non-Javadoc)
200
	 * @see org.eclipse.ui.IEditorInput#exists()
201
	 */
202
	/**
203
	 * <p>exists</p>
204
	 *
205
	 * @return a boolean.
206
	 */
207
	public boolean exists() {
208
		return taxonNode != null;
209
	}
210

    
211
	/* (non-Javadoc)
212
	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
213
	 */
214
	/**
215
	 * <p>getImageDescriptor</p>
216
	 *
217
	 * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object.
218
	 */
219
	public ImageDescriptor getImageDescriptor() {
220
		return null;
221
	}
222

    
223
	/* (non-Javadoc)
224
	 * @see org.eclipse.ui.IEditorInput#getName()
225
	 */
226
	/**
227
	 * <p>getName</p>
228
	 *
229
	 * @return a {@link java.lang.String} object.
230
	 */
231
	public String getName() {
232
		if(getTaxon() == null){
233
			return null;
234
		}
235
		TaxonNameBase<?, ?> name = getTaxon().getName();
236
		if (name == null || name.getTitleCache() == null) {
237
			return "New taxon";
238
		} else {
239
			return name.getTitleCache();
240
		}	
241
	}
242

    
243
	/* (non-Javadoc)
244
	 * @see org.eclipse.ui.IEditorInput#getPersistable()
245
	 */
246
	/**
247
	 * <p>getPersistable</p>
248
	 *
249
	 * @return a {@link org.eclipse.ui.IPersistableElement} object.
250
	 */
251
	public IPersistableElement getPersistable() {
252
//		if(CdmStore.isActive()){
253
//			TaxonNode test = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid());
254
//			boolean isPersistable = CdmStore.getTaxonTreeService().getTaxonNodeByUuid(taxonNode.getUuid()) != null;
255
//			if (isPersistable) {
256
//				return this;
257
//			}
258
//		}
259
		return null;
260
	}
261

    
262
	/* (non-Javadoc)
263
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
264
	 */
265
	/**
266
	 * <p>getToolTipText</p>
267
	 *
268
	 * @return a {@link java.lang.String} object.
269
	 */
270
	public String getToolTipText() {
271
		return getName();
272
	}
273

    
274
	/* (non-Javadoc)
275
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
276
	 */
277
	/** {@inheritDoc} */
278
	public Object getAdapter(Class adapter) {
279

    
280
		if (adapter == Taxon.class) {
281
			return getTaxon();
282
		}
283
		
284
		if (adapter == TaxonNode.class) {
285
			return taxonNode;
286
		}
287
		
288
		return null;
289
	}
290
	
291
	/**
292
	 * {@inheritDoc}
293
	 *
294
	 * Overrides equals to ensure that a taxon can only be edited by
295
	 * one editor at a time.
296
	 */
297
	public boolean equals(Object obj) {
298
		if (TaxonEditorInput.class.equals(obj.getClass()) 
299
				&& getTaxon() != null
300
				&& getTaxon().equals(((TaxonEditorInput) obj).getTaxon())){
301
			if(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase() != null){
302
				setInitiallySelectedTaxonBase(((TaxonEditorInput) obj).getInitiallySelectedTaxonBase());
303
			}
304
			return true;
305
		}
306
		return false;
307
	}
308

    
309
	/**
310
	 * <p>getTaxon</p>
311
	 *
312
	 * @return the taxon
313
	 */
314
	public Taxon getTaxon(){
315
		if(taxon == null){
316
			List<String> TAXON_INIT_STRATEGY = Arrays.asList(new String []{
317
					// CdmBase 					: toOne-> "created, createdBy, uuid"
318
					// VersionableEntity 		: toOne-> "updated, updatedBy"
319
					// AnnotatableEntity 		: toMany-> "annotations, markers"
320
					// IdentifiableEntity		: toMany-> "credits, extensions, rights, sources" 
321
					//							: toOne-> "lsid"
322
					// TaxonBase				: toOne-> "homotypicgroup, name, sec"
323
					// Taxon					: toMany-> "descriptions, heterotypicSynonymyGroups, homotypicSynonymsByHomotypicGroup, homotypicSynonymsByHomotypicRelationship, homotypicSynonymyGroups, misappliedNames, relationsFromThisTaxon, relationsToThisTaxon, synonymNames, synonymRelations, synonyms, synonymsSortedByType, taxonNodes, taxonRelations"
324
					// Taxon					: toOne-> "imageGallery"
325
					"*",
326

    
327
					// CdmBase 					: toOne-> "created, createdBy, uuid"
328
					// VersionableEntity 		: toOne-> "updated, updatedBy"
329
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
330
					// LanguageStringBase		: toOne-> "language"
331
					// Annotation				: toOne-> "annotatedObj, annotationType, commentator, linkbackUrl
332
					"annotations.$",
333

    
334
					// CdmBase 					: toOne-> "created, createdBy, uuid"
335
					// VersionableEntity 		: toOne-> "updated, updatedBy"
336
					// Marker					: toOne-> "markedObj, markerType"	
337
					"markers.$",
338

    
339
					// CdmBase 					: toOne-> "created, createdBy, uuid"
340
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
341
					// LanguageStringBase		: toOne-> "language"
342
					// Annotation				: toOne-> "annotatedObj, annotationType, commentator, linkbackUrl
343
					// Credit					: toOne-> "agent"	
344
					"credits.$",
345

    
346
					// CdmBase 					: toOne-> "created, createdBy, uuid"
347
					// VersionableEntity 		: toOne-> "updated, updatedBy"
348
					// Extension				: toOne-> "extendedObj, type"	
349
					"extensions.$",
350

    
351
					// CdmBase 					: toOne-> "created, createdBy, uuid"
352
					// VersionableEntity 		: toOne-> "updated, updatedBy"
353
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
354
					// LanguageStringBase		: toOne-> "language"
355
					// Rights					: toOne-> "agent, type, uri"	
356
					"rights.$",
357

    
358
					// CdmBase 					: toOne-> "created, createdBy, uuid"
359
					// VersionableEntity 		: toOne-> "updated, updatedBy"
360
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
361
					// ReferencedEntityBase		: toOne-> "citation" 	
362
					// OriginalSourceBase		: 	
363
					// IdentifiableSource		: toOne-> "sourcedObj"	
364
					"sources.$",
365

    
366
					// CdmBase 					: toOne-> "created, createdBy, uuid"
367
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
368
					// HomotypicalGroup			: toMany-> "" (available: "basionymAndReplacedSynonymRelations, basionyms, basionymsOrReplacedSynonyms, nameTypeDesignations, newCombinations, replacedSynonym, specimenTypeDesignations, synonymsInGroup, typeDesignations, typifiedNames, unrelatedNames" )  
369
					"homotypicGroup.$",
370

    
371
					// CdmBase 					: toOne-> "created, createdBy, uuid"
372
					// AnnotatableEntity 		: toMany-> "" (available: "annotations, markers")
373
					// TaxonNameBase			: toMany-> "" (available: "basionyms, descriptions, nameRelations, nameTypeDesignations, relationsFromThisName, relationsToThisName, specimenTypeDesignations, specimenTypeDesignationsOfHomotypicalGroup, status, synonyms, taggedName, taxa, taxonBases, typeDesignations" ) 
374
					//							: toOne-> "basionym, citation, homotypicalGroup, nomenclaturalCode, nomenclaturalReference, rank"
375
					// ViralName 
376
					// NonViralName				: toMany->"" (available: "childRelationships, hybridChildRelations, hybridParentRelations, orderedChildRelationships, parentRelationships") 
377
					//							: toOne-> "basionymAuthorTeam, combinationAuthorTeam, exBasionymAuthorTeam, exCombinationAuthorTeam"
378
					"name.$",
379

    
380
					// CdmBase 					: toOne-> "created, createdBy, uuid"
381
					// VersionableEntity 		: toOne-> "updated, updatedBy"
382
					// AnnotatableEntity 		: toMany-> "annotations, markers"
383
					// IdentifiableEntity		: toMany-> "credits, extensions, rights, sources" 
384
					//							: toOne-> "lsid"
385
					// IdentifiableMediaEntity	: toMany->"" (available: "media") 
386
					// Reference				: toOne->"authorTeam, datePublished, inBook, inJournal, inProceedings, inReference, inSeries, institution, school, type, uri" 
387
					"sec.$",
388
					
389
					// CdmBase 					: toOne-> "created, createdBy, uuid"
390
					// AnnotatableEntity 		: toMany-> "annotations, markers"
391
					// IdentifiableEntity		: toMany-> "credits, extensions, rights, sources" 
392
					//							: toOne-> "lsid"
393
					// DescriptionBase			: toMany->"" (available: "describedSpecimenObservations, descriptiveSystem, elements, workingSets" )
394
					// TaxonDescription			: toMany->"" (available: "geoScopes, scopes" )
395
					//							: toOne-> "taxon"
396
					"descriptions.$",
397

    
398
					// CdmBase 					: toOne-> "created, createdBy, uuid"
399
					// VersionableEntity 		: toOne-> "updated, updatedBy"
400
					// AnnotatableEntity 		: toMany-> "annotations, markers"
401
					// ReferencedEntityBase		: toOne-> "citation" 	
402
					// RelationshipBase			: 
403
					// TaxonRelationship		: toOne->"fromTaxon, relatedFrom, relatedTo, toTaxon, type"
404
					"relationsFromThisTaxon.$",
405

    
406
					// CdmBase 					: toOne-> "created, createdBy, uuid"
407
					// VersionableEntity 		: toOne-> "updated, updatedBy"
408
					// AnnotatableEntity 		: toMany-> "annotations, markers"
409
					// ReferencedEntityBase		: toOne-> "citation" 	
410
					// RelationshipBase			: 
411
					// TaxonRelationship		: toOne->"fromTaxon, relatedFrom, relatedTo, toTaxon, type"
412
					"relationsToThisTaxon.$",
413

    
414
					// CdmBase 					: toOne-> "created, createdBy, uuid"
415
					// VersionableEntity 		: toOne-> "updated, updatedBy"
416
					// AnnotatableEntity 		: toMany-> "annotations, markers"
417
					// ReferencedEntityBase		: toOne-> "citation" 	
418
					// RelationshipBase			: 
419
					// SynonymRelationship		: toOne->"acceptedTaxon, relatedFrom, relatedTo, synonym, type"
420
					"synonymRelations.$",
421

    
422
					// CdmBase 					: toOne-> "created, createdBy, uuid"
423
					// VersionableEntity 		: toOne-> "updated, updatedBy"
424
					// AnnotatableEntity 		: toMany-> "annotations, markers"
425
					// IdentifiableEntity		: toMany-> "credits, extensions, rights, sources" 
426
					//							: toOne-> "lsid"
427
					// TaxonBase				: toOne-> "homotypicgroup, name, sec"
428
					// Synonym					: toMany-> "" (available: "acceptedTaxa, relationType, synonymRelations" )
429
					"synonyms.$",
430

    
431
					// TaxonNameEditor.createOrUpdateNameComposites()
432
					// ContainerFactory.createOrUpdateAcceptedTaxonsHomotypicGroup()
433
					"name.homotypicalGroup.typifiedNames.$",
434
					"name.homotypicalGroup.synonymsInGroup",
435
					"name.synonymRelations",
436
					"name.descriptions.elements.$",
437
					// ContainerFactory.createOrUpdateAcceptedTaxonsHomotypicGroup()
438
					"name.homotypicalGroup.$",
439
					"name.homotypicalGroup.typifiedNames:$",					
440
					"synonymRelations.synonym.name.$",
441
					"synonymRelations.synonym.name.descriptions.elements.$",
442
					"synonymRelations.synonym.name.homotypicalGroup.$",
443
					"synonymRelations.synonym.name.homotypicalGroup.typifiedNames.$",
444
					"synonymRelations.synonym.name.status.$",
445

    
446
					// NameEditorDropTargetListener.drop()
447
//					"name.nomenclaturalReference.$",
448
//					"synonymRelations.synonym.name.nomenclaturalReference.$",
449

    
450
					// MediaContentProvider.getImages()
451
					// DescriptionBase.getMedia()
452
					
453
					// CdmBase 					: toOne-> "created, createdBy, uuid"
454
					// VersionableEntity 		: toOne-> "updated, updatedBy"
455
					// AnnotatableEntity 		: toMany-> "annotations, markers"
456
					// DescriptionElementBase	: toMany->"" (available: "media, modifiers, modifyingText, sources" )
457
					//							: toOne-> "feature, inDescription"
458
					// CategoricalData			: toMany->"" (available: "states" )
459
					// CommonTaxaName			: toOne->"area, language"
460
					// Distribution				: toOne->"area, status"
461
					// IndividualsAssociation	: toMany->"" (available: "description" )
462
					//							: toOne-> "associatedSpecimenOrObserviation"
463
					// QuantitativeData			: toMany->"" (available: "statisticalValues" )
464
					//							: toOne-> "unit"
465
					// TaxonInteraction			: toMany->"" (available: "descriptions" )
466
					//							: toOne-> "taxon2"
467
					// TextData					: toMany->"" (available: "multilanguageText" )
468
					//							: toOne-> "format, languageText, preferredLanguageString"
469
					"descriptions.elements.$",
470
					
471
					// CdmBase 					: toOne-> "created, createdBy, uuid"
472
					// VersionableEntity 		: toOne-> "updated, updatedBy"
473
					// AnnotatableEntity 		: toMany-> "annotations, markers"
474
					// IdentifiableEntity		: toMany-> "credits, extensions, rights, sources" 
475
					//							: toOne-> "lsid"
476
					// Media					: toMany->"allDescriptions, allTitles, representations"
477
					//							: toOne-> "artist, description, mediaCreated, title"
478
		            "descriptions.elements.media.$",
479
//		            "descriptions.elements.media.allDescriptions.$",
480
					// CdmBase 					: toOne-> "created, createdBy, uuid"
481
					// VersionableEntity 		: toOne-> "updated, updatedBy"
482
		            // MediaRepresentation		: toMany-> "parts"
483
					//							: toOne-> "media"
484
		            // MediaRepresentationPart	: toOne-> "mediaRepresentation, size, uri"
485
		            "descriptions.elements.media.representations.parts.$",
486

    
487
		            "descriptions.elements.media.annotations.$",
488
		            "descriptions.elements.media.credits.$",
489
		            "descriptions.elements.media.extensions.$",
490
		            "descriptions.elements.media.markers.$",
491
		            "descriptions.elements.media.rights.$",
492
		            "descriptions.elements.media.sources.$",
493

    
494
					"descriptions.elements.states.$",
495
					"descriptions.elements.statisticalValues.$",
496
		            
497
		            
498
		            // DescriptiveContentProvider.getContainerTreeForDesription()
499
		            // FeatureNodeContainerTree.getDescriptionsElementsForFeature()		            
500
		            // DescriptionHelper.getElementText()
501

    
502
		            // CdmBase 					: toOne-> "created, createdBy, uuid"
503
					// VersionableEntity 		: toOne-> "updated, updatedBy"
504
					// AnnotatableEntity 		: toMany-> "annotations, markers"
505
					// ReferencedEntityBase		: toOne-> "citation" 	
506
					// DescriptionElementSource	: toOne-> "nameUsedInSource, sourcedObj"
507
					"descriptions.elements.sources.$",
508

    
509
					// NamedArea.labelWithLevel()
510

    
511
		            // CdmBase 					: toOne-> "created, createdBy, uuid"
512
					// VersionableEntity 		: toOne-> "updated, updatedBy"
513
					// AnnotatableEntity 		: toMany-> "annotations, markers"
514
					// ReferencedEntityBase		: toOne-> "citation" 	
515
					// NamedArea				: toMany->"" (available: "allLevelList, generalizationOf, includes, waterbodiesOrCountries" )
516
					//							: toOne-> "hierarchieList, kindOf, level, partOf, pointApproximation, shape, type, validPeriod"
517
					"descriptions.elements.area.$",
518
					
519
					// NameRelationshipDetailSection.createElementComposite()
520
					// NameRelationshipDetailElement.setEntity()
521
					"name.nameRelations.$",
522
					"name.status.$",
523
					});
524
			
525
			taxon = (Taxon) CdmStore.getService(ITaxonService.class).load(taxonNode.getTaxon().getUuid(), TAXON_INIT_STRATEGY);
526
		}
527
		
528
		return taxon;
529
	}
530

    
531
//	public Taxon getTaxon(){
532
//		if(taxon == null){
533
//			List<String> TAXON_INIT_STRATEGY = Arrays.asList(new String []{
534
//					"*",
535
//					// synonyms
536
//					"synonymRelations.synonym.name.homotypicalGroup.typifiedNames",
537
//					"synonymRelations.synonym.name.status",
538
//					"synonymRelations.synonym.name.relationsToThisName.fromTaxon.name",
539
//					// synonym name
540
//					"synonymRelations.synonym.name.descriptions.elements",
541
//					"synonymRelations.synonym.name.typeDesignations", 
542
//					"synonymRelations.synonym.name.relationsToThisName",
543
//					"synonymRelations.synonym.name.relationsFromThisName",
544
//					"synonymRelations.synonym.name.homotypicalGroup.typifiedNames",
545
//					"synonymRelations.synonym.name.rank.representations",
546
//					"synonymRelations.synonym.name.status.type.representations",
547
//					// snonym name supplemental
548
//					"synonymRelations.synonym.name.annotations",
549
//					"synonymRelations.synonym.name.annotations.annotationType",
550
//					"synonymRelations.synonym.name.annotations.commentator",
551
//					"synonymRelations.synonym.name.markers",
552
//					"synonymRelations.synonym.name.markers.markerType",
553
//					"synonymRelations.synonym.name.credits",
554
//					"synonymRelations.synonym.name.extensions",
555
//					"synonymRelations.synonym.name.rights",
556
//					"synonymRelations.synonym.name.rights.agent",
557
//					"synonymRelations.synonym.name.rights.type",
558
//					"synonymRelations.synonym.name.sources",
559
//					"synonymRelations.synonym.name.sources.citation",
560
//					"synonymRelations.synonym.name.combinationAuthor",
561
//					"synonymRelations.synonym.name.combinationAuthor.contact.addresses",
562
//					"synonymRelations.synonym.name.combinationAuthor.contact.emailAddresses",
563
//					"synonymRelations.synonym.name.combinationAuthor.contact.faxNumbers",
564
//					"synonymRelations.synonym.name.combinationAuthor.contact.phoneNumbers",
565
//					"synonymRelations.synonym.name.combinationAuthor.contact.urls",
566
//					"synonymRelations.synonym.name.combinationAuthor.institutionalMembership",
567
//					"synonymRelations.synonym.name.combinationAuthor.institutionalMembership.types",
568
//					"synonymRelations.synonym.name.exCombinationAuthor",
569
//					"synonymRelations.synonym.name.exCombinationAuthor.contact.addresses",
570
//					"synonymRelations.synonym.name.exCombinationAuthor.contact.emailAddresses",
571
//					"synonymRelations.synonym.name.exCombinationAuthor.contact.faxNumbers",
572
//					"synonymRelations.synonym.name.exCombinationAuthor.contact.phoneNumbers",
573
//					"synonymRelations.synonym.name.exCombinationAuthor.contact.urls",
574
//					"synonymRelations.synonym.name.exCombinationAuthor.institutionalMembership",
575
//					"synonymRelations.synonym.name.exCombinationAuthor.institutionalMembership.types",
576
//					"synonymRelations.synonym.name.basionymAuthor",
577
//					"synonymRelations.synonym.name.basionymAuthor.contact.addresses",
578
//					"synonymRelations.synonym.name.basionymAuthor.contact.emailAddresses",
579
//					"synonymRelations.synonym.name.basionymAuthor.contact.faxNumbers",
580
//					"synonymRelations.synonym.name.basionymAuthor.contact.phoneNumbers",
581
//					"synonymRelations.synonym.name.basionymAuthor.contact.urls",
582
//					"synonymRelations.synonym.name.basionymAuthor.institutionalMembership",
583
//					"synonymRelations.synonym.name.basionymAuthor.institutionalMembership.types",
584
//					"synonymRelations.synonym.name.exBasionymAuthor",
585
//					"synonymRelations.synonym.name.exBasionymAuthor.contact.addresses",
586
//					"synonymRelations.synonym.name.exBasionymAuthor.contact.emailAddresses",
587
//					"synonymRelations.synonym.name.exBasionymAuthor.contact.faxNumbers",
588
//					"synonymRelations.synonym.name.exBasionymAuthor.contact.phoneNumbers",
589
//					"synonymRelations.synonym.name.exBasionymAuthor.contact.urls",
590
//					"synonymRelations.synonym.name.exBasionymAuthor.institutionalMembership",
591
//					"synonymRelations.synonym.name.exBasionymAuthor.institutionalMembership.types",
592
//					"synonymRelations.synonym.name.nomenclaturalReference",
593
//					"synonymRelations.synonym.name.sec",
594
//					"synonymRelations.synonym.sec",
595
//					"synonymRelations.synonym.annotations",
596
//					"synonymRelations.synonym.annotations.annotationType",
597
//					"synonymRelations.synonym.annotations.commentator",
598
//					"synonymRelations.synonym.markers",
599
//					"synonymRelations.synonym.markers.markerType",
600
//					"synonymRelations.synonym.credits",
601
//					"synonymRelations.synonym.extensions",
602
//					"synonymRelations.synonym.rights",
603
//					"synonymRelations.synonym.rights.agent",
604
//					"synonymRelations.synonym.rights.type",
605
//					"synonymRelations.synonym.sources",
606
//					"synonymRelations.synonym.sources.citation",
607
//					//
608
//					"relationsToThisTaxon",
609
//					"relationsFromThisTaxon",
610
//					// taxon relations 
611
//					"relationsToThisName.fromTaxon.name",
612
//					// the name
613
//					"name.nomenclaturalReference",
614
//					"name.descriptions.elements",
615
//					"name.typeDesignations", 
616
//					"name.nameRelations.type",
617
//					"name.homotypicalGroup.typifiedNames",
618
//					"homotypicGroup.synonymsInGroup.synonym.sec",
619
//					"homotypicGroup.synonymsInGroup.synonym.name.nomenclaturalReference",
620
//					"homotypicGroup.synonymsInGroup.synonym.name.annotations",
621
//					"homotypicGroup.synonymsInGroup.synonym.name.annotations.annotationType",
622
//					"homotypicGroup.synonymsInGroup.synonym.name.annotations.commentator",
623
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor",
624
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.contact.addresses",
625
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.contact.emailAddresses",
626
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.contact.faxNumbers",
627
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.contact.phoneNumbers",
628
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.contact.urls",
629
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.institutionalMembership",
630
//					"homotypicGroup.synonymsInGroup.synonym.name.combinationAuthor.institutionalMembership.types",
631
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor",
632
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.contact.addresses",
633
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.contact.emailAddresses",
634
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.contact.faxNumbers",
635
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.contact.phoneNumbers",
636
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.contact.urls",
637
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.institutionalMembership",
638
//					"homotypicGroup.synonymsInGroup.synonym.name.exCombinationAuthor.institutionalMembership.types",
639
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor",
640
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.contact.addresses",
641
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.contact.emailAddresses",
642
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.contact.faxNumbers",
643
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.contact.phoneNumbers",
644
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.contact.urls",
645
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.institutionalMembership",
646
//					"homotypicGroup.synonymsInGroup.synonym.name.basionymAuthor.institutionalMembership.types",
647
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor",
648
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.contact.addresses",
649
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.contact.emailAddresses",
650
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.contact.faxNumbers",
651
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.contact.phoneNumbers",
652
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.contact.urls",
653
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.institutionalMembership",
654
//					"homotypicGroup.synonymsInGroup.synonym.name.exBasionymAuthor.institutionalMembership.types",
655
//					"homotypicGroup.synonymsInGroup.synonym.name.rights",
656
//					"homotypicGroup.synonymsInGroup.synonym.name.rights.agent",
657
//					"homotypicGroup.synonymsInGroup.synonym.name.rights.type",
658
//					"homotypicGroup.synonymsInGroup.synonym.annotations.annotationType",
659
//					"homotypicGroup.synonymsInGroup.synonym.annotations.commentator",
660
//					"name.rank.representations",
661
//					"name.status.type.representations",
662
//					// name supplemental
663
//					"name.combinationAuthor",
664
//					"name.combinationAuthor.contact.addresses",
665
//					"name.combinationAuthor.contact.emailAddresses",
666
//					"name.combinationAuthor.contact.faxNumbers",
667
//					"name.combinationAuthor.contact.phoneNumbers",
668
//					"name.combinationAuthor.contact.urls",
669
//					"name.combinationAuthor.institutionalMembership",
670
//					"name.combinationAuthor.institutionalMembership.types",
671
//					"name.exCombinationAuthor",
672
//					"name.exCombinationAuthor.contact.addresses",
673
//					"name.exCombinationAuthor.contact.emailAddresses",
674
//					"name.exCombinationAuthor.contact.faxNumbers",
675
//					"name.exCombinationAuthor.contact.phoneNumbers",
676
//					"name.exCombinationAuthor.contact.urls",
677
//					"name.exCombinationAuthor.institutionalMembership",
678
//					"name.exCombinationAuthor.institutionalMembership.types",
679
//					"name.basionymAuthor",
680
//					"name.basionymAuthor.contact.addresses",
681
//					"name.basionymAuthor.contact.emailAddresses",
682
//					"name.basionymAuthor.contact.faxNumbers",
683
//					"name.basionymAuthor.contact.phoneNumbers",
684
//					"name.basionymAuthor.contact.urls",
685
//					"name.basionymAuthor.institutionalMembership",
686
//					"name.basionymAuthor.institutionalMembership.types",
687
//					"name.exBasionymAuthor",
688
//					"name.exBasionymAuthor.contact.addresses",
689
//					"name.exBasionymAuthor.contact.emailAddresses",
690
//					"name.exBasionymAuthor.contact.faxNumbers",
691
//					"name.exBasionymAuthor.contact.phoneNumbers",
692
//					"name.exBasionymAuthor.contact.urls",
693
//					"name.exBasionymAuthor.institutionalMembership",
694
//					"name.exBasionymAuthor.institutionalMembership.types",
695
//					"name.nomenclaturalReference",
696
//					"name.annotations",
697
//					"name.annotations.annotationType",
698
//					"name.annotations.commentator",
699
//					"name.markers",
700
//					"name.markers.markerType",
701
//					"name.credits",
702
//					"name.extensions",
703
//					"name.rights",
704
//					"name.rights.agent",
705
//					"name.rights.type",
706
//					"name.sources",
707
//					"name.sources.citation",
708
//					"media.annotations",
709
//					"media.annotations.annotationType",
710
//					"media.annotations.commentator",
711
//					"media.markers",
712
//					"media.markers.markerType",
713
//					"media.credits",
714
//					"media.extensions",
715
//					"media.rights",
716
//					"media.rights.type",
717
//					"media.rights.agent",
718
//					"media.sources",
719
//					"media.sources.citation",
720
//					"media.representations",
721
//					"media.representations.parts",
722
//					"media.title",
723
//					"media.allDescriptions",
724
////					"media.representations.mediaRepresentationParts.mediaRepresentation",
725
//					"rights.type",
726
//					"rights.agent",
727
//					// taxon descriptions
728
//					"descriptions.describedSpecimenOrObservations",
729
//					"descriptions.sources",
730
//					"descriptions.sources.citation",
731
//					"descriptions.scopes",
732
//					// taxon description supplemental
733
//					"descriptions.annotations",
734
//					"descriptions.annotations.annotationType",
735
//					"descriptions.annotations.commentator",
736
//					"descriptions.markers",
737
//					"descriptions.markers.markerType",
738
//					"descriptions.credits",
739
//					"descriptions.extensions",
740
//					"descriptions.rights",
741
//					// description elements
742
//					"descriptions.elements.*",
743
//					"descriptions.elements.media",
744
//					"descriptions.elements.media.title",
745
//					"descriptions.elements.media.allDescriptions",
746
//					"descriptions.elements.media.representations",
747
//					"descriptions.elements.media.representations.parts",
748
////					"descriptions.elements.media.representations.mediaRepresentationParts.mediaRepresentation",
749
//					"descriptions.elements.modifiers",
750
//					"descriptions.elements.modifyingText",
751
//					"descriptions.elements.sources",
752
//					"descriptions.elements.sources.citation",
753
//					"descriptions.elements.sources.nameUsedInSource",
754
//					"descriptions.elements.area.$",
755
//					"descriptions.elements.multilanguageText",
756
//					"descriptions.elements.media",
757
//					"descriptions.elements.media.annotations",
758
//					"descriptions.elements.media.annotations.annotationType",
759
//					"descriptions.elements.media.annotations.commentator",
760
//					"descriptions.elements.media.markers",
761
//					"descriptions.elements.media.markers.markerType",
762
//					"descriptions.elements.media.credits",
763
//					"descriptions.elements.media.extensions",
764
//					"descriptions.elements.media.rights",
765
//					"descriptions.elements.media.rights.type",
766
//					"descriptions.elements.media.rights.agent",
767
//					"descriptions.elements.media.sources",
768
//					"descriptions.elements.media.sources.citation",
769
//					// descriptin element supplemental
770
//					"descriptions.elements.annotations",
771
//					"descriptions.elements.annotations.annotationType",
772
//					"descriptions.elements.annotations.commentator",
773
//					"descriptions.elements.markers",
774
//					"descriptions.elements.markers.markerType",
775
//					"descriptions.elements.credits",
776
//					"descriptions.elements.extensions",
777
//					"descriptions.elements.rights",
778
//					"descriptions.elements.sources",
779
//					"descriptions.elements.sources.citation",
780
//					"descriptions.elements.sources.annotations",
781
//					"descriptions.elements.sources.annotations.annotationType",
782
//					"descriptions.elements.sources.markers",
783
//					"descriptions.elements.sources.markers.markerType",
784
//					// supplemental
785
//					"annotations.annotationType",
786
//					"annotations.commentator",
787
//					"markers",
788
//					"markers.markerType",
789
//					"credits",
790
//					"extensions",
791
//					"rights",
792
//					"sources",
793
//					"sources.citation",
794
//					"sec",
795
//					"authorTeam",
796
//					"authorTeam.contact.addresses",
797
//					"authorTeam.contact.emailAddresses",
798
//					"authorTeam.contact.faxNumbers",
799
//					"authorTeam.contact.phoneNumbers",
800
//					"authorTeam.contact.urls",
801
//					"authorTeam.institutionalMembership",
802
//					"authorTeam.institutionalMembership.types",
803
//					"authorTeam.teamMembers",
804
//					"authorTeam.teamMembers.institutionalMembership",
805
//					"authorTeam.teamMembers.institutionalMembership.types",
806
//					"agent",
807
//					"agent.contact.addresses",
808
//					"agent.contact.emailAddresses",
809
//					"agent.contact.faxNumbers",
810
//					"agent.contact.phoneNumbers",
811
//					"agent.contact.urls",
812
//					"agent.institutionalMembership",
813
//					"agent.institutionalMembership.types",
814
//					"agent.teamMembers",
815
//					"agent.teamMembers.institutionalMembership",
816
//					"agent.teamMembers.institutionalMembership.types"
817
//					});
818
//			
819
//			taxon = (Taxon) CdmStore.getService(ITaxonService.class).load(taxonNode.getTaxon().getUuid(), TAXON_INIT_STRATEGY);
820
//		}
821
//		
822
//		return taxon;
823
//	}
824
	
825
	/**
826
	 * <p>Getter for the field <code>taxonNode</code>.</p>
827
	 *
828
	 * @return the taxonNode
829
	 */
830
	public TaxonNode getTaxonNode() {
831
		return taxonNode;
832
	}
833
	
834
	/*
835
	 * (non-Javadoc)
836
	 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
837
	 */
838
	/**
839
	 * <p>getConversationHolder</p>
840
	 *
841
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
842
	 */
843
	public ConversationHolder getConversationHolder() {
844
		return conversation;
845
	}
846

    
847
	/*
848
	 * (non-Javadoc)
849
	 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
850
	 */
851
	/** {@inheritDoc} */
852
	public void update(CdmDataChangeMap events) {
853
		if(dataChangeBehavior == null){
854
			dataChangeBehavior = new TaxonEditorInputDataChangeBehaviour(this);
855
		}
856
		
857
		DataChangeBridge.handleDataChange(events, dataChangeBehavior);
858
	}
859

    
860
	/* (non-Javadoc)
861
	 * @see org.eclipse.ui.IPersistableElement#getFactoryId()
862
	 */
863
	/**
864
	 * <p>getFactoryId</p>
865
	 *
866
	 * @return a {@link java.lang.String} object.
867
	 */
868
	public String getFactoryId() {
869
		return TaxonEditorInputFactory.getFactoryId();
870
	}
871

    
872
	/* (non-Javadoc)
873
	 * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
874
	 */
875
	/** {@inheritDoc} */
876
	public void saveState(IMemento memento) {
877
		TaxonEditorInputFactory.saveState(memento, this);
878
	}
879

    
880
    
881
    /**
882
     * <p>Setter for the field <code>initiallySelectedTaxonBase</code>.</p>
883
     *
884
     * @param taxonBase a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
885
     */
886
    public void setInitiallySelectedTaxonBase(TaxonBase taxonBase) {
887
		this.initiallySelectedTaxonBase = taxonBase;
888
	}
889

    
890
	/**
891
	 * <p>Getter for the field <code>initiallySelectedTaxonBase</code>.</p>
892
	 *
893
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonBase} object.
894
	 */
895
	public TaxonBase getInitiallySelectedTaxonBase() {
896
		return initiallySelectedTaxonBase;
897
	}
898
}
(13-13/16)