KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.roller.pojos;
2
3 import org.roller.RollerException;
4 import org.roller.business.PersistenceStrategy;
5 import org.roller.model.RollerFactory;
6
7 /**
8  * <p>WeblogCategoryAssoc represents association between weblog categories
9  * in the weblog category hierarchy. For each category, there will be zero
10  * or one parent category association and zero or more grandparent
11  * associations.</p>
12  *
13  * <p>Creating a new Cat</p>
14  * WeblogManager creates new Cat, not a PO<br />
15  * Cat has a parent Cat or null if parent is null. Parent must be PO.<br />
16  * On save, CatAssoc will be created for Cat.<br />
17  *
18  * <p>Saving an existing Cat</p>
19  * If Cat has a new parent Cat, then update all of Cat's CatAssocs<br />
20  *
21  * @author David M Johnson
22  *
23  * @ejb:bean name="WeblogCategoryAssoc"
24  * @hibernate.class table="weblogcategoryassoc"
25  * hibernate.jcs-cache usage="read-write"
26  */

27 public class WeblogCategoryAssoc extends PersistentObject
28     implements Assoc
29 {
30     static final long serialVersionUID = 674856287447472015L;
31     
32     protected String JavaDoc id;
33     protected WeblogCategoryData category;
34     protected WeblogCategoryData ancestor;
35     protected java.lang.String JavaDoc relation;
36     
37     public WeblogCategoryAssoc()
38     {
39     }
40
41     public WeblogCategoryAssoc(
42         String JavaDoc id,
43         WeblogCategoryData category,
44         WeblogCategoryData ancestor,
45         java.lang.String JavaDoc relation)
46     {
47         this.id = id;
48         this.category = category;
49         this.ancestor = ancestor;
50         this.relation = relation;
51     }
52
53     public WeblogCategoryAssoc(WeblogCategoryAssoc otherData)
54     {
55         this.id = otherData.id;
56         this.category = otherData.category;
57         this.ancestor = otherData.ancestor;
58         this.relation = otherData.relation;
59     }
60
61     /**
62      * @ejb:persistent-field
63      * @hibernate.id column="id" type="string"
64      * generator-class="uuid.hex" unsaved-value="null"
65      */

66     public java.lang.String JavaDoc getId()
67     {
68         return this.id;
69     }
70     /** @ejb:persistent-field */
71     public void setId(java.lang.String JavaDoc id)
72     {
73         this.id = id;
74     }
75
76
77     /**
78      * Remove self and all child categories.
79      */

80     public void remove() throws RollerException
81     {
82         PersistenceStrategy pstrategy =
83             RollerFactory.getRoller().getPersistenceStrategy();
84         pstrategy.remove(this);
85     }
86
87     public void save() throws RollerException
88     {
89         PersistenceStrategy pstrategy =
90             RollerFactory.getRoller().getPersistenceStrategy();
91         pstrategy.store(this);
92     }
93
94     /**
95      * Setter is needed in RollerImpl.storePersistentObject()
96      */

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

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

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

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