Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/RuntimeCollective/bboard/bean/SimpleBlog.java


1   /* $Header: /home/CVS/rjp/src/com/RuntimeCollective/bboard/bean/SimpleBlog.java,v 1.4 2003/09/30 15:12:43 joe Exp $
2    * $Revision: 1.4 $
3    * $Date: 2003/09/30 15:12:43 $
4    *
5    * ====================================================================
6    *
7    * Josephine : http://www.runtime-collective.com/josephine/index.html
8    *
9    * Copyright (C) 2003 Runtime Collective
10   * 
11   * This product includes software developed by the
12   * Apache Software Foundation (http://www.apache.org/).
13   *
14   * This library is free software; you can redistribute it and/or
15   * modify it under the terms of the GNU Lesser General Public
16   * License as published by the Free Software Foundation; either
17   * version 2.1 of the License, or (at your option) any later version.
18   *
19   * This library is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   * Lesser General Public License for more details.
23   *
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this library; if not, write to the Free Software
26   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27   *
28   */
29  
30  package com.RuntimeCollective.bboard.bean;
31  
32  import com.RuntimeCollective.bboard.TopicList;
33  import com.RuntimeCollective.webapps.RuntimeParameters;
34  import com.RuntimeCollective.webapps.EntityBeanStore;
35  
36  import java.sql.SQLException;
37  
38  /** A simple implementation of a Blog.
39   * @author Joe Faith
40   * @version $Id: SimpleBlog.java,v 1.4 2003/09/30 15:12:43 joe Exp $
41   */
42  public class SimpleBlog extends SimpleBoard implements Blog {
43  
44      /** The name of the interface that this bean implements, and which may be used to key this bean on the session. */
45      public static final String INTERFACE_BEAN = "com.RuntimeCollective.bboard.bean.Blog";
46  
47      /** Default constructor generates a new blank blog.
48      * @exception SQLException if unable to connect to the database.
49      */
50      public SimpleBlog() throws SQLException { 
51    super();
52      }
53  
54      /** Get the given Blog from the database.
55      * @param id The primary key of the blog to find.
56      * @exception SQLException if no bean is found for that id.
57      */
58      public SimpleBlog( int id ) throws SQLException {
59    super(id);
60      }
61  
62      /** Get the single topic for this Blog. If there are no topics for this Blog, then a new one is created. 
63       * <p> Blogs may have more than one topic; in which case this method will return the first.
64       */
65      public Topic getTopic() throws SQLException {
66    TopicList topics = getTopicList();
67    if ( topics.size()>0 ) return (Topic) topics.get(0);
68    else {
69        // Create a new topic
70        EntityBeanStore store = RuntimeParameters.getStore();
71        Topic topic = (Topic) store.create( "com.RuntimeCollective.bboard.bean.SimpleTopic" );
72        topic.setBoard( this );
73        addTopic( topic );
74        store.save( topic );
75        store.save( this );
76        return topic;
77    }
78      }
79  
80  }
81  
82  
83