View Javadoc

1   /**
2    * Copyright 2005-2008 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.businessobjects.reporting;
16  
17  import org.figure8.join.core.EntityObject;
18  
19  import java.util.Date;
20  /**
21   * Represents a user's subdscription to a mailing list.
22   * @author  <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
23   * @version $Revision: 1.3 $
24   *
25   * @hibernate.class table="join_subscriptions" lazy="true"
26   * @hibernate.cache usage="read-write"
27   *
28   * @hibernate.query name="join.subscription_findByUserId"
29   *    query="from Subscription sub left join fetch sub.mailingList where sub.userId = :userId"
30   */
31  public class Subscription extends EntityObject{
32     
33     // Attributes ---------------------------------------------------------------
34  
35     /** Identifier of user owning this subscription */
36     private String userId;
37     /** The date this subscription was done */
38     private Date creationDate;
39     /** The mailing list that is subscribed to */
40     private MailingList mailingList;
41  
42  
43     // Constructors -------------------------------------------------------------
44     
45     /** Creates a new instance of Subscription */
46     public Subscription(){
47     }
48  
49     /**
50      * Creates a new insatnce of Subscription with mandatory attributes
51      * @param userId Identifier of owner that want to subscribe
52      * @param mailingList Mainling list this user wants to subscribe to
53      */
54     public Subscription(String userId, MailingList mailingList){
55        this.userId = userId;
56        this.mailingList = mailingList;
57        this.creationDate = new Date();
58        /* TODO: why this statement makes Hibernate fails with a ClassCastException when
59           reassociating mailing lists subscriptions proxy with session ? */ 
60        // mailingList.addSubscription(this);
61     }
62  
63  
64     // Public -------------------------------------------------------------------
65  
66     /**
67      * @hibernate.property column="s_userid"
68      *    length="20" not-null="true"
69      * @return The identifier of user owning this subscription
70      */
71     public String getUserId(){
72        return userId;
73     }
74     /** @param userId The identifier of user owning this subscription */
75     public void setUserId(String userId){
76        this.userId = userId;
77     }
78  
79     /**
80      * @hibernate.property column="d_creation"
81      *    not-null="true" type="timestamp"
82      *    update="false"
83      * @return The date this subscription was done
84      */
85     public Date getCreationDate(){
86        return creationDate;
87     }
88     /** @param creationDate The date this subscription was done */
89     public void setCreationDate(Date creationDate){
90        this.creationDate = creationDate;
91     }
92  
93     /**
94      * @hibernate.many-to-one column="n_mailinglist_fk" not-null="true"
95      * @return The mailing list that is subscribed to
96      */
97     public MailingList getMailingList(){
98        return mailingList;
99     }
100    /** @param mailingList The mailing list that is subscribed to */
101    public void setMailingList(MailingList mailingList){
102       this.mailingList = mailingList;
103    }
104 }