KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > odmg > shared > ProductGroup


1 package org.apache.ojb.odmg.shared;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Vector JavaDoc;
5 import java.util.List JavaDoc;
6
7 /** represents a product group containing a set of Articles.
8  * @see org.apache.ojb.odmg.shared.Article
9  */

10 public class ProductGroup implements org.apache.ojb.odmg.TransactionAware, Serializable JavaDoc
11 {
12     /** return group id*/
13     public int getId()
14     {
15         return groupId;
16     }
17
18     /**return string representation*/
19     public String JavaDoc toString()
20     {
21         return
22                 "----\n" +
23                 "group Id: " + groupId + "\n" +
24                 "name: " + groupName + "\n" +
25                 "description: " + description + "\n" +
26                 "articles in group: " + allArticlesInGroup;
27     }
28
29     public ProductGroup(int pGroupId, String JavaDoc pGroupName,
30                         String JavaDoc pDescription)
31     {
32         groupId = pGroupId;
33         groupName = pGroupName;
34         description = pDescription;
35     }
36
37     public ProductGroup()
38     {
39     }
40
41     /** return groupname*/
42     public String JavaDoc getName()
43     {
44         return groupName;
45     }
46
47     /** collection containing all articles of a given product group*/
48     private List JavaDoc allArticlesInGroup;
49     /** a textual description of the group*/
50     private String JavaDoc description;
51     /** the unique id of a product group*/
52     private int groupId;
53     /** the name of a group*/
54     private String JavaDoc groupName;
55
56     public String JavaDoc getDescription()
57     {
58         return description;
59     }
60
61     /**
62      * Sets the description.
63      * @param description The description to set
64      */

65     public void setDescription(String JavaDoc description)
66     {
67         this.description = description;
68     }
69
70     /**
71      * afterAbort will be called after a transaction has been aborted.
72      * The values of fields which get persisted will have changed to
73      * what they were at the begining of the transaction. This method
74      * should be overridden to reset any transient or non-persistent
75      * fields.
76      */

77     public void afterAbort()
78     {
79         //System.out.println("afterAbort: " + new Identity(this));
80
}
81
82     /**
83      * afterCommit is called only after a successful commit has taken
84      * place.
85      */

86     public void afterCommit()
87     {
88         //System.out.println("afterCommit: " + new Identity(this));
89
}
90
91     /**
92      * beforeAbort is called before a transaction is aborted.
93      */

94     public void beforeAbort()
95     {
96         //System.out.println("beforeAbort: " + new Identity(this));
97
}
98
99     /**
100      * beforeCommit will give an object a chance to kill a
101      * transaction before it is committed.
102      *
103      * To kill a transaction, throw a new TransactionAbortedException.
104      */

105     public void beforeCommit() throws org.odmg.TransactionAbortedException
106     {
107         //System.out.println("beforeCommit: " + new Identity(this));
108
}
109
110
111     /** set groupname*/
112     public void setName(String JavaDoc newName)
113     {
114         groupName = newName;
115     }
116     /**
117      * Gets the allArticlesInGroup.
118      * @return Returns a List
119      */

120     public List JavaDoc getAllArticlesInGroup()
121     {
122         return allArticlesInGroup;
123     }
124
125     /**
126      * Sets the allArticlesInGroup.
127      * @param allArticlesInGroup The allArticlesInGroup to set
128      */

129     public void setAllArticlesInGroup(Vector JavaDoc allArticlesInGroup)
130     {
131         this.allArticlesInGroup = allArticlesInGroup;
132     }
133
134     public void addArticle(Article article)
135     {
136         if(allArticlesInGroup == null)
137         {
138             allArticlesInGroup = new Vector JavaDoc();
139         }
140         allArticlesInGroup.add(article);
141     }
142
143     /**
144      * Gets the groupId.
145      * @return Returns a int
146      */

147     public int getGroupId()
148     {
149         return groupId;
150     }
151
152     /**
153      * Sets the groupId.
154      * @param groupId The groupId to set
155      */

156     public void setGroupId(int groupId)
157     {
158         this.groupId = groupId;
159     }
160
161     /**
162      * Gets the groupName.
163      * @return Returns a String
164      */

165     public String JavaDoc getGroupName()
166     {
167         return groupName;
168     }
169
170     /**
171      * Sets the groupName.
172      * @param groupName The groupName to set
173      */

174     public void setGroupName(String JavaDoc groupName)
175     {
176         this.groupName = groupName;
177     }
178
179 }
180
Popular Tags