001/**
002 * Copyright 2005-2017 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.kew.useroptions;
017
018import java.util.Collection;
019import java.util.List;
020import java.util.Map;
021
022/**
023 * Sits on top of the UserOptionsTable and manages certain aspects of action list refresh behaviors.
024 * This service could probably be broken up and it's dao put somewhere else and injected in the appropriate places.
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public interface UserOptionsService {
029
030    /**
031     * Finds {@link UserOptions} for the given workflow id.
032     * @param principalId the workflow id to search by
033     * @return a collection of {@link UserOptions} or an empty collection if no results were found.
034     */
035    Collection<UserOptions> findByWorkflowUser(String principalId);
036
037    /**
038     * Finds a collection of {@link UserOptions} for the given principal id and search string.
039     * @param principalId the workflow id.
040     * @param likeString the option id search string.
041     * @return  A {@link List} of {@link UserOptions} or an empty collection if no results are found.
042     */
043    List<UserOptions> findByUserQualified(String principalId, String likeString);
044
045    /**
046     * Persists the given {@link UserOptions} to the datasource.
047     * @param userOptions the {@link UserOptions} to persist to the datasource
048     */
049    void save(UserOptions userOptions);
050
051    /**
052     * This overridden method saves an option for each optionsMap entry, all for the given principalId.
053     * @param principalId the unique identifier
054     * @param optionsMap a {@link Map} of user options keyed with option ids
055     */
056    void save(String principalId, Map<String, String> optionsMap);
057
058    /**
059     * Combines the given parameters into an {@link UserOptions} and persists the object to the datasource.
060     * @param principalId the principal id to persist to the datasource
061     * @param optionId the option id to persist to the datasource
062     * @param optionValue the option value to persist to the datasource
063     */
064    void save(String principalId, String optionId, String optionValue);
065
066    /**
067     * Removes the given {@link UserOptions} from the underlining datasource.
068     * @param userOptions the {@link UserOptions} to delete
069     */
070    void deleteUserOptions(UserOptions userOptions);
071
072    /**
073     * Find a {@link UserOptions} for the given option id and principal id.
074     * @param optionId the option id to search by.
075     * @param principalId the workflow id to search by
076     * @return a {@link UserOptions} or null if no results are found.
077     */
078    UserOptions findByOptionId(String optionId, String principalId);
079
080    /**
081     * Finds a {@link List} of {@link UserOptions} for the given email setting.
082     * @param emailSetting the option value to search by.
083     * @return a {@link List} of {@link UserOptions} or an empty collection if no results are found.
084     */
085    List<UserOptions> retrieveEmailPreferenceUserOptions(String emailSetting);
086}