001/**
002 * Copyright 2005-2015 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.krad.uif.service;
017
018import org.kuali.rice.krad.uif.view.View;
019import org.kuali.rice.krad.uif.field.AttributeQueryResult;
020
021import java.util.Map;
022
023/**
024 * Provides methods for executing <code>AttributeQuery</code> instances
025 * and preparing the <code>AttributeQueryResult</code> with the result of the query
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029public interface AttributeQueryService {
030
031    /**
032     * Executes the <code>AttributeQuery</code> associated with the <code>Suggest</code> widget within
033     * the field given by the Id. The given Map of key/value pairs are used to populate the criteria part of the
034     * attribute query or as arguments to the query method. The fieldTerm parameter gives the current value
035     * of the field that should be matched on. The query is expected to return a list of values to suggest
036     *
037     * @param view - view instance for which the field belongs
038     * @param fieldId - id for the attribute field to perform the query for
039     * @param fieldTerm - the partial value of the query field to match
040     * @param queryParameters - map of key/value pairs that are parameters to the query
041     * @return AttributeQueryResult instance populated with the List<String> data field of result data
042     */
043    public AttributeQueryResult performFieldSuggestQuery(View view, String fieldId, String fieldTerm,
044            Map<String, String> queryParameters);
045
046    /**
047     * Executes the <code>AttributeQuery</code> associated with the field given by the id. The given Map of key/value
048     * pairs are used to populate the criteria part of the attribute query or as arguments to the query method.
049     * The query is expected to return a Map of field name/value pairs (unlike the suggest query which just returns
050     * values for one field)
051     *
052     * @param view - view instance for which the field belongs
053     * @param fieldId - id for the attribute field to perform the query for
054     * @param queryParameters - map of key/value pairs that are parameters to the query
055     * @return AttributeQueryResult instance populated with the Map<String, String> of result field data
056     */
057    public AttributeQueryResult performFieldQuery(View view, String fieldId, Map<String, String> queryParameters);
058}