Project

General

Profile

Download (23.4 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2013 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
package eu.etaxonomy.taxeditor.view.derivateSearch;
10

    
11
import java.util.ArrayList;
12
import java.util.Collection;
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Map.Entry;
18
import java.util.Set;
19
import java.util.UUID;
20

    
21
import org.eclipse.jface.viewers.ColumnLabelProvider;
22
import org.eclipse.jface.viewers.TreeNode;
23
import org.eclipse.swt.graphics.Image;
24
import org.hibernate.LazyInitializationException;
25

    
26
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
27
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
28
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
29
import eu.etaxonomy.cdm.common.CdmUtils;
30
import eu.etaxonomy.cdm.format.CdmFormatterFactory;
31
import eu.etaxonomy.cdm.format.ICdmFormatter.FormatKey;
32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
33
import eu.etaxonomy.cdm.model.common.CdmBase;
34
import eu.etaxonomy.cdm.model.common.DefinedTerm;
35
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
36
import eu.etaxonomy.cdm.model.common.Identifier;
37
import eu.etaxonomy.cdm.model.molecular.DnaSample;
38
import eu.etaxonomy.cdm.model.molecular.Sequence;
39
import eu.etaxonomy.cdm.model.molecular.SingleRead;
40
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
41
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
42
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
43
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
44
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
45
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
46
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
47
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
48
import eu.etaxonomy.taxeditor.model.ImageResources;
49
import eu.etaxonomy.taxeditor.store.CdmStore;
50

    
51
/**
52
 * Label provider for the views to show {@link SpecimenOrObservationBase}s.<br>
53
 * <br>
54
 * <b>Note:</b> If you use this label provider you need to assure that you
55
 * created a {@link ConversationHolder} resp. have an open session because
56
 * the labels are generated from various fields of the derivate hierarchy which
57
 * are lazy loaded and could therefore throw a {@link LazyInitializationException}.<br>
58
 * Use <b>{@link #setConversation(ConversationHolder)}</b> to assign the session to this provider.
59
 */
60
public class DerivateLabelProvider extends ColumnLabelProvider {
61

    
62
    private static final String NO_SAMPLE_DESIGNATION = "[no sample designation]";
63

    
64
    private static Set<SingleRead> multiLinkSingleReads;
65

    
66
    private static Map<DerivedUnit, Collection<SpecimenTypeDesignation>> typeDesignations;
67

    
68
    private ConversationHolder conversation;
69

    
70
    private static DefinedTerm photoTerm = null;
71
    private static DefinedTerm drawingTerm = null;
72
    private static DefinedTerm specimenScanTerm = null;
73
    private static DefinedTerm detailImageTerm = null;
74
    private static DefinedTerm sampleDesignationTerm = null;
75

    
76
    //FIXME: move static term getters to new singleton utility class
77
    private static void initializeTerms() {
78
        List<DefinedTerm> preferredTerms = CdmStore.getTermManager().getPreferredTerms(DefinedTerm.class);
79
        for (DefinedTerm definedTerm : preferredTerms) {
80
            if(definedTerm.getUuid().equals(UUID.fromString("c5c59c42-f254-471e-96c6-09f459f7c903"))){
81
                photoTerm = definedTerm;
82
            }
83
            else if(definedTerm.getUuid().equals(UUID.fromString("669b0409-4aa4-4695-aae4-a95ed27bad4c"))){
84
                drawingTerm = definedTerm;
85
            }
86
            else if(definedTerm.getUuid().equals(UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03"))){
87
                specimenScanTerm = definedTerm;
88
            }
89
            else if(definedTerm.getUuid().equals(UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34"))){
90
                detailImageTerm = definedTerm;
91
            }
92
            else if(definedTerm.getUuid().equals(UUID.fromString("fadeba12-1be3-4bc7-9ff5-361b088d86fc"))){
93
                sampleDesignationTerm = definedTerm;
94
            }
95
        }
96
    }
97

    
98
    public static DefinedTerm getLivingPlantPhotoTerm(){
99
        if(photoTerm==null){
100
            initializeTerms();
101
        }
102
        return photoTerm;
103
    }
104

    
105
    public static DefinedTerm getArtworkTerm(){
106
        if(drawingTerm==null){
107
            initializeTerms();
108
        }
109
        return drawingTerm;
110
    }
111

    
112
    public static DefinedTerm getSpecimenScanTerm(){
113
        if(specimenScanTerm==null){
114
            initializeTerms();
115
        }
116
        return specimenScanTerm;
117
    }
118

    
119
    public static DefinedTerm getDetailImageTerm(){
120
        if(detailImageTerm==null){
121
            initializeTerms();
122
        }
123
        return detailImageTerm;
124
    }
125

    
126
    public static DefinedTerm getSampleDesignationTerm(){
127
        if(sampleDesignationTerm==null){
128
            initializeTerms();
129
        }
130
        return sampleDesignationTerm;
131
    }
132

    
133

    
134
    /** {@inheritDoc} */
135
    @Override
136
    public String getText(Object element) {
137
        if(element instanceof TreeNode){
138
            element = ((TreeNode) element).getValue();
139
        }
140
        //Use titlecache for FieldUnits
141
        if(element instanceof FieldUnit){
142
            return ((FieldUnit) element).getTitleCache();
143
        }
144
        FormatKey[] formatKeys = {
145
                FormatKey.GATHERING_COUNTRY, FormatKey.SPACE,
146
                FormatKey.GATHERING_LOCALITY_TEXT, FormatKey.SPACE,
147
                FormatKey.GATHERING_DATE, FormatKey.SPACE,
148
                FormatKey.GATHERING_COLLECTOR, FormatKey.SPACE,
149
                FormatKey.FIELD_NUMBER, FormatKey.SPACE,
150
                FormatKey.COLLECTION_CODE, FormatKey.SPACE,
151
                FormatKey.MOST_SIGNIFICANT_IDENTIFIER, FormatKey.SPACE,
152
//                FormatKey.KIND_OF_UNIT, FormatKey.SPACE,
153
                FormatKey.SAMPLE_DESIGNATION, FormatKey.SPACE,
154
                FormatKey.SINGLE_READ_PHEROGRAM_TITLE_CACHE, FormatKey.SPACE,
155
                FormatKey.SEQUENCE_DNA_MARKER, FormatKey.SPACE,
156
                FormatKey.AMPLIFICATION_LABEL, FormatKey.SPACE,
157
                FormatKey.MEDIA_TITLE, FormatKey.SPACE,
158
                FormatKey.MEDIA_ARTIST, FormatKey.SPACE
159
        };
160
        String text = CdmFormatterFactory.format(element, formatKeys);
161
        if(element instanceof MediaSpecimen){
162
            formatKeys = new FormatKey[]{FormatKey.MEDIA_TITLE_CACHE};
163
            text = CdmFormatterFactory.format(element, formatKeys);
164
        }
165
        else if(element instanceof IdentifiableEntity){
166
        	IdentifiableEntity identifiableEntity = (IdentifiableEntity) element;
167
        	if(identifiableEntity.isProtectedTitleCache()){
168
        		text = identifiableEntity.getTitleCache();
169
        	}
170
        }
171
        if(CdmUtils.isBlank(text) || text.equals(IdentifiableEntityDefaultCacheStrategy.TITLE_CACHE_GENERATION_NOT_IMPLEMENTED)){
172
            if(element instanceof CdmBase){
173
                text = ((CdmBase) element).getUuid().toString();
174
            }
175
            else{
176
                text = element.toString();
177
            }
178
        }
179
		return text;
180
    }
181

    
182
    /** {@inheritDoc} */
183
    @Override
184
    public String getToolTipText(Object element) {
185
        return getDerivateText(element);
186
    }
187

    
188
    /**
189
     * @param conversation the conversation to set
190
     */
191
    public void setConversation(ConversationHolder conversation) {
192
        this.conversation = conversation;
193
    }
194

    
195
    public String getDerivateText(Object element){
196
        return getDerivateText(element, conversation);
197
    }
198

    
199
    public static String getDerivateText(Object element, ConversationHolder conversation){
200
        //TODO: use list of strings to assemble labels to avoid adding the separator every time and to allow null values
201
        TreeNode parentNode = null;
202
        TreeNode node = null;
203
        Object derivate = element;
204
        if(element instanceof TreeNode){
205
            node = (TreeNode) element;
206
            parentNode = node.getParent();
207
            //unwrap specimen from TreeNode
208
            derivate = node.getValue();
209
        }
210

    
211
        if(conversation!=null){
212
            conversation.bind();
213
        }
214

    
215
        final String emptyString = "";
216
        final String separator = " ";
217

    
218
        String label = emptyString;
219

    
220
        //Field Unit
221
        if(derivate instanceof FieldUnit){
222
            FieldUnit fieldUnit = (FieldUnit)derivate;
223
            if(fieldUnit.getGatheringEvent()!=null){
224
                GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
225
                label += gatheringEvent.getCountry()!=null?gatheringEvent.getCountry().getLabel()+separator:emptyString;
226
                label += gatheringEvent.getLocality()!=null?gatheringEvent.getLocality().getText()+separator:emptyString;
227
                label += gatheringEvent.getGatheringDate()!=null?gatheringEvent.getGatheringDate()+separator:emptyString;
228
                label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
229
            }
230
            label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber():emptyString;
231
        }
232
        //MediaSpecimen
233
        else if(derivate instanceof MediaSpecimen){
234
            MediaSpecimen mediaSpecimen = (MediaSpecimen)derivate;
235
            if(mediaSpecimen.getMediaSpecimen()!=null){
236
                label += mediaSpecimen.getMediaSpecimen().getTitle()!=null?mediaSpecimen.getMediaSpecimen().getTitle().getText()+separator:"[no motif]";
237
                label += mediaSpecimen.getMediaSpecimen().getArtist()!=null?mediaSpecimen.getMediaSpecimen().getArtist()+separator:emptyString;
238
            }
239
            eu.etaxonomy.cdm.model.occurrence.Collection collection = mediaSpecimen.getCollection();
240
            if(collection!=null){
241
                label += collection.getName()!=null?collection.getName()+" ":emptyString;
242
                label += collection.getCode()!=null?"("+collection.getCode()+")"+separator:emptyString;
243
            }
244
            label += mediaSpecimen.getAccessionNumber()!=null?mediaSpecimen.getAccessionNumber()+separator:emptyString;
245
            label += mediaSpecimen.getBarcode()!=null?mediaSpecimen.getBarcode()+separator:emptyString;
246
        }
247
        //TissueSample + DnaSample
248
        else if(derivate instanceof DnaSample){
249
            DnaSample dnaSample = (DnaSample)derivate;
250
            if(((DnaSample) derivate).getRecordBasis()==SpecimenOrObservationType.DnaSample){
251
                Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(dnaSample);
252
                if(currentSampleDesignation!=null && currentSampleDesignation.getIdentifier()!=null){
253
                    label += currentSampleDesignation.getIdentifier()+separator;
254
                }
255
                else{
256
                    label += NO_SAMPLE_DESIGNATION+separator;
257
                }
258
            }
259
            else if(((DnaSample) derivate).getRecordBasis()==SpecimenOrObservationType.TissueSample){
260
                if(dnaSample.getKindOfUnit()!=null){
261
                    label += dnaSample.getKindOfUnit()+separator;
262
                }
263
                Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(dnaSample);
264
                if(currentSampleDesignation!=null && currentSampleDesignation.getIdentifier()!=null){
265
                    label += currentSampleDesignation.getIdentifier()+separator;
266
                }
267
                else{
268
                    label += NO_SAMPLE_DESIGNATION+separator;
269
                }
270
            }
271

    
272
        }
273
        //DerivedUnit + TissueSample
274
        else if(derivate instanceof DerivedUnit){
275
            DerivedUnit derivedUnit = (DerivedUnit)derivate;
276
            if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
277
                //check for type designation
278
                if(typeDesignations.get(derivedUnit)==null){
279
                    for (SpecimenTypeDesignation specimenTypeDesignation : derivedUnit.getSpecimenTypeDesignations()) {
280
                        addTypeDesignation(derivedUnit, specimenTypeDesignation);
281
                    }
282
                }
283
                //java.util.Collection<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).getFieldUnits(derivedUnit.getUuid());
284
                //TODO : This is not generic anymore for performance reasons
285
                Set<SpecimenOrObservationBase> originals = derivedUnit.getOriginals();
286
                if(originals!=null && originals.size() ==1) {
287
                    SpecimenOrObservationBase specimen = originals.iterator().next();
288
                    if(specimen instanceof FieldUnit) {
289
                        FieldUnit fieldUnit = (FieldUnit)specimen;
290
                        GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
291
                        if(gatheringEvent!=null){
292
                            label += gatheringEvent.getCollector()!=null?gatheringEvent.getCollector()+separator:emptyString;
293
                        }
294
                        label += fieldUnit.getFieldNumber()!=null?fieldUnit.getFieldNumber()+separator:emptyString;
295
                    }
296
                }
297

    
298
                eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
299
                if(collection!=null){
300
                    label += collection.getCode()!=null?"("+collection.getCode()+")"+separator:emptyString;
301
                }
302
                String mostSignificantIdentifier = derivedUnit.getMostSignificantIdentifier();
303
                label += mostSignificantIdentifier!=null?mostSignificantIdentifier+separator:emptyString;
304
            }
305
            else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
306
                //TissueSample should only be created by using it's own class
307
                //in future using only one class with different SpecimenOrObservationTypes is desired
308
//                label += derivedUnit.getKindOfUnit() + NO_SAMPLE_DESIGNATION;
309
            }
310
        }
311
        //Sequence
312
        else if(derivate instanceof Sequence){
313
            Sequence sequence = (Sequence)derivate;
314
            Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(sequence);
315
            if(currentSampleDesignation!=null && currentSampleDesignation.getIdentifier()!=null){
316
                label += currentSampleDesignation.getIdentifier()+separator;
317
            }
318
            else{
319
                label += NO_SAMPLE_DESIGNATION+separator;
320
            }
321
            label += sequence.getDnaMarker()!=null?sequence.getDnaMarker():emptyString;
322
        }
323
        //SingleRead
324
        else if(derivate instanceof SingleRead){
325
            SingleRead singleRead = (SingleRead)derivate;
326
            if(parentNode!=null && parentNode.getValue() instanceof Sequence){
327
                Sequence sequence = (Sequence) parentNode.getValue();
328
                Identifier<DnaSample> currentSampleDesignation = getCurrentSampleDesignation(sequence);
329
                if(currentSampleDesignation!=null && currentSampleDesignation.getIdentifier()!=null){
330
                    label = currentSampleDesignation.getIdentifier()+separator;
331
                }
332
                else{
333
                    label += NO_SAMPLE_DESIGNATION+separator;
334
                }
335
                label += singleRead.getPrimer()!=null?singleRead.getPrimer().getLabel()+separator:emptyString;
336
                if(sequence!=null && sequence.getDnaMarker()!=null){
337
                    label += sequence.getDnaMarker()+separator;
338
                }
339
                if(singleRead.getAmplificationResult()!=null && singleRead.getAmplificationResult().getAmplification()!=null){
340
                    label += singleRead.getAmplificationResult().getAmplification().getLabelCache()+separator;
341
                }
342
            }
343
        }
344
        //SOOB
345
        else if(derivate instanceof SpecimenOrObservationBase){
346
            SpecimenOrObservationBase<?> specimen = (SpecimenOrObservationBase<?>) derivate;
347
            SpecimenOrObservationType type = specimen.getRecordBasis();
348
            return specimen.getTitleCache() + (type!=null?" ["+type.toString()+"]":emptyString);
349
        }
350
        if(label.isEmpty()){
351
            label = derivate.toString();
352
        }
353
        //remove last comma
354
        else if(label.endsWith(separator)){
355
            label = label.substring(0, label.length()-separator.length());
356
        }
357
        return label;
358
    }
359

    
360
    @Override
361
    public Image getImage(Object element) {
362
        if(element instanceof TreeNode){
363
            element = ((TreeNode) element).getValue();
364
        }
365
        if(element instanceof CdmBase){
366
            CdmBase cdmBase = (CdmBase)element;
367
            boolean hasCharacterData = false;
368
            if(cdmBase.isInstanceOf(SpecimenOrObservationBase.class)){
369
                SpecimenOrObservationBase<?> specimen = HibernateProxyHelper.deproxy(cdmBase, SpecimenOrObservationBase.class);
370
                if(specimen.hasCharacterData()){
371
                    hasCharacterData = true;
372
                }
373
            }
374
            if(cdmBase.isInstanceOf(FieldUnit.class)){
375
                return hasCharacterData?ImageResources.getImage(ImageResources.FIELD_UNIT_CHARACTER_DATA):ImageResources.getImage(ImageResources.FIELD_UNIT);
376
            }
377
            else if(cdmBase.isInstanceOf(DerivedUnit.class)){
378
                DerivedUnit derivedUnit = HibernateProxyHelper.deproxy(element, DerivedUnit.class);
379

    
380
                if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.FieldUnit){
381
                    return hasCharacterData?ImageResources.getImage(ImageResources.FIELD_UNIT_CHARACTER_DATA):ImageResources.getImage(ImageResources.FIELD_UNIT);
382
                }
383
                else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.DnaSample){
384
                    return hasCharacterData?ImageResources.getImage(ImageResources.DNA_SAMPLE_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.DNA_SAMPLE_DERIVATE);
385
                }
386
                else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.TissueSample){
387
                    return hasCharacterData?ImageResources.getImage(ImageResources.TISSUE_SAMPLE_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.TISSUE_SAMPLE_DERIVATE);
388
                }
389
                else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
390
                    if(typeDesignations.get(derivedUnit)!=null && !typeDesignations.get(derivedUnit).isEmpty()){
391
                        return ImageResources.getImage(ImageResources.SPECIMEN_DERIVATE_TYPE);
392
                    }
393
                    return hasCharacterData?ImageResources.getImage(ImageResources.SPECIMEN_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.SPECIMEN_DERIVATE);
394
                }
395
                else if(derivedUnit.getRecordBasis().isMedia()
396
                        || derivedUnit.getRecordBasis().isKindOf(SpecimenOrObservationType.Media)){
397
                    if(derivedUnit.getKindOfUnit()!=null){
398
                        if(derivedUnit.getKindOfUnit().equals(getArtworkTerm())){
399
                            return hasCharacterData?ImageResources.getImage(ImageResources.ARTWORK_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.ARTWORK_DERIVATE);
400
                        }
401
                        else if(derivedUnit.getKindOfUnit().equals(getLivingPlantPhotoTerm())){
402
                            return hasCharacterData?ImageResources.getImage(ImageResources.LIVING_PLANT_PHOTO_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.LIVING_PLANT_PHOTO_DERIVATE);
403
                        }
404
                        else if(derivedUnit.getKindOfUnit().equals(getSpecimenScanTerm())){
405
                            return hasCharacterData?ImageResources.getImage(ImageResources.SPECIMEN_SCAN_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.SPECIMEN_SCAN_DERIVATE);
406
                        }
407
                        else if(derivedUnit.getKindOfUnit().equals(getDetailImageTerm())){
408
                            return hasCharacterData?ImageResources.getImage(ImageResources.DETAIL_IMAGE_DERIVATE_CHARACTER_DATA):ImageResources.getImage(ImageResources.DETAIL_IMAGE_DERIVATE);
409
                        }
410
                    }
411
                }
412
            }
