|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mycompany.expense.ReportHandler
This class contains properties and methods for the JSF components in the report area of the sample expense report application.
Nested Class Summary | |
static class |
ReportHandler.Page
This class represents a page in the page navigation bar model. |
Field Summary | |
private static java.util.Comparator |
ASC_DATE_COMPARATOR
|
private static java.util.Comparator |
ASC_OWNER_COMPARATOR
|
private static java.util.Comparator |
ASC_STATUS_COMPARATOR
|
private static java.util.Comparator |
ASC_TITLE_COMPARATOR
|
private static java.util.Comparator |
ASC_TOTAL_COMPARATOR
|
private boolean |
ascending
|
private Report |
currentReport
|
private java.lang.String |
currentUser
|
private static java.util.Comparator |
DESC_DATE_COMPARATOR
|
private static java.util.Comparator |
DESC_OWNER_COMPARATOR
|
private static java.util.Comparator |
DESC_STATUS_COMPARATOR
|
private static java.util.Comparator |
DESC_TITLE_COMPARATOR
|
private static java.util.Comparator |
DESC_TOTAL_COMPARATOR
|
private javax.faces.model.DataModel |
entriesModel
|
private int |
firstRowIndex
|
private java.util.Date |
from
|
private boolean |
isManager
|
private int |
noOfPageLinks
|
private int |
noOfRows
|
private ReportRegistry |
registry
|
private javax.faces.model.DataModel |
reportsModel
|
private Rules |
rules
|
private static int |
SORT_BY_DATE
|
private static int |
SORT_BY_OWNER
|
private static int |
SORT_BY_STATUS
|
private static int |
SORT_BY_TITLE
|
private static int |
SORT_BY_TOTAL
|
private int |
sortBy
|
private int[] |
status
|
private java.util.Date |
to
|
Constructor Summary | |
ReportHandler()
Creates a new instance, initialized with a new Report and information about the current user. |
Method Summary | |
java.lang.String |
accept()
Accepts the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
java.lang.String |
addEntry(ReportEntry entry)
Adds an entry to the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
private void |
addMessage(java.lang.String messageKey,
java.lang.Object param)
Adds the message matching the key in the application's resource bundle, formatted with the parameters (if any), the the JSF message queue as a global message. |
java.lang.String |
create()
Creates a new Report and makes it the current report. |
private Report |
createNewReport()
Creates a new Report instance initialized with the current user as the owner, and resets the cached entries DataModel. |
java.lang.String |
delete()
Deletes the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
int |
getCurrentPage()
Returns the index for the page matching the currently rendered set of reports in the reports list. |
Report |
getCurrentReport()
Returns the current Report instance, or a new instance if there's no current instance. |
java.util.List |
getCurrentReportEntries()
Returns a List with the ReportEntry instances for the current Report, sorted on the entry dates. |
private java.lang.String |
getCurrentUser()
Returns the username of the current, authenticated user. |
int |
getFirstPageIndex()
Returns the index for the first page link to render. |
int |
getFirstRowIndex()
Returns the index for the first row in the reports table. |
java.util.Date |
getFrom()
Returns the from date, or a Date representing the previous month if no from date is set. |
int |
getNoOfPageLinks()
Returns the number of links to render in the navigation bar. |
int |
getNoOfRows()
Returns the number of rows to show in the reports table. |
java.util.List |
getPages()
Returns a List with Page instances for each page of reports. |
private java.util.Date |
getPreviousMonth(java.util.Date current)
Returns a Date one month prior to the provided Date. |
javax.faces.model.DataModel |
getReportEntriesModel()
Returns a DataModel with the ReportEntry instances for the current Report, sorted on the entry dates. |
java.util.List |
getReports()
Returns a List with Report instances matching the filtering criteria. |
javax.faces.model.DataModel |
getReportsModel()
Returns a DataModel with Report instances matching the filtering criteria. |
javax.faces.model.DataModel |
getSortedReportsModel()
Returns a DataModel with Report instances matching the filtering criteria, sorted according to the current sort column and order. |
java.lang.String[] |
getStatus()
Returns the status codes for displayed reports, or the code for "Submitted" if no status code is set and the current user is a manager, or all status codes if no status code is set and the current user isn't a manager. |
java.util.Date |
getTo()
Returns the to date, or a Date representing today if no to date is set. |
boolean |
isAcceptDisabled()
Returns "true" if the current report is new (no entries yet) or the current user isn't allowed to accept the report. |
boolean |
isAcceptRendered()
Returns "true" if the current user is a manager. |
boolean |
isDeleteDisabled()
Returns "true" if the current report is new (no entries yet) or the current user isn't allowed to delete the report. |
boolean |
isEditDisabled()
Returns "true" if the current report isn't new (no entries yet) and the current user isn't allowed to edit the report. |
boolean |
isManager()
Returns "true" if the current user is associated with the "manager" role. |
boolean |
isNewDisabled()
Returns "true" if the current report is new (no entries yet). |
boolean |
isRejectDisabled()
Returns "true" if the current report is new (no entries yet) or the current user isn't allowed to reject the report. |
boolean |
isRejectRendered()
Returns "true" if the current user is a manager. |
private boolean |
isReportNew()
Returns "true" if the current report has status "new". |
boolean |
isScrollFirstDisabled()
Returns "true" if the first page of reports is displayed. |
boolean |
isScrollLastDisabled()
Returns "true" if the last page of reports is displayed. |
boolean |
isScrollNextDisabled()
Returns "true" if there aren't enough rows to scroll forward one page. |
boolean |
isScrollPreviousDisabled()
Returns "true" if the first page is displayed. |
boolean |
isSubmitDisabled()
Returns "true" if the current report is new (no entries yet) or the current user isn't allowed to submit the report. |
private void |
refreshCache()
If the current report isn't new (i.e., not yet stored), refreshes the current report with a copy from the registry to ensure the local copy is the latest version. |
java.lang.String |
reject()
Rejects the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
java.lang.String |
removeEntry()
Removes the entry represented by the current row in the entries DataModel from the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
java.lang.String |
removeEntry(int entryId)
Removes the specified entry from the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
private void |
saveReport()
If the current report is new, changes its status to "open" and add it to the registry; otherwise, updates the report in the registry. |
java.lang.String |
scrollFirst()
Sets the index for the first row to display in the reports list to zero. |
java.lang.String |
scrollLast()
Sets the index for the first row to display in the reports list to the index of the top row for the last page. |
java.lang.String |
scrollNext()
Sets the index for the first row to display in the reports table to the index of the top row for the next page, or to zero if there is no more page. |
java.lang.String |
scrollPrevious()
Sets the index for the first row to display in the reports table to the index of the top row for the previou page, or to zero if there is no more page. |
java.lang.String |
select()
Makes the report at the current row in the reports DataModel the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
private void |
setCurrentPage(int currentPage)
Sets the index for the first row in the reports table to match the specified page number. |
private void |
setCurrentReport(Report report)
Makes the provided Report the current report, and resets the cached entries DataModel. |
void |
setFrom(java.util.Date from)
Sets the from date. |
void |
setNoOfRows(int noOfRows)
Sets the number of rows to show in the reports table. |
void |
setReportRegistry(ReportRegistry registry)
Sets the ReportRegistry instance used by this application. |
void |
setStatus(java.lang.String[] stringStatus)
Sets the status codes to display. |
void |
setTo(java.util.Date to)
Sets the to date. |
java.lang.String |
sortByDate()
Sets the sorting column for the reports list to the "date" column, reversing the order if the table is already sorted by this column. |
java.lang.String |
sortByOwner()
Sets the sorting column for the reports list to the "owner" column, reversing the order if the table is already sorted by this column. |
java.lang.String |
sortByStatus()
Sets the sorting column for the reports list to the "status" column, reversing the order if the table is already sorted by this column. |
java.lang.String |
sortByTitle()
Sets the sorting column for the reports list to the "title" column, reversing the order if the table is already sorted by this column. |
java.lang.String |
sortByTotal()
Sets the sorting column for the reports list to the "total" column, reversing the order if the table is already sorted by this column. |
private void |
sortReports(java.util.List reports)
Sorts the reports according to the current sort column and order. |
java.lang.String |
submit()
Submits the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
java.lang.String |
updateEntry()
Uses the entry represented by the current row in the entries DataModel to update the corresponding entry in the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
java.lang.String |
updateEntry(ReportEntry entry)
Uses the provided entry to update the corresponding entry in the current report, or queues an error message if the current user isn't allowed to do that or the registry throws an exception. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int SORT_BY_TITLE
private static final int SORT_BY_OWNER
private static final int SORT_BY_DATE
private static final int SORT_BY_TOTAL
private static final int SORT_BY_STATUS
private ReportRegistry registry
private Rules rules
private Report currentReport
private java.lang.String currentUser
private boolean isManager
private javax.faces.model.DataModel reportsModel
private javax.faces.model.DataModel entriesModel
private java.util.Date from
private java.util.Date to
private int[] status
private boolean ascending
private int sortBy
private int noOfRows
private int firstRowIndex
private int noOfPageLinks
private static final java.util.Comparator ASC_TITLE_COMPARATOR
private static final java.util.Comparator DESC_TITLE_COMPARATOR
private static final java.util.Comparator ASC_OWNER_COMPARATOR
private static final java.util.Comparator DESC_OWNER_COMPARATOR
private static final java.util.Comparator ASC_DATE_COMPARATOR
private static final java.util.Comparator DESC_DATE_COMPARATOR
private static final java.util.Comparator ASC_TOTAL_COMPARATOR
private static final java.util.Comparator DESC_TOTAL_COMPARATOR
private static final java.util.Comparator ASC_STATUS_COMPARATOR
private static final java.util.Comparator DESC_STATUS_COMPARATOR
Constructor Detail |
public ReportHandler()
Method Detail |
public void setReportRegistry(ReportRegistry registry)
public Report getCurrentReport()
public java.util.List getReports()
public javax.faces.model.DataModel getReportsModel()
public javax.faces.model.DataModel getSortedReportsModel()
public java.util.Date getFrom()
public void setFrom(java.util.Date from)
public java.util.Date getTo()
public void setTo(java.util.Date to)
public java.lang.String[] getStatus()
public void setStatus(java.lang.String[] stringStatus)
public java.util.List getCurrentReportEntries()
public javax.faces.model.DataModel getReportEntriesModel()
public java.lang.String create()
public java.lang.String delete()
public java.lang.String submit()
public java.lang.String accept()
public java.lang.String reject()
public java.lang.String select()
public java.lang.String addEntry(ReportEntry entry)
public java.lang.String removeEntry()
public java.lang.String removeEntry(int entryId)
public java.lang.String updateEntry()
public java.lang.String updateEntry(ReportEntry entry)
public boolean isNewDisabled()
public boolean isDeleteDisabled()
public boolean isSubmitDisabled()
public boolean isAcceptDisabled()
public boolean isAcceptRendered()
public boolean isRejectDisabled()
public boolean isRejectRendered()
public boolean isEditDisabled()
public boolean isManager()
public java.lang.String sortByTitle()
public java.lang.String sortByOwner()
public java.lang.String sortByDate()
public java.lang.String sortByTotal()
public java.lang.String sortByStatus()
private void sortReports(java.util.List reports)
public int getNoOfRows()
public void setNoOfRows(int noOfRows)
public int getFirstRowIndex()
public boolean isScrollFirstDisabled()
public boolean isScrollLastDisabled()
public boolean isScrollNextDisabled()
public boolean isScrollPreviousDisabled()
public java.lang.String scrollFirst()
public java.lang.String scrollLast()
public java.lang.String scrollNext()
public java.lang.String scrollPrevious()
public java.util.List getPages()
public int getNoOfPageLinks()
public int getFirstPageIndex()
public int getCurrentPage()
private void setCurrentPage(int currentPage)
private void saveReport() throws RegistryException
RegistryException
private void refreshCache() throws RegistryException
RegistryException
private Report createNewReport()
private void setCurrentReport(Report report)
private java.util.Date getPreviousMonth(java.util.Date current)
private java.lang.String getCurrentUser()
private void addMessage(java.lang.String messageKey, java.lang.Object param)
private boolean isReportNew()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |