View Javadoc
1   /**
2    * Copyright 2005-2014 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.impl.permission;
17  
18  
19  
20  import java.util.List;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.rice.kim.api.KimConstants;
24  import org.kuali.rice.kim.api.identity.Person;
25  import org.kuali.rice.kim.api.permission.Permission;
26  import org.kuali.rice.kim.impl.group.GroupBo;
27  import org.kuali.rice.kim.impl.identity.PersonImpl;
28  import org.kuali.rice.kim.impl.role.RoleBo;
29  import org.kuali.rice.krad.bo.BusinessObject;
30  import org.springframework.util.AutoPopulatingList;
31  
32  //strange - hacky non-PBO
33  public class UberPermissionBo extends PermissionBo implements BusinessObject {
34  
35      private static final long serialVersionUID = 1L;
36  
37      private List<RoleBo> assignedToRoles = new AutoPopulatingList(RoleBo.class);
38      private String assignedToRoleNamespaceForLookup;
39      private String assignedToRoleNameForLookup;
40      private RoleBo assignedToRole = new RoleBo();
41      private String assignedToPrincipalNameForLookup;
42      private Person assignedToPrincipal = new PersonImpl();
43      private String assignedToGroupNamespaceForLookup;
44      private String assignedToGroupNameForLookup;
45      private GroupBo assignedToGroup = new GroupBo();
46      private String attributeName;
47      private String attributeValue;
48      private String detailCriteria;
49  
50      public static UberPermissionBo from(PermissionBo bo) {
51          if (bo == null) {
52              return null;
53          }
54          Permission.Builder builder =  Permission.Builder.create(bo);
55          return (UberPermissionBo) PermissionBo.from(builder.build());
56  
57      }
58      public String getAssignedToRolesToDisplay() {
59          StringBuffer assignedToRolesText = new StringBuffer();
60          for (RoleBo roleImpl: assignedToRoles) {
61              assignedToRolesText.append(roleImpl.getNamespaceCode().trim())
62                      .append(" ")
63                      .append(roleImpl.getName().trim())
64                      .append(KimConstants.KimUIConstants.COMMA_SEPARATOR);
65          }
66          return StringUtils.chomp(assignedToRolesText.toString(), KimConstants.KimUIConstants.COMMA_SEPARATOR);
67      }
68  
69      public List<RoleBo> getAssignedToRoles() {
70          return assignedToRoles;
71      }
72  
73      public void setAssignedToRoles(List<RoleBo> assignedToRoles) {
74          this.assignedToRoles = assignedToRoles;
75      }
76  
77      public String getAssignedToRoleNamespaceForLookup() {
78          return assignedToRoleNamespaceForLookup;
79      }
80  
81      public void setAssignedToRoleNamespaceForLookup(String assignedToRoleNamespaceForLookup) {
82          this.assignedToRoleNamespaceForLookup = assignedToRoleNamespaceForLookup;
83      }
84  
85      public String getAssignedToRoleNameForLookup() {
86          return assignedToRoleNameForLookup;
87      }
88  
89      public void setAssignedToRoleNameForLookup(String assignedToRoleNameForLookup) {
90          this.assignedToRoleNameForLookup = assignedToRoleNameForLookup;
91      }
92  
93      public RoleBo getAssignedToRole() {
94          return assignedToRole;
95      }
96  
97      public void setAssignedToRole(RoleBo assignedToRole) {
98          this.assignedToRole = assignedToRole;
99      }
100 
101     public String getAssignedToPrincipalNameForLookup() {
102         return assignedToPrincipalNameForLookup;
103     }
104 
105     public void setAssignedToPrincipalNameForLookup(String assignedToPrincipalNameForLookup) {
106         this.assignedToPrincipalNameForLookup = assignedToPrincipalNameForLookup;
107     }
108 
109     public Person getAssignedToPrincipal() {
110         return assignedToPrincipal;
111     }
112 
113     public void setAssignedToPrincipal(Person assignedToPrincipal) {
114         this.assignedToPrincipal = assignedToPrincipal;
115     }
116 
117     public String getAssignedToGroupNamespaceForLookup() {
118         return assignedToGroupNamespaceForLookup;
119     }
120 
121     public void setAssignedToGroupNamespaceForLookup(String assignedToGroupNamespaceForLookup) {
122         this.assignedToGroupNamespaceForLookup = assignedToGroupNamespaceForLookup;
123     }
124 
125     public String getAssignedToGroupNameForLookup() {
126         return assignedToGroupNameForLookup;
127     }
128 
129     public void setAssignedToGroupNameForLookup(String assignedToGroupNameForLookup) {
130         this.assignedToGroupNameForLookup = assignedToGroupNameForLookup;
131     }
132 
133     public GroupBo getAssignedToGroup() {
134         return assignedToGroup;
135     }
136 
137     public void setAssignedToGroup(GroupBo assignedToGroup) {
138         this.assignedToGroup = assignedToGroup;
139     }
140 
141     public String getAttributeName() {
142         return attributeName;
143     }
144 
145     public void setAttributeName(String attributeName) {
146         this.attributeName = attributeName;
147     }
148 
149     public String getAttributeValue() {
150         return attributeValue;
151     }
152 
153     public void setAttributeValue(String attributeValue) {
154         this.attributeValue = attributeValue;
155     }
156 
157     public String getDetailCriteria() {
158         return detailCriteria;
159     }
160 
161     public void setDetailCriteria(String detailCriteria) {
162         this.detailCriteria = detailCriteria;
163     }
164 
165     @Override
166     public void refresh() {
167     }
168 }
169