001/** 002 * Copyright 2005-2016 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.impl; 017 018import java.util.HashMap; 019import java.util.Map; 020 021import org.kuali.rice.krad.uif.UifConstants; 022import org.kuali.rice.krad.uif.UifConstants.ViewType; 023import org.kuali.rice.krad.uif.UifParameters; 024import org.kuali.rice.krad.uif.util.ViewModelUtils; 025import org.kuali.rice.krad.uif.service.ViewTypeService; 026import org.springframework.beans.PropertyValues; 027 028/** 029 * Type service implementation for Lookup views 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033public class LookupViewTypeServiceImpl implements ViewTypeService { 034 035 /** 036 * @see org.kuali.rice.krad.uif.service.ViewTypeService#getViewTypeName() 037 */ 038 public ViewType getViewTypeName() { 039 return ViewType.LOOKUP; 040 } 041 042 /** 043 * @see org.kuali.rice.krad.uif.service.ViewTypeService#getParametersFromViewConfiguration(org.springframework.beans.PropertyValues) 044 */ 045 public Map<String, String> getParametersFromViewConfiguration(PropertyValues propertyValues) { 046 Map<String, String> parameters = new HashMap<String, String>(); 047 048 String viewName = ViewModelUtils.getStringValFromPVs(propertyValues, UifParameters.VIEW_NAME); 049 String dataObjectClassName = ViewModelUtils.getStringValFromPVs(propertyValues, 050 UifParameters.DATA_OBJECT_CLASS_NAME); 051 052 parameters.put(UifParameters.VIEW_NAME, viewName); 053 parameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, dataObjectClassName); 054 055 return parameters; 056 } 057 058 /** 059 * @see org.kuali.rice.krad.uif.service.ViewTypeService#getParametersFromRequest(java.util.Map) 060 */ 061 public Map<String, String> getParametersFromRequest(Map<String, String> requestParameters) { 062 Map<String, String> parameters = new HashMap<String, String>(); 063 064 if (requestParameters.containsKey(UifParameters.VIEW_NAME)) { 065 parameters.put(UifParameters.VIEW_NAME, requestParameters.get(UifParameters.VIEW_NAME)); 066 } 067 else { 068 parameters.put(UifParameters.VIEW_NAME, UifConstants.DEFAULT_VIEW_NAME); 069 } 070 071 if (requestParameters.containsKey(UifParameters.DATA_OBJECT_CLASS_NAME)) { 072 parameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, 073 requestParameters.get(UifParameters.DATA_OBJECT_CLASS_NAME)); 074 } 075 076 return parameters; 077 } 078 079}