Coverage Report - org.kuali.mobility.user.entity.UserPreference
 
Classes in this File Line Coverage Branch Coverage Complexity
UserPreference
0%
0/29
0%
0/4
1.143
 
 1  
 /**
 2  
  * Copyright 2011 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.mobility.user.entity;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.persistence.CascadeType;
 23  
 import javax.persistence.Column;
 24  
 import javax.persistence.Entity;
 25  
 import javax.persistence.FetchType;
 26  
 import javax.persistence.GeneratedValue;
 27  
 import javax.persistence.GenerationType;
 28  
 import javax.persistence.Id;
 29  
 import javax.persistence.OneToMany;
 30  
 import javax.persistence.Table;
 31  
 import javax.persistence.Version;
 32  
 
 33  
 @Entity
 34  
 @Table(name="KME_USR_PRF_T")
 35  
 public class UserPreference implements Serializable {
 36  
 
 37  
         private static final long serialVersionUID = -9145594618847463951L;
 38  
 
 39  
     @Id
 40  
         @GeneratedValue(strategy = GenerationType.TABLE)
 41  
     @Column(name="ID")
 42  
         private Long preferenceId;
 43  
 
 44  
     @Column(name="PRNCPL_ID")
 45  
         private Long principalId;
 46  
 
 47  
     @Column(name="PRF_NM")
 48  
         private String preferenceName;
 49  
 
 50  
     @Version
 51  
     @Column(name="VER_NBR")
 52  
     protected Long versionNumber;
 53  
 
 54  
     @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL}, mappedBy="preferenceId")
 55  
         private List<UserPreferenceValue> preferenceValues;
 56  
 
 57  0
         public UserPreference() {
 58  0
                 this.preferenceValues = new ArrayList<UserPreferenceValue>();
 59  0
         }
 60  
         
 61  
         public UserPreferenceValue getPreferenceValueById(Long preferenceValueId) {
 62  0
                 UserPreferenceValue value = null;
 63  0
             for (UserPreferenceValue val : this.getPreferenceValues()) {
 64  0
                     if (val.getPreferenceValueId().equals(preferenceValueId)) {
 65  0
                             value = val;
 66  0
                             break;
 67  
                     }
 68  
             }
 69  0
             return value;
 70  
         }
 71  
         
 72  
         public void addPreferenceValue(UserPreferenceValue value) {
 73  0
                 value.setPreference(this);
 74  0
                 this.getPreferenceValues().add(value);
 75  0
         }
 76  
         
 77  
         public void removePreferenceValue(Long preferenceValueId) {
 78  0
                 this.getPreferenceValues().remove(getPreferenceValueById(preferenceValueId));
 79  0
         }
 80  
 
 81  
         public Long getPrincipalId() {
 82  0
                 return principalId;
 83  
         }
 84  
 
 85  
         public void setPrincipalId(Long principalId) {
 86  0
                 this.principalId = principalId;
 87  0
         }
 88  
 
 89  
         public Long getPreferenceId() {
 90  0
                 return preferenceId;
 91  
         }
 92  
 
 93  
         public void setPreferenceId(Long preferenceId) {
 94  0
                 this.preferenceId = preferenceId;
 95  0
         }
 96  
 
 97  
         public String getPreferenceName() {
 98  0
                 return preferenceName;
 99  
         }
 100  
 
 101  
         public void setPreferenceName(String preferenceName) {
 102  0
                 this.preferenceName = preferenceName;
 103  0
         }
 104  
 
 105  
         public List<UserPreferenceValue> getPreferenceValues() {
 106  0
                 return preferenceValues;
 107  
         }
 108  
 
 109  
         public void setPreferenceValues(List<UserPreferenceValue> preferenceValues) {
 110  0
                 this.preferenceValues = preferenceValues;
 111  0
         }
 112  
 
 113  
         public Long getVersionNumber() {
 114  0
                 return versionNumber;
 115  
         }
 116  
 
 117  
         public void setVersionNumber(Long versionNumber) {
 118  0
                 this.versionNumber = versionNumber;
 119  0
         }
 120  
         
 121  
 }