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