001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.document.authorization; 017 018import org.kuali.rice.kns.inquiry.InquiryRestrictions; 019import org.kuali.rice.kns.web.ui.Field; 020 021import java.util.HashSet; 022import java.util.Set; 023 024/** 025 * @deprecated Only used in KNS classes, use KRAD. 026 */ 027@Deprecated 028public class InquiryOrMaintenanceDocumentRestrictionsBase extends 029 BusinessObjectRestrictionsBase implements InquiryOrMaintenanceDocumentRestrictions, InquiryRestrictions { 030 private Set<String> hiddenFields; 031 private Set<String> hiddenSectionIds; 032 033 public void addHiddenField(String fieldName) { 034 hiddenFields.add(fieldName); 035 } 036 037 public void addHiddenSectionId(String sectionId) { 038 hiddenSectionIds.add(sectionId); 039 } 040 041 @Override 042 public FieldRestriction getFieldRestriction(String fieldName) { 043 FieldRestriction fieldRestriction = super 044 .getFieldRestriction(fieldName); 045 if (isHiddenField(fieldName)) { 046 fieldRestriction = new FieldRestriction(fieldName, Field.HIDDEN); 047 } 048 return fieldRestriction; 049 } 050 051 /** 052 * @see org.kuali.rice.krad.authorization.BusinessObjectRestrictionsBase#hasRestriction(java.lang.String) 053 */ 054 @Override 055 public boolean hasRestriction(String fieldName) { 056 return super.hasRestriction(fieldName) || isHiddenField(fieldName); 057 } 058 059 /** 060 * @see org.kuali.rice.krad.authorization.BusinessObjectRestrictionsBase#hasAnyFieldRestrictions() 061 */ 062 @Override 063 public boolean hasAnyFieldRestrictions() { 064 return super.hasAnyFieldRestrictions() || !hiddenFields.isEmpty(); 065 } 066 067 @Override 068 public void clearAllRestrictions() { 069 super.clearAllRestrictions(); 070 hiddenFields = new HashSet<String>(); 071 hiddenSectionIds = new HashSet<String>(); 072 } 073 074 /** 075 * @see org.kuali.rice.krad.authorization.InquiryOrMaintenanceDocumentRestrictions#isHiddenSectionId(java.lang.String) 076 */ 077 public boolean isHiddenSectionId(String sectionId) { 078 return hiddenSectionIds.contains(sectionId); 079 } 080 081 protected boolean isHiddenField(String fieldName) { 082 String normalizedFieldName = normalizeFieldName(fieldName); 083 return hiddenFields.contains(normalizedFieldName); 084 } 085}