413
            else if(cdmBase.isInstanceOf(Sequence.class)){
414
                return ImageResources.getImage(ImageResources.SEQUENCE_DERIVATE);
415
            }
416

    
417
            else if(cdmBase.isInstanceOf(SingleRead.class)){
418
                if(multiLinkSingleReads!=null && multiLinkSingleReads.contains(element)){
419
                    return ImageResources.getImage(ImageResources.SINGLE_READ_DERIVATE_MULTILINK);
420
                }
421
                else{
422
                    return ImageResources.getImage(ImageResources.SINGLE_READ_DERIVATE);
423
                }
424
            }
425
        }
426
        return ImageResources.getImage(ImageResources.DEFAULT_DERIVATIVE);
427
    }
428

    
429
    public static Identifier<DnaSample> getCurrentSampleDesignation(CdmBase entity) {
430
        if(entity.isInstanceOf(DnaSample.class)){
431
            DnaSample dnaSample = HibernateProxyHelper.deproxy(entity, DnaSample.class);
432
            for (Identifier<DnaSample> identifier : dnaSample.getIdentifiers()) {
433
                if(identifier.getType()!=null && identifier.getType().equals(DerivateLabelProvider.getSampleDesignationTerm())){
434
                    //first sample designation is the current
435
                    return identifier;
436
                }
437
            }
438
        }
439
        else if(entity.isInstanceOf(Sequence.class)){
440
            Sequence sequence = HibernateProxyHelper.deproxy(entity, Sequence.class);
441
            if(sequence.getDnaSample()!=null){
442
                return getCurrentSampleDesignation(sequence.getDnaSample());
443
            }
444
        }
445
        return null;
446
    }
