Project

General

Profile

Download (3.89 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.remote.dto.tdwg.voc;
2

    
3
import java.util.HashSet;
4
import java.util.Set;
5

    
6
import javax.xml.bind.annotation.XmlAccessType;
7
import javax.xml.bind.annotation.XmlAccessorType;
8
import javax.xml.bind.annotation.XmlElement;
9
import javax.xml.bind.annotation.XmlRootElement;
10
import javax.xml.bind.annotation.XmlType;
11

    
12
import com.sun.xml.bind.CycleRecoverable;
13

    
14
import eu.etaxonomy.cdm.remote.dto.tdwg.Description;
15

    
16
@XmlAccessorType(XmlAccessType.FIELD)
17
@XmlType(name = "SpeciesProfileModel", propOrder = {
18
	    "aboutTaxon",
19
	    "hasInformations"
20
})
21
@XmlRootElement(name = "SpeciesProfileModel", namespace = "http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#")
22
public class SpeciesProfileModel extends Description implements CycleRecoverable {
23
	
24
	@XmlElement(name = "aboutTaxon", namespace = "http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#")
25
	private AboutTaxon aboutTaxon;
26
	
27
	@XmlElement(name = "hasInformation", namespace = "http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#")
28
	private Set<HasInformation> hasInformations = null;
29
	
30
	public TaxonConcept getAboutTaxon() {
31
		return aboutTaxon != null ? aboutTaxon.getTaxonConcept() : null;
32
	}
33

    
34
	public void setAboutTaxon(TaxonConcept taxonConcept) {
35
		this.aboutTaxon = new AboutTaxon(taxonConcept, false);
36
	}
37
	
38
	public TaxonConcept getAboutTaxonRelation() {
39
		return aboutTaxon != null ? aboutTaxon.getTaxonConcept() : null;
40
	}
41

    
42
	public void setAboutTaxonRelation(TaxonConcept taxonConcept) {
43
		this.aboutTaxon = new AboutTaxon(taxonConcept, true);
44
	}
45
	
46
	public Set<InfoItem> getHasInformation() {
47
		if(hasInformations != null) {
48
			Set<InfoItem> infoItems = new HashSet<InfoItem>();
49
			for(HasInformation hasInformation : hasInformations) {
50
				infoItems.add(hasInformation.getInfoItem());
51
			}
52
			return infoItems;
53
		} else {
54
			return null;
55
		}
56
	}
57

    
58
	public void setHasInformation(Set<InfoItem> infoItems) {
59
		if(infoItems != null) {
60
		  this.hasInformations = new HashSet<HasInformation>();
61
		  for(InfoItem infoItem : infoItems) {
62
			hasInformations.add( new HasInformation(infoItem));
63
		  }
64
		} else {
65
			hasInformations = null;
66
		}
67
	}
68
	
69
	@XmlAccessorType(XmlAccessType.FIELD)
70
    @XmlType(name = "AboutTaxon", propOrder = {
71
        "taxonConcept"
72
    })
73
	public static class AboutTaxon extends LinkType {
74
		@XmlElement(name = "TaxonConcept", namespace = "http://rs.tdwg.org/ontology/voc/TaxonConcept#")
75
		private TaxonConcept taxonConcept;
76
		
77
        protected AboutTaxon() {}
78
		
79
        protected AboutTaxon(TaxonConcept taxonConcept, boolean useRelation) {
80
        	if(useRelation) {
81
			    if(taxonConcept != null && taxonConcept.getIdentifier() != null) {
82
			    	this.setResource(taxonConcept.getIdentifier());
83
			    }  else {
84
			    	this.taxonConcept = taxonConcept;
85
			    }
86
			} else {
87
				this.taxonConcept = taxonConcept;
88
			}
89
		}
90

    
91
		protected TaxonConcept getTaxonConcept() {
92
			return taxonConcept;
93
		}
94

    
95
		protected void setTaxonConcept(TaxonConcept taxonConcept) {
96
			this.taxonConcept = taxonConcept;
97
		}
98
	}
99
	
100
	@XmlAccessorType(XmlAccessType.FIELD)
101
    @XmlType(name = "HasInformation", propOrder = {
102
        "infoItem"
103
    })
104
	public static class HasInformation extends LinkType {
105

    
106
		@XmlElement(name = "InfoItem", namespace = "http://rs.tdwg.org/ontology/voc/SpeciesProfileModel#")
107
		private InfoItem infoItem;
108
		
109
		protected HasInformation() {}
110
		
111
		protected HasInformation(InfoItem infoItem) {
112
			this.infoItem = infoItem;
113
		}
114
		
115
		protected InfoItem getInfoItem() {
116
			return infoItem;
117
		}
118

    
119
		protected void setInfoItem(InfoItem infoItem) {
120
			this.infoItem = infoItem;
121
		}
122
	}
123

    
124
	public Object onCycleDetected(Context context) {
125
		SpeciesProfileModel speciesProfileModel = new SpeciesProfileModel();
126
		speciesProfileModel.setIdentifier(super.getIdentifier());
127
		speciesProfileModel.setTitle(super.getTitle());
128
		return speciesProfileModel;
129
	}
130
}
(7-7/12)