View Javadoc

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