KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > pojos > WeblogCategoryAssoc


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.pojos;
19
20 import org.apache.roller.RollerException;
21 import org.apache.roller.model.RollerFactory;
22
23 /**
24  * <p>WeblogCategoryAssoc represents association between weblog categories
25  * in the weblog category hierarchy. For each category, there will be zero
26  * or one parent category association and zero or more grandparent
27  * associations.</p>
28  *
29  * <p>Creating a new Cat</p>
30  * WeblogManager creates new Cat, not a PO<br />
31  * Cat has a parent Cat or null if parent is null. Parent must be PO.<br />
32  * On save, CatAssoc will be created for Cat.<br />
33  *
34  * <p>Saving an existing Cat</p>
35  * If Cat has a new parent Cat, then update all of Cat's CatAssocs<br />
36  *
37  * @author David M Johnson
38  *
39  * @ejb:bean name="WeblogCategoryAssoc"
40  * @hibernate.class lazy="false" table="weblogcategoryassoc"
41  * @hibernate.cache usage="read-write"
42  */

43 public class WeblogCategoryAssoc extends PersistentObject
44     implements Assoc
45 {
46     static final long serialVersionUID = 674856287447472015L;
47     
48     private String JavaDoc id;
49     private WeblogCategoryData category;
50     private WeblogCategoryData ancestor;
51     private java.lang.String JavaDoc relation;
52     
53     public WeblogCategoryAssoc()
54     {
55     }
56
57     public WeblogCategoryAssoc(
58         String JavaDoc id,
59         WeblogCategoryData category,
60         WeblogCategoryData ancestor,
61         java.lang.String JavaDoc relation)
62     {
63         this.id = id;
64         this.category = category;
65         this.ancestor = ancestor;
66         this.relation = relation;
67     }
68
69     public WeblogCategoryAssoc(WeblogCategoryAssoc otherData)
70     {
71         setData(otherData);
72     }
73
74     /**
75      * @ejb:persistent-field
76      * @hibernate.id column="id"
77      * generator-class="uuid.hex" unsaved-value="null"
78      */

79     public java.lang.String JavaDoc getId()
80     {
81         return this.id;
82     }
83     /** @ejb:persistent-field */
84     public void setId(java.lang.String JavaDoc id)
85     {
86         this.id = id;
87     }
88
89
90     /**
91      * Setter is needed in RollerImpl.storePersistentObject()
92      */

93     public void setData(org.apache.roller.pojos.PersistentObject otherData)
94     {
95         this.id = otherData.getId();
96         this.category = ((WeblogCategoryAssoc)otherData).getCategory();
97         this.ancestor = ((WeblogCategoryAssoc)otherData).getAncestorCategory();
98         this.relation = ((WeblogCategoryAssoc)otherData).getRelation();
99     }
100
101     /**
102      * @ejb:persistent-field
103      * @hibernate.many-to-one column="ancestorid" cascade="none"
104      */

105     public WeblogCategoryData getAncestorCategory()
106     {
107         return ancestor;
108     }
109     
110     /** @ejb:persistent-field */
111     public void setAncestorCategory(WeblogCategoryData data)
112     {
113         ancestor = data;
114     }
115
116     /**
117      * @ejb:persistent-field
118      * @hibernate.many-to-one column="categoryid" cascade="none" not-null="true"
119      */

120     public WeblogCategoryData getCategory()
121     {
122         return category;
123     }
124
125     /** @ejb:persistent-field */
126     public void setCategory(WeblogCategoryData data)
127     {
128         category = data;
129     }
130
131     /**
132      * @ejb:persistent-field
133      * @hibernate.property column="relation" non-null="true" unique="false"
134      */

135     public java.lang.String JavaDoc getRelation()
136     {
137         return relation;
138     }
139
140     /** @ejb:persistent-field */
141     public void setRelation(java.lang.String JavaDoc string)
142     {
143         relation = string;
144     }
145
146     public HierarchicalPersistentObject getObject()
147     {
148         return getCategory();
149     }
150
151     public void setObject(HierarchicalPersistentObject hpo)
152     {
153         setCategory((WeblogCategoryData)hpo);
154     }
155
156     public HierarchicalPersistentObject getAncestor()
157     {
158         return getAncestorCategory();
159     }
160
161     public void setAncestor(HierarchicalPersistentObject hpo)
162     {
163         setAncestorCategory((WeblogCategoryData)hpo);
164     }
165 }
166
Popular Tags