001: package org.apache.ojb.odmg.shared;
002:
003: import java.io.Serializable;
004: import java.util.Vector;
005: import java.util.List;
006:
007: /** represents a product group containing a set of Articles.
008: * @see org.apache.ojb.odmg.shared.Article
009: */
010: public class ProductGroup implements
011: org.apache.ojb.odmg.TransactionAware, Serializable {
012: /** return group id*/
013: public int getId() {
014: return groupId;
015: }
016:
017: /**return string representation*/
018: public String toString() {
019: return "----\n" + "group Id: " + groupId + "\n"
020: + "name: " + groupName + "\n" + "description: "
021: + description + "\n" + "articles in group: "
022: + allArticlesInGroup;
023: }
024:
025: public ProductGroup(int pGroupId, String pGroupName,
026: String pDescription) {
027: groupId = pGroupId;
028: groupName = pGroupName;
029: description = pDescription;
030: }
031:
032: public ProductGroup() {
033: }
034:
035: /** return groupname*/
036: public String getName() {
037: return groupName;
038: }
039:
040: /** collection containing all articles of a given product group*/
041: private List allArticlesInGroup;
042: /** a textual description of the group*/
043: private String description;
044: /** the unique id of a product group*/
045: private int groupId;
046: /** the name of a group*/
047: private String groupName;
048:
049: public String getDescription() {
050: return description;
051: }
052:
053: /**
054: * Sets the description.
055: * @param description The description to set
056: */
057: public void setDescription(String description) {
058: this .description = description;
059: }
060:
061: /**
062: * afterAbort will be called after a transaction has been aborted.
063: * The values of fields which get persisted will have changed to
064: * what they were at the begining of the transaction. This method
065: * should be overridden to reset any transient or non-persistent
066: * fields.
067: */
068: public void afterAbort() {
069: //System.out.println("afterAbort: " + new Identity(this));
070: }
071:
072: /**
073: * afterCommit is called only after a successful commit has taken
074: * place.
075: */
076: public void afterCommit() {
077: //System.out.println("afterCommit: " + new Identity(this));
078: }
079:
080: /**
081: * beforeAbort is called before a transaction is aborted.
082: */
083: public void beforeAbort() {
084: //System.out.println("beforeAbort: " + new Identity(this));
085: }
086:
087: /**
088: * beforeCommit will give an object a chance to kill a
089: * transaction before it is committed.
090: *
091: * To kill a transaction, throw a new TransactionAbortedException.
092: */
093: public void beforeCommit()
094: throws org.odmg.TransactionAbortedException {
095: //System.out.println("beforeCommit: " + new Identity(this));
096: }
097:
098: /** set groupname*/
099: public void setName(String newName) {
100: groupName = newName;
101: }
102:
103: /**
104: * Gets the allArticlesInGroup.
105: * @return Returns a List
106: */
107: public List getAllArticlesInGroup() {
108: return allArticlesInGroup;
109: }
110:
111: /**
112: * Sets the allArticlesInGroup.
113: * @param allArticlesInGroup The allArticlesInGroup to set
114: */
115: public void setAllArticlesInGroup(Vector allArticlesInGroup) {
116: this .allArticlesInGroup = allArticlesInGroup;
117: }
118:
119: public void addArticle(Article article) {
120: if (allArticlesInGroup == null) {
121: allArticlesInGroup = new Vector();
122: }
123: allArticlesInGroup.add(article);
124: }
125:
126: /**
127: * Gets the groupId.
128: * @return Returns a int
129: */
130: public int getGroupId() {
131: return groupId;
132: }
133:
134: /**
135: * Sets the groupId.
136: * @param groupId The groupId to set
137: */
138: public void setGroupId(int groupId) {
139: this .groupId = groupId;
140: }
141:
142: /**
143: * Gets the groupName.
144: * @return Returns a String
145: */
146: public String getGroupName() {
147: return groupName;
148: }
149:
150: /**
151: * Sets the groupName.
152: * @param groupName The groupName to set
153: */
154: public void setGroupName(String groupName) {
155: this.groupName = groupName;
156: }
157:
158: }
|