1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.imca.model.entities;
17
18 import java.util.Collection;
19 import java.util.Locale;
20
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.GenerationType;
24 import javax.persistence.Id;
25 import javax.persistence.NamedQuery;
26 import javax.persistence.NamedQueries;
27 import javax.persistence.OneToMany;
28 import javax.persistence.ManyToMany;
29
30
31
32
33
34
35
36
37 @Entity
38 @NamedQueries( {
39 @NamedQuery(name = "findAssociationByCountryCode",
40 query = "SELECT a FROM AssociationEntity a WHERE " +
41 "a.isoCountryCode= :isoCountryCode"),
42 @NamedQuery(name = "findAssociationByCountryCodeAndArea",
43 query = "SELECT a FROM AssociationEntity a WHERE " +
44 "a.isoCountryCode= :isoCountryCode AND a.area = :area"),
45 @NamedQuery(name = "findAllAssociations",
46 query = "SELECT a FROM AssociationEntity a " +
47 "ORDER BY a.isoCountryCode"),
48 @NamedQuery(name = "findAssociationsWithWebsites",
49 query = "SELECT a FROM AssociationEntity a " +
50 "WHERE a.url != '' ORDER BY a.isoCountryCode"),
51 @NamedQuery(name = "findAssociationByIsOfficial",
52 query = "SELECT a FROM AssociationEntity a " +
53 "WHERE a.isOfficiallyImca = :isOfficial"),
54 @NamedQuery(name = "AssociationBasicSearch",
55 query = "SELECT a FROM AssociationEntity a WHERE " +
56 "a.isoCountryCode LIKE :search OR a.area LIKE :search")
57 })
58 public class AssociationEntity {
59
60
61
62
63 @Id
64 @GeneratedValue(strategy=GenerationType.TABLE)
65 private long id;
66
67
68
69
70 private boolean isOfficiallyImca = false;
71
72
73
74
75 private String url = "";
76
77
78
79
80
81 private String paymentExplanation = "Contact Secretary for info.";
82
83
84
85
86 @ManyToMany
87 private Collection<MembershipEntity> members;
88
89
90
91
92 @OneToMany
93 private Collection<CommitteeMemberEntity> committee;
94
95
96
97
98 private String area = "";
99
100
101
102
103 private String isoCountryCode = "";
104
105 public String getIsoCountryCode() {
106 return isoCountryCode;
107 }
108
109 public void setIsoContryCode(String isoCountryCode) {
110 this.isoCountryCode = isoCountryCode;
111 }
112
113 public boolean getIsOfficiallyImca() {
114 return isOfficiallyImca;
115 }
116
117 public void setIsOfficiallyImca(boolean isOfficiallyImca) {
118 this.isOfficiallyImca = isOfficiallyImca;
119 }
120
121 public String getPaymentExplanation() {
122 return paymentExplanation;
123 }
124
125 public void setPaymentExplanation(String paymentExplanation) {
126 this.paymentExplanation = paymentExplanation;
127 }
128
129 public Collection<CommitteeMemberEntity> getCommittee() {
130 return committee;
131 }
132
133 public void setCommittee(Collection<CommitteeMemberEntity> committee) {
134 this.committee = committee;
135 }
136
137 public void setIsoCountryCode(String isoCountryCode) {
138 this.isoCountryCode = isoCountryCode;
139 }
140
141 public String getArea() {
142 return area;
143 }
144
145 public void setArea(String area) {
146 this.area = area;
147 }
148
149 public long getId() {
150 return id;
151 }
152
153 public void setId(long id) {
154 this.id = id;
155 }
156
157 public Collection<MembershipEntity> getMembers() {
158 return members;
159 }
160
161 public void setMembers(Collection<MembershipEntity> members) {
162 this.members = members;
163 }
164
165 public String getUrl() {
166 return url;
167 }
168
169 public void setUrl(String url) {
170 this.url = url;
171 }
172
173
174
175
176
177 public String toString() {
178 StringBuffer buf = new StringBuffer();
179 buf.append("International Moth ");
180
181 if (this.isOfficiallyImca) {
182 buf.append("Class Association");
183 } else {
184 buf.append("Fleet");
185 }
186 if (!"".equals(isoCountryCode)){
187 buf.append(" ( ");
188 if (!"".equals(area)){
189 buf.append(area);
190 buf.append(", ");
191 }
192 Locale loc = new Locale("", isoCountryCode);
193 buf.append(loc.getISO3Country().toUpperCase(Locale.ENGLISH));
194 buf.append(" ).");
195 }
196 return buf.toString();
197 }
198
199 }