447

    
448
    private static void addTypeDesignation(DerivedUnit derivedUnit, SpecimenTypeDesignation typeDesignation){
449
        Collection<SpecimenTypeDesignation> list = typeDesignations.get(derivedUnit);
450
        if(list==null){
451
            list = new ArrayList<SpecimenTypeDesignation>();
452
        }
453
        list.add(typeDesignation);
454
        typeDesignations.put(derivedUnit, list);
455
    }
456

    
457
    public static Set<SingleRead> getMultiLinkSingleReads() {
458
        return multiLinkSingleReads;
459
    }
460

    
461
    public void updateLabelCache(Collection<SpecimenOrObservationBase<?>> rootElements) {
462
        multiLinkSingleReads = new HashSet<SingleRead>();
463
        typeDesignations = new HashMap<DerivedUnit, Collection<SpecimenTypeDesignation>>();
464
        for(Entry<SingleRead, Collection<Sequence>> entry:CdmStore.getService(ISequenceService.class).getSingleReadSequencesMap().entrySet()){
465
            if(entry.getValue().size()>1){
466
                multiLinkSingleReads.add(entry.getKey());
467
            }
468
        }
469
        if(rootElements!=null){
470
            Collection<DerivedUnit> derivedUnits = new ArrayList<DerivedUnit>();
471
            for (SpecimenOrObservationBase specimenOrObservationBase : rootElements) {
472
                derivedUnits.addAll(CdmStore.getService(IOccurrenceService.class).getAllChildDerivatives(specimenOrObservationBase.getUuid()));
473
                if(specimenOrObservationBase.isInstanceOf(DerivedUnit.class)){
474
                    derivedUnits.add(HibernateProxyHelper.deproxy(specimenOrObservationBase, DerivedUnit.class));
475
                }
476
            }
477
            for (DerivedUnit derivedUnit : derivedUnits) {
478
                if(!derivedUnit.getSpecimenTypeDesignations().isEmpty()){
479
                    typeDesignations.put(derivedUnit, derivedUnit.getSpecimenTypeDesignations());
480
                }
481
            }
482
        }
483
    }
484

    
485
}
(2-2/2)