Coverage Report - org.kuali.rice.kns.datadictionary.AttributeSecurity
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeSecurity
0%
0/30
0%
0/22
1.733
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.datadictionary;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 import org.apache.commons.logging.LogFactory;
 22  
 import org.kuali.rice.kew.attribute.Attribute;
 23  
 import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException;
 24  
 import org.kuali.rice.kns.datadictionary.mask.MaskFormatter;
 25  
 
 26  
 /**
 27  
  * This class defines a set of restrictions that are possible on an attribute in a 
 28  
  * {@link BusinessObjectEntry} or a maintainable field in a {@link MaintenanceDocumentEntry}
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  * 
 32  
  */
 33  0
 public class AttributeSecurity extends DataDictionaryDefinitionBase {
 34  
         private static final long serialVersionUID = -7923499408946975318L;
 35  
         
 36  0
         boolean readOnly = false;
 37  0
         boolean hide = false;
 38  0
         boolean mask = false;
 39  0
         boolean partialMask = false;
 40  
         MaskFormatter partialMaskFormatter;
 41  
         MaskFormatter maskFormatter;
 42  
 
 43  
         /**
 44  
          * @return the readOnly
 45  
          */
 46  
         public boolean isReadOnly() {
 47  0
                 return this.readOnly;
 48  
         }
 49  
 
 50  
         /**
 51  
          * @param readOnly
 52  
          *            the readOnly to set
 53  
          */
 54  
         public void setReadOnly(boolean readOnly) {
 55  0
                 this.readOnly = readOnly;
 56  0
         }
 57  
 
 58  
         /**
 59  
          * @return the hide
 60  
          */
 61  
         public boolean isHide() {
 62  0
                 return this.hide;
 63  
         }
 64  
 
 65  
         /**
 66  
          * @param hide
 67  
          *            the hide to set
 68  
          */
 69  
         public void setHide(boolean hide) {
 70  0
                 this.hide = hide;
 71  0
         }
 72  
 
 73  
         /**
 74  
          * @return the mask
 75  
          */
 76  
         public boolean isMask() {
 77  0
                 return this.mask;
 78  
         }
 79  
 
 80  
         /**
 81  
          * @param mask
 82  
          *            the mask to set
 83  
          */
 84  
         public void setMask(boolean mask) {
 85  0
                 this.mask = mask;
 86  0
         }
 87  
 
 88  
         /**
 89  
          * @return the partialMask
 90  
          */
 91  
         public boolean isPartialMask() {
 92  0
                 return this.partialMask;
 93  
         }
 94  
 
 95  
         /**
 96  
          * @param partialMask
 97  
          *            the partialMask to set
 98  
          */
 99  
         public void setPartialMask(boolean partialMask) {
 100  0
                 this.partialMask = partialMask;
 101  0
         }
 102  
 
 103  
         /**
 104  
          * @return the maskFormatter
 105  
          */
 106  
         public MaskFormatter getMaskFormatter() {
 107  0
                 return this.maskFormatter;
 108  
         }
 109  
 
 110  
         /**
 111  
          * @param maskFormatter
 112  
          *            the maskFormatter to set
 113  
          */
 114  
         public void setMaskFormatter(MaskFormatter maskFormatter) {
 115  0
                 this.maskFormatter = maskFormatter;
 116  0
         }
 117  
 
 118  
         /**
 119  
          * @return the partialMaskFormatter
 120  
          */
 121  
         public MaskFormatter getPartialMaskFormatter() {
 122  0
                 return this.partialMaskFormatter;
 123  
         }
 124  
 
 125  
         /**
 126  
          * @param partialMaskFormatter
 127  
          *            the partialMaskFormatter to set
 128  
          */
 129  
         public void setPartialMaskFormatter(MaskFormatter partialMaskFormatter) {
 130  0
                 this.partialMaskFormatter = partialMaskFormatter;
 131  0
         }
 132  
 
 133  
         /**
 134  
          * This overridden method ...
 135  
          * 
 136  
          * @see org.kuali.rice.kns.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class,
 137  
          *      java.lang.Class)
 138  
          */
 139  
         public void completeValidation(Class rootBusinessObjectClass,
 140  
                         Class otherBusinessObjectClass) {
 141  
 
 142  0
                 if (mask && maskFormatter == null) {
 143  0
                         throw new AttributeValidationException("MaskFormatter is required");
 144  
                 }
 145  0
                 if (partialMask && partialMaskFormatter == null) {
 146  0
                         throw new AttributeValidationException(
 147  
                                         "PartialMaskFormatter is required");
 148  
                 }
 149  0
         }
 150  
 
 151  
         /**
 152  
          * Returns whether any of the restrictions defined in this class are true.
 153  
          */
 154  
         public boolean hasAnyRestriction() {
 155  0
                 return readOnly || mask || partialMask || hide;
 156  
         }
 157  
         
 158  
         
 159  
         /**
 160  
          * Returns whether any of the restrictions defined in this class indicate that the attribute value potentially needs
 161  
          * to be not shown to the user (i.e. masked, partial mask, hide).  Note that readonly does not fall in this category.
 162  
          * 
 163  
          * @return
 164  
          */
 165  
         public boolean hasRestrictionThatRemovesValueFromUI() {
 166  0
                 return mask || partialMask || hide;        
 167  
         }
 168  
 }