Coverage Report - org.kuali.rice.kew.doctype.DocumentTypeAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypeAttribute
0%
0/31
0%
0/4
1.176
 
 1  
 /*
 2  
  * Copyright 2005-2007 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.doctype;
 18  
 
 19  
 import java.io.Serializable;
 20  
 
 21  
 import javax.persistence.Column;
 22  
 import javax.persistence.Entity;
 23  
 import javax.persistence.FetchType;
 24  
 import javax.persistence.GeneratedValue;
 25  
 import javax.persistence.Id;
 26  
 import javax.persistence.JoinColumn;
 27  
 import javax.persistence.ManyToOne;
 28  
 import javax.persistence.Table;
 29  
 import javax.persistence.Transient;
 30  
 
 31  
 import org.hibernate.annotations.GenericGenerator;
 32  
 import org.hibernate.annotations.Parameter;
 33  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 34  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 35  
 import org.kuali.rice.kew.rule.bo.RuleAttribute;
 36  
 import org.kuali.rice.kew.rule.service.RuleAttributeService;
 37  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 38  
 
 39  
 
 40  
 /**
 41  
  * Data bean representing an attribute associated at the document type level.  e.g. NoteAttribute, 
 42  
  * EmailAttribute, SearchableAttribute, etc.
 43  
  * 
 44  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 45  
  *
 46  
  */
 47  
 @Entity
 48  
 //@Sequence(name="KREW_DOC_TYP_ATTR_S", property="documentTypeAttributeId")
 49  
 @Table(name="KREW_DOC_TYP_ATTR_T")
 50  0
 public class DocumentTypeAttribute implements Comparable, Serializable {
 51  
 
 52  
         private static final long serialVersionUID = -4429421648373903566L;
 53  
 
 54  
         @Id
 55  
         @GeneratedValue(generator="KREW_DOC_TYP_ATTR_S")
 56  
         @GenericGenerator(name="KREW_DOC_TYP_ATTR_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 57  
                         @Parameter(name="sequence_name",value="KREW_DOC_TYP_ATTR_S"),
 58  
                         @Parameter(name="value_column",value="id")
 59  
         })
 60  
         @Column(name="DOC_TYP_ATTRIB_ID")
 61  
         private String documentTypeAttributeId; 
 62  
     @Column(name="RULE_ATTR_ID",insertable=false, updatable=false)
 63  
         private String ruleAttributeId;
 64  
     @ManyToOne(fetch=FetchType.EAGER)
 65  
         @JoinColumn(name="RULE_ATTR_ID")
 66  
         private RuleAttribute ruleAttribute;
 67  
     @Column(name="DOC_TYP_ID",insertable=false, updatable=false)
 68  
         private String documentTypeId;
 69  
     @ManyToOne(fetch=FetchType.EAGER)
 70  
         @JoinColumn(name="DOC_TYP_ID")
 71  
         private DocumentType documentType;
 72  
     @Column(name="ORD_INDX")
 73  
         private int orderIndex;
 74  
     @Transient
 75  
     private Integer lockVerNbr;
 76  
     
 77  
         //@PrePersist
 78  
         public void beforeInsert(){
 79  0
                 OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
 80  0
         }
 81  
 
 82  
         /**
 83  
          * @param documentTypeAttributeId The documentTypeAttributeId to set.
 84  
          */
 85  
         public void setDocumentTypeAttributeId(String documentTypeAttributeId) {
 86  0
                 this.documentTypeAttributeId = documentTypeAttributeId;
 87  0
         }
 88  
 
 89  
         /**
 90  
          * @return Returns the documentTypeAttributeId.
 91  
          */
 92  
         public String getDocumentTypeAttributeId() {
 93  0
                 return documentTypeAttributeId;
 94  
         }
 95  
 
 96  
         /**
 97  
          * @param documentTypeId The documentTypeId to set.
 98  
          */
 99  
         public void setDocumentTypeId(String documentTypeId) {
 100  0
                 this.documentTypeId = documentTypeId;
 101  0
         }
 102  
 
 103  
         /**
 104  
          * @return Returns the documentTypeId.
 105  
          */
 106  
         public String getDocumentTypeId() {
 107  0
                 return documentTypeId;
 108  
         }
 109  
 
 110  
         /**
 111  
          * @param ruleAttributeId The ruleAttributeId to set.
 112  
          */
 113  
         public void setRuleAttributeId(String ruleAttributeId) {
 114  0
                 this.ruleAttributeId = ruleAttributeId;
 115  0
         if (ruleAttributeId == null) {
 116  0
                 ruleAttribute = null;
 117  
         } else {
 118  0
             ruleAttribute = getRuleAttributeService().findByRuleAttributeId(ruleAttributeId);
 119  
         }
 120  0
         }
 121  
 
 122  
         /**
 123  
          * @return Returns the ruleAttributeId.
 124  
          */
 125  
         public String getRuleAttributeId() {
 126  0
                 return ruleAttributeId;
 127  
         }
 128  
 
 129  
         /**
 130  
          * @param ruleAttribute The ruleAttribute to set.
 131  
          */
 132  
         public void setRuleAttribute(RuleAttribute ruleAttribute) {
 133  0
                 this.ruleAttribute = ruleAttribute;
 134  0
         }
 135  
 
 136  
         /**
 137  
          * @return Returns the ruleAttribute.
 138  
          */
 139  
         public RuleAttribute getRuleAttribute() {
 140  0
                 return ruleAttribute;
 141  
         }
 142  
 
 143  
     private RuleAttributeService getRuleAttributeService() {
 144  0
         return (RuleAttributeService) KEWServiceLocator.getService(KEWServiceLocator.RULE_ATTRIBUTE_SERVICE);
 145  
     }
 146  
 
 147  
         /* (non-Javadoc)
 148  
          * @see java.lang.Comparable#compareTo(java.lang.Object)
 149  
          */
 150  
         public int compareTo(Object o) {
 151  0
         if (o instanceof DocumentTypeAttribute) {
 152  0
             return this.getRuleAttribute().getName().compareTo(((DocumentTypeAttribute) o).getRuleAttribute().getName());
 153  
         }
 154  0
         return 0;
 155  
      }
 156  
 
 157  
         public DocumentType getDocumentType() {
 158  0
                 return documentType;
 159  
         }
 160  
 
 161  
         public void setDocumentType(DocumentType documentType) {
 162  0
                 this.documentType = documentType;
 163  0
         }
 164  
         
 165  
     public int getOrderIndex() {
 166  0
         return orderIndex;
 167  
     }
 168  
 
 169  
     public void setOrderIndex(int orderIndex) {
 170  0
         this.orderIndex = orderIndex;
 171  0
     }
 172  
 
 173  
         public Integer getLockVerNbr() {
 174  0
                 return lockVerNbr;
 175  
         }
 176  
 
 177  
         public void setLockVerNbr(Integer lockVerNbr) {
 178  0
                 this.lockVerNbr = lockVerNbr;
 179  0
         }
 180  
 
 181  
 }
 182