Revision 3f476989
Added by Patrick Plitzner about 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateLabelProvider.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
29 | 29 |
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; |
30 | 30 |
import eu.etaxonomy.cdm.format.CdmFormatterFactory; |
31 |
import eu.etaxonomy.cdm.format.ICdmFormatter; |
|
31 | 32 |
import eu.etaxonomy.cdm.format.ICdmFormatter.FormatKey; |
32 | 33 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
33 | 34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
... | ... | |
62 | 63 |
private static Set<SingleRead> multiLinkSingleReads; |
63 | 64 |
|
64 | 65 |
private static Map<DerivedUnit, Collection<SpecimenTypeDesignation>> typeDesignations; |
66 |
|
|
67 |
private static Map<Class<? extends Object>, ICdmFormatter> formatterMap = new HashMap<>(); |
|
65 | 68 |
|
66 | 69 |
private ConversationHolder conversation; |
67 | 70 |
|
... | ... | |
135 | 138 |
if(element instanceof TreeNode){ |
136 | 139 |
element = ((TreeNode) element).getValue(); |
137 | 140 |
} |
138 |
return CdmFormatterFactory.format(element,
|
|
141 |
FormatKey[] formatKeys = {
|
|
139 | 142 |
FormatKey.GATHERING_COUNTRY, FormatKey.SPACE, |
140 | 143 |
FormatKey.GATHERING_LOCALITY_TEXT, FormatKey.SPACE, |
141 | 144 |
FormatKey.GATHERING_DATE, FormatKey.SPACE, |
... | ... | |
150 | 153 |
FormatKey.AMPLIFICATION_LABEL, FormatKey.SPACE, |
151 | 154 |
FormatKey.MEDIA_TITLE, FormatKey.SPACE, |
152 | 155 |
FormatKey.MEDIA_ARTIST, FormatKey.SPACE |
153 |
); |
|
156 |
}; |
|
157 |
ICdmFormatter formatter = formatterMap.get(element.getClass()); |
|
158 |
if(formatter==null){ |
|
159 |
formatter = CdmFormatterFactory.getFormatter(element, formatKeys); |
|
160 |
formatterMap.put(element.getClass(), formatter); |
|
161 |
} |
|
162 |
return formatter.format(element); |
|
154 | 163 |
} |
155 | 164 |
|
156 | 165 |
/** {@inheritDoc} */ |
... | ... | |
432 | 441 |
} |
433 | 442 |
|
434 | 443 |
public void updateLabelCache(Collection<SpecimenOrObservationBase<?>> rootElements) { |
435 |
DerivateLabelProvider.multiLinkSingleReads = new HashSet<SingleRead>();
|
|
436 |
DerivateLabelProvider.typeDesignations = new HashMap<DerivedUnit, Collection<SpecimenTypeDesignation>>();
|
|
444 |
multiLinkSingleReads = new HashSet<SingleRead>(); |
|
445 |
typeDesignations = new HashMap<DerivedUnit, Collection<SpecimenTypeDesignation>>(); |
|
437 | 446 |
for(Entry<SingleRead, Collection<Sequence>> entry:CdmStore.getService(ISequenceService.class).getSingleReadSequencesMap().entrySet()){ |
438 | 447 |
if(entry.getValue().size()>1){ |
439 | 448 |
multiLinkSingleReads.add(entry.getKey()); |
Also available in: Unified diff
Cache cdm formatter in DerivateLabelProvider