Revision 3e6de1b7
Added by Patrick Plitzner over 9 years ago
- fixed possible LazyInitializaitionException in DerivateLabelProvdider
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateLabelProvider.java | ||
---|---|---|
40 | 40 |
* <b>Note:</b> If you use this label provider you need to assure that you |
41 | 41 |
* created a {@link ConversationHolder} resp. have an open session because |
42 | 42 |
* the labels are generated from various fields of the derivate hierarchy which |
43 |
* are lazy loaded and could therefore throw a {@link LazyInitializationException}. |
|
43 |
* are lazy loaded and could therefore throw a {@link LazyInitializationException}.<br> |
|
44 |
* Use <b>{@link #setConversation(ConversationHolder)}</b> to assign the session to this provider. |
|
44 | 45 |
*/ |
45 | 46 |
public class DerivateLabelProvider extends ColumnLabelProvider { |
46 | 47 |
|
47 | 48 |
private Set<SingleRead> multiLinkSingleReads; |
48 | 49 |
|
50 |
private ConversationHolder conversation; |
|
51 |
|
|
49 | 52 |
private static DefinedTerm photoTerm = null; |
50 | 53 |
private static DefinedTerm drawingTerm = null; |
51 | 54 |
private static DefinedTerm specimenScanTerm = null; |
... | ... | |
110 | 113 |
return getDerivateText(element); |
111 | 114 |
} |
112 | 115 |
|
116 |
/** |
|
117 |
* @param conversation the conversation to set |
|
118 |
*/ |
|
119 |
public void setConversation(ConversationHolder conversation) { |
|
120 |
this.conversation = conversation; |
|
121 |
} |
|
122 |
|
|
113 | 123 |
/** |
114 | 124 |
* |
115 | 125 |
* @param element |
116 | 126 |
* @return |
117 | 127 |
*/ |
118 |
public static String getDerivateText(Object element){
|
|
128 |
public String getDerivateText(Object element){ |
|
119 | 129 |
if(element instanceof TreeNode){ |
120 | 130 |
//unwrap specimen from TreeNode |
121 | 131 |
element = ((TreeNode) element).getValue(); |
122 | 132 |
} |
123 | 133 |
|
134 |
conversation.bind(); |
|
135 |
|
|
124 | 136 |
String label = ""; |
125 | 137 |
if(element instanceof FieldUnit){ |
126 | 138 |
FieldUnit fieldUnit = (FieldUnit)element; |
127 |
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent(); |
|
128 |
if(gatheringEvent!=null){ |
|
139 |
if(fieldUnit.getGatheringEvent()!=null){ |
|
140 |
GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent(); |
|
141 |
if(!conversation.getSession().contains(gatheringEvent)){ |
|
142 |
fieldUnit = (FieldUnit) CdmStore.getService(IOccurrenceService.class).load(fieldUnit.getUuid()); |
|
143 |
gatheringEvent = fieldUnit.getGatheringEvent(); |
|
144 |
} |
|
129 | 145 |
label += gatheringEvent.getCountry()!=null?gatheringEvent.getCountry().getLabel()+", ":""; |
130 | 146 |
label += gatheringEvent.getLocality()!=null?gatheringEvent.getLocality().getText()+", ":""; |
131 | 147 |
label += gatheringEvent.getGatheringDate()!=null?gatheringEvent.getGatheringDate()+", ":""; |
Also available in: Unified diff