Project

General

Profile

« Previous | Next » 

Revision cedc4ff1

Added by Katja Luther about 6 years ago

ref #2380: implement usage of Dto for taxon navigator

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java
17 17
import org.eclipse.swt.graphics.Image;
18 18
import org.eclipse.swt.graphics.TextStyle;
19 19
import org.eclipse.ui.navigator.IDescriptionProvider;
20
import org.hibernate.LazyInitializationException;
21 20

  
22
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
23 21
import eu.etaxonomy.cdm.model.common.CdmBase;
24
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
25 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
26 23
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27
import eu.etaxonomy.taxeditor.model.MessagingUtils;
24
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
28 25
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
29 26
import eu.etaxonomy.taxeditor.preference.Resources;
30 27
import eu.etaxonomy.taxeditor.security.RequiredPermissions;
......
52 49
	/** {@inheritDoc} */
53 50
	@Override
54 51
	public String getText(Object element) {
55
		if (element instanceof TaxonNode){
56
			TaxonNode taxonNode = (TaxonNode) HibernateProxyHelper.deproxy(element);
52
		if (element instanceof UuidAndTitleCache){
53
			if(((UuidAndTitleCache)element).getTitleCache() != null){
54
			    String text = ((UuidAndTitleCache)element).getTitleCache();
55
                return text;
56

  
57
			}else{
58
				return  new String();
57 59

  
58
			try{
59
				Taxon taxon = HibernateProxyHelper.deproxy(taxonNode.getTaxon());
60
				if(taxon == null){
61
				    String text = taxonNode.getClassification().getName().getText();
62
					if(text==null){
63
					    text = taxonNode.getClassification().getTitleCache();
64
					}
65
                    return text;
66
					//MessagingUtils.error(getClass(), String.format(Messages.TaxonNodeLabelProvider_NODE_WITH_NO_TAXON, element), null);
67
//					throw new RuntimeException("The data your are trying to view is corrupt. Please check your import.");
68
				}else{
69
					try{
70
						return taxon.getName() != null ? ((IIdentifiableEntity) HibernateProxyHelper.deproxy(taxon.getName())).getTitleCache() : new String();
71
					}catch(Exception e){
72
						MessagingUtils.error(getClass(), e);
73
					}
74
				}
75
			}catch (LazyInitializationException e){
76
				MessagingUtils.error(getClass(), e);
77 60
			}
78 61

  
79 62
		}
......
86 69
		if (anElement instanceof TaxonNode) {
87 70
			Taxon data = ((TaxonNode) anElement).getTaxon();
88 71
			String text =  (data != null ? Messages.TaxonNodeLabelProvider_TAXON + data.getTitleCache() : Messages.TaxonNodeLabelProvider_CLASSIFICATION + ((TaxonNode)anElement).getClassification().getTitleCache());
89
		
72

  
90 73
			return text;
91 74
		}
92 75
		return null;

Also available in: Unified diff