001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kns.lookup;
017
018import org.kuali.rice.kns.web.ui.ResultRow;
019import org.kuali.rice.krad.bo.BusinessObject;
020
021import java.io.Serializable;
022import java.sql.Timestamp;
023import java.util.Collection;
024import java.util.List;
025import java.util.Set;
026
027/**
028 * @deprecated Only used in KNS classes, use KRAD.
029 */
030@Deprecated
031public interface LookupResultsService extends Serializable {
032    /**
033     * Persists a list of result row objects into a database.  The lookup results sequence number acts like a key identifying the lookup
034     * results set.  If results are persisted under the same sequence number, then the previously persisted list will be overwritten. 
035     * 
036     * @param lookupResultsSequenceNumber the lookup sequence number.  Every time a user clicks "search", a new sequence number should be generated
037     * @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
038     * @param personId the user that is performing the search.  This prevents a malicious user from passing someone else's sequence number 
039     * (which he can guess) and eventually retrieving it, possibly exposing sensitive data
040     * @throws Exception
041     */
042    public void persistResultsTable(String lookupResultsSequenceNumber, List<ResultRow> resultTable, String personId) throws Exception;
043    
044    /**
045     * Persists a list of BO object IDs that have been selected for return to the calling document (the back location in lookup terminology).
046     * The lookup results sequence number acts like a key identifying the selected object IDs.  If results are persisted under the same 
047     * sequence number, then the previously persisted list will be overwritten. 
048     * 
049     * @param lookupResultsSequenceNumber the lookup sequence number.  Every time a user clicks "search", a new sequence number should be generated
050     * @param selectedObjectIds A set of the object IDs of the selected rows.
051     * @param personId the user that is performing the search.  This prevents a malicious user from passing someone else's sequence number 
052     * (which he can guess) and eventually retrieving it, possibly exposing sensitive data
053     * @throws Exception
054     */
055    public void persistSelectedObjectIds(String lookupResultsSequenceNumber, Set<String> selectedObjectIds, String personId) throws Exception;
056    
057    /**
058     * Returns the list of result rows that was persisted under the passed in sequence number
059     * 
060     * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist
061     * @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 
062     * (which he can guess) and eventually retrieving it, possibly exposing sensitive data
063     * @return 
064     * @throws Exception many reasons, including if the user id parameter does not match the user used to persist the results
065     */
066    public List<ResultRow> retrieveResultsTable(String lookupResultsSequenceNumber, String personId) throws Exception;
067    
068    /**
069     * Returns the BOs that correspond to the selected objected IDs that were persisted under the given lookup results number
070     * 
071     * DB data may have changed since the time the user clicked the "search" button (e.g. someone may have changed a value that was
072     * used as a query criterion).  If so, implementations may or may not choose to handle this situation.
073     *
074     * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist
075     * @param boClass The class of BO being retrieved from the lookup
076     * @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 
077     * (which he can guess) and eventually retrieving it, possibly exposing sensitive data
078     * @return A list of BOs corresponding to the 
079     * @throws Exception many reasons, including if the user id parameter does not match the user used to persist the results
080     */
081    public <T extends BusinessObject> Collection<T> retrieveSelectedResultBOs(String lookupResultsSequenceNumber, Class<T> boClass, String personId) throws Exception;
082    
083    /**
084     * Returns whether a user is allowed to view the lookup results of the given sequence number
085     * 
086     * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist the results table
087     * @param personId the user id that was used to persist the results table.
088     * @return if the user ID used to persist the lookup results is the same user ID as the parameter
089     */
090    public boolean isAuthorizedToAccessLookupResults(String lookupResultsSequenceNumber, String personId);
091    
092    /**
093     * Returns whether a user is allowed to view the selected object IDs of the given sequence number
094     * 
095     * @param lookupResultsSequenceNumber the lookup sequence number that was used to persist the selected object IDs
096     * @param personId the user id that was used to persist the selected object IDs
097     * @return if the user ID used to persist the selected object IDs is the same user ID as the parameter
098     */
099    public boolean isAuthorizedToAccessSelectedObjectIds(String lookupResultsSequenceNumber, String personId);
100    
101    /**
102     * Removes the lookup results that were persisted under this lookup results sequence number
103     * 
104     * @param lookupResultsSequenceNumber
105     * @throws Exception
106     */
107    public void clearPersistedLookupResults(String lookupResultsSequenceNumber) throws Exception;
108    
109    /**
110     * Removes the lookup results that were persisted under this selected object IDs
111     * 
112     * @param lookupResultsSequenceNumber
113     * @throws Exception
114     */
115    public void clearPersistedSelectedObjectIds(String lookupResultsSequenceNumber) throws Exception;
116    
117    /**
118     * removes all LookupResults BO where the lookup date attribute is older than
119     * the parameter
120     * 
121     * @param expirationDate all LookupResults having a lookup date before this date 
122     * will be removed
123     */
124    public void deleteOldLookupResults(Timestamp expirationDate);
125    
126    /**
127     * removes all LookupResults BO where the lookup date attribute is older than
128     * the parameter
129     * 
130     * @param expirationDate all LookupResults having a lookup date before this date 
131     * will be removed
132     */
133    public void deleteOldSelectedObjectIds(Timestamp expirationDate);
134    
135    /**
136     * Determines the lookup id for a given business object
137     * 
138     * @param businessObject the business object to get a lookup id for
139     * @return the lookup id
140     */
141    public abstract String getLookupId(BusinessObject businessObject);
142}
143