Coverage Report - org.kuali.rice.kns.document.authorization.InquiryOrMaintenanceDocumentRestrictionsBase
 
Classes in this File Line Coverage Branch Coverage Complexity
InquiryOrMaintenanceDocumentRestrictionsBase
0%
0/18
0%
0/10
1.375
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kns.document.authorization;
 17  
 
 18  
 import org.kuali.rice.kns.inquiry.InquiryRestrictions;
 19  
 import org.kuali.rice.kns.web.ui.Field;
 20  
 
 21  
 import java.util.HashSet;
 22  
 import java.util.Set;
 23  
 
 24  0
 public class InquiryOrMaintenanceDocumentRestrictionsBase extends
 25  
                 BusinessObjectRestrictionsBase implements InquiryOrMaintenanceDocumentRestrictions, InquiryRestrictions {
 26  
         private Set<String> hiddenFields;
 27  
         private Set<String> hiddenSectionIds;
 28  
 
 29  
         public void addHiddenField(String fieldName) {
 30  0
                 hiddenFields.add(fieldName);
 31  0
         }
 32  
 
 33  
         public void addHiddenSectionId(String sectionId) {
 34  0
                 hiddenSectionIds.add(sectionId);
 35  0
         }
 36  
 
 37  
         @Override
 38  
         public FieldRestriction getFieldRestriction(String fieldName) {
 39  0
                 FieldRestriction fieldRestriction = super
 40  
                                 .getFieldRestriction(fieldName);
 41  0
                 if (isHiddenField(fieldName)) {
 42  0
                         fieldRestriction = new FieldRestriction(fieldName, Field.HIDDEN);
 43  
                 }
 44  0
                 return fieldRestriction;                        
 45  
         }
 46  
 
 47  
         /**
 48  
          * @see org.kuali.rice.krad.authorization.BusinessObjectRestrictionsBase#hasRestriction(java.lang.String)
 49  
          */
 50  
         @Override
 51  
         public boolean hasRestriction(String fieldName) {
 52  0
                 return super.hasRestriction(fieldName) || isHiddenField(fieldName);
 53  
         }
 54  
         
 55  
         /**
 56  
          * @see org.kuali.rice.krad.authorization.BusinessObjectRestrictionsBase#hasAnyFieldRestrictions()
 57  
          */
 58  
         @Override
 59  
         public boolean hasAnyFieldRestrictions() {
 60  0
                 return super.hasAnyFieldRestrictions() || !hiddenFields.isEmpty();
 61  
         }
 62  
 
 63  
         @Override
 64  
         public void clearAllRestrictions() {
 65  0
                 super.clearAllRestrictions();
 66  0
                 hiddenFields = new HashSet<String>();
 67  0
                 hiddenSectionIds = new HashSet<String>();
 68  0
         }
 69  
 
 70  
         /**
 71  
          * @see org.kuali.rice.krad.authorization.InquiryOrMaintenanceDocumentRestrictions#isHiddenSectionId(java.lang.String)
 72  
          */
 73  
         public boolean isHiddenSectionId(String sectionId) {
 74  0
                 return hiddenSectionIds.contains(sectionId);
 75  
         }
 76  
 
 77  
         protected boolean isHiddenField(String fieldName) {
 78  0
                 String normalizedFieldName = normalizeFieldName(fieldName);
 79  0
                 return hiddenFields.contains(normalizedFieldName);
 80  
         }
 81  
 }