Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LookupResultsService |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php | |
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 org.kuali.rice.krad.lookup; | |
17 | ||
18 | import java.io.Serializable; | |
19 | import java.sql.Timestamp; | |
20 | import java.util.Collection; | |
21 | import java.util.List; | |
22 | import java.util.Set; | |
23 | ||
24 | import org.kuali.rice.krad.bo.BusinessObject; | |
25 | import org.kuali.rice.krad.web.ui.ResultRow; | |
26 | ||
27 | public interface LookupResultsService extends Serializable { | |
28 | /** | |
29 | * Persists a list of result row objects into a database. The lookup results sequence number acts like a key identifying the lookup | |
30 | * results set. If results are persisted under the same sequence number, then the previously persisted list will be overwritten. | |
31 | * | |
32 | * @param lookupResultsSequenceNumber the lookup sequence number. Every time a user clicks "search", a new sequence number should be generated | |
33 | * @param resultTable A list of result rows. Note that this list does not contain BOs, but the data necessary to render a lookup results screen | |
34 | * @param personId the user that is performing the search. This prevents a malicious user from passing someone else's sequence number | |
35 | * (which he can guess) and eventually retrieving it, possibly exposing sensitive data | |
36 | * @throws Exception | |
37 | */ | |
38 | public void persistResultsTable(String lookupResultsSequenceNumber, List<ResultRow> resultTable, String personId) throws Exception; | |
39 | ||
40 | /** | |
41 | * Persists a list of BO object IDs that have been selected for return to the calling document (the back location in lookup terminology). | |
42 | * The lookup results sequence number acts like a key identifying the selected object IDs. If results are persisted under the same | |
43 | * sequence number, then the previously persisted list will be overwritten. | |
44 | * | |
45 | * @param lookupResultsSequenceNumber the lookup sequence number. Every time a user clicks "search", a new sequence number should be generated | |
46 | * @param selectedObjectIds A set of the object IDs of the selected rows. | |
47 | * @param personId the user that is performing the search. This prevents a malicious user from passing someone else's sequence number | |
48 | * (which he can guess) and eventually retrieving it, possibly exposing sensitive data | |
49 | * @throws Exception | |
50 | */ | |
51 | public void persistSelectedObjectIds(String lookupResultsSequenceNumber, Set<String> selectedObjectIds, String personId) throws Exception; | |
52 | ||
53 | /** | |
54 | * Returns the list of result rows that was persisted under the passed in sequence number | |
55 | * | |
56 | * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist | |
57 | * @param personId the user id that was used to persist the results table. This prevents a malicious user from passing someone else's sequence number | |
58 | * (which he can guess) and eventually retrieving it, possibly exposing sensitive data | |
59 | * @return | |
60 | * @throws Exception many reasons, including if the user id parameter does not match the user used to persist the results | |
61 | */ | |
62 | public List<ResultRow> retrieveResultsTable(String lookupResultsSequenceNumber, String personId) throws Exception; | |
63 | ||
64 | /** | |
65 | * Returns the BOs that correspond to the selected objected IDs that were persisted under the given lookup results number | |
66 | * | |
67 | * DB data may have changed since the time the user clicked the "search" button (e.g. someone may have changed a value that was | |
68 | * used as a query criterion). If so, implementations may or may not choose to handle this situation. | |
69 | * | |
70 | * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist | |
71 | * @param boClass The class of BO being retrieved from the lookup | |
72 | * @param personId the user id that was used to persist the results table. This prevents a malicious user from passing someone else's sequence number | |
73 | * (which he can guess) and eventually retrieving it, possibly exposing sensitive data | |
74 | * @return A list of BOs corresponding to the | |
75 | * @throws Exception many reasons, including if the user id parameter does not match the user used to persist the results | |
76 | */ | |
77 | public <T extends BusinessObject> Collection<T> retrieveSelectedResultBOs(String lookupResultsSequenceNumber, Class<T> boClass, String personId) throws Exception; | |
78 | ||
79 | /** | |
80 | * Returns whether a user is allowed to view the lookup results of the given sequence number | |
81 | * | |
82 | * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist the results table | |
83 | * @param personId the user id that was used to persist the results table. | |
84 | * @return if the user ID used to persist the lookup results is the same user ID as the parameter | |
85 | */ | |
86 | public boolean isAuthorizedToAccessLookupResults(String lookupResultsSequenceNumber, String personId); | |
87 | ||
88 | /** | |
89 | * Returns whether a user is allowed to view the selected object IDs of the given sequence number | |
90 | * | |
91 | * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist the selected object IDs | |
92 | * @param personId the user id that was used to persist the selected object IDs | |
93 | * @return if the user ID used to persist the selected object IDs is the same user ID as the parameter | |
94 | */ | |
95 | public boolean isAuthorizedToAccessSelectedObjectIds(String lookupResultsSequenceNumber, String personId); | |
96 | ||
97 | /** | |
98 | * Removes the lookup results that were persisted under this lookup results sequence number | |
99 | * | |
100 | * @param lookupResultsSequenceNumber | |
101 | * @throws Exception | |
102 | */ | |
103 | public void clearPersistedLookupResults(String lookupResultsSequenceNumber) throws Exception; | |
104 | ||
105 | /** | |
106 | * Removes the lookup results that were persisted under this selected object IDs | |
107 | * | |
108 | * @param lookupResultsSequenceNumber | |
109 | * @throws Exception | |
110 | */ | |
111 | public void clearPersistedSelectedObjectIds(String lookupResultsSequenceNumber) throws Exception; | |
112 | ||
113 | /** | |
114 | * removes all LookupResults BO where the lookup date attribute is older than | |
115 | * the parameter | |
116 | * | |
117 | * @param expirationDate all LookupResults having a lookup date before this date | |
118 | * will be removed | |
119 | */ | |
120 | public void deleteOldLookupResults(Timestamp expirationDate); | |
121 | ||
122 | /** | |
123 | * removes all LookupResults BO where the lookup date attribute is older than | |
124 | * the parameter | |
125 | * | |
126 | * @param expirationDate all LookupResults having a lookup date before this date | |
127 | * will be removed | |
128 | */ | |
129 | public void deleteOldSelectedObjectIds(Timestamp expirationDate); | |
130 | ||
131 | /** | |
132 | * Determines the lookup id for a given business object | |
133 | * | |
134 | * @param businessObject the business object to get a lookup id for | |
135 | * @return the lookup id | |
136 | */ | |
137 | public abstract String getLookupId(BusinessObject businessObject); | |
138 | } | |
139 |