Coverage Report - org.kuali.rice.core.impl.style.StyleBo
 
Classes in this File Line Coverage Branch Coverage Complexity
StyleBo
92%
26/28
50%
2/4
1.364
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.core.impl.style;
 18  
 
 19  
 import javax.persistence.Basic;
 20  
 import javax.persistence.Column;
 21  
 import javax.persistence.Entity;
 22  
 import javax.persistence.FetchType;
 23  
 import javax.persistence.GeneratedValue;
 24  
 import javax.persistence.Id;
 25  
 import javax.persistence.Lob;
 26  
 import javax.persistence.Table;
 27  
 
 28  
 import org.hibernate.annotations.GenericGenerator;
 29  
 import org.hibernate.annotations.Parameter;
 30  
 import org.kuali.rice.core.api.style.Style;
 31  
 import org.kuali.rice.core.api.style.StyleContract;
 32  
 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
 33  
 
 34  
 /**
 35  
  * A BusinessObject implementation of the StyleContract which is mapped to the
 36  
  * database for persistence.
 37  
  * 
 38  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 39  
  */
 40  
 @Entity
 41  
 @Table(name="KREW_STYLE_T")
 42  
 //@Sequence(name="KREW_EDL_S", property="edocLiteStyleId")
 43  
 public class StyleBo extends PersistableBusinessObjectBase implements StyleContract {
 44  
 
 45  
         private static final long serialVersionUID = 2020611019976731725L;
 46  
     
 47  
         @Id
 48  
     @GeneratedValue(generator="KREW_EDL_S")
 49  
         @GenericGenerator(name="KREW_EDL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 50  
                         @Parameter(name="sequence_name",value="KREW_EDL_S"),
 51  
                         @Parameter(name="value_column",value="id")
 52  
         })
 53  
         @Column(name="STYLE_ID")
 54  
         private Long styleId;
 55  
 
 56  
         @Column(name="NM")
 57  
         private String name;
 58  
     
 59  
         @Lob
 60  
         @Basic(fetch=FetchType.LAZY)
 61  
         @Column(name="XML")
 62  
         private String xmlContent;
 63  
     
 64  
         @Column(name="ACTV_IND")
 65  
         private boolean active;
 66  
 
 67  3
         public StyleBo() {
 68  
                 // default active to true
 69  3
                 this.active = true;
 70  3
         }
 71  
         
 72  
         @Override
 73  
     public Long getStyleId() {
 74  3
         return styleId;
 75  
     }
 76  
     
 77  
     public void setStyleId(Long styleId) {
 78  3
         this.styleId = styleId;
 79  3
     }
 80  
     
 81  
     @Override
 82  
     public String getName() {
 83  7
         return name;
 84  
     }
 85  
     
 86  
     public void setName(String name) {
 87  3
         this.name = name;
 88  3
     }
 89  
     
 90  
     @Override
 91  
     public String getXmlContent() {
 92  3
         return xmlContent;
 93  
     }
 94  
     
 95  
     public void setXmlContent(String xmlContent) {
 96  3
         this.xmlContent = xmlContent;
 97  3
     }
 98  
     
 99  
     @Override
 100  
     public boolean isActive() {
 101  3
         return active;
 102  
     }
 103  
 
 104  
     public void setActive(boolean active) {
 105  5
         this.active = active;
 106  5
     }
 107  
     
 108  
     /**
 109  
      * Converts the given StyleBo to a Style object.
 110  
      * 
 111  
      * @param styleBo the StyleBo to convert
 112  
      * @return the resulting Style object, or null if the given styleBo was null
 113  
      */
 114  
     public static Style to(StyleBo styleBo) {
 115  2
             if (styleBo == null) {
 116  0
                     return null;
 117  
             }
 118  2
             return Style.Builder.create(styleBo).build();
 119  
     }
 120  
     
 121  
     /**
 122  
      * Constructs a StyleBo from the given Style.
 123  
      * 
 124  
      * @param style the Style to convert
 125  
      * @return the resulting StyleBo object, or null if the given style was null
 126  
      */
 127  
     public static StyleBo from(Style style) {
 128  3
             if (style == null) {
 129  0
                     return null;
 130  
             }
 131  3
             StyleBo styleBo = new StyleBo();
 132  3
             styleBo.setStyleId(style.getStyleId());
 133  3
             styleBo.setName(style.getName());
 134  3
             styleBo.setXmlContent(style.getXmlContent());
 135  3
             styleBo.setActive(style.isActive());
 136  3
             styleBo.setVersionNumber(style.getVersionNumber());
 137  3
             styleBo.setObjectId(style.getObjectId());
 138  3
             return styleBo;
 139  
     }
 140  
 
 141  
 }