public class News extends BasicItem implements Nameable, Removable, Validatable, Registered
Modifier and Type | Class and Description |
---|---|
private static class |
News.QueryRuntimeFilterImpl |
Modifier and Type | Field and Description |
---|---|
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.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Modifier and Type | Method and Description |
---|---|
static News |
getById(DbControl dc,
int id)
Get a
News item when you know the ID. |
(package private) NewsData |
getData()
Get the
BasicData object that holds all data for this item. |
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.
|
addUsingItems, addUsingItems, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
private static final QueryRuntimeFilter RUNTIME_FILTER
News(NewsData newsData)
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 newsNews
itemBaseException
- 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 loadNews
itemItemNotFoundException
- If an item with the specified
ID is not foundPermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the itemBaseException
- If there is another errorpublic static ItemQuery<News> getQuery()
ItemQuery
objectNewsData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
public String getName()
Nameable
public void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.setName
in interface Nameable
name
- The new name for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- 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 itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic boolean isRemoved()
Removable
public void setRemoved(boolean removed) throws PermissionDeniedException
Removable
setRemoved
in interface Removable
removed
- TRUE if the item should be flagged as removed,
FALSE otherwisePermissionDeniedException
- 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
BaseException
- If there is an errorInvalidDataException
Validatable
,
Developer documentation: Data validation,
Developer documentation: Coding rules and guidelines for item classesvoid initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialisedpublic Date getStartDate()
public void setStartDate(Date startDate) throws PermissionDeniedException, InvalidDataException
startDate
- The new date and timePermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permissionInvalidDataException
- If the date is nullpublic Date getNewsDate()
public void setNewsDate(Date newsDate) throws PermissionDeniedException, InvalidDataException
newsDate
- The new date and timePermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permissionInvalidDataException
- 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 foreverPermissionDeniedException
- If the logged in user doesn't have
Permission.WRITE
permission