Coverage Report - org.kuali.rice.krad.uif.control.GroupControl
 
Classes in this File Line Coverage Branch Coverage Complexity
GroupControl
0%
0/25
0%
0/16
2.333
 
 1  
 /*
 2  
  * Copyright 2007 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.rice.krad.uif.control;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.uif.container.View;
 20  
 import org.kuali.rice.krad.uif.core.Component;
 21  
 import org.kuali.rice.krad.uif.field.AttributeField;
 22  
 import org.kuali.rice.kim.api.group.Group;
 23  
 
 24  
 /**
 25  
  * Represents a group control, which is a special control to handle
 26  
  * the input of a KIM Group by group name
 27  
  *
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  
 public class GroupControl extends TextControl {
 31  
     private static final long serialVersionUID = 5598459655735440981L;
 32  
     private String namespaceCodePropertyName;
 33  
     private String groupIdPropertyName;
 34  
 
 35  
     public GroupControl() {
 36  0
                 super();
 37  0
         }
 38  
 
 39  
     @Override
 40  
     public void performApplyModel(View view, Object model, Component parent) {
 41  0
         super.performApplyModel(view, model, parent);
 42  
 
 43  0
         if (parent instanceof AttributeField) {
 44  0
             AttributeField field = (AttributeField) parent;
 45  
 
 46  0
             if (StringUtils.isNotBlank(groupIdPropertyName)) {
 47  0
                 field.getHiddenPropertyNames().add(groupIdPropertyName);
 48  
             }
 49  
 
 50  0
             if (StringUtils.isBlank(field.getFieldLookup().getDataObjectClassName())) {
 51  0
                 field.getFieldLookup().setDataObjectClassName(Group.class.getName());
 52  
             }
 53  
 
 54  0
             if (field.getFieldLookup().getFieldConversions().isEmpty()) {
 55  0
                 if (StringUtils.isNotBlank(groupIdPropertyName)) {
 56  0
                     field.getFieldLookup().getFieldConversions().put("id", groupIdPropertyName);
 57  
                 }
 58  
 
 59  0
                 field.getFieldLookup().getFieldConversions().put("name", field.getPropertyName());
 60  
 
 61  0
                 if (StringUtils.isNotBlank(namespaceCodePropertyName)) {
 62  0
                     field.getFieldLookup().getFieldConversions().put("namespaceCode", namespaceCodePropertyName);
 63  
                 }
 64  
             }
 65  
 
 66  0
             if (field.getFieldLookup().getLookupParameters().isEmpty()) {
 67  0
                 if (StringUtils.isNotBlank(namespaceCodePropertyName)) {
 68  0
                     field.getFieldLookup().getLookupParameters().put("namespaceCode", namespaceCodePropertyName);
 69  
                 }
 70  
             }
 71  
         }
 72  0
     }
 73  
 
 74  
     /**
 75  
          * The name of the property on the parent object that holds the group namespace
 76  
          *
 77  
          * @return String namespaceCodePropertyName
 78  
          */
 79  
     public String getNamespaceCodePropertyName() {
 80  0
         return namespaceCodePropertyName;
 81  
     }
 82  
 
 83  
     /**
 84  
      * Setter for the name of the property on the parent object that holds the group namespace
 85  
      *
 86  
      * @param namespaceCodePropertyName
 87  
      */
 88  
     public void setNamespaceCodePropertyName(String namespaceCodePropertyName) {
 89  0
         this.namespaceCodePropertyName = namespaceCodePropertyName;
 90  0
     }
 91  
 
 92  
     /**
 93  
          * The name of the property on the parent object that holds the group id
 94  
          *
 95  
          * @return String groupIdPropertyName
 96  
          */
 97  
     public String getGroupIdPropertyName() {
 98  0
         return groupIdPropertyName;
 99  
     }
 100  
 
 101  
     /**
 102  
      * Setter for the name of the property on the parent object that holds the group id
 103  
      *
 104  
      * @param groupIdPropertyName
 105  
      */
 106  
     public void setGroupIdPropertyName(String groupIdPropertyName) {
 107  0
         this.groupIdPropertyName = groupIdPropertyName;
 108  0
     }
 109  
 }