KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > entities > management > CategoryVO


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  *
23  * $Id: CategoryVO.java,v 1.3 2006/03/06 17:19:50 mattias Exp $
24  */

25 package org.infoglue.cms.entities.management;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.infoglue.cms.entities.kernel.Persistent;
31 import org.infoglue.cms.util.ConstraintExceptionBuffer;
32 import org.infoglue.cms.util.DomainUtils;
33 import org.infoglue.cms.util.validators.ValidatorFactory;
34
35 /**
36  * This is a Category to be used for categorizing Content
37  *
38  * @author Frank Febbraro (frank@phase2technology.com)
39  */

40 public class CategoryVO extends Persistent
41 {
42     private Integer JavaDoc categoryId;
43     private String JavaDoc name;
44     private String JavaDoc description;
45     private boolean active = true;
46     private Integer JavaDoc parentId;
47     private List JavaDoc children = new ArrayList JavaDoc();
48
49     public CategoryVO() {}
50
51     public CategoryVO(String JavaDoc name)
52     {
53         setName(name);
54     }
55
56     public CategoryVO(Integer JavaDoc id, String JavaDoc name)
57     {
58         this(name);
59         setCategoryId(id);
60     }
61
62     public Integer JavaDoc getId()
63     {
64         return getCategoryId();
65     }
66
67     public Integer JavaDoc getCategoryId()
68     {
69         return categoryId;
70     }
71
72     public void setCategoryId(Integer JavaDoc i)
73     {
74         categoryId = i;
75     }
76
77     public String JavaDoc getName()
78     {
79         return name;
80     }
81
82     public void setName(String JavaDoc s)
83     {
84         name = s;
85     }
86
87     public String JavaDoc getDescription()
88     {
89         return description;
90     }
91
92     public void setDescription(String JavaDoc s)
93     {
94         description = s;
95     }
96
97     public boolean isActive()
98     {
99         return active;
100     }
101
102     public void setActive(boolean b)
103     {
104         active = b;
105     }
106
107     public Integer JavaDoc getParentId()
108     {
109         return parentId;
110     }
111
112     public void setParentId(Integer JavaDoc i)
113     {
114         parentId = i;
115     }
116
117     public List JavaDoc getChildren()
118     {
119         return children;
120     }
121
122     public void setChildren(List JavaDoc l)
123     {
124         children = l;
125     }
126
127     public boolean isRoot()
128     {
129         return getParentId() == null;
130     }
131
132     public ConstraintExceptionBuffer validate()
133     {
134         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
135         ValidatorFactory.createStringValidator("Category.name", true, 1, 100).validate(name, ceb);
136         ValidatorFactory.createStringValidator("Category.description", false, 255).validate(description, ceb);
137         return ceb;
138     }
139
140     public boolean equals(Object JavaDoc o)
141     {
142         if (super.equals(o))
143         {
144             CategoryVO category = (CategoryVO)o;
145             return DomainUtils.equals(categoryId, category.categoryId)
146                     && DomainUtils.equals(name, category.name)
147                     && DomainUtils.equals(description, category.description)
148                     && DomainUtils.equals(parentId, category.parentId)
149                     && children.size() == category.children.size()
150                     && (active == category.active);
151         }
152
153         return false;
154     }
155
156     public StringBuffer JavaDoc toStringBuffer()
157     {
158         StringBuffer JavaDoc sb = super.toStringBuffer();
159         sb.append(" name=").append(name)
160                 .append(" description=").append(description)
161                 .append(" active=").append(active)
162                 .append(" parentId=").append(parentId)
163                 .append(" children.size=").append(children.size());
164         return sb;
165     }
166 }
167
Popular Tags