|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<NewsData> net.sf.basedb.core.News
public class News
This class represents news items.
Nested Class Summary | |
---|---|
private static class |
News.QueryRuntimeFilterImpl
|
Field Summary | |
---|---|
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter limits the returned news items to those where todays date falls between the start and end dates unless the logged in user has generic read permission. |
static Item |
TYPE
The type of item represented by this class. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
Constructor Summary | |
---|---|
News(NewsData newsData)
|
Method Summary | |
---|---|
static News |
getById(DbControl dc,
int id)
Get a News item when you know the ID. |
String |
getDescription()
Get the description for the item. |
Date |
getEndDate()
Get the end date and time for this news item to be published. |
Date |
getEntryDate()
Get the date that the item was registered in the database. |
String |
getName()
Get the name of the item. |
static News |
getNew(DbControl dc,
Date startDate,
Date newsDate)
Create a new News item. |
Date |
getNewsDate()
Get the date that is shown in listings. |
static ItemQuery<News> |
getQuery()
Get a query configured to retrieve news. |
Date |
getStartDate()
Get the start date and time for this news item to be published. |
Item |
getType()
Get the type of item represented by the object. |
(package private) void |
initPermissions(int granted,
int denied)
Read permission is granted if today is between the start and end date. |
boolean |
isRemoved()
Check if the removed flag is set for this item. |
void |
setDescription(String description)
Set the description for the item. |
void |
setEndDate(Date endDate)
Set the end date and time for this item to be published. |
void |
setName(String name)
Set the name of the item. |
void |
setNewsDate(Date newsDate)
Set the date that is shown in listings. |
void |
setRemoved(boolean removed)
Set the removed flag for this item. |
void |
setStartDate(Date startDate)
Set the start date and time for this item to be published. |
(package private) void |
validate()
Check that startDate is before newsDate is before endDate. |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Field Detail |
---|
public static final Item TYPE
Item.NEWS
,
getType()
private static final QueryRuntimeFilter RUNTIME_FILTER
Constructor Detail |
---|
News(NewsData newsData)
Method Detail |
---|
public static News getNew(DbControl dc, Date startDate, Date newsDate) throws BaseException
News
item.
dc
- The DbControl
which will be used for
permission checking and database accessstartDate
- The first day this news item should be shownnewsDate
- The date appearing in listings of news
News
item
BaseException
- If there is an errorpublic static News getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
News
item when you know the ID.
dc
- The DbControl
which will be used for
permission checking and database access.id
- The ID of the item to load
News
item
ItemNotFoundException
- If an item with the specified
ID is not found
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- If there is another errorpublic static ItemQuery<News> getQuery()
ItemQuery
objectpublic Item getType()
Identifiable
Item
enumeration.
getType
in interface Identifiable
public String getName()
Nameable
getName
in interface Nameable
String
with the name of the itempublic void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.
setName
in interface Nameable
name
- The new name for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.
setDescription
in interface Nameable
description
- The new description for the item
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
isRemoved
in interface Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException
- If the logged in user doesn't
have Permission.DELETE
permission for setting the flag
to TRUE or Permission.WRITE
permission for setting the
flag to FALSEpublic Date getEntryDate()
Registered
getEntryDate
in interface Registered
void validate() throws InvalidDataException, BaseException
validate
in class BasicItem<NewsData>
BaseException
- If there is an error
InvalidDataException
Validatable
,
Core API overview - Data validation,
Coding rules and guidelines for item classesvoid initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem<NewsData>
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclass
BaseException
- If the permissions couldn't be initialisedpublic Date getStartDate()
public void setStartDate(Date startDate) throws PermissionDeniedException, InvalidDataException
startDate
- The new date and time
PermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permission
InvalidDataException
- If the date is nullpublic Date getNewsDate()
public void setNewsDate(Date newsDate) throws PermissionDeniedException, InvalidDataException
newsDate
- The new date and time
PermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permission
InvalidDataException
- If the date is nullpublic Date getEndDate()
public void setEndDate(Date endDate) throws PermissionDeniedException
endDate
- The new date and time, or null to publish this new item forever
PermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permission
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |