KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > pojos > PageData


1 package org.roller.pojos;
2
3 import java.util.Date JavaDoc;
4
5 import org.roller.RollerException;
6 import org.roller.model.Roller;
7 import org.roller.model.RollerFactory;
8
9
10 /** Page bean.
11  * @author David M Johnson
12  *
13  * @ejb:bean name="PageData"
14  * @struts.form include-all="true"
15  * @hibernate.class table="webpage"
16  * hibernate.jcs-cache usage="read-write"
17  */

18 public class PageData
19    extends org.roller.pojos.PersistentObject
20    implements java.io.Serializable JavaDoc
21 {
22    static final long serialVersionUID = -613737191638263428L;
23
24    protected java.lang.String JavaDoc id;
25    protected java.lang.String JavaDoc name;
26    protected java.lang.String JavaDoc description;
27    protected java.lang.String JavaDoc link;
28    protected java.lang.String JavaDoc template;
29    protected java.util.Date JavaDoc updateTime;
30
31    protected WebsiteData mWebsite = null;
32
33    public PageData()
34    {
35    }
36
37    public PageData(
38        java.lang.String JavaDoc id,
39        WebsiteData website,
40        java.lang.String JavaDoc name,
41        java.lang.String JavaDoc description,
42        java.lang.String JavaDoc link,
43        java.lang.String JavaDoc template,
44        java.util.Date JavaDoc updateTime )
45    {
46       this.id = id;
47       this.mWebsite = website;
48       this.name = name;
49       this.description = description;
50       this.link = link;
51       this.template = template;
52       this.updateTime = (Date JavaDoc)updateTime.clone();
53    }
54
55    public PageData( PageData otherData )
56    {
57       this.id = otherData.id;
58       this.mWebsite = otherData.mWebsite;
59       this.name = otherData.name;
60       this.description = otherData.description;
61       this.link = otherData.link;
62       this.template = otherData.template;
63       this.updateTime = otherData.updateTime;
64
65    }
66
67    /**
68     * @ejb:persistent-field
69     * @hibernate.id column="id" type="string"
70     * generator-class="uuid.hex" unsaved-value="null"
71     */

72    public java.lang.String JavaDoc getId()
73    {
74       return this.id;
75    }
76    /** @ejb:persistent-field */
77    public void setId( java.lang.String JavaDoc id )
78    {
79       this.id = id;
80    }
81
82    /**
83     * @ejb:persistent-field
84     * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
85     */

86    public WebsiteData getWebsite()
87    {
88       return this.mWebsite;
89    }
90    /** @ejb:persistent-field */
91    public void setWebsite( WebsiteData website )
92    {
93       this.mWebsite = website;
94    }
95
96    /**
97     * @ejb:persistent-field
98     * @hibernate.property column="name" non-null="true" unique="false"
99     */

100    public java.lang.String JavaDoc getName()
101    {
102       return this.name;
103    }
104    /** @ejb:persistent-field */
105    public void setName( java.lang.String JavaDoc name )
106    {
107       this.name = name;
108    }
109
110    /**
111     * Description
112     * @ejb:persistent-field
113     * @hibernate.property column="description" non-null="true" unique="false"
114     */

115    public java.lang.String JavaDoc getDescription()
116    {
117       return this.description;
118    }
119    /** @ejb:persistent-field */
120    public void setDescription( java.lang.String JavaDoc description )
121    {
122       this.description = description;
123    }
124
125    /**
126     * @ejb:persistent-field
127     * @hibernate.property column="link" non-null="true" unique="false"
128     */

129    public java.lang.String JavaDoc getLink()
130    {
131       return this.link;
132    }
133    /** @ejb:persistent-field */
134    public void setLink( java.lang.String JavaDoc link )
135    {
136       this.link = link;
137    }
138
139    /**
140     * @ejb:persistent-field
141     * @hibernate.property column="template" non-null="true" unique="false"
142     */

143    public java.lang.String JavaDoc getTemplate()
144    {
145       return this.template;
146    }
147    /** @ejb:persistent-field */
148    public void setTemplate( java.lang.String JavaDoc template )
149    {
150       this.template = template;
151    }
152
153    /**
154     * @ejb:persistent-field
155     * @hibernate.property column="updatetime" non-null="true" unique="false"
156     */

157    public java.util.Date JavaDoc getUpdateTime()
158    {
159       return (Date JavaDoc)this.updateTime.clone();
160    }
161    /** @ejb:persistent-field */
162    public void setUpdateTime(final java.util.Date JavaDoc newtime )
163    {
164       if (newtime != null)
165       {
166          updateTime = (Date JavaDoc)newtime.clone();
167       }
168       else
169       {
170          updateTime = null;
171       }
172    }
173
174    public String JavaDoc toString()
175    {
176       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
177
178       str.append("id=" + id + " " + "name=" + name + " " + "description="
179       + description + " " + "link=" + link + " " + "template=" + template
180       + " " + "updateTime=" + updateTime);
181       str.append('}');
182
183       return(str.toString());
184    }
185
186    public boolean equals( Object JavaDoc pOther )
187    {
188       if( pOther instanceof PageData )
189       {
190          PageData lTest = (PageData) pOther;
191          boolean lEquals = true;
192
193          if( this.id == null )
194          {
195             lEquals = lEquals && ( lTest.id == null );
196          }
197          else
198          {
199             lEquals = lEquals && this.id.equals( lTest.id );
200          }
201          if( this.mWebsite == null )
202          {
203             lEquals = lEquals && ( lTest.mWebsite == null );
204          }
205          else
206          {
207             lEquals = lEquals && this.mWebsite.equals( lTest.mWebsite );
208          }
209          if( this.name == null )
210          {
211             lEquals = lEquals && ( lTest.name == null );
212          }
213          else
214          {
215             lEquals = lEquals && this.name.equals( lTest.name );
216          }
217          if( this.description == null )
218          {
219             lEquals = lEquals && ( lTest.description == null );
220          }
221          else
222          {
223             lEquals = lEquals && this.description.equals( lTest.description );
224          }
225          if( this.link == null )
226          {
227             lEquals = lEquals && ( lTest.link == null );
228          }
229          else
230          {
231             lEquals = lEquals && this.link.equals( lTest.link );
232          }
233          if( this.template == null )
234          {
235             lEquals = lEquals && ( lTest.template == null );
236          }
237          else
238          {
239             lEquals = lEquals && this.template.equals( lTest.template );
240          }
241          if( this.updateTime == null )
242          {
243             lEquals = lEquals && ( lTest.updateTime == null );
244          }
245          else
246          {
247             lEquals = lEquals && this.updateTime.equals( lTest.updateTime );
248          }
249
250          return lEquals;
251       }
252       else
253       {
254          return false;
255       }
256    }
257
258    public int hashCode()
259    {
260       int result = 17;
261       result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
262       result = 37*result + ((this.mWebsite != null) ? this.mWebsite.hashCode() : 0);
263       result = 37*result + ((this.name != null) ? this.name.hashCode() : 0);
264       result = 37*result + ((this.description != null) ? this.description.hashCode() : 0);
265       result = 37*result + ((this.link != null) ? this.link.hashCode() : 0);
266       result = 37*result + ((this.template != null) ? this.template.hashCode() : 0);
267       result = 37*result + ((this.updateTime != null) ? this.updateTime.hashCode() : 0);
268       return result;
269       }
270
271    /**
272     * Setter is needed in RollerImpl.storePersistentObject()
273     */

274    public void setData( org.roller.pojos.PersistentObject otherData )
275    {
276
277       this.id = ((PageData)otherData).id;
278
279       this.mWebsite = ((PageData)otherData).mWebsite;
280
281       this.name = ((PageData)otherData).name;
282
283       this.description = ((PageData)otherData).description;
284
285       this.link = ((PageData)otherData).link;
286
287       this.template = ((PageData)otherData).template;
288
289       this.updateTime = ((PageData)otherData).updateTime;
290    }
291
292    public boolean canSave() throws RollerException
293    {
294        Roller roller = RollerFactory.getRoller();
295        if (roller.getUser().equals(UserData.SYSTEM_USER))
296        {
297            return true;
298        }
299        if (roller.getUser().equals(getWebsite().getUser()))
300        {
301            return true;
302        }
303        return false;
304    }
305
306 }
307
Popular Tags