KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > persistence > news > NewsDAO


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.persistence.news;
17
18 import com.blandware.atleap.common.util.PartialCollection;
19 import com.blandware.atleap.common.util.QueryInfo;
20 import com.blandware.atleap.model.news.NewsItem;
21 import com.blandware.atleap.persistence.core.PageDAO;
22 import com.blandware.atleap.persistence.exception.DeleteException;
23
24 import java.util.Map JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Date JavaDoc;
27
28 /**
29  * <p>DAO for news items</p>
30  * <p><a HREF="NewsDAO.java.htm"><i>View Source</i></a></p>
31  *
32  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
33  * @version $Revision: 1.6 $ $Date: 2005/07/29 14:12:20 $
34  */

35 public interface NewsDAO extends PageDAO {
36
37     // ~ CRUD methods ================================================================
38

39     /**
40      * Creates new news item
41      *
42      * @param newsItem Value object that represents what news item must be created
43      * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the annotation or body to
44      * corresponding object (resource or page) if it exists
45      * @return ID of created news item
46      */

47     public Long JavaDoc createNewsItem(NewsItem newsItem, Map JavaDoc linkedObjects);
48
49     /**
50      * Retrieves news item with specified ID
51      *
52      * @param newsItemId ID to search by
53      * @return News item with specified ID or null if no item with specified ID exists in database
54      */

55     public NewsItem retrieveNewsItem(Long JavaDoc newsItemId);
56
57     /**
58      * Retrieves lite version (with empty 'title', 'annotation' and 'body' maps) of news item with specified ID
59      *
60      * @param newsItemId ID to search by
61      * @return News item with specified ID or null if no item with specified ID exists in database
62      */

63     public NewsItem retrieveNewsItemLite(Long JavaDoc newsItemId);
64
65     /**
66      * Updates news item
67      *
68      * @param newsItem News item to update
69      * @param linkedObjects Map of pairs <code>uri -&gt; object<code>, which link URI in the annotation or body to
70      * corresponding object (resource or page) if it exists
71      */

72     public void updateNewsItem(NewsItem newsItem, Map JavaDoc linkedObjects);
73
74     /**
75      * Deletes news item
76      *
77      * @param newsItem item to delete
78      * @throws com.blandware.atleap.persistence.exception.DeleteException
79      * if news item cannot be deleted
80      */

81     public void deleteNewsItem(NewsItem newsItem) throws DeleteException;
82
83     // ~ Additional methods ================================================================
84

85     /**
86      * Retrieves filtered/sorted collection of news items.
87      *
88      * @param queryInfo Object that contains information about how to filter and sort data
89      * @return Collection of news items
90      */

91     public PartialCollection listNewsItems(QueryInfo queryInfo);
92
93
94     /**
95      * Retrieves no more than number of elements, specified in queryInfo's <code>limit</code> field.
96      *
97      * @param queryInfo Object that contains list of user roles, number of elements to return and identifier of locale.
98      * All of these are passed as query parameters: list of roles under key 'roles'
99      * and identifier of locale under key 'localeIdentifier'. Only news items
100      * that are allowed to view for some of the given roles are returned.
101      * @return List of news items that correspond to <code>queryInfo</code>
102      */

103     public List JavaDoc getLastNews(QueryInfo queryInfo);
104
105     // ~ Finders ================================================================
106

107     /**
108      * Finds news item by URI
109      *
110      * @param newsItemUri URI of news item to search by
111      * @return News item or null if nothing was found
112      */

113     public NewsItem findNewsItemByUri(String JavaDoc newsItemUri);
114
115     /**
116      * Returns list of news, which are not published and are not expired at the specified date
117      * @param date Date to compare publication and expiration date to
118      * @return List of unpublished news
119      */

120     public List JavaDoc findUnpublishedNews(Date JavaDoc date);
121
122     /**
123      * Returns list of news, which are expired in comparison to specified date
124      * @param date Date to compare expiration date to
125      * @return List of expired news
126      */

127     public List JavaDoc findExpiredNews(Date JavaDoc date);
128
129 }
130
Popular Tags