Coverage Report - net.sf.webphotos.model.AlbumVO
 
Classes in this File Line Coverage Branch Coverage Complexity
AlbumVO
0%
0/48
0%
0/12
1,333
 
 1  
 /**
 2  
  * Copyright 2008 WebPhotos
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package net.sf.webphotos.model;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.ArrayList;
 20  
 import java.util.Date;
 21  
 import java.util.HashSet;
 22  
 import java.util.Set;
 23  
 import javax.persistence.CascadeType;
 24  
 import javax.persistence.Column;
 25  
 import javax.persistence.Entity;
 26  
 import javax.persistence.FetchType;
 27  
 import javax.persistence.GeneratedValue;
 28  
 import javax.persistence.GenerationType;
 29  
 import javax.persistence.Id;
 30  
 import javax.persistence.JoinColumn;
 31  
 import javax.persistence.ManyToOne;
 32  
 import javax.persistence.NamedQueries;
 33  
 import javax.persistence.NamedQuery;
 34  
 import javax.persistence.OneToMany;
 35  
 import javax.persistence.Table;
 36  
 import javax.persistence.Temporal;
 37  
 import javax.persistence.TemporalType;
 38  
 import net.sf.webphotos.entity.HasID;
 39  
 
 40  
 /**
 41  
  *
 42  
  * @author Guilhe
 43  
  */
 44  0
 @Entity
 45  
 @Table(name = "ALBUNS")
 46  
 @NamedQueries({
 47  
     @NamedQuery(name = "AlbumVO.findByAlbumID", query = "SELECT a FROM AlbumVO a WHERE a.albumid = :albumid"),
 48  
     @NamedQuery(name = "AlbumVO.findByNmAlbum", query = "SELECT a FROM AlbumVO a WHERE a.nmalbum = :nmalbum"),
 49  
     @NamedQuery(name = "AlbumVO.findByDtInsercao", query = "SELECT a FROM AlbumVO a WHERE a.dtInsercao = :dtInsercao"),
 50  
     @NamedQuery(name = "AlbumVO.findByCategoriaID", query = "SELECT a FROM AlbumVO a WHERE a.categoriasVO.categoriaID = :categoriaID")
 51  
 })
 52  
 public class AlbumVO implements Serializable, HasID<Integer> {
 53  
     
 54  
     private static final long serialVersionUID = 1L;
 55  
     
 56  
     @Id
 57  
     @Column(name = "ALBUMID", nullable = false)
 58  
     @GeneratedValue(strategy = GenerationType.IDENTITY)
 59  
     private Integer albumid;
 60  
     
 61  
     @Column(name = "NMALBUM", nullable = false)
 62  
     private String nmalbum;
 63  
     
 64  
     @Column(name = "DESCRICAO", nullable = true)
 65  
     private String descricao;
 66  
     
 67  
     @Column(name = "DTINSERCAO", nullable = false)
 68  
     @Temporal(TemporalType.DATE)
 69  
     private Date dtInsercao;
 70  
     
 71  
     @ManyToOne
 72  
     @JoinColumn(name = "CATEGORIAID", nullable = false)
 73  
     private CategoryVO categoriasVO;
 74  
     
 75  
     @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "album")
 76  
     private Set<PhotoVO> photos;
 77  
 
 78  
     public CategoryVO getCategoriasVO() {
 79  0
         return categoriasVO;
 80  
     }
 81  
 
 82  
     public void setCategoriasVO(CategoryVO categoriasVO) {
 83  0
         this.categoriasVO = categoriasVO;
 84  0
     }
 85  
 
 86  
     @Deprecated
 87  0
     public AlbumVO() {
 88  0
     }
 89  
 
 90  0
     AlbumVO(String nmalbum, String descricao, Date dtInsercao, CategoryVO categoriasVO, Set<PhotoVO> photos) {
 91  0
         this.nmalbum = nmalbum;
 92  0
         this.descricao = descricao;
 93  0
         this.dtInsercao = dtInsercao;
 94  0
         this.categoriasVO = categoriasVO;
 95  0
         this.photos = photos;
 96  0
     }
 97  
 
 98  
     AlbumVO(Integer key, String nmalbum, String descricao, Date dtInsercao, CategoryVO categoriasVO, Set<PhotoVO> photos) {
 99  0
         this(nmalbum, descricao, dtInsercao, categoriasVO, photos);
 100  0
         this.albumid = key;
 101  0
     }
 102  
 
 103  
     public static AlbumVOBuilder builder() {
 104  0
         return new AlbumVOBuilder();
 105  
     }
 106  
 
 107  
     public static AlbumVOBuilder builder(Integer key) {
 108  0
         return new AlbumVOBuilder(key);
 109  
     }
 110  
 
 111  
     /**
 112  
      *
 113  
      * @return
 114  
      */
 115  
     public Integer getAlbumid() {
 116  0
         return albumid;
 117  
     }
 118  
 
 119  
     /**
 120  
      *
 121  
      * @param albumid
 122  
      */
 123  
     public void setAlbumid(Integer albumid) {
 124  0
         this.albumid = albumid;
 125  0
     }
 126  
 
 127  
     /**
 128  
      *
 129  
      * @return
 130  
      */
 131  
     public String getNmalbum() {
 132  0
         return nmalbum;
 133  
     }
 134  
 
 135  
     /**
 136  
      *
 137  
      * @param nmalbum
 138  
      */
 139  
     public void setNmalbum(String nmalbum) {
 140  0
         this.nmalbum = nmalbum;
 141  0
     }
 142  
 
 143  
     /**
 144  
      * @return the descricao
 145  
      */
 146  
     public String getDescricao() {
 147  0
         return descricao;
 148  
     }
 149  
 
 150  
     /**
 151  
      * @param descricao the descricao to set
 152  
      */
 153  
     public void setDescricao(String descricao) {
 154  0
         this.descricao = descricao;
 155  0
     }
 156  
 
 157  
     /**
 158  
      *
 159  
      * @return
 160  
      */
 161  
     public Date getDtInsercao() {
 162  0
         return dtInsercao;
 163  
     }
 164  
 
 165  
     /**
 166  
      *
 167  
      * @param dtInsercao
 168  
      */
 169  
     public void setDtInsercao(Date dtInsercao) {
 170  0
         this.dtInsercao = dtInsercao;
 171  0
     }
 172  
 
 173  
     @Override
 174  
     public int hashCode() {
 175  0
         int hash = 0;
 176  0
         hash += (albumid != null ? albumid.hashCode() : 0);
 177  0
         return hash;
 178  
     }
 179  
 
 180  
     @Override
 181  
     public boolean equals(Object object) {
 182  
         // TODO: Warning - this method won't work in the case the id fields are not set
 183  0
         if (!(object instanceof AlbumVO)) {
 184  0
             return false;
 185  
         }
 186  0
         AlbumVO other = (AlbumVO) object;
 187  0
         if ((this.albumid == null && other.albumid != null) || (this.albumid != null && !this.albumid.equals(other.albumid))) {
 188  0
             return false;
 189  
         }
 190  0
         return true;
 191  
     }
 192  
 
 193  
     @Override
 194  
     public String toString() {
 195  0
         return this.getClass().getCanonicalName() + "[albumid=" + albumid + "]";
 196  
     }
 197  
 
 198  
     /**
 199  
      * @return the photos
 200  
      */
 201  
     public Set<PhotoVO> getPhotos() {
 202  0
         return photos;
 203  
     }
 204  
 
 205  
     /**
 206  
      * @param photos the photos to add
 207  
      */
 208  
     public void addPhotos(HashSet<PhotoVO> photos) {
 209  0
         this.photos.addAll(photos);
 210  0
     }
 211  
 
 212  
     /**
 213  
      * @param photos the photo to add
 214  
      */
 215  
     public void addPhoto(PhotoVO photos) {
 216  0
         this.photos.add(photos);
 217  0
     }
 218  
 
 219  
     /**
 220  
      *
 221  
      * @param id
 222  
      * @return Photo
 223  
      */
 224  
     public PhotoVO getPhotoBy(Integer id) {
 225  0
         return new ArrayList<PhotoVO>(this.photos).get(id);
 226  
     }
 227  
 
 228  
     /**
 229  
      * remove one photo
 230  
      *
 231  
      * @param id
 232  
      * @return Photo
 233  
      */
 234  
     public boolean removePhotoBy(Integer id) {
 235  0
         return this.photos.remove(getPhotoBy(id));
 236  
     }
 237  
 
 238  
     /**
 239  
      *
 240  
      * @return
 241  
      */
 242  
     @Override
 243  
     public Integer getId() {
 244  0
         return this.albumid;
 245  
     }
 246  
 }