|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
   package org.kuali.rice.krad.web.spring.controller;  | 
  |  12 |     | 
     | 
  |  13 |     | 
   import java.util.Collections;  | 
  |  14 |     | 
   import java.util.Enumeration;  | 
  |  15 |     | 
   import java.util.HashMap;  | 
  |  16 |     | 
   import java.util.HashSet;  | 
  |  17 |     | 
   import java.util.Map;  | 
  |  18 |     | 
   import java.util.Map.Entry;  | 
  |  19 |     | 
   import java.util.Properties;  | 
  |  20 |     | 
   import java.util.Set;  | 
  |  21 |     | 
     | 
  |  22 |     | 
   import javax.servlet.http.HttpServletRequest;  | 
  |  23 |     | 
   import javax.servlet.http.HttpServletResponse;  | 
  |  24 |     | 
     | 
  |  25 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  26 |     | 
   import org.kuali.rice.core.api.config.property.ConfigContext;  | 
  |  27 |     | 
   import org.kuali.rice.core.api.mo.common.Attributes;  | 
  |  28 |     | 
   import org.kuali.rice.core.util.AttributeSet;  | 
  |  29 |     | 
   import org.kuali.rice.core.web.format.BooleanFormatter;  | 
  |  30 |     | 
   import org.kuali.rice.kim.api.services.KimApiServiceLocator;  | 
  |  31 |     | 
   import org.kuali.rice.kim.util.KimConstants;  | 
  |  32 |     | 
   import org.kuali.rice.krad.UserSession;  | 
  |  33 |     | 
   import org.kuali.rice.krad.exception.AuthorizationException;  | 
  |  34 |     | 
   import org.kuali.rice.krad.service.KRADServiceLocatorWeb;  | 
  |  35 |     | 
   import org.kuali.rice.krad.service.ModuleService;  | 
  |  36 |     | 
   import org.kuali.rice.krad.service.SessionDocumentService;  | 
  |  37 |     | 
   import org.kuali.rice.krad.uif.UifConstants;  | 
  |  38 |     | 
   import org.kuali.rice.krad.uif.UifParameters;  | 
  |  39 |     | 
   import org.kuali.rice.krad.uif.UifPropertyPaths;  | 
  |  40 |     | 
   import org.kuali.rice.krad.uif.container.CollectionGroup;  | 
  |  41 |     | 
   import org.kuali.rice.krad.uif.container.View;  | 
  |  42 |     | 
   import org.kuali.rice.krad.uif.core.Component;  | 
  |  43 |     | 
   import org.kuali.rice.krad.uif.service.ViewService;  | 
  |  44 |     | 
   import org.kuali.rice.krad.uif.field.AttributeQueryResult;  | 
  |  45 |     | 
   import org.kuali.rice.krad.uif.util.ComponentFactory;  | 
  |  46 |     | 
   import org.kuali.rice.krad.uif.util.LookupInquiryUtils;  | 
  |  47 |     | 
   import org.kuali.rice.krad.uif.util.UifWebUtils;  | 
  |  48 |     | 
   import org.kuali.rice.krad.util.GlobalVariables;  | 
  |  49 |     | 
   import org.kuali.rice.krad.util.KRADConstants;  | 
  |  50 |     | 
   import org.kuali.rice.krad.util.KRADUtils;  | 
  |  51 |     | 
   import org.kuali.rice.krad.util.UrlFactory;  | 
  |  52 |     | 
   import org.kuali.rice.krad.util.WebUtils;  | 
  |  53 |     | 
   import org.kuali.rice.krad.web.spring.form.UifFormBase;  | 
  |  54 |     | 
   import org.springframework.validation.BindingResult;  | 
  |  55 |     | 
   import org.springframework.web.bind.annotation.ModelAttribute;  | 
  |  56 |     | 
   import org.springframework.web.bind.annotation.RequestMapping;  | 
  |  57 |     | 
   import org.springframework.web.bind.annotation.RequestMethod;  | 
  |  58 |     | 
   import org.springframework.web.bind.annotation.ResponseBody;  | 
  |  59 |     | 
   import org.springframework.web.servlet.ModelAndView;  | 
  |  60 |     | 
     | 
  |  61 |     | 
     | 
  |  62 |     | 
     | 
  |  63 |     | 
     | 
  |  64 |     | 
     | 
  |  65 |     | 
     | 
  |  66 |     | 
     | 
  |  67 |     | 
     | 
  |  68 |     | 
     | 
  |  69 |     | 
     | 
  |  70 |     | 
     | 
  |  71 |     | 
     | 
  |  72 |     | 
     | 
  |  73 |     | 
     | 
  |  74 |     | 
     | 
  |  75 |     | 
     | 
  |  76 |     | 
     | 
  |  77 |     | 
     | 
  |  78 |    0 |    public abstract class UifControllerBase { | 
  |  79 |    0 |        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UifControllerBase.class);  | 
  |  80 |     | 
     | 
  |  81 |     | 
       protected static final String REDIRECT_PREFIX = "redirect:";  | 
  |  82 |     | 
       private SessionDocumentService sessionDocumentService;  | 
  |  83 |     | 
     | 
  |  84 |     | 
         | 
  |  85 |     | 
     | 
  |  86 |     | 
     | 
  |  87 |     | 
     | 
  |  88 |     | 
     | 
  |  89 |     | 
     | 
  |  90 |     | 
     | 
  |  91 |     | 
       @ModelAttribute(value = "KualiForm")  | 
  |  92 |     | 
       public UifFormBase initForm(HttpServletRequest request) { | 
  |  93 |    0 |            UifFormBase form = null;  | 
  |  94 |    0 |            String formKeyParam = request.getParameter(UifParameters.FORM_KEY);  | 
  |  95 |    0 |            String documentNumber = request.getParameter(KRADConstants.DOCUMENT_DOCUMENT_NUMBER);  | 
  |  96 |     | 
     | 
  |  97 |    0 |            if (StringUtils.isNotBlank(formKeyParam)) { | 
  |  98 |    0 |                form = (UifFormBase) request.getSession().getAttribute(formKeyParam);  | 
  |  99 |     | 
     | 
  |  100 |     | 
                 | 
  |  101 |    0 |                if (form == null) { | 
  |  102 |    0 |                    UserSession userSession = (UserSession) request.getSession()  | 
  |  103 |     | 
                           .getAttribute(KRADConstants.USER_SESSION_KEY);  | 
  |  104 |    0 |                    form = getSessionDocumentService().getUifDocumentForm(documentNumber, formKeyParam, userSession,  | 
  |  105 |     | 
                           request.getRemoteAddr());  | 
  |  106 |    0 |                }  | 
  |  107 |     | 
           } else { | 
  |  108 |    0 |                form = createInitialForm(request);  | 
  |  109 |     | 
           }  | 
  |  110 |     | 
     | 
  |  111 |    0 |            return form;  | 
  |  112 |     | 
       }  | 
  |  113 |     | 
     | 
  |  114 |     | 
         | 
  |  115 |     | 
     | 
  |  116 |     | 
     | 
  |  117 |     | 
     | 
  |  118 |     | 
     | 
  |  119 |     | 
     | 
  |  120 |     | 
     | 
  |  121 |     | 
       protected abstract UifFormBase createInitialForm(HttpServletRequest request);  | 
  |  122 |     | 
     | 
  |  123 |    0 |        private Set<String> methodToCallsToNotCheckAuthorization = new HashSet<String>();  | 
  |  124 |     | 
       { | 
  |  125 |    0 |            methodToCallsToNotCheckAuthorization.add("performLookup"); | 
  |  126 |    0 |            methodToCallsToNotCheckAuthorization.add("performQuestion"); | 
  |  127 |    0 |            methodToCallsToNotCheckAuthorization.add("performQuestionWithInput"); | 
  |  128 |    0 |            methodToCallsToNotCheckAuthorization.add("performQuestionWithInputAgainBecauseOfErrors"); | 
  |  129 |    0 |            methodToCallsToNotCheckAuthorization.add("performQuestionWithoutInput"); | 
  |  130 |    0 |            methodToCallsToNotCheckAuthorization.add("performWorkgroupLookup"); | 
  |  131 |    0 |        }  | 
  |  132 |     | 
     | 
  |  133 |     | 
         | 
  |  134 |     | 
     | 
  |  135 |     | 
     | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
       protected final void addMethodToCallToUncheckedList(String methodToCall) { | 
  |  139 |    0 |            methodToCallsToNotCheckAuthorization.add(methodToCall);  | 
  |  140 |    0 |        }  | 
  |  141 |     | 
     | 
  |  142 |     | 
         | 
  |  143 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |     | 
       public Set<String> getMethodToCallsToNotCheckAuthorization() { | 
  |  147 |    0 |            return Collections.unmodifiableSet(methodToCallsToNotCheckAuthorization);  | 
  |  148 |     | 
       }  | 
  |  149 |     | 
     | 
  |  150 |     | 
         | 
  |  151 |     | 
     | 
  |  152 |     | 
     | 
  |  153 |     | 
     | 
  |  154 |     | 
       public void checkAuthorization(UifFormBase form, String methodToCall) throws AuthorizationException { | 
  |  155 |    0 |            String principalId = GlobalVariables.getUserSession().getPrincipalId();  | 
  |  156 |    0 |            AttributeSet roleQualifier = new AttributeSet(getRoleQualification(form, methodToCall));  | 
  |  157 |    0 |            AttributeSet permissionDetails = KRADUtils.getNamespaceAndActionClass(this.getClass());  | 
  |  158 |     | 
     | 
  |  159 |    0 |            if (!KimApiServiceLocator.getIdentityManagementService().isAuthorizedByTemplateName(principalId,  | 
  |  160 |     | 
                   KRADConstants.KRAD_NAMESPACE, KimConstants.PermissionTemplateNames.USE_SCREEN, Attributes.fromMap(permissionDetails),  | 
  |  161 |     | 
                   Attributes.fromMap(roleQualifier))) { | 
  |  162 |    0 |                throw new AuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalName(),  | 
  |  163 |     | 
                       methodToCall, this.getClass().getSimpleName());  | 
  |  164 |     | 
           }  | 
  |  165 |    0 |        }  | 
  |  166 |     | 
     | 
  |  167 |     | 
         | 
  |  168 |     | 
     | 
  |  169 |     | 
     | 
  |  170 |     | 
     | 
  |  171 |     | 
       protected Map<String, String> getRoleQualification(UifFormBase form, String methodToCall) { | 
  |  172 |    0 |            return new HashMap<String, String>();  | 
  |  173 |     | 
       }  | 
  |  174 |     | 
     | 
  |  175 |     | 
         | 
  |  176 |     | 
     | 
  |  177 |     | 
     | 
  |  178 |     | 
     | 
  |  179 |     | 
       @RequestMapping(method = RequestMethod.GET, params = "methodToCall=start")  | 
  |  180 |     | 
       public ModelAndView start(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  181 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  182 |     | 
     | 
  |  183 |    0 |            return getUIFModelAndView(form);  | 
  |  184 |     | 
       }  | 
  |  185 |     | 
     | 
  |  186 |     | 
         | 
  |  187 |     | 
     | 
  |  188 |     | 
     | 
  |  189 |     | 
     | 
  |  190 |     | 
     | 
  |  191 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=addLine")  | 
  |  192 |     | 
       public ModelAndView addLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, | 
  |  193 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  194 |     | 
     | 
  |  195 |    0 |            String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);  | 
  |  196 |    0 |            if (StringUtils.isBlank(selectedCollectionPath)) { | 
  |  197 |    0 |                throw new RuntimeException("Selected collection was not set for add line action, cannot add new line"); | 
  |  198 |     | 
           }  | 
  |  199 |     | 
     | 
  |  200 |    0 |            View view = uifForm.getPreviousView();  | 
  |  201 |    0 |            view.getViewHelperService().processCollectionAddLine(view, uifForm, selectedCollectionPath);  | 
  |  202 |     | 
     | 
  |  203 |    0 |            return getUIFModelAndView(uifForm);  | 
  |  204 |     | 
       }  | 
  |  205 |     | 
     | 
  |  206 |     | 
         | 
  |  207 |     | 
     | 
  |  208 |     | 
     | 
  |  209 |     | 
     | 
  |  210 |     | 
     | 
  |  211 |     | 
     | 
  |  212 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteLine")  | 
  |  213 |     | 
       public ModelAndView deleteLine(@ModelAttribute("KualiForm") UifFormBase uifForm, BindingResult result, | 
  |  214 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  215 |     | 
     | 
  |  216 |    0 |            String selectedCollectionPath = uifForm.getActionParamaterValue(UifParameters.SELLECTED_COLLECTION_PATH);  | 
  |  217 |    0 |            if (StringUtils.isBlank(selectedCollectionPath)) { | 
  |  218 |    0 |                throw new RuntimeException("Selected collection was not set for delete line action, cannot delete line"); | 
  |  219 |     | 
           }  | 
  |  220 |     | 
     | 
  |  221 |    0 |            int selectedLineIndex = -1;  | 
  |  222 |    0 |            String selectedLine = uifForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);  | 
  |  223 |    0 |            if (StringUtils.isNotBlank(selectedLine)) { | 
  |  224 |    0 |                selectedLineIndex = Integer.parseInt(selectedLine);  | 
  |  225 |     | 
           }  | 
  |  226 |     | 
     | 
  |  227 |    0 |            if (selectedLineIndex == -1) { | 
  |  228 |    0 |                throw new RuntimeException("Selected line index was not set for delete line action, cannot delete line"); | 
  |  229 |     | 
           }  | 
  |  230 |     | 
     | 
  |  231 |    0 |            View view = uifForm.getPreviousView();  | 
  |  232 |    0 |            view.getViewHelperService().processCollectionDeleteLine(view, uifForm, selectedCollectionPath,  | 
  |  233 |     | 
                   selectedLineIndex);  | 
  |  234 |     | 
     | 
  |  235 |    0 |            return getUIFModelAndView(uifForm);  | 
  |  236 |     | 
       }  | 
  |  237 |     | 
     | 
  |  238 |     | 
         | 
  |  239 |     | 
     | 
  |  240 |     | 
     | 
  |  241 |     | 
     | 
  |  242 |     | 
     | 
  |  243 |     | 
     | 
  |  244 |     | 
     | 
  |  245 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=toggleInactiveRecordDisplay")  | 
  |  246 |     | 
       public ModelAndView toggleInactiveRecordDisplay(@ModelAttribute("KualiForm") UifFormBase uifForm, | 
  |  247 |     | 
               BindingResult result, HttpServletRequest request, HttpServletResponse response) { | 
  |  248 |    0 |            String collectionGroupId = request.getParameter(UifParameters.REQUESTED_COMPONENT_ID);  | 
  |  249 |    0 |            if (StringUtils.isBlank(collectionGroupId)) { | 
  |  250 |    0 |                throw new RuntimeException(  | 
  |  251 |     | 
                       "Collection group id to update for inactive record display not found in request");  | 
  |  252 |     | 
           }  | 
  |  253 |     | 
     | 
  |  254 |    0 |            String showInactiveStr = request.getParameter(UifParameters.SHOW_INACTIVE_RECORDS);  | 
  |  255 |    0 |            Boolean showInactive = false;  | 
  |  256 |    0 |            if (StringUtils.isNotBlank(showInactiveStr)) { | 
  |  257 |     | 
                 | 
  |  258 |    0 |                showInactive = (Boolean) (new BooleanFormatter()).convertFromPresentationFormat(showInactiveStr);  | 
  |  259 |     | 
           } else { | 
  |  260 |    0 |                throw new RuntimeException("Show inactive records flag not found in request"); | 
  |  261 |     | 
           }  | 
  |  262 |     | 
     | 
  |  263 |    0 |            CollectionGroup collectionGroup = (CollectionGroup) ComponentFactory.getComponentById(uifForm, collectionGroupId);  | 
  |  264 |     | 
     | 
  |  265 |     | 
             | 
  |  266 |    0 |            collectionGroup.setShowInactive(showInactive);  | 
  |  267 |     | 
     | 
  |  268 |     | 
             | 
  |  269 |    0 |            uifForm.getView().getViewHelperService().performComponentLifecycle(uifForm, collectionGroup, collectionGroupId);  | 
  |  270 |    0 |            uifForm.getView().getViewIndex().indexComponent(collectionGroup);  | 
  |  271 |     | 
     | 
  |  272 |    0 |            return UifWebUtils.getComponentModelAndView(collectionGroup, uifForm);  | 
  |  273 |     | 
       }  | 
  |  274 |     | 
     | 
  |  275 |     | 
         | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |     | 
       @RequestMapping(params = "methodToCall=cancel")  | 
  |  279 |     | 
       public ModelAndView cancel(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  280 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  281 |    0 |            return close(form, result, request, response);  | 
  |  282 |     | 
       }  | 
  |  283 |     | 
     | 
  |  284 |     | 
         | 
  |  285 |     | 
     | 
  |  286 |     | 
     | 
  |  287 |     | 
       @RequestMapping(params = "methodToCall=close")  | 
  |  288 |     | 
       public ModelAndView close(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  289 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  290 |    0 |            Properties props = new Properties();  | 
  |  291 |    0 |            props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.REFRESH);  | 
  |  292 |    0 |            if (StringUtils.isNotBlank(form.getReturnFormKey())) { | 
  |  293 |    0 |                props.put(UifParameters.FORM_KEY, form.getReturnFormKey());  | 
  |  294 |     | 
           }  | 
  |  295 |     | 
     | 
  |  296 |     | 
             | 
  |  297 |     | 
             | 
  |  298 |    0 |            String returnUrl = form.getReturnLocation();  | 
  |  299 |    0 |            if (StringUtils.isBlank(returnUrl)) { | 
  |  300 |    0 |                returnUrl = ConfigContext.getCurrentContextConfig().getProperty(KRADConstants.APPLICATION_URL_KEY);  | 
  |  301 |     | 
           }  | 
  |  302 |     | 
     | 
  |  303 |    0 |            return performRedirect(form, returnUrl, props);  | 
  |  304 |     | 
       }  | 
  |  305 |     | 
     | 
  |  306 |     | 
         | 
  |  307 |     | 
     | 
  |  308 |     | 
     | 
  |  309 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=navigate")  | 
  |  310 |     | 
       public ModelAndView navigate(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  311 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  312 |    0 |            String pageId = form.getActionParamaterValue(UifParameters.NAVIGATE_TO_PAGE_ID);  | 
  |  313 |     | 
     | 
  |  314 |     | 
             | 
  |  315 |    0 |            form.setRenderFullView(false);  | 
  |  316 |     | 
     | 
  |  317 |    0 |            return getUIFModelAndView(form, form.getViewId(), pageId);  | 
  |  318 |     | 
       }  | 
  |  319 |     | 
     | 
  |  320 |     | 
       @RequestMapping(params = "methodToCall=refresh")  | 
  |  321 |     | 
       public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  322 |     | 
               HttpServletRequest request, HttpServletResponse response) throws Exception { | 
  |  323 |     | 
             | 
  |  324 |     | 
             | 
  |  325 |    0 |            return getUIFModelAndView(form);  | 
  |  326 |     | 
       }  | 
  |  327 |     | 
     | 
  |  328 |     | 
         | 
  |  329 |     | 
     | 
  |  330 |     | 
     | 
  |  331 |     | 
     | 
  |  332 |     | 
     | 
  |  333 |     | 
     | 
  |  334 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=updateComponent")  | 
  |  335 |     | 
       public ModelAndView updateComponent(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  336 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  337 |    0 |            String requestedComponentId = request.getParameter(UifParameters.REQUESTED_COMPONENT_ID);  | 
  |  338 |    0 |            if (StringUtils.isBlank(requestedComponentId)) { | 
  |  339 |    0 |                throw new RuntimeException("Requested component id for update not found in request"); | 
  |  340 |     | 
           }  | 
  |  341 |     | 
     | 
  |  342 |    0 |            Component comp = ComponentFactory.getComponentByIdWithLifecycle(form, requestedComponentId);  | 
  |  343 |     | 
     | 
  |  344 |    0 |            return UifWebUtils.getComponentModelAndView(comp, form);  | 
  |  345 |     | 
       }  | 
  |  346 |     | 
     | 
  |  347 |     | 
         | 
  |  348 |     | 
     | 
  |  349 |     | 
     | 
  |  350 |     | 
     | 
  |  351 |     | 
       @RequestMapping(method = RequestMethod.POST, params = "methodToCall=performLookup")  | 
  |  352 |     | 
       public ModelAndView performLookup(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, | 
  |  353 |     | 
               HttpServletRequest request, HttpServletResponse response) { | 
  |  354 |    0 |            Properties lookupParameters = form.getActionParametersAsProperties();  | 
  |  355 |     | 
     | 
  |  356 |    0 |            String lookupObjectClassName = (String) lookupParameters.get(UifParameters.DATA_OBJECT_CLASS_NAME);  | 
  |  357 |    0 |            Class<?> lookupObjectClass = null;  | 
  |  358 |     | 
           try { | 
  |  359 |    0 |                lookupObjectClass = Class.forName(lookupObjectClassName);  | 
  |  360 |    0 |            } catch (ClassNotFoundException e) { | 
  |  361 |    0 |                LOG.error("Unable to get class for name: " + lookupObjectClassName); | 
  |  362 |    0 |                throw new RuntimeException("Unable to get class for name: " + lookupObjectClassName, e); | 
  |  363 |    0 |            }  | 
  |  364 |     | 
     | 
  |  365 |     | 
             | 
  |  366 |    0 |            String lookupParameterString = (String) lookupParameters.get(UifParameters.LOOKUP_PARAMETERS);  | 
  |  367 |    0 |            if (lookupParameterString != null) { | 
  |  368 |    0 |                Map<String, String> lookupParameterFields = WebUtils.getMapFromParameterString(lookupParameterString);  | 
  |  369 |    0 |                for (Entry<String, String> lookupParameter : lookupParameterFields.entrySet()) { | 
  |  370 |    0 |                    String lookupParameterValue = LookupInquiryUtils.retrieveLookupParameterValue(form, request,  | 
  |  371 |     | 
                           lookupObjectClass, lookupParameter.getValue(), lookupParameter.getKey());  | 
  |  372 |    0 |                    if (StringUtils.isNotBlank(lookupParameterValue)) { | 
  |  373 |    0 |                        lookupParameters.put(UifPropertyPaths.CRITERIA_FIELDS + "['" + lookupParameter.getValue() + "']", lookupParameterValue);  | 
  |  374 |     | 
                   }  | 
  |  375 |    0 |                }  | 
  |  376 |     | 
           }  | 
  |  377 |     | 
     | 
  |  378 |     | 
             | 
  |  379 |     | 
     | 
  |  380 |     | 
             | 
  |  381 |     | 
     | 
  |  382 |    0 |            String baseLookupUrl = (String) lookupParameters.get(UifParameters.BASE_LOOKUP_URL);  | 
  |  383 |    0 |            lookupParameters.remove(UifParameters.BASE_LOOKUP_URL);  | 
  |  384 |     | 
     | 
  |  385 |     | 
             | 
  |  386 |    0 |            lookupParameters.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.START);  | 
  |  387 |    0 |            String autoSearchString = (String) lookupParameters.get(UifParameters.AUTO_SEARCH);  | 
  |  388 |    0 |            if (Boolean.parseBoolean(autoSearchString)) { | 
  |  389 |    0 |                lookupParameters.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.SEARCH);  | 
  |  390 |     | 
           }  | 
  |  391 |     | 
     | 
  |  392 |    0 |            lookupParameters.put(UifParameters.RETURN_LOCATION, form.getFormPostUrl());  | 
  |  393 |    0 |            lookupParameters.put(UifParameters.RETURN_FORM_KEY, form.getFormKey());  | 
  |  394 |     | 
     | 
  |  395 |     | 
             | 
  |  396 |    0 |            if (lookupObjectClass != null) { | 
  |  397 |    0 |                ModuleService responsibleModuleService = KRADServiceLocatorWeb.getKualiModuleService()  | 
  |  398 |     | 
                       .getResponsibleModuleService(lookupObjectClass);  | 
  |  399 |    0 |                if (responsibleModuleService != null && responsibleModuleService.isExternalizable(lookupObjectClass)) { | 
  |  400 |    0 |                    Map<String, String> parameterMap = new HashMap<String, String>();  | 
  |  401 |    0 |                    Enumeration<Object> e = lookupParameters.keys();  | 
  |  402 |    0 |                    while (e.hasMoreElements()) { | 
  |  403 |    0 |                        String paramName = (String) e.nextElement();  | 
  |  404 |    0 |                        parameterMap.put(paramName, lookupParameters.getProperty(paramName));  | 
  |  405 |    0 |                    }  | 
  |  406 |     | 
     | 
  |  407 |    0 |                    String lookupUrl = responsibleModuleService.getExternalizableBusinessObjectLookupUrl(lookupObjectClass,  | 
  |  408 |     | 
                           parameterMap);  | 
  |  409 |    0 |                    return performRedirect(form, lookupUrl, new Properties());  | 
  |  410 |     | 
               }  | 
  |  411 |     | 
           }  | 
  |  412 |     | 
     | 
  |  413 |    0 |            return performRedirect(form, baseLookupUrl, lookupParameters);  | 
  |  414 |     | 
       }  | 
  |  415 |     | 
     | 
  |  416 |     | 
         | 
  |  417 |     | 
     | 
  |  418 |     | 
     | 
  |  419 |     | 
     | 
  |  420 |     | 
     | 
  |  421 |     | 
     | 
  |  422 |     | 
       @RequestMapping(method = RequestMethod.GET, params = "methodToCall=performFieldSuggest")  | 
  |  423 |     | 
       public @ResponseBody AttributeQueryResult performFieldSuggest(@ModelAttribute("KualiForm") UifFormBase form, | 
  |  424 |     | 
               BindingResult result, HttpServletRequest request, HttpServletResponse response) { | 
  |  425 |     | 
     | 
  |  426 |     | 
             | 
  |  427 |    0 |            Map<String, String> queryParameters = new HashMap<String, String>();  | 
  |  428 |    0 |            for (Object parameterName : request.getParameterMap().keySet()) { | 
  |  429 |    0 |                if (parameterName.toString().startsWith(UifParameters.QUERY_PARAMETER + ".")) { | 
  |  430 |    0 |                    String fieldName =  | 
  |  431 |     | 
                           StringUtils.substringAfter(parameterName.toString(), UifParameters.QUERY_PARAMETER + ".");  | 
  |  432 |    0 |                    String fieldValue = request.getParameter(parameterName.toString());  | 
  |  433 |    0 |                    queryParameters.put(fieldName, fieldValue);  | 
  |  434 |    0 |                }  | 
  |  435 |     | 
           }  | 
  |  436 |     | 
     | 
  |  437 |     | 
             | 
  |  438 |    0 |            String queryFieldId = request.getParameter(UifParameters.QUERY_FIELD_ID);  | 
  |  439 |    0 |            if (StringUtils.isBlank(queryFieldId)) { | 
  |  440 |    0 |                throw new RuntimeException(  | 
  |  441 |     | 
                       "Unable to find id for field to perform query on under request parameter name: " +  | 
  |  442 |     | 
                               UifParameters.QUERY_FIELD_ID);  | 
  |  443 |     | 
           }  | 
  |  444 |     | 
     | 
  |  445 |     | 
             | 
  |  446 |    0 |            String queryTerm = request.getParameter(UifParameters.QUERY_TERM);  | 
  |  447 |    0 |            if (StringUtils.isBlank(queryTerm)) { | 
  |  448 |    0 |                throw new RuntimeException(  | 
  |  449 |     | 
                       "Unable to find id for query term value for attribute query on under request parameter name: " +  | 
  |  450 |     | 
                               UifParameters.QUERY_TERM);  | 
  |  451 |     | 
           }  | 
  |  452 |     | 
     | 
  |  453 |     | 
             | 
  |  454 |    0 |            AttributeQueryResult queryResult = KRADServiceLocatorWeb.getAttributeQueryService()  | 
  |  455 |     | 
                   .performFieldSuggestQuery(form.getView(), queryFieldId, queryTerm, queryParameters);  | 
  |  456 |     | 
     | 
  |  457 |    0 |            return queryResult;  | 
  |  458 |     | 
       }  | 
  |  459 |     | 
     | 
  |  460 |     | 
         | 
  |  461 |     | 
     | 
  |  462 |     | 
     | 
  |  463 |     | 
     | 
  |  464 |     | 
     | 
  |  465 |     | 
     | 
  |  466 |     | 
     | 
  |  467 |     | 
       @RequestMapping(method = RequestMethod.GET, params = "methodToCall=performFieldQuery")  | 
  |  468 |     | 
       public @ResponseBody AttributeQueryResult performFieldQuery(@ModelAttribute("KualiForm") UifFormBase form, | 
  |  469 |     | 
               BindingResult result, HttpServletRequest request, HttpServletResponse response) { | 
  |  470 |     | 
     | 
  |  471 |     | 
             | 
  |  472 |    0 |            Map<String, String> queryParameters = new HashMap<String, String>();  | 
  |  473 |    0 |            for (Object parameterName : request.getParameterMap().keySet()) { | 
  |  474 |    0 |                if (parameterName.toString().startsWith(UifParameters.QUERY_PARAMETER + ".")) { | 
  |  475 |    0 |                    String fieldName =  | 
  |  476 |     | 
                           StringUtils.substringAfter(parameterName.toString(), UifParameters.QUERY_PARAMETER + ".");  | 
  |  477 |    0 |                    String fieldValue = request.getParameter(parameterName.toString());  | 
  |  478 |    0 |                    queryParameters.put(fieldName, fieldValue);  | 
  |  479 |    0 |                }  | 
  |  480 |     | 
           }  | 
  |  481 |     | 
     | 
  |  482 |     | 
             | 
  |  483 |    0 |            String queryFieldId = request.getParameter(UifParameters.QUERY_FIELD_ID);  | 
  |  484 |    0 |            if (StringUtils.isBlank(queryFieldId)) { | 
  |  485 |    0 |                throw new RuntimeException(  | 
  |  486 |     | 
                       "Unable to find id for field to perform query on under request parameter name: " +  | 
  |  487 |     | 
                               UifParameters.QUERY_FIELD_ID);  | 
  |  488 |     | 
           }  | 
  |  489 |     | 
     | 
  |  490 |     | 
             | 
  |  491 |    0 |            AttributeQueryResult queryResult = KRADServiceLocatorWeb.getAttributeQueryService()  | 
  |  492 |     | 
                   .performFieldQuery(form.getView(), queryFieldId, queryParameters);  | 
  |  493 |     | 
     | 
  |  494 |    0 |            return queryResult;  | 
  |  495 |     | 
       }  | 
  |  496 |     | 
     | 
  |  497 |     | 
         | 
  |  498 |     | 
     | 
  |  499 |     | 
     | 
  |  500 |     | 
     | 
  |  501 |     | 
     | 
  |  502 |     | 
     | 
  |  503 |     | 
     | 
  |  504 |     | 
     | 
  |  505 |     | 
     | 
  |  506 |     | 
     | 
  |  507 |     | 
     | 
  |  508 |     | 
     | 
  |  509 |     | 
       protected ModelAndView performRedirect(UifFormBase form, String baseUrl, Properties urlParameters) { | 
  |  510 |     | 
             | 
  |  511 |     | 
             | 
  |  512 |    0 |            urlParameters.setProperty(UifConstants.UrlParams.HISTORY, form.getFormHistory().getHistoryParameterString());  | 
  |  513 |     | 
     | 
  |  514 |     | 
             | 
  |  515 |     | 
             | 
  |  516 |    0 |            if (urlParameters.get("ajaxCall") != null && urlParameters.get("ajaxCall").equals("true")) { | 
  |  517 |    0 |                urlParameters.remove("ajaxCall"); | 
  |  518 |    0 |                String redirectUrl = UrlFactory.parameterizeUrl(baseUrl, urlParameters);  | 
  |  519 |     | 
     | 
  |  520 |    0 |                ModelAndView modelAndView = new ModelAndView("redirectURL"); | 
  |  521 |    0 |                modelAndView.addObject("redirectUrl", redirectUrl); | 
  |  522 |    0 |                return modelAndView;  | 
  |  523 |     | 
           }  | 
  |  524 |     | 
     | 
  |  525 |    0 |            String redirectUrl = UrlFactory.parameterizeUrl(baseUrl, urlParameters);  | 
  |  526 |    0 |            ModelAndView modelAndView = new ModelAndView(REDIRECT_PREFIX + redirectUrl);  | 
  |  527 |     | 
     | 
  |  528 |    0 |            return modelAndView;  | 
  |  529 |     | 
       }  | 
  |  530 |     | 
     | 
  |  531 |     | 
       protected ModelAndView getUIFModelAndView(UifFormBase form) { | 
  |  532 |    0 |            return getUIFModelAndView(form, form.getViewId(), form.getPageId());  | 
  |  533 |     | 
       }  | 
  |  534 |     | 
     | 
  |  535 |     | 
       protected ModelAndView getUIFModelAndView(UifFormBase form, String viewId) { | 
  |  536 |    0 |            return getUIFModelAndView(form, viewId, "");  | 
  |  537 |     | 
       }  | 
  |  538 |     | 
     | 
  |  539 |     | 
         | 
  |  540 |     | 
     | 
  |  541 |     | 
     | 
  |  542 |     | 
     | 
  |  543 |     | 
     | 
  |  544 |     | 
     | 
  |  545 |     | 
     | 
  |  546 |     | 
     | 
  |  547 |     | 
     | 
  |  548 |     | 
     | 
  |  549 |     | 
     | 
  |  550 |     | 
     | 
  |  551 |     | 
     | 
  |  552 |     | 
       protected ModelAndView getUIFModelAndView(UifFormBase form, String viewId, String pageId) { | 
  |  553 |    0 |            return UifWebUtils.getUIFModelAndView(form, viewId, pageId);  | 
  |  554 |     | 
       }  | 
  |  555 |     | 
     | 
  |  556 |     | 
       protected ViewService getViewService() { | 
  |  557 |    0 |            return KRADServiceLocatorWeb.getViewService();  | 
  |  558 |     | 
       }  | 
  |  559 |     | 
     | 
  |  560 |     | 
       public SessionDocumentService getSessionDocumentService() { | 
  |  561 |    0 |            return KRADServiceLocatorWeb.getSessionDocumentService();  | 
  |  562 |     | 
       }  | 
  |  563 |     | 
     | 
  |  564 |     | 
   }  |