Project

General

Profile

« Previous | Next » 

Revision 407dc559

Added by Andreas Müller over 16 years ago

first taxon in database

View differences:

cdmlibrary/src/main/java/eu/etaxonomy/cdm/model/common/TermBase.java
16 16
@MappedSuperclass
17 17
public abstract class TermBase extends VersionableEntity {
18 18
	static Logger logger = Logger.getLogger(TermBase.class);
19
	
19 20
	private String uri;
20
	private Set<Representation> representations = new HashSet();
21

  
22

  
21
	private Set<Representation> representations = new HashSet<Representation>();
22
	
23 23
	public TermBase() {
24 24
		super();
25 25
	}
......
28 28
		this.addRepresentation(new Representation(term, label, Language.DEFAULT()) );
29 29
	}
30 30

  
31

  
32
	@OneToMany(fetch=FetchType.EAGER)
31
	@OneToMany//(fetch=FetchType.EAGER)
33 32
	@Cascade( { CascadeType.SAVE_UPDATE, CascadeType.DELETE })
34 33
	public Set<Representation> getRepresentations() {
35 34
		return this.representations;
......
50 49
	@Transient
51 50
	public Representation getRepresentation(Language lang) {
52 51
		for (Representation repr : representations){
53
			if (repr.getLanguage().equals(lang)){
52
			Language reprLanguage = repr.getLanguage();
53
			if (reprLanguage != null && reprLanguage.equals(lang)){
54 54
				return repr;
55 55
			}
56 56
		}
......
68 68
	@Transient
69 69
	public String getLabel() {
70 70
		if(getLabel(Language.DEFAULT())!=null){
71
			return this.getRepresentation(Language.DEFAULT()).getLabel();
71
			Representation repr = getRepresentation(Language.DEFAULT());
72
			return (repr == null)? null :repr.getLabel();
72 73
		}else{
73 74
			for (Representation r : representations){
74 75
				return r.getLabel();
......
79 80

  
80 81
	@Transient
81 82
	public String getLabel(Language lang) {
82
		return this.getRepresentation(lang).getLabel();
83
		Representation repr = this.getRepresentation(lang);
84
		return (repr == null) ? null : repr.getLabel();
83 85
	}
84 86

  
85 87
	@Transient
86 88
	public String getDescription() {
87
		return this.getRepresentation(Language.DEFAULT()).getDescription();
89
		return this.getDescription(Language.DEFAULT());
88 90
	}
89 91

  
90 92
	@Transient
91 93
	public String getDescription(Language lang) {
92
		return this.getRepresentation(lang).getDescription();
94
		Representation repr = this.getRepresentation(lang);
95
		return (repr == null) ? null :repr.getDescription();
93 96
	}
94 97

  
95 98
	@Override

Also available in: Unified diff