Coverage Report - org.kuali.rice.kim.bo.impl.GenericPermission
 
Classes in this File Line Coverage Branch Coverage Complexity
GenericPermission
0%
0/74
0%
0/14
1.414
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.bo.impl;
 17  
 
 18  
 import java.util.Iterator;
 19  
 import java.util.LinkedHashMap;
 20  
 
 21  
 import javax.persistence.Column;
 22  
 import javax.persistence.Entity;
 23  
 import javax.persistence.Id;
 24  
 import javax.persistence.PrePersist;
 25  
 import javax.persistence.PreUpdate;
 26  
 import javax.persistence.Table;
 27  
 
 28  
 import org.apache.commons.lang.StringUtils;
 29  
 import org.apache.ojb.broker.PersistenceBroker;
 30  
 import org.apache.ojb.broker.PersistenceBrokerException;
 31  
 import org.kuali.rice.kim.bo.role.KimPermission;
 32  
 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
 33  
 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
 34  
 
 35  
 /**
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 @Entity
 39  
 @Table(name="KRIM_PERM_T")
 40  
 public class GenericPermission extends PersistableBusinessObjectBase {
 41  
 //        private static final Logger LOG = Logger.getLogger(GenericPermission.class);        
 42  
         
 43  
         private static final long serialVersionUID = 1L;
 44  
         
 45  
         @Id
 46  
         @Column(name="PERM_ID")
 47  
         protected String permissionId;
 48  
         protected String namespaceCode;
 49  
         protected String name;
 50  
         protected String description;
 51  
         protected boolean active;
 52  
         protected String templateId;
 53  
         protected String detailValues;
 54  
         protected AttributeSet details;
 55  
         
 56  
         /**
 57  
          * This constructs a ...
 58  
          * 
 59  
          */
 60  0
         public GenericPermission() {
 61  0
         }
 62  
         
 63  0
         public GenericPermission( KimPermission perm ) {
 64  0
                 loadFromKimPermission( perm );
 65  0
         }
 66  
         public void loadFromKimPermission( KimPermission perm ) {
 67  0
                 setPermissionId( perm.getPermissionId() );
 68  0
                 setNamespaceCode( perm.getNamespaceCode() );
 69  0
                 setName( perm.getName() );
 70  0
                 setTemplateId( perm.getTemplateId() );
 71  0
                 setDescription( perm.getDescription() );
 72  0
                 setActive( perm.isActive() );
 73  0
                 setDetails( perm.getDetails() );
 74  0
         }
 75  
         
 76  
         public String getDetailValues() {
 77  
                 /*StringBuffer sb = new StringBuffer();
 78  
                 if ( details != null ) {
 79  
                         Iterator<String> keyIter = details.keySet().iterator();
 80  
                         while ( keyIter.hasNext() ) {
 81  
                                 String key = keyIter.next();
 82  
                                 sb.append( key ).append( '=' ).append( details.get( key ) );
 83  
                                 if ( keyIter.hasNext() ) {
 84  
                                         sb.append( '\n' );
 85  
                                 }
 86  
                         }
 87  
                 }
 88  
                 return sb.toString();*/
 89  0
                 return detailValues;
 90  
         }
 91  
         
 92  
         public void setDetailValues( String detailValues ) {
 93  0
                 this.detailValues = detailValues;
 94  0
                 String detailValuesTemp = detailValues;
 95  0
                 AttributeSet details = new AttributeSet();
 96  0
                 if ( detailValuesTemp != null ) {
 97  
                         // ensure that all line delimiters are single linefeeds
 98  0
                         detailValuesTemp = detailValuesTemp.replace( "\r\n", "\n" );
 99  0
                         detailValuesTemp = detailValuesTemp.replace( '\r', '\n' );
 100  0
                         if ( StringUtils.isNotBlank( detailValuesTemp ) ) {
 101  0
                                 String[] values = detailValuesTemp.split( "\n" );
 102  0
                                 for ( String attrib : values ) {
 103  0
                                         if ( attrib.indexOf( '=' ) != -1 ) {
 104  0
                                                 String[] keyValueArray = attrib.split( "=", 2 );
 105  0
                                                 details.put( keyValueArray[0].trim(), keyValueArray[1].trim() );
 106  
                                         }
 107  
                                 }
 108  
                         }
 109  
                 }
 110  0
                 this.details = details;
 111  0
         }
 112  
         
 113  
         public void setDetailValues( AttributeSet detailsAttribs ) {
 114  0
                 StringBuffer sb = new StringBuffer();
 115  0
                 if ( detailsAttribs != null ) {
 116  0
                         Iterator<String> keyIter = detailsAttribs.keySet().iterator();
 117  0
                         while ( keyIter.hasNext() ) {
 118  0
                                 String key = keyIter.next();
 119  0
                                 sb.append( key ).append( '=' ).append( detailsAttribs.get( key ) );
 120  0
                                 if ( keyIter.hasNext() ) {
 121  0
                                         sb.append( '\n' );
 122  
                                 }
 123  0
                         }
 124  
                 }
 125  0
                 detailValues = sb.toString();
 126  0
         }
 127  
         
 128  
         /**
 129  
          * @see org.kuali.rice.kns.bo.Inactivateable#isActive()
 130  
          */
 131  
         public boolean isActive() {
 132  0
                 return active;
 133  
         }
 134  
 
 135  
         /**
 136  
          * @see org.kuali.rice.kns.bo.Inactivateable#setActive(boolean)
 137  
          */
 138  
         public void setActive(boolean active) {
 139  0
                 this.active = active;
 140  0
         }
 141  
 
 142  
         /**
 143  
          * @see org.kuali.rice.kim.bo.role.KimPermission#getDescription()
 144  
          */
 145  
         public String getDescription() {
 146  0
                 return description;
 147  
         }
 148  
 
 149  
         /**
 150  
          * @see org.kuali.rice.kim.bo.role.KimPermission#getPermissionId()
 151  
          */
 152  
         public String getPermissionId() {
 153  0
                 return permissionId;
 154  
         }
 155  
 
 156  
         /**
 157  
          * @see org.kuali.rice.kim.bo.role.KimPermission#getName()
 158  
          */
 159  
         public String getName() {
 160  0
                 return name;
 161  
         }
 162  
 
 163  
         public void setDescription(String permissionDescription) {
 164  0
                 this.description = permissionDescription;
 165  0
         }
 166  
 
 167  
         public void setName(String permissionName) {
 168  0
                 this.name = permissionName;
 169  0
         }
 170  
 
 171  
         /**
 172  
          * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
 173  
          */
 174  
         @SuppressWarnings("unchecked")
 175  
         @Override
 176  
         protected LinkedHashMap toStringMapper() {
 177  0
                 LinkedHashMap m = new LinkedHashMap();
 178  0
                 m.put( "permissionId", permissionId );
 179  0
                 m.put( "name", name );
 180  0
                 m.put( "details", getDetails() );
 181  0
                 return m;
 182  
         }
 183  
 
 184  
         public void setDetails( AttributeSet details ) {
 185  0
                 this.details = details;
 186  0
                 setDetailValues(details);
 187  0
         }
 188  
         
 189  
         public String getTemplateId() {
 190  0
                 return this.templateId;
 191  
         }
 192  
 
 193  
         public void setTemplateId(String templateId) {
 194  0
                 this.templateId = templateId;
 195  0
         }
 196  
 
 197  
         public AttributeSet getDetails() {
 198  0
                 return details;
 199  
         }
 200  
         
 201  
         public String getNamespaceCode() {
 202  0
                 return this.namespaceCode;
 203  
         }
 204  
 
 205  
         public void setNamespaceCode(String namespaceCode) {
 206  0
                 this.namespaceCode = namespaceCode;
 207  0
         }
 208  
 
 209  
         public void setPermissionId(String permissionId) {
 210  0
                 this.permissionId = permissionId;
 211  0
         }
 212  
 
 213  
 
 214  
         public void refresh() {
 215  
                 // do nothing - not a persistable object
 216  0
         }
 217  
         
 218  
         @Override
 219  
         public void refreshNonUpdateableReferences() {
 220  
                 // do nothing - not a persistable object
 221  0
         }
 222  
         @Override
 223  
         public void refreshReferenceObject(String referenceObjectName) {
 224  
                 // do nothing - not a persistable object
 225  0
         }
 226  
 
 227  
         /**
 228  
          * This overridden method ...
 229  
          * 
 230  
          * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#beforeInsert()
 231  
          */
 232  
         @Override
 233  
         @PrePersist
 234  
         public void beforeInsert() {
 235  0
                 throw new UnsupportedOperationException( "This object should never be persisted.");
 236  
         }
 237  
         
 238  
         /**
 239  
          * This overridden method ...
 240  
          * 
 241  
          * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#beforeUpdate()
 242  
          */
 243  
         @Override
 244  
         @PreUpdate
 245  
         public void beforeUpdate() {
 246  0
                 throw new UnsupportedOperationException( "This object should never be persisted.");
 247  
         }
 248  
         
 249  
         /**
 250  
          * This overridden method ...
 251  
          * 
 252  
          * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#beforeInsert(org.apache.ojb.broker.PersistenceBroker)
 253  
          */
 254  
         @Override
 255  
         public void beforeInsert(PersistenceBroker persistenceBroker)
 256  
                         throws PersistenceBrokerException {
 257  0
                 throw new UnsupportedOperationException( "This object should never be persisted.");
 258  
         }
 259  
         
 260  
         /**
 261  
          * This overridden method ...
 262  
          * 
 263  
          * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#beforeUpdate(org.apache.ojb.broker.PersistenceBroker)
 264  
          */
 265  
         @Override
 266  
         public void beforeUpdate(PersistenceBroker persistenceBroker) {
 267  0
                 throw new UnsupportedOperationException( "This object should never be persisted.");
 268  
         }
 269  
 
 270  
         /**
 271  
          * This overridden method ...
 272  
          * 
 273  
          * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#beforeDelete(org.apache.ojb.broker.PersistenceBroker)
 274  
          */
 275  
         @Override
 276  
         public void beforeDelete(PersistenceBroker persistenceBroker)
 277  
                         throws PersistenceBrokerException {
 278  0
                 throw new UnsupportedOperationException( "This object should never be persisted.");
 279  
         }
 280  
 
 281  
 }