001    /**
002     * Copyright 2005-2012 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     */
016    package org.kuali.rice.krad.uif.service;
017    
018    import org.kuali.rice.krad.uif.UifConstants;
019    import org.kuali.rice.krad.uif.view.View;
020    import org.kuali.rice.krad.uif.UifConstants.ViewType;
021    
022    import java.util.Map;
023    
024    /**
025     * Provides service methods for retrieving and updating <code>View</code> instances. The UIF
026     * interacts with this service from the client layer to pull information from the View dictionary
027     * and manage the View instance through its lifecycle
028     *
029     * @author Kuali Rice Team (rice.collab@kuali.org)
030     */
031    public interface ViewService {
032    
033        /**
034         * Returns the <code>View</code> entry identified by the given id
035         *
036         * <p>
037         * The id matches the id configured for the View through the dictionary. A new view instance
038         * is returned that is in the created state
039         * </p>
040         *
041         * @param viewId - unique id for view configured on its definition
042         * @return View instance associated with the id or Null if id is not found
043         */
044        public View getViewById(String viewId);
045    
046        /**
047         * Retrieves the <code>View</code> instance that is of the given view type and matches the
048         * given parameters (that are applicable for that type). If more than one views exists for the
049         * type and parameters, the view type may choose a default or throw an exception
050         *
051         * <p>
052         * If a view if found for the type parameters, a new instance is returned that is in the
053         * created state
054         * </p>
055         *
056         * @param viewType - name that identifies the view type
057         * @param parameters - Map of parameter key/value pairs that are used to select the
058         * view, the parameters allowed depend on the view type
059         * @return View instance or Null if a matching view was not found
060         */
061        public View getViewByType(ViewType viewType, Map<String, String> parameters);
062    
063        /**
064         * Executes the view lifecycle on the given <code>View</code> instance which will
065         * prepare it for rendering
066         *
067         * <p>
068         * Any configuration sent through the options Map is used to initialize the
069         * View. This map contains present options the view is aware of and will
070         * typically come from request parameters. e.g. For maintenance Views there
071         * is the maintenance type option (new, edit, copy)
072         * </p>
073         *
074         * <p>
075         * After view retrieval, applies updates to the view based on the model data which
076         * Performs dynamic generation of fields (such as collection rows),
077         * conditional logic, and state updating (conditional hidden, read-only,
078         * required).
079         * </p>
080         *
081         * @param view - view instance that should be built
082         * @param model - object instance containing the view data
083         * @param parameters - Map of key values pairs that provide configuration for the
084         * <code>View</code>, this is generally comes from the request
085         * and can be the request parameter Map itself. Any parameters
086         * not valid for the View will be filtered out
087         */
088        public void buildView(View view, Object model, Map<String, String> parameters);
089    
090        // TODO: remove once can get beans by type
091        public ViewTypeService getViewTypeService(UifConstants.ViewType viewType);
092    
093    }