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 javax.persistence.DiscriminatorValue;
9   import javax.persistence.Entity;
10  import javax.persistence.ManyToOne;
11  import javax.persistence.Transient;
12  
13  import org.hibernate.annotations.Cache;
14  import org.hibernate.annotations.CacheConcurrencyStrategy;
15  
16  import com.hack23.cia.model.sweden.impl.Vote.Position;
17  
18  /***
19   * The Class PartyBallotResult.
20   */
21  @Entity
22  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
23  @DiscriminatorValue("PartyBallotMetaData")
24  public class PartyBallotResult extends AbstractBallotResult {
25  
26      /*** The Constant serialVersionUID. */
27      private static final long serialVersionUID = -7843524383033778447L;
28  
29      /*** The political party. */
30      private PoliticalParty politicalParty;
31      
32      /***
33       * Instantiates a new party ballot result.
34       */
35      public PartyBallotResult() {
36  		super();
37  	}
38  
39  	/***
40  	 * Gets the political party.
41  	 *
42  	 * @return the political party
43  	 */
44  	@ManyToOne
45  	public PoliticalParty getPoliticalParty() {
46  		return politicalParty;
47  	}
48  
49  	/***
50  	 * Checks if is rebel vote.
51  	 *
52  	 * @param vote the vote
53  	 * @return true, if is rebel vote
54  	 */
55  	@Transient
56  	public boolean isRebelVote(final Vote vote) {
57  		if (vote.getPosition().equals(Position.Absent)) {
58  			return false;
59  		} else {
60  			return !getWinningPosition().equals(vote.getPosition());
61  		}
62  	}
63  
64  	/***
65  	 * Sets the political party.
66  	 *
67  	 * @param politicalParty the new political party
68  	 */
69  	public void setPoliticalParty(final PoliticalParty politicalParty) {
70  		this.politicalParty = politicalParty;
71  	}
72  }