View Javadoc
1   /*
2    * Copyright 2012 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.select.lookup;
17  
18  import org.kuali.ole.sys.OLEConstants;
19  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
20  import org.kuali.rice.kns.web.struts.form.LookupForm;
21  import org.kuali.rice.kns.web.ui.Field;
22  import org.kuali.rice.kns.web.ui.Row;
23  import org.kuali.rice.krad.bo.BusinessObject;
24  import java.util.Iterator;
25  import java.util.List;
26  import java.util.Map;
27  
28  public class OleLoadSumRecordLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
29  
30      @Override
31      public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
32          String fileName = fieldValues.get("fileName");
33          if (!fileName.contains("*")) {
34              StringBuilder loadFileName = new StringBuilder();
35              loadFileName.append("*");
36              loadFileName.append(fileName);
37              loadFileName.append("*");
38              fieldValues.put("fileName", loadFileName.toString());
39          }
40          return super.getSearchResults(fieldValues);
41      }
42  
43      @Override
44      public void performClear(LookupForm lookupForm){
45          super.performClear(lookupForm);
46          for (Iterator iter = this.getRows().iterator(); iter.hasNext();) {
47              Row row = (Row) iter.next();
48              for (Iterator iterator = row.getFields().iterator(); iterator.hasNext();) {
49                  Field field = (Field) iterator.next();
50                  if(field.getPropertyName().equalsIgnoreCase(OLEConstants.PRINCIPAL_ID)){
51                      field.setPropertyValue(null);
52                  }
53              }
54          }
55      }
56  
57  }