Project

General

Profile

Download (7.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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.cdm.remote.dto.tdwg.voc;
10

    
11
import java.util.HashSet;
12
import java.util.Set;
13

    
14
import javax.xml.bind.annotation.XmlAccessType;
15
import javax.xml.bind.annotation.XmlAccessorType;
16
import javax.xml.bind.annotation.XmlElement;
17
import javax.xml.bind.annotation.XmlElements;
18
import javax.xml.bind.annotation.XmlRootElement;
19
import javax.xml.bind.annotation.XmlType;
20

    
21
import com.sun.xml.bind.CycleRecoverable;
22

    
23
import eu.etaxonomy.cdm.remote.dto.tdwg.Actor;
24
import eu.etaxonomy.cdm.remote.dto.tdwg.Concept;
25

    
26
@XmlAccessorType(XmlAccessType.FIELD)
27
@XmlType(name = "TaxonConcept", propOrder = {
28
	    "primary",
29
	    "accordingTo",
30
	    "hasName",
31
	    "hasRelationships",
32
	    "describedBys"
33
})
34
@XmlRootElement(name = "TaxonConcept", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
35
public class TaxonConcept extends Concept implements CycleRecoverable {
36

    
37
	@XmlElement(namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
38
	private Boolean primary;
39

    
40
	@XmlElement(namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
41
	private AccordingTo accordingTo;
42
	
43
	@XmlElement(name = "hasName", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
44
	private HasName hasName;
45
	
46
	@XmlElement(name = "hasRelationship", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
47
	private Set<HasRelationship> hasRelationships = null;
48
	
49
	@XmlElement(name = "describedBy", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
50
	private Set<DescribedBy> describedBys = null;
51
	
52
	public Set<Relationship> getHasRelationship() {
53
		if(hasRelationships != null) {
54
			Set<Relationship> relationships = new HashSet<Relationship>();
55
			for(HasRelationship hasRelationship : hasRelationships) {
56
				relationships.add(hasRelationship.getRelationship());
57
			}
58
			return relationships;
59
		} else {
60
			return null;
61
		}
62
	}
63

    
64
	public void setHasRelationship(Set<Relationship> relationships) {
65
		if(relationships != null) {
66
		  this.hasRelationships = new HashSet<HasRelationship>();
67
		  for(Relationship relationship : relationships) {
68
			hasRelationships.add( new HasRelationship(relationship));
69
		  }
70
		} else {
71
			hasRelationships = null;
72
		}
73
	}
74
	
75
	public Set<SpeciesProfileModel> getDescribedBy() {
76
		if(describedBys != null) {
77
			Set<SpeciesProfileModel> speciesProfileModels = new HashSet<SpeciesProfileModel>();
78
			for(DescribedBy describedBy : describedBys) {
79
				speciesProfileModels.add(describedBy.getSpeciesProfileModel());
80
			}
81
			return speciesProfileModels;
82
		} else {
83
			return null;
84
		}
85
	}
86

    
87
	public void setDescribedBy(Set<SpeciesProfileModel> speciesProfileModels) {
88
		if(speciesProfileModels != null) {
89
		  this.describedBys = new HashSet<DescribedBy>();
90
		  for(SpeciesProfileModel speciesProfileModel : speciesProfileModels) {
91
			describedBys.add( new DescribedBy(speciesProfileModel));
92
		  }
93
		} else {
94
			describedBys = null;
95
		}
96
	}
97

    
98
	public TaxonName getHasName() {
99
		return hasName != null ? hasName.getTaxonName() : null;
100
	}
101

    
102
	public void setHasName(TaxonName taxonName) {
103
		this.hasName = new HasName(taxonName, false);
104
	}
105
	
106
	public TaxonName getHasNameRelation() {
107
		return hasName != null ? hasName.getTaxonName() : null;
108
	}
109

    
110
	public void setHasNameRelation(TaxonName taxonName) {
111
		this.hasName = new HasName(taxonName, true);
112
	}
113

    
114
	public Boolean isPrimary() {
115
		return primary;
116
	}
117
	
118
	public Actor getAccordingTo() {
119
		return accordingTo != null ? accordingTo.getActor() : null;
120
	}
121

    
122
	public void setAccordingTo(Actor accordingTo) {
123
		this.accordingTo = new AccordingTo(accordingTo, false);
124
	}
125
	
126
	public Actor getAccordingToRelation() {
127
		return accordingTo != null ? accordingTo.getActor() : null;
128
	}
129

    
130
	public void setAccordingToRelation(Actor accordingTo) {
131
		this.accordingTo = new AccordingTo(accordingTo, true);
132
	}
133

    
134
	public void setPrimary(Boolean primary) {
135
		this.primary = primary;
136
	}
137
	
138
	@XmlAccessorType(XmlAccessType.FIELD)
139
    @XmlType(name = "HasName", propOrder = {
140
        "taxonName"
141
    })
142
	public static class HasName extends LinkType {
143
		@XmlElement(name = "TaxonName", namespace = "http://rs.tdwg.org/ontology/voc/TaxonName#")
144
		private TaxonName taxonName;
145
		
146
        protected HasName() {}
147
		
148
        protected HasName(TaxonName taxonName, boolean useRelation) {
149
        	if(useRelation) {
150
			    if(taxonName != null && taxonName.getIdentifier() != null) {
151
			    	this.setResource(taxonName.getIdentifier());
152
			    }  else {
153
			    	this.taxonName = taxonName;
154
			    }
155
			} else {
156
				this.taxonName = taxonName;
157
			}
158
		}
159

    
160
		protected TaxonName getTaxonName() {
161
			return taxonName;
162
		}
163

    
164
		protected void setTaxonName(TaxonName taxonName) {
165
			this.taxonName = taxonName;
166
		}
167
	}
168
	
169
	@XmlAccessorType(XmlAccessType.FIELD)
170
    @XmlType(name = "HasRelationship", propOrder = {
171
        "relationship"
172
    })
173
	public static class HasRelationship extends LinkType {
174

    
175
		@XmlElement(name = "Relationship", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
176
		private Relationship relationship;
177
		
178
		public HasRelationship() {}
179
		
180
		public HasRelationship(Relationship relationship) {
181
			this.relationship = relationship;
182
		}
183
		
184
		public Relationship getRelationship() {
185
			return relationship;
186
		}
187

    
188
		public void setRelationship(Relationship relationship) {
189
			this.relationship = relationship;
190
		}
191
	}
192
	
193
	@XmlAccessorType(XmlAccessType.FIELD)
194
    @XmlType(name = "AccordingTo", propOrder = {
195
        "actor"
196
    })
197
	public static class AccordingTo extends LinkType {
198

    
199
		@XmlElements({
200
			@XmlElement(name = "Person", namespace = "http://rs.tdwg.org/ontology/voc/Person#", type = Person.class),
201
			@XmlElement(name = "Team", namespace = "http://rs.tdwg.org/ontology/voc/Team#", type = Team.class)
202
		})
203
		private Actor actor;
204
		
205
		protected AccordingTo() {}
206
		
207
		protected AccordingTo(Actor actor, boolean useRelation) {
208
			if(useRelation) {
209
			    if(actor != null && actor.getIdentifier() != null) {
210
			    	this.setResource(actor.getIdentifier());
211
			    }  else {
212
			    	this.actor = actor;
213
			    }
214
			} else {
215
				this.actor = actor;
216
			}
217
		}
218
		
219
		protected Actor getActor() {
220
			return actor;
221
		}
222

    
223
		protected void setActor(Actor actor) {
224
			this.actor = actor;
225
		}
226
	}
227
	
228
	@XmlAccessorType(XmlAccessType.FIELD)
229
    @XmlType(name = "DescribedBy", propOrder = {
230
        "speciesProfileModel"
231
    })
232
	public static class DescribedBy extends LinkType {
233

    
234
		@XmlElement(name = "SpeciesProfileModel", namespace = "http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#")
235
		private SpeciesProfileModel speciesProfileModel;
236
		
237
		protected DescribedBy() {}
238
		
239
		protected DescribedBy(SpeciesProfileModel speciesProfileModel) {
240
			this.speciesProfileModel = speciesProfileModel;
241
		}
242
		
243
		protected SpeciesProfileModel getSpeciesProfileModel() {
244
			return speciesProfileModel;
245
		}
246

    
247
		protected void setSpeciesProfileModel(SpeciesProfileModel speciesProfileModel) {
248
			this.speciesProfileModel = speciesProfileModel;
249
		}
250
	}
251

    
252
	public Object onCycleDetected(Context context) {
253
		TaxonConcept taxonConcept = new TaxonConcept();
254
		taxonConcept.setIdentifier(super.getIdentifier());
255
		taxonConcept.setTitle(super.getTitle());
256
		return taxonConcept;
257
	}
258
}
(9-9/12)