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