Coverage Report - org.kuali.rice.kew.rule.RuleExpressionDef
 
Classes in this File Line Coverage Branch Coverage Complexity
RuleExpressionDef
0%
0/26
0%
0/12
2
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kew.rule;
 17  
 
 18  
 import org.apache.commons.lang.ObjectUtils;
 19  
 import org.hibernate.annotations.GenericGenerator;
 20  
 import org.hibernate.annotations.Parameter;
 21  
 import org.kuali.rice.kew.api.rule.*;
 22  
 import org.kuali.rice.kew.api.rule.RuleExpression;
 23  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
 24  
 
 25  
 import javax.persistence.*;
 26  
 
 27  
 /**
 28  
  * BO for rule expressions 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  
 @Entity
 32  
 @Table(name="KREW_RULE_EXPR_T")
 33  
 //@Sequence(name="KREW_RULE_EXPR_S", property="id")
 34  0
 public class RuleExpressionDef extends PersistableBusinessObjectBase implements RuleExpressionContract {
 35  
     
 36  
     /**
 37  
      * Primary key
 38  
      */
 39  
     @Id
 40  
     @GeneratedValue(generator="KREW_RULE_EXPR_S")
 41  
         @GenericGenerator(name="KREW_RULE_EXPR_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 42  
                         @Parameter(name="sequence_name",value="KREW_RULE_EXPR_S"),
 43  
                         @Parameter(name="value_column",value="id")
 44  
         })
 45  
         @Column(name="RULE_EXPR_ID")
 46  
         private String id;
 47  
     /**
 48  
      * The type of the expression
 49  
      */
 50  
     @Column(name="TYP")
 51  
         private String type;
 52  
     /**
 53  
      * The content of the expression
 54  
      */
 55  
     @Column(name="RULE_EXPR", nullable=true)
 56  
         private String expression;
 57  
     /**
 58  
      * @return the id
 59  
      */
 60  
     public String getId() {
 61  0
         return this.id;
 62  
     }
 63  
     /**
 64  
      * @param id the id to set
 65  
      */
 66  
     public void setId(String id) {
 67  0
         this.id = id;
 68  0
     }
 69  
     /**
 70  
      * @return the type
 71  
      */
 72  
     public String getType() {
 73  0
         return this.type;
 74  
     }
 75  
     /**
 76  
      * @param type the type to set
 77  
      */
 78  
     public void setType(String type) {
 79  0
         this.type = type;
 80  0
     }
 81  
     /**
 82  
      * @return the expression
 83  
      */
 84  
     public String getExpression() {
 85  0
         return this.expression;
 86  
     }
 87  
     /**
 88  
      * @param expression the expression to set
 89  
      */
 90  
     public void setExpression(String expression) {
 91  0
         this.expression = expression;
 92  0
     }
 93  
 
 94  
     /**
 95  
      * Returns whether the object is an <i>equivalent</i> rule expression, i.e.
 96  
      * the type and expression are the same.  This is necessary for rule duplicate
 97  
      * detection.
 98  
      * @see java.lang.Object#equals(java.lang.Object)
 99  
      */
 100  
     @Override
 101  
     public boolean equals(Object obj) {
 102  0
         if (obj == null) return false;
 103  0
         if (!(obj instanceof RuleExpressionDef)) return false;
 104  0
         RuleExpressionDef arg = (RuleExpressionDef) obj;
 105  0
         return ObjectUtils.equals(type, arg.getType()) && ObjectUtils.equals(expression, arg.getExpression());
 106  
     }
 107  
 
 108  
     /**
 109  
      * Converts a mutable bo to its immutable counterpart
 110  
      * @param bo the mutable business object
 111  
      * @return the immutable object
 112  
      */
 113  
     public static org.kuali.rice.kew.api.rule.RuleExpression to(RuleExpressionDef bo) {
 114  0
         if (bo == null) {
 115  0
             return null;
 116  
         }
 117  
 
 118  0
         return RuleExpression.Builder.create(bo).build();
 119  
     }
 120  
 
 121  
     /**
 122  
      * Converts a immutable object to its mutable counterpart
 123  
      * @param im immutable object
 124  
      * @return the mutable bo
 125  
      */
 126  
     public static RuleExpressionDef from(RuleExpression im) {
 127  0
         if (im == null) {
 128  0
             return null;
 129  
         }
 130  
 
 131  0
         RuleExpressionDef bo = new RuleExpressionDef();
 132  0
         bo.setId(im.getId());
 133  0
         bo.setType(im.getType());
 134  0
         bo.setExpression(im.getExpression());
 135  0
         bo.setVersionNumber(im.getVersionNumber());
 136  0
         bo.setObjectId(im.getObjectId());
 137  
 
 138  0
         return bo;
 139  
     }
 140  
 }