Coverage Report - org.kuali.rice.kim.lookup.GroupLookupableHelperServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
GroupLookupableHelperServiceImpl
0%
0/265
0%
0/118
4.318
GroupLookupableHelperServiceImpl$1
0%
0/2
N/A
4.318
 
 1  
 /*
 2  
  * Copyright 2007-2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.kim.lookup;
 17  
 
 18  
 import static java.util.Collections.sort;
 19  
 
 20  
 import java.sql.Date;
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collection;
 23  
 import java.util.Collections;
 24  
 import java.util.Comparator;
 25  
 import java.util.HashMap;
 26  
 import java.util.Iterator;
 27  
 import java.util.List;
 28  
 import java.util.ListIterator;
 29  
 import java.util.Map;
 30  
 import java.util.Properties;
 31  
 
 32  
 import org.apache.commons.collections.CollectionUtils;
 33  
 import org.apache.commons.lang.StringUtils;
 34  
 import org.kuali.rice.core.util.ClassLoaderUtils;
 35  
 import org.kuali.rice.core.util.KeyLabelPair;
 36  
 import org.kuali.rice.kew.util.KEWConstants;
 37  
 import org.kuali.rice.kim.bo.Group;
 38  
 import org.kuali.rice.kim.bo.Person;
 39  
 import org.kuali.rice.kim.bo.group.dto.GroupInfo;
 40  
 import org.kuali.rice.kim.bo.impl.GroupImpl;
 41  
 import org.kuali.rice.kim.bo.types.dto.AttributeDefinitionMap;
 42  
 import org.kuali.rice.kim.bo.types.dto.KimTypeInfo;
 43  
 import org.kuali.rice.kim.bo.ui.KimAttributeDataComparator;
 44  
 import org.kuali.rice.kim.dao.KimGroupDao;
 45  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 46  
 import org.kuali.rice.kim.service.support.KimTypeService;
 47  
 import org.kuali.rice.kim.util.KIMPropertyConstants;
 48  
 import org.kuali.rice.kim.util.KimCommonUtils;
 49  
 import org.kuali.rice.kim.util.KimConstants;
 50  
 import org.kuali.rice.kns.authorization.BusinessObjectRestrictions;
 51  
 import org.kuali.rice.kns.bo.BusinessObject;
 52  
 import org.kuali.rice.kns.bo.PersistableBusinessObject;
 53  
 import org.kuali.rice.kns.datadictionary.AttributeDefinition;
 54  
 import org.kuali.rice.kns.datadictionary.KimDataDictionaryAttributeDefinition;
 55  
 import org.kuali.rice.kns.datadictionary.KimNonDataDictionaryAttributeDefinition;
 56  
 import org.kuali.rice.kns.lookup.HtmlData;
 57  
 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
 58  
 import org.kuali.rice.kns.lookup.keyvalues.IndicatorValuesFinder;
 59  
 import org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder;
 60  
 import org.kuali.rice.kns.util.GlobalVariables;
 61  
 import org.kuali.rice.kns.util.KNSConstants;
 62  
 import org.kuali.rice.kns.util.ObjectUtils;
 63  
 import org.kuali.rice.kns.util.UrlFactory;
 64  
 import org.kuali.rice.kns.web.comparator.CellComparatorHelper;
 65  
 import org.kuali.rice.kns.web.format.BooleanFormatter;
 66  
 import org.kuali.rice.kns.web.format.CollectionFormatter;
 67  
 import org.kuali.rice.kns.web.format.DateFormatter;
 68  
 import org.kuali.rice.kns.web.format.Formatter;
 69  
 import org.kuali.rice.kns.web.struts.form.LookupForm;
 70  
 import org.kuali.rice.kns.web.ui.Column;
 71  
 import org.kuali.rice.kns.web.ui.Field;
 72  
 import org.kuali.rice.kns.web.ui.ResultRow;
 73  
 import org.kuali.rice.kns.web.ui.Row;
 74  
 
 75  
 /**
 76  
  * This is a description of what this class does - shyu don't forget to fill this in.
 77  
  *
 78  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 79  
  *
 80  
  */
 81  0
 public class GroupLookupableHelperServiceImpl  extends KimLookupableHelperServiceImpl {
 82  
 
 83  
         // need this so kimtypeId value can be retained in 'rows'
 84  
         // 1st pass populate the grprows
 85  
         // 2nd pass for jsp, no populate, so return the existing one.
 86  0
     private static String KIM_TYPE_ID_PROPERTY_NAME = "kimTypeId";
 87  0
         private List<Row> grpRows = new ArrayList<Row>();
 88  0
         private List<Row> attrRows = new ArrayList<Row>();
 89  
         private KimGroupDao groupDao;
 90  0
         private String typeId = "";
 91  
         private AttributeDefinitionMap attrDefinitions;
 92  0
         private Map<String, String> groupTypeValuesCache = new HashMap<String, String>();
 93  
 
 94  
     @Override
 95  
     public List<HtmlData> getCustomActionUrls(BusinessObject bo, List pkNames) {
 96  0
             GroupImpl groupImpl = (GroupImpl) bo;
 97  0
         List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>();
 98  0
         if(allowsNewOrCopyAction(KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_TYPE_NAME)){
 99  0
                 anchorHtmlDataList.add(getEditGroupUrl(groupImpl));        
 100  
         }
 101  0
             return anchorHtmlDataList;
 102  
     }
 103  
     
 104  
     protected HtmlData getEditGroupUrl(GroupImpl groupImpl) {
 105  0
             String href = "";
 106  
 
 107  0
         Properties parameters = new Properties();
 108  0
         parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.DOC_HANDLER_METHOD);
 109  0
         parameters.put(KNSConstants.PARAMETER_COMMAND, KEWConstants.INITIATE_COMMAND);
 110  0
         parameters.put(KNSConstants.DOCUMENT_TYPE_NAME, KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_TYPE_NAME);
 111  0
         parameters.put(KimConstants.PrimaryKeyConstants.GROUP_ID, groupImpl.getGroupId());
 112  0
         if (StringUtils.isNotBlank(getReturnLocation())) {
 113  0
                 parameters.put(KNSConstants.RETURN_LOCATION_PARAMETER, getReturnLocation());         
 114  
                 }
 115  0
         href = UrlFactory.parameterizeUrl(KimCommonUtils.getKimBasePath()+KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_ACTION, parameters);
 116  
         
 117  0
         AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, 
 118  
                         KNSConstants.DOC_HANDLER_METHOD, KNSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL);
 119  0
         return anchorHtmlData;
 120  
     }
 121  
 
 122  
     /**
 123  
      * Converts GroupInfo objects to GroupImpl objects.
 124  
      * 
 125  
      * @param  fieldValues  names and values returned by the Group Lookup screen
 126  
      * @return  groupImplList  a list of GroupImpl objects
 127  
      * @see  KimCommonUtils#copyInfoToGroup(GroupInfo, GroupImpl)
 128  
      */
 129  
     @Override
 130  
     public List<GroupImpl> getSearchResults(java.util.Map<String,String> fieldValues)  {
 131  0
             List<? extends Group> groupInfoObjs = KIMServiceLocator.getGroupService().lookupGroups(fieldValues);
 132  0
             List<GroupImpl> groupImplList = new ArrayList<GroupImpl>();
 133  0
             for(Group g : groupInfoObjs){                    
 134  0
                     GroupImpl impl = new GroupImpl();
 135  0
                     impl = KimCommonUtils.copyInfoToGroup(g, impl);
 136  0
                     impl.setGroupAttributes(KimCommonUtils.copyInfoAttributesToGroupAttributes(g.getAttributes(), g.getGroupId(), g.getKimTypeId()));
 137  0
                     groupImplList.add(impl);                    
 138  0
             }
 139  0
             return groupImplList;
 140  
     }
 141  
 
 142  
     @Override
 143  
     public boolean checkForAdditionalFields(Map fieldValues) {
 144  0
         List<Row> attributeRows = setupAttributeRows(fieldValues);
 145  0
         if (attributeRows.isEmpty()) {
 146  0
             setAttrRows(attributeRows);
 147  0
         } else if (CollectionUtils.isEmpty(getAttrRows())) {
 148  0
             setAttrRows(attributeRows);
 149  
         }
 150  0
         if (getAttrRows().size() > 0) {
 151  0
             return true;
 152  
         }
 153  0
         return false;
 154  
     }
 155  
 
 156  
 
 157  
         @Override
 158  
         public List<Row> getRows() {
 159  0
                 if (getGrpRows().isEmpty()) {
 160  0
                         List<Row> rows = super.getRows();
 161  0
                         List<Row> returnRows = new ArrayList<Row>();
 162  0
                         for (Row row : rows) {
 163  0
                                 for (int i = row.getFields().size() - 1; i >= 0; i--) {
 164  0
                                         Field field = row.getFields().get(i);
 165  0
                                         if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME)) {
 166  0
                                                 Field typeField = new Field();
 167  0
                                                 typeField.setFieldLabel("Type");
 168  0
                                                 typeField.setPropertyName(KIM_TYPE_ID_PROPERTY_NAME);
 169  0
                                                 typeField.setFieldValidValues(getGroupTypeOptions());
 170  0
                                                 typeField.setFieldType(Field.DROPDOWN);
 171  0
                                                 row.getFields().set(i, typeField);
 172  
                                         }
 173  
                                 }
 174  0
                                 returnRows.add(row);
 175  
                         }
 176  
                         // principalName
 177  0
                         Field typeField = new Field();
 178  0
                         typeField.setFieldLabel("Principal Name");
 179  0
                         typeField.setPropertyName(KIMPropertyConstants.Person.PRINCIPAL_NAME);
 180  0
                         typeField.setFieldType(Field.TEXT);
 181  0
                         typeField.setMaxLength(40);
 182  0
                         typeField.setSize(20);
 183  0
                         typeField.setQuickFinderClassNameImpl("org.kuali.rice.kim.bo.Person");
 184  0
                         typeField.setFieldConversions( "principalName:principalName" );
 185  0
                         typeField.setLookupParameters( "principalName:principalName" );
 186  
                         // Identify the best spot to insert the "Principal Name" search field. Note that the code below assumes that the final row of the
 187  
                         // group search fields is not a row with hidden fields; if this ever becomes the case in the future, this fix may need to
 188  
                         // be modified accordingly.
 189  0
                         List<Field> fields = (returnRows.isEmpty()) ? new ArrayList<Field>() : returnRows.get(returnRows.size() - 1).getFields();
 190  0
                         if (!fields.isEmpty() && fields.get(fields.size() - 1).getFieldType().equals(Field.BLANK_SPACE)) {
 191  
                                 // If the last row in the list has a BLANK_SPACE field coming after any non-BLANK_SPACE fields, add the new field to that row.
 192  0
                                 int insertLoc = fields.size() - 1;
 193  0
                                 while (insertLoc >= 0 && fields.get(insertLoc).getFieldType().equals(Field.BLANK_SPACE)) {
 194  0
                                         insertLoc--;
 195  
                                 }
 196  0
                                 fields.set(insertLoc + 1, typeField);
 197  0
                                 returnRows.get(returnRows.size() - 1).setFields(fields);
 198  0
                         } else {
 199  
                                 // Otherwise, add a new row containing that field.
 200  0
                                 int fieldLen = fields.size();
 201  0
                                 fields = new ArrayList<Field>();
 202  0
                                 fields.add(typeField);
 203  0
                                 for (int i = 1; i < fieldLen; i++) {
 204  0
                                         Field blankSpace = new Field();
 205  0
                                         blankSpace.setFieldType(Field.BLANK_SPACE);
 206  0
                                         blankSpace.setPropertyName(Field.BLANK_SPACE);
 207  0
                                         fields.add(blankSpace);
 208  
                                 }
 209  0
                                 returnRows.add(new Row(fields));
 210  
                         }
 211  
                         
 212  0
                         setGrpRows(returnRows);
 213  
                 }
 214  0
                 if (getAttrRows().isEmpty()) {
 215  0
                         setAttrDefinitions(new AttributeDefinitionMap());
 216  0
                         return getGrpRows();
 217  
                 } else {
 218  0
                         List<Row> fullRows = new ArrayList<Row>();
 219  0
                         fullRows.addAll(getGrpRows());
 220  0
                         fullRows.addAll(getAttrRows());
 221  0
                         return fullRows;
 222  
                 }
 223  
 
 224  
         }
 225  
 
 226  
 
 227  
         @Override
 228  
         public List<Column> getColumns() {
 229  0
                 List<Column> columns =  super.getColumns();
 230  0
         for (Row row : attrRows) {
 231  0
             for (Field field : row.getFields()) {
 232  0
                 Column newColumn = new Column();
 233  0
                 newColumn.setColumnTitle(field.getFieldLabel());
 234  0
                 newColumn.setMaxLength(getColumnMaxLength(field.getPropertyName()));
 235  0
                 newColumn.setPropertyName(field.getPropertyName());
 236  0
                 newColumn.setFormatter((Formatter) field.getFormatter());
 237  0
                 columns.add(newColumn);
 238  0
             }
 239  
         }
 240  0
         return columns;
 241  
         }
 242  
 
 243  
     public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) {
 244  0
         setBackLocation((String) lookupForm.getFieldsForLookup().get(KNSConstants.BACK_LOCATION));
 245  0
         setDocFormKey((String) lookupForm.getFieldsForLookup().get(KNSConstants.DOC_FORM_KEY));
 246  
         Collection displayList;
 247  
 
 248  
         // call search method to get results
 249  0
         if (bounded) {
 250  0
             displayList = getSearchResults(lookupForm.getFieldsForLookup());
 251  
         }
 252  
         else {
 253  0
             displayList = getSearchResultsUnbounded(lookupForm.getFieldsForLookup());
 254  
         }
 255  
 
 256  0
         HashMap<String,Class> propertyTypes = new HashMap<String, Class>();
 257  
 
 258  0
         boolean hasReturnableRow = false;
 259  
 
 260  0
         List returnKeys = getReturnKeys();
 261  0
         List pkNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBusinessObjectClass());
 262  0
         Person user = GlobalVariables.getUserSession().getPerson();
 263  
 
 264  
         // iterate through result list and wrap rows with return url and action urls
 265  0
         for (Iterator iter = displayList.iterator(); iter.hasNext();) {
 266  0
             BusinessObject element = (BusinessObject) iter.next();
 267  0
             if(element instanceof PersistableBusinessObject){
 268  0
                 lookupForm.setLookupObjectId(((PersistableBusinessObject)element).getObjectId());
 269  
             }
 270  
 
 271  0
             BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService().getLookupResultRestrictions(element, user);
 272  
 
 273  0
             HtmlData returnUrl = getReturnUrl(element, lookupForm, returnKeys, businessObjectRestrictions);
 274  
 
 275  0
             String actionUrls = getActionUrls(element, pkNames, businessObjectRestrictions);
 276  
             //Fix for JIRA - KFSMI-2417
 277  0
             if("".equals(actionUrls)){
 278  0
                 actionUrls = ACTION_URLS_EMPTY;
 279  
             }
 280  
 
 281  0
             List<Column> columns = getColumns();
 282  0
             for (Iterator iterator = columns.iterator(); iterator.hasNext();) {
 283  
 
 284  0
                 Column col = (Column) iterator.next();
 285  0
                 Formatter formatter = col.getFormatter();
 286  
 
 287  
                 // pick off result column from result list, do formatting
 288  0
                 String propValue = KNSConstants.EMPTY_STRING;
 289  0
                 Object prop = null;
 290  0
                 boolean skipPropTypeCheck = false;
 291  0
                 if (col.getPropertyName().matches("\\w+\\.\\d+$")) {
 292  0
                     String id = col.getPropertyName().substring(col.getPropertyName().lastIndexOf('.') + 1); //.split("\\d+$"))[1];
 293  0
                     prop = ((GroupImpl)element).getGroupAttributeValueById(id);
 294  
                 }
 295  0
                 if (prop == null) {
 296  0
                     prop = ObjectUtils.getPropertyValue(element, col.getPropertyName());
 297  
                 } else {
 298  0
                     skipPropTypeCheck = true;
 299  
                 }
 300  
 
 301  
                 // set comparator and formatter based on property type
 302  0
                 Class propClass = propertyTypes.get(col.getPropertyName());
 303  0
                 if ( propClass == null /*&& !skipPropTypeCheck*/) {
 304  
                     try {
 305  0
                         propClass = ObjectUtils.getPropertyType( element, col.getPropertyName(), getPersistenceStructureService() );
 306  0
                         propertyTypes.put( col.getPropertyName(), propClass );
 307  0
                     } catch (Exception e) {
 308  0
                         throw new RuntimeException("Cannot access PropertyType for property " + "'" + col.getPropertyName() + "' " + " on an instance of '" + element.getClass().getName() + "'.", e);
 309  0
                     }
 310  
                 }
 311  
 
 312  
                 // formatters
 313  0
                 if (prop != null) {
 314  
                     // for Booleans, always use BooleanFormatter
 315  0
                     if (prop instanceof Boolean) {
 316  0
                         formatter = new BooleanFormatter();
 317  
                     }
 318  
 
 319  
                     // for Dates, always use DateFormatter
 320  0
                     if (prop instanceof Date) {
 321  0
                         formatter = new DateFormatter();
 322  
                     }
 323  
 
 324  
                     // for collection, use the list formatter if a formatter hasn't been defined yet
 325  0
                     if (prop instanceof Collection && formatter == null) {
 326  0
                     formatter = new CollectionFormatter();
 327  
                     }
 328  
 
 329  0
                     if (formatter != null) {
 330  0
                         propValue = (String) formatter.format(prop);
 331  
                     }
 332  
                     else {
 333  0
                         propValue = prop.toString();
 334  0
                         if (col.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME)) {
 335  0
                             propValue = groupTypeValuesCache.get(prop.toString());
 336  
                         }
 337  
                     }
 338  
                 }
 339  
 
 340  
                 // comparator
 341  0
                 col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass));
 342  0
                 col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass));
 343  
 
 344  0
                 propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, businessObjectRestrictions);
 345  
 
 346  0
                 col.setPropertyValue(propValue);
 347  
 
 348  0
                 if (StringUtils.isNotBlank(propValue)) {
 349  0
                     col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName()));
 350  
 
 351  
                 }
 352  0
             }
 353  
 
 354  0
             ResultRow row = new ResultRow(columns, returnUrl.constructCompleteHtmlTag(), actionUrls);
 355  0
             row.setRowId(returnUrl.getName());
 356  0
             row.setReturnUrlHtmlData(returnUrl);
 357  
             // because of concerns of the BO being cached in session on the ResultRow,
 358  
             // let's only attach it when needed (currently in the case of export)
 359  0
             if (getBusinessObjectDictionaryService().isExportable(getBusinessObjectClass())) {
 360  0
                 row.setBusinessObject(element);
 361  
             }
 362  0
             if(element instanceof PersistableBusinessObject){
 363  0
                 row.setObjectId((((PersistableBusinessObject)element).getObjectId()));
 364  
             }
 365  
 
 366  
 
 367  0
             boolean rowReturnable = isResultReturnable(element);
 368  0
             row.setRowReturnable(rowReturnable);
 369  0
             if (rowReturnable) {
 370  0
                 hasReturnableRow = true;
 371  
             }
 372  0
             resultTable.add(row);
 373  0
         }
 374  
 
 375  0
         lookupForm.setHasReturnableRow(hasReturnableRow);
 376  
 
 377  0
         return displayList;
 378  
     }
 379  
 
 380  
         private List<KeyLabelPair> getGroupTypeOptions() {
 381  0
                 List<KeyLabelPair> options = new ArrayList<KeyLabelPair>();
 382  0
                 options.add(new KeyLabelPair("", ""));
 383  
 
 384  0
                 Collection<KimTypeInfo> kimGroupTypes = KIMServiceLocator.getTypeInfoService().getAllTypes();
 385  
                 // get the distinct list of type IDs from all groups in the system
 386  0
         for (KimTypeInfo kimType : kimGroupTypes) {
 387  0
             if (KimTypeLookupableHelperServiceImpl.hasGroupTypeService(kimType) && groupTypeValuesCache.get(kimType.getKimTypeId()) == null) {
 388  0
                 String value = kimType.getNamespaceCode().trim() + KNSConstants.FIELD_CONVERSION_PAIR_SEPARATOR + kimType.getName().trim();
 389  0
                 options.add(new KeyLabelPair(kimType.getKimTypeId(), value));
 390  0
             }
 391  
         }
 392  0
         Collections.sort(options, new Comparator<KeyLabelPair>() {
 393  
            public int compare(KeyLabelPair k1, KeyLabelPair k2) {
 394  0
                return k1.getLabel().compareTo(k2.getLabel());
 395  
            }
 396  
         });
 397  0
                 return options;
 398  
         }
 399  
 
 400  
         private List<Row> setupAttributeRows(Map fieldValues) {
 401  0
                 List<Row> returnRows = new ArrayList<Row>();
 402  0
                 for (Row row : getGrpRows()) {
 403  0
                         Field field = (Field) row.getFields().get(0);
 404  0
                         if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME) && StringUtils.isNotBlank(field.getPropertyValue())) {
 405  0
                                 if (!StringUtils.isBlank(getTypeId()) || !getTypeId().equals(field.getPropertyValue())) {
 406  0
                                         setTypeId(field.getPropertyValue());
 407  0
                                         setAttrRows(new ArrayList<Row>());
 408  0
                                         KimTypeInfo kimType = getTypeInfoService().getKimType( field.getPropertyValue() );
 409  0
                                         KimTypeService kimTypeService = KimCommonUtils.getKimTypeService(kimType);
 410  0
                                 AttributeDefinitionMap definitions = kimTypeService.getAttributeDefinitions(kimType.getKimTypeId());
 411  0
                                 setAttrDefinitions(definitions);
 412  0
                             for (AttributeDefinition definition  : definitions.values()) {
 413  0
                                         List<Field> fields = new ArrayList<Field>();
 414  0
                                                 Field typeField = new Field();
 415  
 
 416  0
                                                 String attrDefnId = getAttrDefnId(definition);
 417  0
                                                 typeField.setFieldLabel(definition.getLabel());
 418  0
                                                 typeField.setPropertyName(definition.getName()+"."+attrDefnId);
 419  0
                                                 typeField.setPropertyValue(fieldValues.get(typeField.getPropertyName()));
 420  0
                                                 if (definition.getControl().isSelect()) {
 421  
                                                 try {
 422  0
                                                     KeyValuesFinder finder = (KeyValuesFinder) ClassLoaderUtils.getClass(definition.getControl().getValuesFinderClass()).newInstance();
 423  0
                                                         typeField.setFieldValidValues(finder.getKeyValues());
 424  0
                                                         typeField.setFieldType(Field.DROPDOWN);
 425  
                                                 }
 426  0
                                                 catch (InstantiationException e) {
 427  0
                                                     throw new RuntimeException(e.getMessage());
 428  
                                                 }
 429  0
                                                 catch (IllegalAccessException e) {
 430  0
                                                     throw new RuntimeException(e.getMessage());
 431  0
                                                 }
 432  0
                                                 } else if (definition.getControl().isText()){
 433  0
                                                         typeField.setMaxLength(definition.getMaxLength());
 434  0
                                                         if (definition.getControl().getSize() != null) {
 435  0
                                                             typeField.setSize(definition.getControl().getSize());
 436  
                                                         }
 437  0
                                                     typeField.setFieldType(Field.TEXT);
 438  0
                                                 } else if (definition.getControl().isRadio()) {
 439  
                                                     try {
 440  0
                                 KeyValuesFinder finder = (KeyValuesFinder) ClassLoaderUtils.getClass(definition.getControl().getValuesFinderClass()).newInstance();
 441  0
                                 typeField.setFieldValidValues(finder.getKeyValues());
 442  0
                                 typeField.setFieldType(Field.RADIO);
 443  
                             }
 444  0
                             catch (InstantiationException e) {
 445  0
                                 throw new RuntimeException(e.getMessage());
 446  
                             }
 447  0
                             catch (IllegalAccessException e) {
 448  0
                                 throw new RuntimeException(e.getMessage());
 449  0
                             }
 450  0
                                                 } else if (definition.getControl().isCheckbox()) {
 451  0
                                                     KeyValuesFinder finder = (KeyValuesFinder)new IndicatorValuesFinder();
 452  0
                             typeField.setFieldValidValues(finder.getKeyValues());
 453  0
                             typeField.setFieldType(Field.RADIO);
 454  
                                                     //typeField.setFieldType(Field.CHECKBOX);
 455  0
                                                 } else if (definition.getControl().isHidden()) {
 456  0
                                                     typeField.setFieldType(Field.HIDDEN);
 457  0
                                                 } else if (definition.getControl().isLookupReadonly()) {
 458  0
                                                     typeField.setFieldType(Field.LOOKUP_READONLY);
 459  0
                                                 } else if (definition.getControl().isTextarea()) {
 460  0
                                                     typeField.setMaxLength(definition.getMaxLength());
 461  0
                             if (definition.getControl().getSize() != null) {
 462  0
                                 typeField.setSize(definition.getControl().getSize());
 463  
                             }
 464  0
                             typeField.setFieldType(Field.TEXT_AREA);
 465  
                                                 }
 466  0
                                                 fields.add(typeField);
 467  0
                                                 returnRows.add(new Row(fields));
 468  0
                             }
 469  0
                                 } else {
 470  0
                                         return getAttrRows();
 471  
                                 }
 472  0
                         } else if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME) && StringUtils.isBlank(field.getPropertyValue())) {
 473  0
                                 setTypeId("");
 474  
                         }
 475  0
                 }
 476  0
                 return returnRows;
 477  
         }
 478  
 
 479  
     private String getAttrDefnId(AttributeDefinition definition) {
 480  0
             if (definition instanceof KimDataDictionaryAttributeDefinition) {
 481  0
                     return ((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId();
 482  
             } else {
 483  0
                     return ((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId();
 484  
 
 485  
             }
 486  
     }
 487  
 
 488  
         public List<Row> getGrpRows() {
 489  0
                 return this.grpRows;
 490  
         }
 491  
 
 492  
         public void setGrpRows(List<Row> grpRows) {
 493  0
                 this.grpRows = grpRows;
 494  0
         }
 495  
 
 496  
         public KimGroupDao getGroupDao() {
 497  0
                 return this.groupDao;
 498  
         }
 499  
 
 500  
         public void setGroupDao(KimGroupDao groupDao) {
 501  0
                 this.groupDao = groupDao;
 502  0
         }
 503  
 
 504  
         public AttributeDefinitionMap getAttrDefinitions() {
 505  0
                 return this.attrDefinitions;
 506  
         }
 507  
 
 508  
         public void setAttrDefinitions(AttributeDefinitionMap attrDefinitions) {
 509  0
                 this.attrDefinitions = attrDefinitions;
 510  0
         }
 511  
 
 512  
         public List<Row> getAttrRows() {
 513  0
                 return this.attrRows;
 514  
         }
 515  
 
 516  
         public void setAttrRows(List<Row> attrRows) {
 517  0
                 this.attrRows = attrRows;
 518  0
         }
 519  
 
 520  
         public String getTypeId() {
 521  0
                 return this.typeId;
 522  
         }
 523  
 
 524  
         public void setTypeId(String typeId) {
 525  0
                 this.typeId = typeId;
 526  0
         }
 527  
 
 528  
     @Override
 529  
     public void performClear(LookupForm lookupForm) {
 530  0
         super.performClear(lookupForm);
 531  0
         this.attrRows = new ArrayList<Row>();
 532  0
     }
 533  
 
 534  
 }