View Javadoc

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