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.krad.demo.uif.authorizer;
17  
18  import org.kuali.rice.kim.api.identity.Person;
19  import org.kuali.rice.krad.inquiry.InquiryViewAuthorizerBase;
20  import org.kuali.rice.krad.uif.container.Group;
21  import org.kuali.rice.krad.uif.field.DataField;
22  import org.kuali.rice.krad.uif.field.Field;
23  import org.kuali.rice.krad.uif.view.View;
24  import org.kuali.rice.krad.uif.view.ViewModel;
25  
26  /**
27   * The DemoInquiryViewAuthorizer is used to demonstrate the ability to  to control the visibility
28   * and masking of sections and fields based on permission checks.
29   *
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class DemoInquiryViewAuthorizer extends InquiryViewAuthorizerBase {
34  
35      @Override
36      public boolean canViewField(View view, ViewModel model, Field field, String propertyName, Person user)
37      {
38         //hide travel authorization number from admin
39          if(propertyName.equals("travelAuthorizationDocumentId") &&
40                  user.getPrincipalName().equals("admin"))   {
41              return false;
42          }
43  
44          return super.canViewField(view,model,field,propertyName,user);
45      }
46  
47      @Override
48      public boolean canViewGroup(View view, ViewModel model, Group group, String groupId, Person user) {
49  
50          //hide the estimates section if the user is admin
51          if(groupId.equals("TravelAccount-InquiryView-Costs") &&
52                  user.getPrincipalName().equals("admin"))  {
53              return false;
54          }
55  
56          return super.canViewGroup(view,model,group,groupId,user);
57      }
58  
59  
60  
61  
62  
63  }