Coverage Report - org.directdemocracyportal.democracy.model.application.UserSession
 
Classes in this File Line Coverage Branch Coverage Complexity
UserSession
55%
15/27
N/A
1
 
 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.application;
 6  
 
 7  
 import java.util.Date;
 8  
 
 9  
 import javax.persistence.CascadeType;
 10  
 import javax.persistence.Entity;
 11  
 import javax.persistence.GeneratedValue;
 12  
 import javax.persistence.GenerationType;
 13  
 import javax.persistence.Id;
 14  
 import javax.persistence.JoinColumn;
 15  
 import javax.persistence.OneToOne;
 16  
 import javax.persistence.Temporal;
 17  
 import javax.persistence.TemporalType;
 18  
 
 19  
 import org.directdemocracyportal.democracy.model.core.BaseEntity;
 20  
 import org.hibernate.annotations.Cache;
 21  
 import org.hibernate.annotations.CacheConcurrencyStrategy;
 22  
 
 23  
 /**
 24  
  * The Class UserSession.
 25  
  */
 26  
 @Entity
 27  
 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
 28  
 public class UserSession extends BaseEntity
 29  
 {
 30  
 
 31  
     /** The Constant serialVersionUID. */
 32  
     private static final long serialVersionUID = -2831588433419103923L;
 33  
 
 34  
     /** The id. */
 35  
     private Long id;
 36  
 
 37  
     /** The user. */
 38  
     private User user;
 39  
 
 40  
     /** The session id. */
 41  
     private String sessionId;
 42  
 
 43  
     /** The created at. */
 44  
     private Date createdAt;
 45  
 
 46  
     /** The ended at. */
 47  
     private Date endedAt;
 48  
 
 49  
     /** The active. */
 50  
     private boolean active;
 51  
 
 52  
     /**
 53  
      * Instantiates a new user session.
 54  
      */
 55  1
     public UserSession() {
 56  1
     }
 57  
 
 58  
     /**
 59  
      * Instantiates a new user session.
 60  
      *
 61  
      * @param user the user
 62  
      * @param sessionId the session id
 63  
      * @param createdAt the created at
 64  
      */
 65  1
     public UserSession(User user, String sessionId, Date createdAt) {
 66  1
         this.user = user;
 67  1
         this.sessionId = sessionId;
 68  1
         this.createdAt = createdAt;
 69  1
         this.active = true;
 70  1
         this.endedAt = null;
 71  1
     }
 72  
 
 73  
     /*
 74  
      * (non-Javadoc)
 75  
      *
 76  
      * @see org.directdemocracyportal.democracy.model.core.BaseEntity#getId()
 77  
      */
 78  
     @Override
 79  
     @Id
 80  
     @GeneratedValue(strategy = GenerationType.AUTO)
 81  
     public Long getId() {
 82  1
         return this.id;
 83  
     }
 84  
 
 85  
     /**
 86  
      * Sets the id.
 87  
      *
 88  
      * @param id the new id
 89  
      */
 90  
     public void setId(Long id) {
 91  0
         this.id = id;
 92  0
     }
 93  
 
 94  
     /**
 95  
      * Checks if is active.
 96  
      *
 97  
      * @return true, if is active
 98  
      */
 99  
     public boolean isActive() {
 100  0
         return active;
 101  
     }
 102  
 
 103  
     /**
 104  
      * Sets the active.
 105  
      *
 106  
      * @param active the new active
 107  
      */
 108  
     public void setActive(boolean active) {
 109  1
         this.active = active;
 110  1
     }
 111  
 
 112  
     /**
 113  
      * Gets the created at.
 114  
      *
 115  
      * @return the created at
 116  
      */
 117  
     @Temporal(TemporalType.DATE)
 118  
     public Date getCreatedAt() {
 119  0
         return createdAt;
 120  
     }
 121  
 
 122  
     /**
 123  
      * Sets the created at.
 124  
      *
 125  
      * @param createdAt the new created at
 126  
      */
 127  
     public void setCreatedAt(Date createdAt) {
 128  0
         this.createdAt = createdAt;
 129  0
     }
 130  
 
 131  
     /**
 132  
      * Gets the ended at.
 133  
      *
 134  
      * @return the ended at
 135  
      */
 136  
     @Temporal(TemporalType.DATE)
 137  
     public Date getEndedAt() {
 138  0
         return endedAt;
 139  
     }
 140  
 
 141  
     /**
 142  
      * Sets the ended at.
 143  
      *
 144  
      * @param endedAt the new ended at
 145  
      */
 146  
     public void setEndedAt(Date endedAt) {
 147  1
         this.endedAt = endedAt;
 148  1
     }
 149  
 
 150  
     /**
 151  
      * Gets the session id.
 152  
      *
 153  
      * @return the session id
 154  
      */
 155  
     public String getSessionId() {
 156  0
         return sessionId;
 157  
     }
 158  
 
 159  
     /**
 160  
      * Sets the session id.
 161  
      *
 162  
      * @param sessionId the new session id
 163  
      */
 164  
     public void setSessionId(String sessionId) {
 165  0
         this.sessionId = sessionId;
 166  0
     }
 167  
 
 168  
     /**
 169  
      * Gets the user.
 170  
      *
 171  
      * @return the user
 172  
      */
 173  
     @OneToOne(cascade = CascadeType.ALL)
 174  
     @JoinColumn
 175  
     public User getUser() {
 176  4
         return user;
 177  
     }
 178  
 
 179  
     /**
 180  
      * Sets the user.
 181  
      *
 182  
      * @param user the new user
 183  
      */
 184  
     public void setUser(User user) {
 185  0
         this.user = user;
 186  0
     }
 187  
 }