KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > entities > content > ContentVO


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
24 package org.infoglue.cms.entities.content;
25
26 import java.util.Calendar JavaDoc;
27 import java.util.Hashtable JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.infoglue.cms.entities.kernel.BaseEntityVO;
31 import org.infoglue.cms.exception.ConstraintException;
32 import org.infoglue.cms.util.ConstraintExceptionBuffer;
33 import org.infoglue.cms.util.DateHelper;
34 import org.infoglue.cms.util.validators.ValidatorFactory;
35
36 public class ContentVO implements BaseEntityVO
37 {
38     public static final Integer JavaDoc NO = new Integer JavaDoc(0);
39     public static final Integer JavaDoc YES = new Integer JavaDoc(1);
40     public static final Integer JavaDoc INHERITED = new Integer JavaDoc(2);
41     
42     private java.lang.Integer JavaDoc contentId;
43     private java.lang.String JavaDoc name = "";
44     private java.util.Date JavaDoc publishDateTime = DateHelper.getSecondPreciseDate();
45     private java.util.Date JavaDoc expireDateTime = DateHelper.getSecondPreciseDate();
46     private java.lang.Boolean JavaDoc isBranch = new Boolean JavaDoc(false);
47     private java.lang.Integer JavaDoc isProtected = INHERITED;
48     private java.lang.Integer JavaDoc repositoryId = null;
49     private java.lang.Integer JavaDoc contentTypeDefinitionId = null;
50     private java.lang.Integer JavaDoc parentContentId = null;
51     
52     private Integer JavaDoc childCount;
53     private String JavaDoc creatorName;
54   
55     //Used if an application wants to add more properties to this item... used for performance reasons.
56
private Map JavaDoc extraProperties = new Hashtable JavaDoc();
57     
58     public ContentVO()
59     {
60         //Initilizing the expireDateTime...
61
Calendar JavaDoc calendar = Calendar.getInstance();
62         calendar.add(Calendar.YEAR, 50);
63         expireDateTime = calendar.getTime();
64     }
65     
66     /**
67      * @see org.infoglue.cms.entities.kernel.BaseEntityVO#getId()
68      */

69     public Integer JavaDoc getId()
70     {
71         return getContentId();
72     }
73     
74     public java.lang.Integer JavaDoc getContentId()
75     {
76         return this.contentId;
77     }
78     
79     public void setRepositoryId(java.lang.Integer JavaDoc repositoryId)
80     {
81         this.repositoryId = repositoryId;
82     }
83     
84     public java.lang.Integer JavaDoc getRepositoryId()
85     {
86         return this.repositoryId;
87     }
88     
89                 
90     public void setContentId(java.lang.Integer JavaDoc contentId)
91     {
92         this.contentId = contentId;
93     }
94     
95     public java.lang.String JavaDoc getName()
96     {
97         return this.name;
98     }
99                 
100     public void setName(java.lang.String JavaDoc name)
101     {
102         this.name = name;
103     }
104     
105     public java.util.Date JavaDoc getPublishDateTime()
106     {
107         return this.publishDateTime;
108     }
109                 
110     public void setPublishDateTime(java.util.Date JavaDoc publishDateTime)
111     {
112         this.publishDateTime = publishDateTime;
113     }
114     
115     public java.util.Date JavaDoc getExpireDateTime()
116     {
117         return this.expireDateTime;
118     }
119                 
120     public void setExpireDateTime(java.util.Date JavaDoc expireDateTime)
121     {
122         this.expireDateTime = expireDateTime;
123     }
124                   
125     public java.lang.Boolean JavaDoc getIsBranch()
126     {
127         return this.isBranch;
128     }
129     
130     public void setIsBranch(java.lang.Boolean JavaDoc isBranch)
131     {
132         this.isBranch = isBranch;
133     }
134     
135     
136     /**
137      * @see org.infoglue.cms.entities.kernel.BaseEntityVO#validate()
138      */

139     public ConstraintExceptionBuffer validate()
140     {
141         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
142         ValidatorFactory.createStringValidator("Content.name", true, 2, 100).validate(name, ceb);
143         
144         if(this.publishDateTime == null)
145             ceb.add(new ConstraintException("Content.publishDateTime", "300"));
146         if(this.expireDateTime == null)
147             ceb.add(new ConstraintException("Content.expireDateTime", "300"));
148         if(this.publishDateTime != null && this.expireDateTime != null)
149             if(this.publishDateTime.after(this.expireDateTime))
150                 ceb.add(new ConstraintException("Content.publishDateTime", "308"));
151         
152         return ceb;
153     }
154
155     /**
156      * Returns the childCount.
157      * @return Integer
158      */

159     public Integer JavaDoc getChildCount()
160     {
161         return childCount;
162     }
163
164     /**
165      * Sets the childCount.
166      * @param childCount The childCount to set
167      */

168     public void setChildCount(Integer JavaDoc childCount)
169     {
170         this.childCount = childCount;
171     }
172
173     /**
174      * Returns the creatorName.
175      * @return String
176      */

177     public String JavaDoc getCreatorName()
178     {
179         return creatorName;
180     }
181
182     /**
183      * Sets the creatorName.
184      * @param creatorName The creatorName to set
185      */

186     public void setCreatorName(String JavaDoc creatorName)
187     {
188         this.creatorName = creatorName;
189     }
190
191     public java.lang.Integer JavaDoc getIsProtected()
192     {
193         return isProtected;
194     }
195
196     public void setIsProtected(java.lang.Integer JavaDoc isProtected)
197     {
198         this.isProtected = isProtected;
199     }
200
201     public java.lang.Integer JavaDoc getContentTypeDefinitionId()
202     {
203         return contentTypeDefinitionId;
204     }
205
206     public void setContentTypeDefinitionId(java.lang.Integer JavaDoc contentTypeDefinitionId)
207     {
208         this.contentTypeDefinitionId = contentTypeDefinitionId;
209     }
210
211     public java.lang.Integer JavaDoc getParentContentId()
212     {
213         return parentContentId;
214     }
215
216     public void setParentContentId(java.lang.Integer JavaDoc parentContentId)
217     {
218         this.parentContentId = parentContentId;
219     }
220
221     public String JavaDoc toString()
222     {
223         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
224         sb.append("id=").append(contentId)
225             .append(" name=").append(name)
226             .append(" publishDateTime=").append(publishDateTime)
227             .append(" expireDateTime=").append(expireDateTime)
228             .append(" isBranch=").append(isBranch)
229             .append(" isProtected=").append(isProtected)
230             .append(" repositoryId=").append(repositoryId)
231             .append(" contentTypeDefinitionId=").append(contentTypeDefinitionId)
232             .append(" parentContentId=").append(parentContentId)
233             .append(" creatorName=").append(creatorName);
234         return sb.toString();
235     }
236     
237     public Map JavaDoc getExtraProperties()
238     {
239         return extraProperties;
240     }
241     
242     public void setExtraProperties(Map JavaDoc extraProperties)
243     {
244         this.extraProperties = extraProperties;
245     }
246 }
247         
248
Popular Tags