Coverage Report - org.kuali.rice.kew.rule.RuleExtension
 
Classes in this File Line Coverage Branch Coverage Complexity
RuleExtension
0%
0/34
0%
0/12
1.368
 
 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.kew.rule;
 18  
 
 19  
 import org.apache.commons.lang.ObjectUtils;
 20  
 import org.hibernate.annotations.Fetch;
 21  
 import org.hibernate.annotations.FetchMode;
 22  
 import org.hibernate.annotations.GenericGenerator;
 23  
 import org.hibernate.annotations.Parameter;
 24  
 import org.kuali.rice.core.util.CollectionUtils;
 25  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 26  
 import org.kuali.rice.kew.rule.bo.RuleAttribute;
 27  
 import org.kuali.rice.kew.rule.bo.RuleTemplateAttribute;
 28  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 29  
 
 30  
 import javax.persistence.*;
 31  
 import java.io.Serializable;
 32  
 import java.util.ArrayList;
 33  
 import java.util.List;
 34  
 
 35  
 
 36  
 /**
 37  
  * An extension of a {@link RuleBaseValues}.  Provides attribute-specific data
 38  
  * extensions to the rule for a particular {@link RuleAttribute}.  Contains
 39  
  * a List of {@link RuleExtensionValue}s.
 40  
  * 
 41  
  * @see RuleBaseValues
 42  
  * @see RuleAttribute
 43  
  * @see RuleExtensionValue
 44  
  *
 45  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 46  
  */
 47  
 @Entity
 48  
 @Table(name="KREW_RULE_EXT_T")
 49  
 //@Sequence(name="KREW_RTE_TMPL_S", property="ruleExtensionId")
 50  
 public class RuleExtension implements Serializable {
 51  
 
 52  
         private static final long serialVersionUID = 8178135296413950516L;
 53  
 
 54  
         @Id
 55  
         @GeneratedValue(generator="KREW_RTE_TMPL_S")
 56  
         @GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 57  
                         @Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"),
 58  
                         @Parameter(name="value_column",value="id")
 59  
         })
 60  
         @Column(name="RULE_EXT_ID")
 61  
         private String ruleExtensionId;
 62  
 
 63  
         @Column(name="RULE_TMPL_ATTR_ID", insertable=false, updatable=false)
 64  
         private String ruleTemplateAttributeId;
 65  
 
 66  
         @Column(name="RULE_ID", insertable=false, updatable=false)
 67  
         private String ruleBaseValuesId;
 68  
 
 69  
         @Version
 70  
         @Column(name="VER_NBR")
 71  
         private Integer lockVerNbr;
 72  
         
 73  
         @ManyToOne(fetch=FetchType.EAGER)
 74  
         @JoinColumn(name="RULE_ID")
 75  
         private RuleBaseValues ruleBaseValues;
 76  
 
 77  
         @ManyToOne(fetch=FetchType.EAGER)
 78  
         @JoinColumn(name="RULE_TMPL_ATTR_ID")
 79  
         private RuleTemplateAttribute ruleTemplateAttribute;
 80  
 
 81  
         @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, mappedBy="extension")
 82  
         @Fetch(value = FetchMode.SELECT)
 83  
         private List<RuleExtensionValue> extensionValues;
 84  
 
 85  0
         public RuleExtension() {
 86  0
                 extensionValues = new ArrayList<RuleExtensionValue>();
 87  0
         }
 88  
 
 89  
         //@PrePersist
 90  
     public void beforeInsert(){
 91  0
         OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
 92  0
     }
 93  
         
 94  
         public List<RuleExtensionValue> getExtensionValues() {
 95  0
                 return extensionValues;
 96  
         }
 97  
 
 98  
         public void setExtensionValues(List<RuleExtensionValue> extensionValues) {
 99  0
                 this.extensionValues = extensionValues;
 100  0
         }
 101  
 
 102  
         public RuleTemplateAttribute getRuleTemplateAttribute() {
 103  0
                 return ruleTemplateAttribute;
 104  
         }
 105  
 
 106  
         public void setRuleTemplateAttribute(RuleTemplateAttribute ruleTemplateAttribute) {
 107  0
                 this.ruleTemplateAttribute = ruleTemplateAttribute;
 108  0
         }
 109  
 
 110  
         public RuleExtensionValue getRuleExtensionValue(int index) {
 111  0
                 while (getExtensionValues().size() <= index) {
 112  0
                         getExtensionValues().add(new RuleExtensionValue());
 113  
                 }
 114  0
                 return (RuleExtensionValue) getExtensionValues().get(index);
 115  
         }
 116  
 
 117  
         public RuleBaseValues getRuleBaseValues() {
 118  0
                 return ruleBaseValues;
 119  
         }
 120  
 
 121  
         public void setRuleBaseValues(RuleBaseValues ruleBaseValues) {
 122  0
                 this.ruleBaseValues = ruleBaseValues;
 123  0
         }
 124  
 
 125  
         public Integer getLockVerNbr() {
 126  0
                 return lockVerNbr;
 127  
         }
 128  
 
 129  
         public void setLockVerNbr(Integer lockVerNbr) {
 130  0
                 this.lockVerNbr = lockVerNbr;
 131  0
         }
 132  
 
 133  
         public String getRuleBaseValuesId() {
 134  0
                 return ruleBaseValuesId;
 135  
         }
 136  
 
 137  
         public void setRuleBaseValuesId(String ruleBaseValuesId) {
 138  0
                 this.ruleBaseValuesId = ruleBaseValuesId;
 139  0
         }
 140  
 
 141  
         public String getRuleExtensionId() {
 142  0
                 return ruleExtensionId;
 143  
         }
 144  
 
 145  
         public void setRuleExtensionId(String ruleExtensionId) {
 146  0
                 this.ruleExtensionId = ruleExtensionId;
 147  0
         }
 148  
 
 149  
         public String getRuleTemplateAttributeId() {
 150  0
                 return ruleTemplateAttributeId;
 151  
         }
 152  
 
 153  
         public void setRuleTemplateAttributeId(String ruleTemplateAttributeId) {
 154  0
                 this.ruleTemplateAttributeId = ruleTemplateAttributeId;
 155  0
         }
 156  
 
 157  
     public boolean equals(Object o) {
 158  0
         if (o == null) return false;
 159  0
         if (!(o instanceof RuleExtension)) return false;
 160  0
         RuleExtension pred = (RuleExtension) o;
 161  0
         return ObjectUtils.equals(ruleBaseValues.getRuleTemplate(), pred.getRuleBaseValues().getRuleTemplate()) &&
 162  
                ObjectUtils.equals(ruleTemplateAttribute, pred.getRuleTemplateAttribute()) &&
 163  
                CollectionUtils.collectionsEquivalent(extensionValues, pred.getExtensionValues());
 164  
     }
 165  
 
 166  
     public String toString() {
 167  0
         return "[RuleExtension:"
 168  
                +  " ruleExtensionId=" + ruleExtensionId
 169  
                + ", ruleTemplateAttributeId=" + ruleTemplateAttributeId
 170  
                + ", ruleBaseValuesId=" + ruleBaseValuesId
 171  
                + ", ruleBaseValues=" + ruleBaseValues
 172  
                + ", ruleTemplateAttribute=" + ruleTemplateAttribute
 173  
                + ", extensionValues=" + extensionValues
 174  
                + ", lockVerNbr=" + lockVerNbr
 175  
                + "]";
 176  
     }
 177  
 
 178  
 }