|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
   package org.kuali.rice.kns.lookup;  | 
  |  18 |     | 
     | 
  |  19 |     | 
   import java.sql.Date;  | 
  |  20 |     | 
   import java.sql.Timestamp;  | 
  |  21 |     | 
   import java.text.ParseException;  | 
  |  22 |     | 
   import java.util.ArrayList;  | 
  |  23 |     | 
   import java.util.Calendar;  | 
  |  24 |     | 
   import java.util.Collection;  | 
  |  25 |     | 
   import java.util.Comparator;  | 
  |  26 |     | 
   import java.util.HashMap;  | 
  |  27 |     | 
   import java.util.HashSet;  | 
  |  28 |     | 
   import java.util.Iterator;  | 
  |  29 |     | 
   import java.util.List;  | 
  |  30 |     | 
   import java.util.Map;  | 
  |  31 |     | 
   import java.util.Set;  | 
  |  32 |     | 
   import java.util.StringTokenizer;  | 
  |  33 |     | 
     | 
  |  34 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  35 |     | 
   import org.apache.ojb.broker.query.Criteria;  | 
  |  36 |     | 
   import org.kuali.rice.core.api.config.property.ConfigurationService;  | 
  |  37 |     | 
   import org.kuali.rice.core.api.datetime.DateTimeService;  | 
  |  38 |     | 
   import org.kuali.rice.core.api.encryption.EncryptionService;  | 
  |  39 |     | 
   import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;  | 
  |  40 |     | 
   import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator;  | 
  |  41 |     | 
   import org.kuali.rice.kns.bo.BusinessObject;  | 
  |  42 |     | 
   import org.kuali.rice.kns.bo.BusinessObjectRelationship;  | 
  |  43 |     | 
   import org.kuali.rice.kns.datadictionary.RelationshipDefinition;  | 
  |  44 |     | 
   import org.kuali.rice.kns.datadictionary.control.ControlDefinition;  | 
  |  45 |     | 
   import org.kuali.rice.kns.datadictionary.exception.UnknownBusinessClassAttributeException;  | 
  |  46 |     | 
   import org.kuali.rice.kns.exception.ClassNotPersistableException;  | 
  |  47 |     | 
   import org.kuali.rice.kns.service.BusinessObjectDictionaryService;  | 
  |  48 |     | 
   import org.kuali.rice.kns.service.BusinessObjectMetaDataService;  | 
  |  49 |     | 
   import org.kuali.rice.kns.service.DataDictionaryService;  | 
  |  50 |     | 
   import org.kuali.rice.kns.service.KNSServiceLocator;  | 
  |  51 |     | 
   import org.kuali.rice.kns.service.PersistenceStructureService;  | 
  |  52 |     | 
   import org.kuali.rice.kns.util.KNSConstants;  | 
  |  53 |     | 
   import org.kuali.rice.kns.util.KNSPropertyConstants;  | 
  |  54 |     | 
   import org.kuali.rice.kns.util.ObjectUtils;  | 
  |  55 |     | 
   import org.kuali.rice.kns.web.comparator.NullValueComparator;  | 
  |  56 |     | 
   import org.kuali.rice.kns.web.ui.Field;  | 
  |  57 |     | 
   import org.kuali.rice.kns.web.ui.ResultRow;  | 
  |  58 |     | 
     | 
  |  59 |     | 
     | 
  |  60 |     | 
     | 
  |  61 |     | 
     | 
  |  62 |     | 
   public class LookupUtils { | 
  |  63 |    0 |        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LookupUtils.class);  | 
  |  64 |     | 
     | 
  |  65 |     | 
       private static DataDictionaryService dataDictionaryService;  | 
  |  66 |     | 
       private static PersistenceStructureService persistenceStructureService;  | 
  |  67 |     | 
       private static BusinessObjectDictionaryService businessObjectDictionaryService;  | 
  |  68 |     | 
       private static BusinessObjectMetaDataService businessObjectMetaDataService;  | 
  |  69 |     | 
       private static DateTimeService dateTimeService;  | 
  |  70 |     | 
     | 
  |  71 |    0 |        public LookupUtils() { | 
  |  72 |     | 
             | 
  |  73 |    0 |        }  | 
  |  74 |     | 
     | 
  |  75 |     | 
       public void setBusinessObjectDictionaryService(BusinessObjectDictionaryService businessObjectDictionaryService) { | 
  |  76 |    0 |            LookupUtils.businessObjectDictionaryService = businessObjectDictionaryService;  | 
  |  77 |    0 |        }  | 
  |  78 |     | 
     | 
  |  79 |     | 
       public void setDataDictionaryService(DataDictionaryService ddService) { | 
  |  80 |    0 |            LookupUtils.dataDictionaryService = ddService;  | 
  |  81 |    0 |        }  | 
  |  82 |     | 
     | 
  |  83 |     | 
       public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) { | 
  |  84 |    0 |            LookupUtils.persistenceStructureService = persistenceStructureService;  | 
  |  85 |    0 |        }  | 
  |  86 |     | 
     | 
  |  87 |     | 
       public void setDateTimeService(DateTimeService dateTimeService) { | 
  |  88 |    0 |                    LookupUtils.dateTimeService = dateTimeService;  | 
  |  89 |    0 |            }  | 
  |  90 |     | 
     | 
  |  91 |     | 
             | 
  |  92 |     | 
     | 
  |  93 |     | 
     | 
  |  94 |     | 
     | 
  |  95 |     | 
       public void setBusinessObjectMetaDataService(BusinessObjectMetaDataService businessObjectMetaDataService) { | 
  |  96 |    0 |            LookupUtils.businessObjectMetaDataService = businessObjectMetaDataService;  | 
  |  97 |    0 |        }  | 
  |  98 |     | 
     | 
  |  99 |     | 
         | 
  |  100 |     | 
     | 
  |  101 |     | 
     | 
  |  102 |     | 
     | 
  |  103 |     | 
     | 
  |  104 |     | 
     | 
  |  105 |     | 
     | 
  |  106 |     | 
     | 
  |  107 |     | 
     | 
  |  108 |     | 
     | 
  |  109 |     | 
      public static String forceUppercase(Class<?> dataObjectClass, String fieldName, String fieldValue) { | 
  |  110 |     | 
     | 
  |  111 |     | 
            | 
  |  112 |    0 |           if (StringUtils.isBlank(fieldValue)) { | 
  |  113 |    0 |               return fieldValue;  | 
  |  114 |     | 
          }  | 
  |  115 |     | 
     | 
  |  116 |     | 
            | 
  |  117 |    0 |           if (dataObjectClass == null) { | 
  |  118 |    0 |               throw new IllegalArgumentException("Parameter dataObjectClass passed in with null value."); | 
  |  119 |     | 
          }  | 
  |  120 |     | 
            | 
  |  121 |    0 |           if (StringUtils.isBlank(fieldName)) { | 
  |  122 |    0 |               throw new IllegalArgumentException("Parameter fieldName passed in with empty value."); | 
  |  123 |     | 
          }  | 
  |  124 |     | 
     | 
  |  125 |    0 |           if (!dataDictionaryService.isAttributeDefined(dataObjectClass, fieldName).booleanValue()) { | 
  |  126 |    0 |               return fieldValue;  | 
  |  127 |     | 
          }  | 
  |  128 |     | 
     | 
  |  129 |     | 
     | 
  |  130 |    0 |           boolean forceUpperCase = false;  | 
  |  131 |     | 
          try { | 
  |  132 |    0 |               forceUpperCase = dataDictionaryService.getAttributeForceUppercase(dataObjectClass, fieldName).booleanValue();  | 
  |  133 |     | 
          }  | 
  |  134 |    0 |           catch (UnknownBusinessClassAttributeException ubae) { | 
  |  135 |     | 
                | 
  |  136 |    0 |           }  | 
  |  137 |    0 |           if (forceUpperCase && !fieldValue.endsWith(EncryptionService.ENCRYPTION_POST_PREFIX)) { | 
  |  138 |    0 |               return fieldValue.toUpperCase();  | 
  |  139 |     | 
          }  | 
  |  140 |     | 
            | 
  |  141 |    0 |           return fieldValue;  | 
  |  142 |     | 
      }  | 
  |  143 |     | 
     | 
  |  144 |     | 
        | 
  |  145 |     | 
     | 
  |  146 |     | 
     | 
  |  147 |     | 
     | 
  |  148 |     | 
     | 
  |  149 |     | 
     | 
  |  150 |     | 
     | 
  |  151 |     | 
     | 
  |  152 |     | 
     | 
  |  153 |     | 
      public static Map<String, String> forceUppercase(Class<?> dataObjectClass, Map<String, String> fieldValues) { | 
  |  154 |    0 |           if (dataObjectClass == null) { | 
  |  155 |    0 |               throw new IllegalArgumentException("Parameter boClass passed in with null value."); | 
  |  156 |     | 
          }  | 
  |  157 |     | 
            | 
  |  158 |    0 |           if (fieldValues == null) { | 
  |  159 |    0 |               throw new IllegalArgumentException("Parameter fieldValues passed in with null value."); | 
  |  160 |     | 
          }  | 
  |  161 |     | 
     | 
  |  162 |    0 |           for (String fieldName : fieldValues.keySet()) { | 
  |  163 |    0 |               fieldValues.put(fieldName, LookupUtils.forceUppercase(dataObjectClass, fieldName, (String) fieldValues.get(fieldName)));  | 
  |  164 |     | 
          }  | 
  |  165 |     | 
            | 
  |  166 |    0 |           return fieldValues;  | 
  |  167 |     | 
      }  | 
  |  168 |     | 
     | 
  |  169 |     | 
         | 
  |  170 |     | 
     | 
  |  171 |     | 
     | 
  |  172 |     | 
     | 
  |  173 |     | 
     | 
  |  174 |     | 
     | 
  |  175 |     | 
     | 
  |  176 |     | 
       public static void applySearchResultsLimit(Class businessObjectClass, Criteria criteria, DatabasePlatform platform) { | 
  |  177 |    0 |            Integer limit = getSearchResultsLimit(businessObjectClass);  | 
  |  178 |    0 |            if (limit != null) { | 
  |  179 |    0 |                platform.applyLimit(limit, criteria);  | 
  |  180 |     | 
           }  | 
  |  181 |    0 |        }  | 
  |  182 |     | 
     | 
  |  183 |     | 
         | 
  |  184 |     | 
     | 
  |  185 |     | 
     | 
  |  186 |     | 
     | 
  |  187 |     | 
     | 
  |  188 |     | 
     | 
  |  189 |     | 
       public static void applySearchResultsLimit(Class businessObjectClass, org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria criteria) { | 
  |  190 |    0 |            Integer limit = getSearchResultsLimit(businessObjectClass);  | 
  |  191 |    0 |            if (limit != null) { | 
  |  192 |    0 |                    criteria.setSearchLimit(limit);  | 
  |  193 |     | 
                   }  | 
  |  194 |    0 |        }  | 
  |  195 |     | 
     | 
  |  196 |     | 
         | 
  |  197 |     | 
     | 
  |  198 |     | 
     | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
     | 
  |  202 |     | 
     | 
  |  203 |     | 
     | 
  |  204 |     | 
     | 
  |  205 |     | 
       public static Integer getSearchResultsLimit(Class businessObjectClass) { | 
  |  206 |    0 |            Integer limit = null;  | 
  |  207 |    0 |            if (BusinessObject.class.isAssignableFrom(businessObjectClass)) { | 
  |  208 |    0 |                limit = getBusinessObjectSearchResultsLimit(businessObjectClass);  | 
  |  209 |     | 
           }  | 
  |  210 |    0 |            if (limit == null) { | 
  |  211 |    0 |                limit = getApplicationSearchResultsLimit();  | 
  |  212 |     | 
           }  | 
  |  213 |    0 |            return limit;  | 
  |  214 |     | 
       }  | 
  |  215 |     | 
     | 
  |  216 |     | 
         | 
  |  217 |     | 
     | 
  |  218 |     | 
     | 
  |  219 |     | 
       private static Integer getApplicationSearchResultsLimit() { | 
  |  220 |    0 |            String limitString = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.LOOKUP_PARM_DETAIL_TYPE, KNSConstants.SystemGroupParameterNames.LOOKUP_RESULTS_LIMIT);  | 
  |  221 |    0 |            if (limitString != null) { | 
  |  222 |    0 |                return Integer.valueOf(limitString);  | 
  |  223 |     | 
           }  | 
  |  224 |    0 |            return null;  | 
  |  225 |     | 
       }  | 
  |  226 |     | 
     | 
  |  227 |     | 
         | 
  |  228 |     | 
     | 
  |  229 |     | 
     | 
  |  230 |     | 
     | 
  |  231 |     | 
     | 
  |  232 |     | 
     | 
  |  233 |     | 
       private static Integer getBusinessObjectSearchResultsLimit(Class businessObjectClass) { | 
  |  234 |    0 |            return businessObjectDictionaryService.getLookupResultSetLimit(businessObjectClass);  | 
  |  235 |     | 
       }  | 
  |  236 |     | 
     | 
  |  237 |     | 
         | 
  |  238 |     | 
     | 
  |  239 |     | 
     | 
  |  240 |     | 
     | 
  |  241 |     | 
     | 
  |  242 |     | 
     | 
  |  243 |     | 
       public static Integer getApplicationMaximumSearchResulsPerPageForMultipleValueLookups() { | 
  |  244 |    0 |            String limitString = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.LOOKUP_PARM_DETAIL_TYPE, KNSConstants.SystemGroupParameterNames.MULTIPLE_VALUE_LOOKUP_RESULTS_PER_PAGE);  | 
  |  245 |    0 |            if (limitString != null) { | 
  |  246 |    0 |                return Integer.valueOf(limitString);  | 
  |  247 |     | 
           }  | 
  |  248 |    0 |            return null;  | 
  |  249 |     | 
       }  | 
  |  250 |     | 
     | 
  |  251 |     | 
         | 
  |  252 |     | 
     | 
  |  253 |     | 
     | 
  |  254 |     | 
     | 
  |  255 |     | 
     | 
  |  256 |     | 
     | 
  |  257 |     | 
       public static List<String> translateReadOnlyFieldsToList(String readOnlyFieldsString) { | 
  |  258 |    0 |            List<String> readOnlyFieldsList = new ArrayList<String>();  | 
  |  259 |    0 |            if (StringUtils.isNotEmpty(readOnlyFieldsString)) { | 
  |  260 |    0 |                if (readOnlyFieldsString.indexOf(",") > 0) { | 
  |  261 |    0 |                    StringTokenizer token = new StringTokenizer(readOnlyFieldsString, ",");  | 
  |  262 |    0 |                    while (token.hasMoreTokens()) { | 
  |  263 |    0 |                        String element = token.nextToken();  | 
  |  264 |    0 |                        readOnlyFieldsList.add(element);  | 
  |  265 |    0 |                    }  | 
  |  266 |    0 |                }  | 
  |  267 |     | 
               else { | 
  |  268 |    0 |                    readOnlyFieldsList.add(readOnlyFieldsString);  | 
  |  269 |     | 
               }  | 
  |  270 |     | 
           }  | 
  |  271 |    0 |          return readOnlyFieldsList;  | 
  |  272 |     | 
       }  | 
  |  273 |     | 
     | 
  |  274 |     | 
         | 
  |  275 |     | 
     | 
  |  276 |     | 
     | 
  |  277 |     | 
     | 
  |  278 |     | 
     | 
  |  279 |     | 
     | 
  |  280 |     | 
       public static Map translateFieldConversions(String fieldConversionsString) { | 
  |  281 |    0 |            Map fieldConversionsMap = new HashMap();  | 
  |  282 |    0 |            if (StringUtils.isNotEmpty(fieldConversionsString)) { | 
  |  283 |    0 |                if (fieldConversionsString.indexOf(",") > 0) { | 
  |  284 |    0 |                    StringTokenizer token = new StringTokenizer(fieldConversionsString, ",");  | 
  |  285 |    0 |                    while (token.hasMoreTokens()) { | 
  |  286 |    0 |                        String element = token.nextToken();  | 
  |  287 |    0 |                        fieldConversionsMap.put(element.substring(0, element.indexOf(":")), element.substring(element.indexOf(":") + 1)); | 
  |  288 |    0 |                    }  | 
  |  289 |    0 |                }  | 
  |  290 |     | 
               else { | 
  |  291 |    0 |                    fieldConversionsMap.put(fieldConversionsString.substring(0, fieldConversionsString.indexOf(":")), fieldConversionsString.substring(fieldConversionsString.indexOf(":") + 1)); | 
  |  292 |     | 
               }  | 
  |  293 |     | 
           }  | 
  |  294 |    0 |            return fieldConversionsMap;  | 
  |  295 |     | 
       }  | 
  |  296 |     | 
     | 
  |  297 |     | 
       @Deprecated  | 
  |  298 |     | 
       public static Field setFieldQuickfinder(BusinessObject businessObject,  | 
  |  299 |     | 
               String attributeName, Field field, List displayedFieldNames) { | 
  |  300 |    0 |            return setFieldQuickfinder( businessObject, (String)null, false, 0, attributeName, field, displayedFieldNames );  | 
  |  301 |     | 
       }  | 
  |  302 |     | 
     | 
  |  303 |     | 
       @Deprecated  | 
  |  304 |     | 
       public static Field setFieldQuickfinder(BusinessObject businessObject,  | 
  |  305 |     | 
               String attributeName, Field field, List displayedFieldNames, SelectiveReferenceRefresher srr) { | 
  |  306 |    0 |            return setFieldQuickfinder( businessObject, (String)null, false, 0, attributeName, field, displayedFieldNames, srr );  | 
  |  307 |     | 
       }  | 
  |  308 |     | 
     | 
  |  309 |     | 
         | 
  |  310 |     | 
     | 
  |  311 |     | 
     | 
  |  312 |     | 
       @Deprecated  | 
  |  313 |     | 
       public static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index,  | 
  |  314 |     | 
               String attributeName, Field field, List displayedFieldNames, SelectiveReferenceRefresher srr) { | 
  |  315 |    0 |            field = setFieldQuickfinder(businessObject, collectionName, addLine, index, attributeName, field, displayedFieldNames);  | 
  |  316 |    0 |            if (srr != null) { | 
  |  317 |    0 |                String collectionPrefix = "";  | 
  |  318 |    0 |                if ( collectionName != null ) { | 
  |  319 |    0 |                    if (addLine) { | 
  |  320 |    0 |                        collectionPrefix = KNSConstants.MAINTENANCE_ADD_PREFIX + collectionName + ".";  | 
  |  321 |     | 
                   }  | 
  |  322 |     | 
                   else { | 
  |  323 |    0 |                        collectionPrefix = collectionName + "[" + index + "].";  | 
  |  324 |     | 
                   }  | 
  |  325 |     | 
               }  | 
  |  326 |    0 |                field.setReferencesToRefresh(convertReferencesToSelectCollectionToString(  | 
  |  327 |     | 
                       srr.getAffectedReferencesFromLookup(businessObject, attributeName, collectionPrefix)));  | 
  |  328 |     | 
           }  | 
  |  329 |    0 |            return field;  | 
  |  330 |     | 
       }  | 
  |  331 |     | 
     | 
  |  332 |     | 
         | 
  |  333 |     | 
     | 
  |  334 |     | 
     | 
  |  335 |     | 
       @Deprecated  | 
  |  336 |     | 
       public static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index,  | 
  |  337 |     | 
                                               String attributeName, Field field, List displayedFieldNames) { | 
  |  338 |    0 |            boolean noLookup = false;  | 
  |  339 |    0 |            if (businessObject == null) { | 
  |  340 |    0 |                return field;  | 
  |  341 |     | 
           }  | 
  |  342 |     | 
     | 
  |  343 |    0 |            Boolean noLookupField = businessObjectDictionaryService.noLookupFieldLookup(businessObject.getClass(), attributeName);  | 
  |  344 |    0 |            if (noLookupField != null && noLookupField) { | 
  |  345 |    0 |                noLookup = true;  | 
  |  346 |     | 
           }  | 
  |  347 |     | 
     | 
  |  348 |    0 |             return setFieldQuickfinder(businessObject, collectionName, addLine, index, attributeName, field, displayedFieldNames, noLookup);  | 
  |  349 |     | 
     | 
  |  350 |     | 
       }  | 
  |  351 |     | 
     | 
  |  352 |     | 
       @Deprecated  | 
  |  353 |     | 
       public static Field setFieldQuickfinder(BusinessObject businessObject, String collectionName, boolean addLine, int index, String attributeName, Field field, List displayedFieldNames, boolean noLookupField)  | 
  |  354 |     | 
       { | 
  |  355 |    0 |             if (businessObject == null) { | 
  |  356 |    0 |                return field;  | 
  |  357 |     | 
           }  | 
  |  358 |     | 
     | 
  |  359 |    0 |            if (noLookupField) { | 
  |  360 |    0 |                return field;  | 
  |  361 |     | 
           }  | 
  |  362 |    0 |            BusinessObjectRelationship relationship = null;  | 
  |  363 |    0 |            if ( LOG.isDebugEnabled() ) { | 
  |  364 |    0 |                LOG.debug( "setFieldQuickfinder("+businessObject.getClass().getName()+","+attributeName+","+field+","+displayedFieldNames+")" ); | 
  |  365 |     | 
           }  | 
  |  366 |     | 
     | 
  |  367 |    0 |            relationship = businessObjectMetaDataService.getBusinessObjectRelationship(businessObject, businessObject.getClass(), attributeName, "", false);  | 
  |  368 |     | 
     | 
  |  369 |    0 |            String collectionPrefix = "";  | 
  |  370 |    0 |            if ( collectionName != null ) { | 
  |  371 |    0 |                if (addLine) { | 
  |  372 |    0 |                    collectionPrefix = KNSConstants.MAINTENANCE_ADD_PREFIX + collectionName + ".";  | 
  |  373 |     | 
               }  | 
  |  374 |     | 
               else { | 
  |  375 |    0 |                    collectionPrefix = collectionName + "[" + index + "].";  | 
  |  376 |     | 
               }  | 
  |  377 |     | 
           }  | 
  |  378 |     | 
     | 
  |  379 |    0 |            if (relationship == null) { | 
  |  380 |    0 |                Class c = ObjectUtils.getPropertyType(businessObject, attributeName, persistenceStructureService);  | 
  |  381 |     | 
     | 
  |  382 |    0 |                if(c!=null) { | 
  |  383 |    0 |                    if (attributeName.contains(".")) { | 
  |  384 |    0 |                        attributeName = StringUtils.substringBeforeLast( attributeName, "." );  | 
  |  385 |     | 
                   }  | 
  |  386 |     | 
     | 
  |  387 |    0 |                    RelationshipDefinition ddReference = businessObjectMetaDataService.getBusinessObjectRelationshipDefinition(businessObject, attributeName);  | 
  |  388 |    0 |                    relationship = businessObjectMetaDataService.getBusinessObjectRelationship(ddReference, businessObject, businessObject.getClass(), attributeName, "", false);  | 
  |  389 |    0 |                    if(relationship!=null) { | 
  |  390 |    0 |                        field.setQuickFinderClassNameImpl(relationship.getRelatedClass().getName());  | 
  |  391 |    0 |                        field.setFieldConversions(generateFieldConversions( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, null));  | 
  |  392 |    0 |                        field.setLookupParameters(generateLookupParameters( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, null));  | 
  |  393 |    0 |                        field.setBaseLookupUrl(LookupUtils.getBaseLookupUrl(false));  | 
  |  394 |    0 |                        field.setImageSrc(businessObjectDictionaryService.getSearchIconOverride(businessObject.getClass()));  | 
  |  395 |     | 
                   }  | 
  |  396 |     | 
               }  | 
  |  397 |     | 
     | 
  |  398 |    0 |                return field;  | 
  |  399 |     | 
           }  | 
  |  400 |    0 |            if (ObjectUtils.isNestedAttribute(attributeName)) { | 
  |  401 |     | 
                 | 
  |  402 |    0 |                String nestedAttributePrefix = StringUtils.substringBeforeLast(attributeName, ".");  | 
  |  403 |     | 
     | 
  |  404 |    0 |                field.setQuickFinderClassNameImpl(relationship.getRelatedClass().getName());  | 
  |  405 |    0 |                field.setFieldConversions( generateFieldConversions( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, nestedAttributePrefix ) );  | 
  |  406 |    0 |                field.setLookupParameters( generateLookupParameters( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, nestedAttributePrefix ) );  | 
  |  407 |    0 |                field.setBaseLookupUrl(LookupUtils.getBaseLookupUrl(false));  | 
  |  408 |    0 |            } else { | 
  |  409 |    0 |                field.setQuickFinderClassNameImpl(relationship.getRelatedClass().getName());  | 
  |  410 |    0 |                field.setFieldConversions( generateFieldConversions( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, null ) );  | 
  |  411 |    0 |                field.setLookupParameters( generateLookupParameters( businessObject, collectionPrefix, relationship, field.getPropertyPrefix(), displayedFieldNames, null ) );  | 
  |  412 |    0 |                field.setBaseLookupUrl(LookupUtils.getBaseLookupUrl(false));  | 
  |  413 |     | 
           }  | 
  |  414 |    0 |            field.setImageSrc(businessObjectDictionaryService.getSearchIconOverride(businessObject.getClass()));  | 
  |  415 |     | 
     | 
  |  416 |    0 |            return field;  | 
  |  417 |     | 
       }  | 
  |  418 |     | 
     | 
  |  419 |    0 |        private static String BASE_LOOKUP_ACTION_URL = null;  | 
  |  420 |    0 |        private static String BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL = null;  | 
  |  421 |    0 |        private static String BASE_INQUIRY_ACTION_URL = null;  | 
  |  422 |     | 
         | 
  |  423 |     | 
       @Deprecated  | 
  |  424 |     | 
       public static String getBaseLookupUrl(boolean isMultipleValue) { | 
  |  425 |    0 |            ConfigurationService kualiConfigurationService = KNSServiceLocator.getKualiConfigurationService();  | 
  |  426 |    0 |                if ( isMultipleValue ) { | 
  |  427 |    0 |                        if ( BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL == null ) { | 
  |  428 |    0 |                                String lookupUrl = kualiConfigurationService.getPropertyString(KNSConstants.APPLICATION_URL_KEY);  | 
  |  429 |    0 |                                if (!lookupUrl.endsWith("/")) { | 
  |  430 |    0 |                                        lookupUrl = lookupUrl + "/";  | 
  |  431 |     | 
                               }  | 
  |  432 |    0 |                                    lookupUrl += "kr/" + KNSConstants.MULTIPLE_VALUE_LOOKUP_ACTION;  | 
  |  433 |    0 |                                    BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL = lookupUrl;  | 
  |  434 |     | 
                       }  | 
  |  435 |    0 |                        return BASE_MULTIPLE_VALUE_LOOKUP_ACTION_URL;  | 
  |  436 |     | 
               } else { | 
  |  437 |    0 |                        if ( BASE_LOOKUP_ACTION_URL == null ) { | 
  |  438 |    0 |                                String lookupUrl = kualiConfigurationService.getPropertyString(KNSConstants.APPLICATION_URL_KEY);  | 
  |  439 |    0 |                                if (!lookupUrl.endsWith("/")) { | 
  |  440 |    0 |                                        lookupUrl = lookupUrl + "/";  | 
  |  441 |     | 
                               }  | 
  |  442 |    0 |                                    lookupUrl += "kr/" + KNSConstants.LOOKUP_ACTION;  | 
  |  443 |    0 |                                    BASE_LOOKUP_ACTION_URL = lookupUrl;  | 
  |  444 |     | 
                       }  | 
  |  445 |    0 |                        return BASE_LOOKUP_ACTION_URL;  | 
  |  446 |     | 
               }  | 
  |  447 |     | 
       }  | 
  |  448 |     | 
     | 
  |  449 |     | 
       @Deprecated  | 
  |  450 |     | 
       public static String getBaseInquiryUrl() { | 
  |  451 |    0 |                if ( BASE_INQUIRY_ACTION_URL == null ) { | 
  |  452 |    0 |                        StringBuffer inquiryUrl = new StringBuffer(   | 
  |  453 |     | 
                                       KNSServiceLocator.getKualiConfigurationService().getPropertyString(KNSConstants.APPLICATION_URL_KEY) );  | 
  |  454 |    0 |                            if (inquiryUrl.charAt(inquiryUrl.length()-1) != '/' ) { | 
  |  455 |    0 |                                    inquiryUrl.append( '/' );  | 
  |  456 |     | 
                           }  | 
  |  457 |    0 |                            inquiryUrl.append("kr/"); | 
  |  458 |    0 |                            inquiryUrl.append( KNSConstants.INQUIRY_ACTION );  | 
  |  459 |    0 |                            BASE_INQUIRY_ACTION_URL = inquiryUrl.toString();  | 
  |  460 |     | 
               }  | 
  |  461 |    0 |                return BASE_INQUIRY_ACTION_URL;  | 
  |  462 |     | 
       }  | 
  |  463 |     | 
     | 
  |  464 |     | 
       public static String transformLookupUrlToMultiple(String lookupUrl) { | 
  |  465 |    0 |                return lookupUrl.replace("kr/" + KNSConstants.LOOKUP_ACTION, "kr/" + KNSConstants.MULTIPLE_VALUE_LOOKUP_ACTION); | 
  |  466 |     | 
       }  | 
  |  467 |     | 
     | 
  |  468 |     | 
         | 
  |  469 |     | 
     | 
  |  470 |     | 
     | 
  |  471 |     | 
     | 
  |  472 |     | 
     | 
  |  473 |     | 
     | 
  |  474 |     | 
     | 
  |  475 |     | 
     | 
  |  476 |     | 
     | 
  |  477 |     | 
     | 
  |  478 |     | 
     | 
  |  479 |     | 
       private static void setFieldDirectInquiry(Field field) { | 
  |  480 |    0 |            if (StringUtils.isNotBlank(field.getFieldConversions())) { | 
  |  481 |    0 |                boolean directInquiriesEnabled = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsBoolean(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.ALL_DETAIL_TYPE, KNSConstants.SystemGroupParameterNames.ENABLE_DIRECT_INQUIRIES_IND);  | 
  |  482 |    0 |                if (directInquiriesEnabled) { | 
  |  483 |    0 |                    if (StringUtils.isNotBlank(field.getFieldConversions())) { | 
  |  484 |    0 |                        String fieldConversions = field.getFieldConversions();  | 
  |  485 |    0 |                        String newInquiryParameters = KNSConstants.EMPTY_STRING;  | 
  |  486 |    0 |                        String[] conversions = StringUtils.split(fieldConversions, KNSConstants.FIELD_CONVERSIONS_SEPARATOR);  | 
  |  487 |     | 
     | 
  |  488 |    0 |                        for (int l = 0; l < conversions.length; l++) { | 
  |  489 |    0 |                            String conversion = conversions[l];  | 
  |  490 |     | 
                             | 
  |  491 |    0 |                            String[] conversionPair = StringUtils.split(conversion, KNSConstants.FIELD_CONVERSION_PAIR_SEPARATOR, 2);  | 
  |  492 |    0 |                            String conversionFrom = conversionPair[0];  | 
  |  493 |    0 |                            String conversionTo = conversionPair[1];  | 
  |  494 |    0 |                            newInquiryParameters += (conversionTo + KNSConstants.FIELD_CONVERSION_PAIR_SEPARATOR + conversionFrom);  | 
  |  495 |     | 
     | 
  |  496 |    0 |                            if (l < conversions.length - 1) { | 
  |  497 |    0 |                                newInquiryParameters += KNSConstants.FIELD_CONVERSIONS_SEPARATOR;  | 
  |  498 |     | 
                           }  | 
  |  499 |     | 
                       }  | 
  |  500 |     | 
     | 
  |  501 |    0 |                        field.setInquiryParameters(newInquiryParameters);  | 
  |  502 |     | 
                   }  | 
  |  503 |     | 
               }  | 
  |  504 |    0 |                field.setFieldDirectInquiryEnabled(directInquiriesEnabled);  | 
  |  505 |    0 |            }  | 
  |  506 |     | 
           else { | 
  |  507 |    0 |                field.setFieldDirectInquiryEnabled(false);  | 
  |  508 |     | 
           }  | 
  |  509 |    0 |        }  | 
  |  510 |     | 
     | 
  |  511 |     | 
         | 
  |  512 |     | 
     | 
  |  513 |     | 
     | 
  |  514 |     | 
     | 
  |  515 |     | 
     | 
  |  516 |     | 
       public static Field setFieldDirectInquiry(BusinessObject businessObject, String attributeName, Field field)  | 
  |  517 |     | 
       { | 
  |  518 |    0 |                    if (businessObject == null)  | 
  |  519 |     | 
                   { | 
  |  520 |    0 |                return field;  | 
  |  521 |     | 
           }  | 
  |  522 |     | 
     | 
  |  523 |    0 |            Boolean noDirectInquiry = businessObjectDictionaryService.noDirectInquiryFieldLookup(businessObject.getClass(), attributeName);  | 
  |  524 |     | 
             | 
  |  525 |    0 |            if (noDirectInquiry != null && noDirectInquiry.booleanValue() || noDirectInquiry == null) { | 
  |  526 |    0 |                return field;  | 
  |  527 |     | 
           }  | 
  |  528 |     | 
     | 
  |  529 |    0 |            setFieldDirectInquiry(field);  | 
  |  530 |     | 
     | 
  |  531 |    0 |            return field;  | 
  |  532 |     | 
       }  | 
  |  533 |     | 
     | 
  |  534 |    0 |        private static Map<Class,Map<String,Map>> referencesForForeignKey = new HashMap<Class, Map<String,Map>>();  | 
  |  535 |     | 
     | 
  |  536 |     | 
       @Deprecated  | 
  |  537 |     | 
       public static Map getPrimitiveReference(BusinessObject businessObject, String attributeName) { | 
  |  538 |    0 |            Map chosenReferenceByKeySize = new HashMap();  | 
  |  539 |    0 |            Map chosenReferenceByFieldName = new HashMap();  | 
  |  540 |     | 
     | 
  |  541 |    0 |            Map referenceClasses = null;  | 
  |  542 |     | 
     | 
  |  543 |     | 
           try { | 
  |  544 |     | 
                 | 
  |  545 |    0 |                Map<String,Map> propMap = referencesForForeignKey.get(businessObject.getClass());  | 
  |  546 |    0 |                if ( propMap == null ) { | 
  |  547 |    0 |                    propMap = new HashMap<String, Map>();  | 
  |  548 |    0 |                    referencesForForeignKey.put(businessObject.getClass(), propMap);  | 
  |  549 |     | 
               }  | 
  |  550 |    0 |                if ( propMap.containsKey(attributeName) ) { | 
  |  551 |    0 |                    referenceClasses = propMap.get( attributeName );  | 
  |  552 |     | 
               } else { | 
  |  553 |     | 
                         | 
  |  554 |    0 |                        referenceClasses = businessObjectMetaDataService.getReferencesForForeignKey(businessObject, attributeName);  | 
  |  555 |    0 |                        if(referenceClasses==null || referenceClasses.isEmpty()) { | 
  |  556 |    0 |                            if ( persistenceStructureService.isPersistable(businessObject.getClass()) ) { | 
  |  557 |    0 |                                referenceClasses = persistenceStructureService.getReferencesForForeignKey(businessObject.getClass(), attributeName);  | 
  |  558 |     | 
                           }  | 
  |  559 |     | 
                       }  | 
  |  560 |    0 |                    propMap.put(attributeName, referenceClasses);  | 
  |  561 |     | 
               }  | 
  |  562 |    0 |            } catch ( ClassNotPersistableException ex ) { | 
  |  563 |     | 
                 | 
  |  564 |    0 |                Map<String,Map> propMap = referencesForForeignKey.get(businessObject.getClass());  | 
  |  565 |    0 |                propMap.put(attributeName, null);  | 
  |  566 |    0 |            }  | 
  |  567 |     | 
     | 
  |  568 |     | 
             | 
  |  569 |    0 |            if (referenceClasses == null || referenceClasses.isEmpty()) { | 
  |  570 |    0 |                return chosenReferenceByKeySize;  | 
  |  571 |     | 
           }  | 
  |  572 |     | 
     | 
  |  573 |     | 
             | 
  |  574 |     | 
     | 
  |  575 |     | 
     | 
  |  576 |     | 
     | 
  |  577 |    0 |            int minKeys = Integer.MAX_VALUE;  | 
  |  578 |    0 |            for (Iterator iter = referenceClasses.keySet().iterator(); iter.hasNext();) { | 
  |  579 |    0 |                String attr = (String) iter.next();  | 
  |  580 |    0 |                Class clazz = (Class) referenceClasses.get(attr);  | 
  |  581 |    0 |                List pkNames = businessObjectMetaDataService.listPrimaryKeyFieldNames(clazz);  | 
  |  582 |     | 
     | 
  |  583 |     | 
                 | 
  |  584 |    0 |                if (pkNames.size() < minKeys) { | 
  |  585 |    0 |                    minKeys = pkNames.size();  | 
  |  586 |    0 |                    chosenReferenceByKeySize.clear();  | 
  |  587 |    0 |                    chosenReferenceByKeySize.put(attr, clazz);  | 
  |  588 |     | 
               }  | 
  |  589 |     | 
     | 
  |  590 |     | 
                 | 
  |  591 |    0 |                if (attributeName.startsWith(attr)) { | 
  |  592 |    0 |                    chosenReferenceByFieldName.clear();  | 
  |  593 |    0 |                    chosenReferenceByFieldName.put(attr, clazz);  | 
  |  594 |     | 
               }  | 
  |  595 |    0 |            }  | 
  |  596 |     | 
     | 
  |  597 |     | 
             | 
  |  598 |    0 |            return chosenReferenceByFieldName.isEmpty() ? chosenReferenceByKeySize : chosenReferenceByFieldName;  | 
  |  599 |     | 
       }  | 
  |  600 |     | 
     | 
  |  601 |     | 
         | 
  |  602 |     | 
     | 
  |  603 |     | 
     | 
  |  604 |     | 
     | 
  |  605 |     | 
     | 
  |  606 |     | 
     | 
  |  607 |     | 
     | 
  |  608 |     | 
     | 
  |  609 |     | 
       public static BusinessObject getNestedBusinessObject(BusinessObject bo, String attributeName) { | 
  |  610 |    0 |            String[] nestedAttributes = StringUtils.split(attributeName, ".");  | 
  |  611 |     | 
     | 
  |  612 |    0 |            BusinessObject childBO = null;  | 
  |  613 |    0 |            String attributeRefName = "";  | 
  |  614 |    0 |            Class clazz = null;  | 
  |  615 |    0 |            if (nestedAttributes.length > 1) { | 
  |  616 |    0 |                String attributeStringSoFar = "";  | 
  |  617 |    0 |                for (int i = 0; i < nestedAttributes.length - 1; i++) { | 
  |  618 |     | 
                     | 
  |  619 |     | 
                     | 
  |  620 |     | 
                     | 
  |  621 |    0 |                    if (i != 0) { | 
  |  622 |    0 |                        attributeStringSoFar = attributeStringSoFar + ".";  | 
  |  623 |     | 
                   }  | 
  |  624 |    0 |                    attributeStringSoFar = attributeStringSoFar + nestedAttributes[i];  | 
  |  625 |     | 
     | 
  |  626 |    0 |                    clazz = ObjectUtils.getPropertyType( bo, attributeStringSoFar, persistenceStructureService );  | 
  |  627 |     | 
     | 
  |  628 |    0 |                    if (clazz != null && BusinessObject.class.isAssignableFrom(clazz)) { | 
  |  629 |     | 
                       try { | 
  |  630 |    0 |                                childBO = (BusinessObject) ObjectUtils.createNewObjectFromClass(clazz);  | 
  |  631 |     | 
                       }  | 
  |  632 |    0 |                        catch (Exception e) { | 
  |  633 |    0 |                            return null;  | 
  |  634 |    0 |                        }  | 
  |  635 |     | 
                   }  | 
  |  636 |     | 
               }  | 
  |  637 |     | 
           }  | 
  |  638 |    0 |            return childBO;  | 
  |  639 |     | 
       }  | 
  |  640 |     | 
     | 
  |  641 |     | 
       public static Class getNestedReferenceClass(BusinessObject businessObject, String attributeName) { | 
  |  642 |    0 |            BusinessObject bo = getNestedBusinessObject(businessObject, attributeName);  | 
  |  643 |    0 |            return null == bo ? null : bo.getClass();  | 
  |  644 |     | 
       }  | 
  |  645 |     | 
     | 
  |  646 |     | 
       @Deprecated  | 
  |  647 |     | 
       private static String generateFieldConversions(BusinessObject businessObject, String collectionName, BusinessObjectRelationship relationship, String propertyPrefix, List displayedFieldNames, String nestedObjectPrefix) { | 
  |  648 |    0 |            String fieldConversions = "";  | 
  |  649 |     | 
     | 
  |  650 |    0 |            if ( LOG.isDebugEnabled() ) { | 
  |  651 |    0 |                LOG.debug( "generateFieldConversions(" + businessObject.getClass().getName() + "," + collectionName + ",\n" + relationship + "\n," + propertyPrefix + "," + displayedFieldNames + "," + nestedObjectPrefix + ")" ); | 
  |  652 |     | 
           }  | 
  |  653 |     | 
     | 
  |  654 |     | 
             | 
  |  655 |    0 |            for ( Map.Entry<String,String> entry : relationship.getParentToChildReferences().entrySet() ) { | 
  |  656 |    0 |                String fromField = entry.getValue();  | 
  |  657 |    0 |                String toField = entry.getKey();  | 
  |  658 |     | 
     | 
  |  659 |     | 
                 | 
  |  660 |    0 |                if (!displayedFieldNames.contains(toField)) { | 
  |  661 |    0 |                    toField = translateToDisplayedField(businessObject.getClass(), toField, displayedFieldNames);  | 
  |  662 |     | 
               }  | 
  |  663 |     | 
     | 
  |  664 |    0 |                if (StringUtils.isNotBlank(fieldConversions)) { | 
  |  665 |    0 |                    fieldConversions += ",";  | 
  |  666 |     | 
               }  | 
  |  667 |     | 
     | 
  |  668 |    0 |                if ( StringUtils.isNotEmpty( propertyPrefix ) ) { | 
  |  669 |    0 |                    toField = propertyPrefix + "." + toField;  | 
  |  670 |     | 
               }  | 
  |  671 |     | 
     | 
  |  672 |    0 |                if ( StringUtils.isNotEmpty( collectionName ) ) { | 
  |  673 |    0 |                    toField = collectionName + toField;  | 
  |  674 |     | 
               }  | 
  |  675 |     | 
     | 
  |  676 |    0 |                fieldConversions += fromField + ":" + toField;  | 
  |  677 |    0 |            }  | 
  |  678 |     | 
     | 
  |  679 |    0 |            return fieldConversions;  | 
  |  680 |     | 
       }  | 
  |  681 |     | 
     | 
  |  682 |     | 
       @Deprecated  | 
  |  683 |     | 
       private static String generateLookupParameters(BusinessObject businessObject, String collectionName, BusinessObjectRelationship relationship, String propertyPrefix, List displayedFieldNames, String nestedObjectPrefix) { | 
  |  684 |     | 
     | 
  |  685 |    0 |            String lookupParameters = "";  | 
  |  686 |     | 
     | 
  |  687 |    0 |            List displayedQFFieldNames = businessObjectDictionaryService.getLookupFieldNames(relationship.getRelatedClass());  | 
  |  688 |    0 |            for ( Map.Entry<String,String> entry : relationship.getParentToChildReferences().entrySet() ) { | 
  |  689 |    0 |                String fromField = entry.getKey();  | 
  |  690 |    0 |                String toField = entry.getValue();  | 
  |  691 |     | 
     | 
  |  692 |    0 |                if ( relationship.getUserVisibleIdentifierKey() == null || relationship.getUserVisibleIdentifierKey().equals( fromField ) ) { | 
  |  693 |     | 
                     | 
  |  694 |    0 |                    if (!displayedFieldNames.contains(fromField)) { | 
  |  695 |    0 |                        fromField = translateToDisplayedField(businessObject.getClass(), fromField, displayedFieldNames);  | 
  |  696 |     | 
                   }  | 
  |  697 |     | 
     | 
  |  698 |     | 
                     | 
  |  699 |    0 |                    if (displayedQFFieldNames != null && !displayedQFFieldNames.contains(toField)) { | 
  |  700 |    0 |                        toField = translateToDisplayedField(relationship.getRelatedClass(), toField, displayedQFFieldNames);  | 
  |  701 |     | 
                   }  | 
  |  702 |     | 
     | 
  |  703 |    0 |                    if (StringUtils.isNotBlank(lookupParameters)) { | 
  |  704 |    0 |                        lookupParameters += ",";  | 
  |  705 |     | 
                   }  | 
  |  706 |     | 
     | 
  |  707 |    0 |                    if (propertyPrefix != null && !propertyPrefix.equals("")) { | 
  |  708 |    0 |                        fromField = propertyPrefix + "." + fromField;  | 
  |  709 |     | 
                   }  | 
  |  710 |     | 
     | 
  |  711 |    0 |                    if ( StringUtils.isNotEmpty( collectionName ) ) { | 
  |  712 |    0 |                        fromField = collectionName + fromField;  | 
  |  713 |     | 
                   }  | 
  |  714 |     | 
     | 
  |  715 |    0 |                    lookupParameters += fromField + ":" + toField;  | 
  |  716 |     | 
               }  | 
  |  717 |    0 |            }  | 
  |  718 |     | 
     | 
  |  719 |    0 |            return lookupParameters;  | 
  |  720 |     | 
       }  | 
  |  721 |     | 
     | 
  |  722 |     | 
       @Deprecated  | 
  |  723 |     | 
       private static String translateToDisplayedField(Class businessObjectClass, String fieldName, List displayedFieldNames) {         | 
  |  724 |    0 |            if ( persistenceStructureService.isPersistable(businessObjectClass) ) { | 
  |  725 |    0 |                Map nestedFkMap = persistenceStructureService.getNestedForeignKeyMap(businessObjectClass);  | 
  |  726 |     | 
     | 
  |  727 |     | 
                 | 
  |  728 |     | 
                 | 
  |  729 |     | 
     | 
  |  730 |     | 
     | 
  |  731 |     | 
     | 
  |  732 |     | 
     | 
  |  733 |    0 |                if (!displayedFieldNames.contains(fieldName)) { | 
  |  734 |    0 |                    for (Iterator iterator = displayedFieldNames.iterator(); iterator.hasNext();) { | 
  |  735 |    0 |                        String dispField = (String) iterator.next();  | 
  |  736 |     | 
     | 
  |  737 |    0 |                        if (nestedFkMap.containsKey(dispField) && nestedFkMap.get(dispField).equals(fieldName)) { | 
  |  738 |    0 |                            fieldName = dispField;  | 
  |  739 |     | 
                       }  | 
  |  740 |    0 |                    }  | 
  |  741 |     | 
               }  | 
  |  742 |     | 
           }  | 
  |  743 |     | 
     | 
  |  744 |    0 |            return fieldName;  | 
  |  745 |     | 
       }  | 
  |  746 |     | 
     | 
  |  747 |     | 
       public static String convertReferencesToSelectCollectionToString(Collection<String> referencesToRefresh) { | 
  |  748 |    0 |            StringBuilder buf = new StringBuilder();  | 
  |  749 |    0 |            for (String reference : referencesToRefresh) { | 
  |  750 |    0 |                buf.append(reference).append(KNSConstants.REFERENCES_TO_REFRESH_SEPARATOR);  | 
  |  751 |     | 
           }  | 
  |  752 |    0 |            if (!referencesToRefresh.isEmpty()) { | 
  |  753 |     | 
                 | 
  |  754 |    0 |                buf.delete(buf.length() - KNSConstants.REFERENCES_TO_REFRESH_SEPARATOR.length(), buf.length());  | 
  |  755 |     | 
           }  | 
  |  756 |    0 |            return buf.toString();  | 
  |  757 |     | 
       }  | 
  |  758 |     | 
     | 
  |  759 |     | 
       public static String convertSetOfObjectIdsToString(Set<String> objectIds) { | 
  |  760 |    0 |            if (objectIds.isEmpty()) { | 
  |  761 |    0 |                return "";  | 
  |  762 |     | 
           }  | 
  |  763 |    0 |            StringBuilder buf = new StringBuilder();  | 
  |  764 |    0 |            for (String objectId : objectIds) { | 
  |  765 |    0 |                if (objectId.contains(KNSConstants.MULTIPLE_VALUE_LOOKUP_OBJ_IDS_SEPARATOR)) { | 
  |  766 |    0 |                    throw new RuntimeException("object ID " + objectId + " contains the selected obj ID separator"); | 
  |  767 |     | 
               }  | 
  |  768 |    0 |                buf.append(objectId).append(KNSConstants.MULTIPLE_VALUE_LOOKUP_OBJ_IDS_SEPARATOR);  | 
  |  769 |     | 
           }  | 
  |  770 |     | 
             | 
  |  771 |    0 |            buf.delete(buf.length() - KNSConstants.MULTIPLE_VALUE_LOOKUP_OBJ_IDS_SEPARATOR.length(), buf.length());  | 
  |  772 |     | 
     | 
  |  773 |    0 |            return buf.toString();  | 
  |  774 |     | 
       }  | 
  |  775 |     | 
     | 
  |  776 |     | 
       public static Set<String> convertStringOfObjectIdsToSet(String objectIdsString) { | 
  |  777 |    0 |            Set<String> set = new HashSet<String>();  | 
  |  778 |     | 
     | 
  |  779 |    0 |            if (StringUtils.isNotBlank(objectIdsString)) { | 
  |  780 |    0 |                String[] objectIds = StringUtils.splitByWholeSeparator(objectIdsString, KNSConstants.MULTIPLE_VALUE_LOOKUP_OBJ_IDS_SEPARATOR);  | 
  |  781 |    0 |                for (String objectId : objectIds) { | 
  |  782 |    0 |                    set.add(objectId);  | 
  |  783 |     | 
               }  | 
  |  784 |     | 
           }  | 
  |  785 |    0 |            return set;  | 
  |  786 |     | 
       }  | 
  |  787 |     | 
     | 
  |  788 |     | 
         | 
  |  789 |     | 
     | 
  |  790 |     | 
     | 
  |  791 |     | 
     | 
  |  792 |     | 
     | 
  |  793 |     | 
     | 
  |  794 |     | 
     | 
  |  795 |     | 
     | 
  |  796 |     | 
     | 
  |  797 |     | 
     | 
  |  798 |     | 
       public static Comparator findBestValueComparatorForColumn(List<ResultRow> resultTable, int column) { | 
  |  799 |     | 
             | 
  |  800 |    0 |            Comparator comp = NullValueComparator.getInstance();  | 
  |  801 |    0 |            for (ResultRow row : resultTable) { | 
  |  802 |    0 |                Comparator tempComp = row.getColumns().get(column).getValueComparator();  | 
  |  803 |    0 |                if (tempComp != null && !NullValueComparator.class.equals(tempComp.getClass())) { | 
  |  804 |    0 |                    return tempComp;  | 
  |  805 |     | 
               }  | 
  |  806 |    0 |            }  | 
  |  807 |    0 |            return comp;  | 
  |  808 |     | 
       }  | 
  |  809 |     | 
     | 
  |  810 |     | 
         | 
  |  811 |     | 
     | 
  |  812 |     | 
     | 
  |  813 |     | 
     | 
  |  814 |     | 
     | 
  |  815 |     | 
     | 
  |  816 |     | 
     | 
  |  817 |     | 
     | 
  |  818 |     | 
     | 
  |  819 |     | 
     | 
  |  820 |     | 
     | 
  |  821 |     | 
       public static Map<String, String> generateCompositeSelectedObjectIds(Set<String> previouslySelectedObjectIds, Set<String> displayedObjectIds, Set<String> selectedObjectIds) { | 
  |  822 |    0 |            Map<String, String> tempMap = new HashMap<String, String>();  | 
  |  823 |     | 
             | 
  |  824 |     | 
             | 
  |  825 |     | 
             | 
  |  826 |     | 
             | 
  |  827 |     | 
     | 
  |  828 |     | 
             | 
  |  829 |    0 |            for (String previouslySelectedObjectId : previouslySelectedObjectIds) { | 
  |  830 |    0 |                tempMap.put(previouslySelectedObjectId, previouslySelectedObjectId);  | 
  |  831 |     | 
           }  | 
  |  832 |     | 
             | 
  |  833 |    0 |            for (String displayedObjectId : displayedObjectIds) { | 
  |  834 |    0 |                tempMap.remove(displayedObjectId);  | 
  |  835 |     | 
           }  | 
  |  836 |     | 
             | 
  |  837 |    0 |            for (String selectedObjectId : selectedObjectIds) { | 
  |  838 |    0 |                tempMap.put(selectedObjectId, selectedObjectId);  | 
  |  839 |     | 
           }  | 
  |  840 |    0 |            return tempMap;  | 
  |  841 |     | 
       }  | 
  |  842 |     | 
     | 
  |  843 |     | 
         | 
  |  844 |     | 
     | 
  |  845 |     | 
     | 
  |  846 |     | 
     | 
  |  847 |     | 
     | 
  |  848 |     | 
     | 
  |  849 |     | 
       public static void removeHiddenCriteriaFields( Class businessObjectClass, Map fieldValues ) { | 
  |  850 |    0 |            List<String> lookupFieldAttributeList = businessObjectMetaDataService.getLookupableFieldNames(businessObjectClass);  | 
  |  851 |    0 |            if (lookupFieldAttributeList != null) { | 
  |  852 |    0 |                for (Iterator iter = lookupFieldAttributeList.iterator(); iter.hasNext();) { | 
  |  853 |    0 |                    String attributeName = (String) iter.next();  | 
  |  854 |    0 |                    if (fieldValues.containsKey(attributeName)) { | 
  |  855 |    0 |                        ControlDefinition controlDef = dataDictionaryService.getAttributeControlDefinition(businessObjectClass, attributeName);  | 
  |  856 |    0 |                        if (controlDef != null && controlDef.isHidden() ) { | 
  |  857 |    0 |                            fieldValues.remove(attributeName);  | 
  |  858 |     | 
                       }  | 
  |  859 |     | 
                   }  | 
  |  860 |    0 |                }  | 
  |  861 |     | 
           }  | 
  |  862 |    0 |            }  | 
  |  863 |     | 
     | 
  |  864 |     | 
         | 
  |  865 |     | 
     | 
  |  866 |     | 
     | 
  |  867 |     | 
     | 
  |  868 |     | 
     | 
  |  869 |     | 
     | 
  |  870 |     | 
     | 
  |  871 |     | 
     | 
  |  872 |     | 
     | 
  |  873 |     | 
     | 
  |  874 |     | 
     | 
  |  875 |     | 
     | 
  |  876 |     | 
     | 
  |  877 |     | 
           public static Timestamp getActiveDateTimestampForCriteria(Map searchValues) { | 
  |  878 |    0 |                    Date activeDate = dateTimeService.getCurrentSqlDate();  | 
  |  879 |    0 |                    Timestamp activeTimestamp = null;  | 
  |  880 |    0 |                    if (searchValues.containsKey(KNSPropertyConstants.ACTIVE_AS_OF_DATE)) { | 
  |  881 |    0 |                            String activeAsOfDate = (String) searchValues.get(KNSPropertyConstants.ACTIVE_AS_OF_DATE);  | 
  |  882 |    0 |                            if (StringUtils.isNotBlank(activeAsOfDate)) { | 
  |  883 |     | 
                                   try { | 
  |  884 |    0 |                                            activeDate = dateTimeService.convertToSqlDate(ObjectUtils.clean(activeAsOfDate));  | 
  |  885 |    0 |                                    } catch (ParseException e) { | 
  |  886 |     | 
                                             | 
  |  887 |     | 
                                           try { | 
  |  888 |    0 |                                                    activeTimestamp = dateTimeService.convertToSqlTimestamp(ObjectUtils.clean(activeAsOfDate));  | 
  |  889 |    0 |                                            } catch (ParseException e1) { | 
  |  890 |    0 |                                                    throw new RuntimeException("Unable to convert date: " + ObjectUtils.clean(activeAsOfDate)); | 
  |  891 |    0 |                                            }  | 
  |  892 |    0 |                                    }  | 
  |  893 |     | 
                           }  | 
  |  894 |     | 
                   }  | 
  |  895 |     | 
     | 
  |  896 |     | 
                     | 
  |  897 |    0 |                    if (activeTimestamp == null) { | 
  |  898 |    0 |                            Calendar cal = Calendar.getInstance();  | 
  |  899 |    0 |                            cal.setTime(activeDate);  | 
  |  900 |    0 |                            cal.set(Calendar.HOUR, cal.getMaximum(Calendar.HOUR));  | 
  |  901 |    0 |                            cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));  | 
  |  902 |    0 |                            cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));  | 
  |  903 |     | 
     | 
  |  904 |    0 |                            activeTimestamp = new Timestamp(cal.getTime().getTime());  | 
  |  905 |     | 
                   }  | 
  |  906 |     | 
     | 
  |  907 |    0 |                    return activeTimestamp;  | 
  |  908 |     | 
           }  | 
  |  909 |     | 
   }  |