View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.model.sweden.impl;
7   
8   import gnu.trove.THashSet;
9   
10  import java.util.Set;
11  
12  import javax.persistence.CascadeType;
13  import javax.persistence.Entity;
14  import javax.persistence.FetchType;
15  import javax.persistence.GeneratedValue;
16  import javax.persistence.GenerationType;
17  import javax.persistence.Id;
18  import javax.persistence.JoinTable;
19  import javax.persistence.OneToMany;
20  import javax.persistence.Version;
21  
22  import org.hibernate.annotations.Cache;
23  import org.hibernate.annotations.CacheConcurrencyStrategy;
24  
25  import com.hack23.cia.model.core.impl.BaseEntity;
26  
27  /***
28   * The Class Parliament.
29   */
30  @Entity
31  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
32  public class Parliament extends BaseEntity {
33  
34      /*** The Constant serialVersionUID. */
35      private static final long serialVersionUID = 1L;
36  
37  
38      /*** The id. */
39      private Long id;
40  
41      /*** The version. */
42      private Long version=1L;
43      
44      /*** The name. */
45      private String name;
46  
47      /*** The description. */
48      private String description;
49      
50      /*** The url. */
51      private String url;
52  
53      /*** The parliament years. */
54      private Set<ParliamentYear> parliamentYears = new THashSet<ParliamentYear>();
55      
56      /*** The committees. */
57      private Set<Committee> committees = new THashSet<Committee>();
58      
59      
60      /*** The elections. */
61      private Set<Election> elections = new THashSet<Election>();    
62      
63      /***
64       * Instantiates a new parliament.
65       */
66  	public Parliament() {
67  		super();
68  	}
69  
70      /*
71       * (non-Javadoc)
72       * 
73       * @see com.hack23.cia.model.core.BaseEntity#getId()
74       */
75      @Override
76      @Id
77      @GeneratedValue(strategy = GenerationType.AUTO)
78      public Long getId() {
79          return id;
80      }
81  
82      /***
83       * Gets the name.
84       *
85       * @return the name
86       */
87  	public String getName() {
88  		return name;
89  	}
90  
91  
92      /***
93       * Gets the parliament years.
94       *
95       * @return the parliament years
96       */
97      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
98      @JoinTable(name = "ParliamentYears")
99  	public Set<ParliamentYear> getParliamentYears() {
100 		return parliamentYears;
101 	}
102 
103 	/***
104 	 * Gets the short code.
105 	 *
106 	 * @return the short code
107 	 */
108 	public String getShortCode() {
109 		return description;
110 	}
111 
112 	/* (non-Javadoc)
113      * @see com.hack23.cia.model.core.BaseEntity#getVersion()
114      */
115     @Override
116     @Version
117     public Long getVersion() {
118         return version;
119     }
120 
121 	/***
122 	 * Sets the id.
123 	 *
124 	 * @param id the new id
125 	 */
126     public void setId(final Long id) {
127         this.id = id;
128     }
129 
130 	/***
131 	 * Sets the name.
132 	 *
133 	 * @param name the new name
134 	 */
135 	public void setName(final String name) {
136 		this.name = name;
137 	}
138 
139 
140     /***
141      * Sets the short code.
142      *
143      * @param shortCode the new short code
144      */
145 	public void setShortCode(final String shortCode) {
146 		this.description = shortCode;
147 	}
148 
149 	/***
150 	 * Sets the version.
151 	 *
152 	 * @param version the new version
153 	 */
154     public void setVersion(final Long version) {
155         this.version = version;
156     }
157 
158 	/***
159 	 * Gets the description.
160 	 *
161 	 * @return the description
162 	 */
163 	public String getDescription() {
164 		return description;
165 	}
166 
167 	/***
168 	 * Sets the description.
169 	 *
170 	 * @param description the new description
171 	 */
172 	public void setDescription(final String description) {
173 		this.description = description;
174 	}
175 
176 	/***
177 	 * Gets the url.
178 	 *
179 	 * @return the url
180 	 */
181 	public String getUrl() {
182 		return url;
183 	}
184 
185 	/***
186 	 * Sets the url.
187 	 *
188 	 * @param url the new url
189 	 */
190 	public void setUrl(final String url) {
191 		this.url = url;
192 	}
193 
194     /***
195      * Gets the elections.
196      *
197      * @return the elections
198      */
199     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
200     @JoinTable(name = "ParliamentElections")
201 	public Set<Election> getElections() {
202 		return elections;
203 	}
204 
205 	/***
206 	 * Sets the elections.
207 	 *
208 	 * @param elections the new elections
209 	 */
210 	public void setElections(final Set<Election> elections) {
211 		this.elections = elections;
212 	}
213 
214 	/***
215 	 * Sets the parliament years.
216 	 *
217 	 * @param parliamentYears the new parliament years
218 	 */
219 	public void setParliamentYears(final Set<ParliamentYear> parliamentYears) {
220 		this.parliamentYears = parliamentYears;
221 	}
222 
223     /***
224      * Gets the committees.
225      *
226      * @return the committees
227      */
228     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
229     @JoinTable(name = "ParliamentCommittees")
230 	public Set<Committee> getCommittees() {
231 		return committees;
232 	}
233 
234 	/***
235 	 * Sets the committees.
236 	 *
237 	 * @param committees the new committees
238 	 */
239 	public void setCommittees(final Set<Committee> committees) {
240 		this.committees = committees;
241 	}
242 
243 
244 }