Coverage Report - org.kuali.rice.kew.doctype.DocumentTypeAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypeAttribute
0%
0/32
0%
0/4
1.167
 
 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 javax.persistence.Column;
 20  
 import javax.persistence.Entity;
 21  
 import javax.persistence.FetchType;
 22  
 import javax.persistence.GeneratedValue;
 23  
 import javax.persistence.Id;
 24  
 import javax.persistence.JoinColumn;
 25  
 import javax.persistence.ManyToOne;
 26  
 import javax.persistence.PrePersist;
 27  
 import javax.persistence.SequenceGenerator;
 28  
 import javax.persistence.Table;
 29  
 import javax.persistence.Transient;
 30  
 
 31  
 import org.kuali.rice.core.jpa.annotations.Sequence;
 32  
 import org.kuali.rice.core.util.OrmUtils;
 33  
 import org.kuali.rice.kew.bo.WorkflowPersistable;
 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 WorkflowPersistable, Comparable {
 51  
 
 52  
         private static final long serialVersionUID = -4429421648373903566L;
 53  
 
 54  
         @Id
 55  
         @Column(name="DOC_TYP_ATTRIB_ID")
 56  
         private Long documentTypeAttributeId; 
 57  
     @Column(name="RULE_ATTR_ID",insertable=false, updatable=false)
 58  
         private Long ruleAttributeId;
 59  
     @ManyToOne(fetch=FetchType.EAGER)
 60  
         @JoinColumn(name="RULE_ATTR_ID")
 61  
         private RuleAttribute ruleAttribute;
 62  
     @Column(name="DOC_TYP_ID",insertable=false, updatable=false)
 63  
         private Long documentTypeId;
 64  
     @ManyToOne(fetch=FetchType.EAGER)
 65  
         @JoinColumn(name="DOC_TYP_ID")
 66  
         private DocumentType documentType;
 67  
     @Column(name="ORD_INDX")
 68  
         private int orderIndex;
 69  
     @Transient
 70  
     private Integer lockVerNbr;
 71  
     
 72  
         @PrePersist
 73  
         public void beforeInsert(){
 74  0
                 OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());                
 75  0
         }
 76  
 
 77  
         /**
 78  
          * @param documentTypeAttributeId The documentTypeAttributeId to set.
 79  
          */
 80  
         public void setDocumentTypeAttributeId(Long documentTypeAttributeId) {
 81  0
                 this.documentTypeAttributeId = documentTypeAttributeId;
 82  0
         }
 83  
 
 84  
         /**
 85  
          * @return Returns the documentTypeAttributeId.
 86  
          */
 87  
         public Long getDocumentTypeAttributeId() {
 88  0
                 return documentTypeAttributeId;
 89  
         }
 90  
 
 91  
         /**
 92  
          * @param documentTypeId The documentTypeId to set.
 93  
          */
 94  
         public void setDocumentTypeId(Long documentTypeId) {
 95  0
                 this.documentTypeId = documentTypeId;
 96  0
         }
 97  
 
 98  
         /**
 99  
          * @return Returns the documentTypeId.
 100  
          */
 101  
         public Long getDocumentTypeId() {
 102  0
                 return documentTypeId;
 103  
         }
 104  
 
 105  
         /**
 106  
          * @param ruleAttributeId The ruleAttributeId to set.
 107  
          */
 108  
         public void setRuleAttributeId(Long ruleAttributeId) {
 109  0
                 this.ruleAttributeId = ruleAttributeId;
 110  0
         if (ruleAttributeId == null) {
 111  0
                 ruleAttribute = null;
 112  
         } else {
 113  0
             ruleAttribute = getRuleAttributeService().findByRuleAttributeId(ruleAttributeId);
 114  
         }
 115  0
         }
 116  
 
 117  
         /**
 118  
          * @return Returns the ruleAttributeId.
 119  
          */
 120  
         public Long getRuleAttributeId() {
 121  0
                 return ruleAttributeId;
 122  
         }
 123  
 
 124  
         /**
 125  
          * @param ruleAttribute The ruleAttribute to set.
 126  
          */
 127  
         public void setRuleAttribute(RuleAttribute ruleAttribute) {
 128  0
                 this.ruleAttribute = ruleAttribute;
 129  0
         }
 130  
 
 131  
         /**
 132  
          * @return Returns the ruleAttribute.
 133  
          */
 134  
         public RuleAttribute getRuleAttribute() {
 135  0
                 return ruleAttribute;
 136  
         }
 137  
 
 138  
         /* (non-Javadoc)
 139  
          * @see org.kuali.rice.kew.WorkflowPersistable#copy(boolean)
 140  
          */
 141  
         public Object copy(boolean preserveKeys) {
 142  0
                 return null;
 143  
         }
 144  
 
 145  
     private RuleAttributeService getRuleAttributeService() {
 146  0
         return (RuleAttributeService) KEWServiceLocator.getService(KEWServiceLocator.RULE_ATTRIBUTE_SERVICE);
 147  
     }
 148  
 
 149  
         /* (non-Javadoc)
 150  
          * @see java.lang.Comparable#compareTo(java.lang.Object)
 151  
          */
 152  
         public int compareTo(Object o) {
 153  0
         if (o instanceof DocumentTypeAttribute) {
 154  0
             return this.getRuleAttribute().getName().compareTo(((DocumentTypeAttribute) o).getRuleAttribute().getName());
 155  
         }
 156  0
         return 0;
 157  
      }
 158  
 
 159  
         public DocumentType getDocumentType() {
 160  0
                 return documentType;
 161  
         }
 162  
 
 163  
         public void setDocumentType(DocumentType documentType) {
 164  0
                 this.documentType = documentType;
 165  0
         }
 166  
         
 167  
     public int getOrderIndex() {
 168  0
         return orderIndex;
 169  
     }
 170  
 
 171  
     public void setOrderIndex(int orderIndex) {
 172  0
         this.orderIndex = orderIndex;
 173  0
     }
 174  
 
 175  
         public Integer getLockVerNbr() {
 176  0
                 return lockVerNbr;
 177  
         }
 178  
 
 179  
         public void setLockVerNbr(Integer lockVerNbr) {
 180  0
                 this.lockVerNbr = lockVerNbr;
 181  0
         }
 182  
 
 183  
 }
 184