2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.mailreaderjpa.User
 
Classes in this File Line Coverage Branch Coverage Complexity
User
0%
0/42
0%
0/4
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.mailreaderjpa;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.sql.Timestamp;
 21  
 import java.util.List;
 22  
 import javax.persistence.CascadeType;
 23  
 import javax.persistence.Column;
 24  
 import javax.persistence.Entity;
 25  
 import javax.persistence.GeneratedValue;
 26  
 import javax.persistence.GenerationType;
 27  
 import javax.persistence.Id;
 28  
 import javax.persistence.NamedQueries;
 29  
 import javax.persistence.NamedQuery;
 30  
 import javax.persistence.OneToMany;
 31  
 import javax.persistence.Version;
 32  
 
 33  
 /**
 34  
  * <p>JPA entity class for the <code>MAILREADER_USERS</code> table.</p>
 35  
  */
 36  
 @Entity(name="mailreader_users")
 37  
 @NamedQueries({
 38  
     @NamedQuery(name="User.findAll", query="SELECT u FROM mailreader_users u"),
 39  
     @NamedQuery(name="User.findByUsername", query="SELECT u FROM mailreader_users u WHERE u.username = :username")
 40  
 })
 41  
 public class User implements Serializable {
 42  
 
 43  
     @Id
 44  
     @Column(name="user_id")
 45  
     @GeneratedValue(strategy = GenerationType.AUTO)
 46  
     private Integer id;
 47  
     
 48  
     /** Creates a new instance of User */
 49  0
     public User() {
 50  0
     }
 51  
 
 52  
     public Integer getId() {
 53  0
         return id;
 54  
     }
 55  
 
 56  
     public void setId(Integer id) {
 57  0
         this.id = id;
 58  0
     }
 59  
 
 60  
     public String toString() {
 61  0
         return "org.apache.mailreaderjpa.User[id=" + id
 62  
                 + ",fromAddress='" + getFromAddress()
 63  
                 + "',fullName='" + getFullName()
 64  
                 + "',password='" + getPassword()
 65  
                 + "',replyToAddress='" + getReplyToAddress()
 66  
                 + "',username='" + getUsername()
 67  
                 + "',lastUpdate='" + getLastUpdate()
 68  
                 + "']";
 69  
     }
 70  
     
 71  
     public int hashCode() {
 72  0
         if (getId() != null) {
 73  0
             return getId().intValue();
 74  
         } else {
 75  0
             return super.hashCode();
 76  
         }
 77  
     }
 78  
 
 79  
     public boolean equals(Object obj) {
 80  0
         if ((obj instanceof User)
 81  
             && (getId() != null)) {
 82  0
             return getId().equals(((User) obj).getId());
 83  
         } else {
 84  0
             return false;
 85  
         }
 86  
     }
 87  
 
 88  
     @Column(name="from_address")
 89  
     private String fromAddress;
 90  
     @Column(name="full_name")
 91  
     private String fullName;
 92  
     @Column(nullable=false)
 93  
     private String password;
 94  
     @Column(name="reply_to_address")
 95  
     private String replyToAddress;
 96  
     @OneToMany(mappedBy="user",cascade=CascadeType.ALL)
 97  
     private List<Subscription> subscriptions;
 98  
     @Column(nullable=false, unique=true)
 99  
     private String username;
 100  
     @Column(name="last_update")
 101  
     @Version()
 102  
     private Timestamp lastUpdate;
 103  
 
 104  
     public String getFromAddress() {
 105  0
         return fromAddress;
 106  
     }
 107  
 
 108  
     public void setFromAddress(String fromAddress) {
 109  0
         this.fromAddress = fromAddress;
 110  0
     }
 111  
 
 112  
     public String getFullName() {
 113  0
         return fullName;
 114  
     }
 115  
 
 116  
     public void setFullName(String fullName) {
 117  0
         this.fullName = fullName;
 118  0
     }
 119  
 
 120  
     public String getPassword() {
 121  0
         return password;
 122  
     }
 123  
 
 124  
     public void setPassword(String password) {
 125  0
         this.password = password;
 126  0
     }
 127  
 
 128  
     public String getReplyToAddress() {
 129  0
         return replyToAddress;
 130  
     }
 131  
 
 132  
     public void setReplyToAddress(String replyToAddress) {
 133  0
         this.replyToAddress = replyToAddress;
 134  0
     }
 135  
 
 136  
     public List<Subscription> getSubscriptions() {
 137  0
         return subscriptions;
 138  
     }
 139  
 
 140  
     public void setSubscriptions(List<Subscription> subscriptions) {
 141  0
         this.subscriptions = subscriptions;
 142  0
     }
 143  
 
 144  
     public String getUsername() {
 145  0
         return username;
 146  
     }
 147  
 
 148  
     public void setUsername(String username) {
 149  0
         this.username = username;
 150  0
     }
 151  
 
 152  
     public Timestamp getLastUpdate() {
 153  0
         return lastUpdate;
 154  
     }
 155  
 
 156  
     public void setLastUpdate(Timestamp lastUpdate) {
 157  0
         this.lastUpdate = lastUpdate;
 158  0
     }
 159  
 
 160  
     public void addSubscription(Subscription subscription) {
 161  0
         List<Subscription> subscriptions = getSubscriptions();
 162  0
         if (!subscriptions.contains(subscription)) {
 163  0
             subscription.setUser(this);
 164  0
             subscriptions.add(subscription);
 165  
         }
 166  0
     }
 167  
 
 168  
     public void removeSubscription(Subscription subscription) {
 169  0
         List<Subscription> subscriptions = getSubscriptions();
 170  0
         if (subscriptions.contains(subscription)) {
 171  0
             subscriptions.remove(subscription);
 172  
             // Commment out following line because it seems to cause
 173  
             // an update of the USER_ID column setting it to null, which
 174  
             // would violate the database integrity constraints
 175  
 //            subscription.setUser(null);
 176  
         }
 177  0
     }
 178  
 
 179  
 
 180  
 }