Coverage Report - org.directdemocracyportal.democracy.model.world.Person
 
Classes in this File Line Coverage Branch Coverage Complexity
Person
14%
2/14
0%
0/8
2.5
 
 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  
 package org.directdemocracyportal.democracy.model.world;
 6  
 
 7  
 import javax.persistence.Entity;
 8  
 import javax.persistence.Transient;
 9  
 
 10  
 import org.directdemocracyportal.democracy.model.core.Agent;
 11  
 import org.directdemocracyportal.democracy.model.core.Role;
 12  
 import org.hibernate.annotations.Cache;
 13  
 import org.hibernate.annotations.CacheConcurrencyStrategy;
 14  
 
 15  
 /**
 16  
  * The Class Person.
 17  
  */
 18  
 @Entity
 19  
 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
 20  
 public class Person extends Agent
 21  
 {
 22  
 
 23  
     /** The Constant serialVersionUID. */
 24  
     private static final long serialVersionUID = -8213090131046642286L;
 25  
 
 26  
     /**
 27  
      * Instantiates a new person.
 28  
      */
 29  1
     public Person() {
 30  1
     }
 31  
 
 32  
     /**
 33  
      * Instantiates a new person.
 34  
      *
 35  
      * @param name the name
 36  
      */
 37  
     public Person(String name) {
 38  0
         super(name);
 39  0
     }
 40  
 
 41  
     /**
 42  
      * Gets the political party.
 43  
      *
 44  
      * @return the political party
 45  
      */
 46  
     @Transient
 47  
     public PoliticalParty getPoliticalParty() {
 48  0
         for (Role role : getRoles()) {
 49  0
             if (role.getGroupAgent() instanceof PoliticalParty) {
 50  0
                 return (PoliticalParty) role.getGroupAgent();
 51  
             }
 52  0
         }
 53  0
         return null;
 54  
     }
 55  
 
 56  
     /**
 57  
      * Gets the role in org.
 58  
      *
 59  
      * @param organisation the organisation
 60  
      * @return the role in org
 61  
      */
 62  
     @Transient
 63  
     public Role getRoleInOrg(Organisation organisation) {
 64  0
         for (Role role : getRoles()) {
 65  0
             if (role.getGroupAgent().equals(organisation)) {
 66  0
                 return role;
 67  
             }
 68  0
         }
 69  0
         return null;
 70  
     }
 71  
 
 72  
 }