KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > model > news > NewsItem


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.model.news;
17
18 import com.blandware.atleap.model.core.Page;
19
20 import java.util.Date JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /**
25  * <p>Class that represents news item. News item is a special case of
26  * {@link Page}. It has localized title, annotation, body and no other content
27  * fields. Annotation contains a brief information, body contains full version.
28  * </p>
29  * <p>
30  * When news item is active, it's available for users. For inactive news item
31  * user will get HTTP 503 (Service Unavailable) error code when trying to view
32  * it.
33  * </p>
34  * <p>
35  * Two dates are assigned to each news item: publication date and expiration
36  * date. When news item is created, it's made active if publication date is not
37  * in future, else it becomes inactive. Then, when publication date comes, news
38  * item is made active. Expiration date has a contrary effect: when it comes,
39  * news item becomes inactive.
40  * </p>
41  * <p>Every News Item has a list of
42  * {@link com.blandware.atleap.model.core.Role}s that are allowed to access it.
43  * If that list is empty, everyone is allowed to access such News Item, otherwise
44  * only users that have at least one role from that list can access the News Item.</p>
45  * <p><a HREF="NewsItem.java.htm"><i>View Source</i></a>
46  * </p>
47  * <p/>
48  *
49  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
50  * @version $Revision: 1.14 $ $Date: 2005/10/19 07:28:16 $
51  * @struts.form include-all="false" extends="BaseForm" resetMappedProperties="false"
52  * @hibernate.joined-subclass table="`al_news_item`" lazy="false"
53  * @hibernate.joined-subclass-key column="`page_id`"
54  */

55 public class NewsItem extends Page {
56
57     //~ Instance variables
58

59     /**
60      * Short annotation for this news item
61      */

62     protected Map JavaDoc annotation = new HashMap JavaDoc();
63
64     /**
65      * Full news item
66      */

67     protected Map JavaDoc body = new HashMap JavaDoc();
68
69     /**
70      * Publication date of news item
71      */

72     protected Date JavaDoc publicationDate = new Date JavaDoc();
73
74     /**
75      * Date when this item must be set inactive
76      */

77     protected Date JavaDoc expirationDate;
78
79     //~ Methods
80

81     /**
82      * Gets publication date of this news item. If the news item is created before
83      * its publication date, it's made inactive; it will become active when
84      * comes date of publication.
85      *
86      * @return publication date
87      * @struts.form-field
88      * @struts.validator type="required, customdate"
89      * @struts.validator-args arg0resource="news.form.publicationDate"
90      * @hibernate.property column="`publication_date`" not-null="false" type="date"
91      */

92     public Date JavaDoc getPublicationDate() {
93         return publicationDate;
94     }
95
96     /**
97      * Sets publication date of this news item. If the news item is created before
98      * its publication date, it's made inactive; it will become active when
99      * comes date of publication.
100      *
101      * @param publicationDate publication date
102      */

103     public void setPublicationDate(Date JavaDoc publicationDate) {
104         this.publicationDate = publicationDate;
105     }
106
107     /**
108      * Gets expiration date of this news item (it's the date when news item becomes
109      * inactive)
110      *
111      * @return expiration date
112      * @struts.form-field
113      * @struts.validator type="required, customdate"
114      * @struts.validator-args arg0resource="news.form.expirationDate"
115      * @hibernate.property column="`expiration_date`" not-null="false" type="date"
116      */

117     public Date JavaDoc getExpirationDate() {
118         return expirationDate;
119     }
120
121     /**
122      * Sets expiration date of this news item (it's the date when news item becomes
123      * inactive)
124      *
125      * @param expirationDate expiration date
126      */

127     public void setExpirationDate(Date JavaDoc expirationDate) {
128         this.expirationDate = expirationDate;
129     }
130
131     // Internal field values
132

133     /**
134      * Gets annotations map
135      *
136      * @return mapping from locale identifiers to annotations
137      * @struts.form-field
138      */

139     public Map JavaDoc getAnnotation() {
140         return annotation;
141     }
142
143     /**
144      * Sets annotations map
145      *
146      * @param annotation mapping from locale identifiers to annotations
147      */

148     public void setAnnotation(Map JavaDoc annotation) {
149         this.annotation = annotation;
150     }
151
152     /**
153      * Gets bodies map
154      *
155      * @return mapping from locale identifiers to bodies
156      * @struts.form-field
157      */

158     public Map JavaDoc getBody() {
159         return body;
160     }
161
162     /**
163      * Sets bodies map
164      *
165      * @param body mapping from locale identifiers to bodies
166      */

167     public void setBody(Map JavaDoc body) {
168         this.body = body;
169     }
170
171 }
172
Popular Tags