Coverage Report - org.kuali.rice.edl.impl.extract.Fields
 
Classes in this File Line Coverage Branch Coverage Complexity
Fields
0%
0/36
0%
0/4
1.286
 
 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.edl.impl.extract;
 17  
 
 18  
 import javax.persistence.CascadeType;
 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.Table;
 27  
 import javax.persistence.Version;
 28  
 
 29  
 import org.hibernate.annotations.GenericGenerator;
 30  
 import org.hibernate.annotations.Parameter;
 31  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 32  
 import org.kuali.rice.edl.framework.extract.FieldDTO;
 33  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 34  
 
 35  
 /**
 36  
  *
 37  
  *
 38  
  *
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  *
 41  
  */
 42  
 @Entity
 43  
 @Table(name="KREW_EDL_FLD_DMP_T")
 44  
 //@Sequence(name="KREW_EDL_FLD_DMP_S", property="fieldId")
 45  0
 public class Fields {
 46  
 
 47  
         private static final long serialVersionUID = -6136544551121011531L;
 48  
 
 49  
     @Id
 50  
     @GeneratedValue(generator="KREW_EDL_FLD_DMP_S")
 51  
         @GenericGenerator(name="KREW_EDL_FLD_DMP_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 52  
                         @Parameter(name="sequence_name",value="KREW_EDL_FLD_DMP_S"),
 53  
                         @Parameter(name="value_column",value="id")
 54  
         })
 55  
         @Column(name="EDL_FIELD_DMP_ID")
 56  
         private Long fieldId;
 57  
     @Column(name="DOC_HDR_ID")
 58  
         private String docId;
 59  
     @Column(name="FLD_NM")
 60  
         private String fieldName;
 61  
     @Column(name="FLD_VAL")
 62  
         private String fieldValue;
 63  
     @Version
 64  
         @Column(name="VER_NBR")
 65  
         private Integer lockVerNbr;
 66  
 
 67  
     @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
 68  
         @JoinColumn(name="DOC_HDR_ID", insertable=false, updatable=false)
 69  
         private Dump dump;
 70  
 
 71  
     //@PrePersist
 72  
     public void beforeInsert(){
 73  0
         OrmUtils.populateAutoIncValue(this, KRADServiceLocator.getEntityManagerFactory().createEntityManager());
 74  0
     }
 75  
 
 76  
 
 77  
         public Long getFieldId() {
 78  0
                 return fieldId;
 79  
         }
 80  
         public String getDocId() {
 81  0
                 return docId;
 82  
         }
 83  
         public void setDocId(final String docId) {
 84  0
                 this.docId = docId;
 85  0
         }
 86  
         public String getFieldValue() {
 87  0
                 return fieldValue;
 88  
         }
 89  
         public void setFieldValue(final String fieldValue) {
 90  0
                 this.fieldValue = fieldValue;
 91  0
         }
 92  
         public String getFiledName() {
 93  0
                 return fieldName;
 94  
         }
 95  
         public void setFieldName(final String filedName) {
 96  0
                 this.fieldName = filedName;
 97  0
         }
 98  
         public Integer getLockVerNbr() {
 99  0
                 return lockVerNbr;
 100  
         }
 101  
         public void setLockVerNbr(final Integer lockVerNbr) {
 102  0
                 this.lockVerNbr = lockVerNbr;
 103  0
         }
 104  
         public Dump getDump() {
 105  0
                 return dump;
 106  
         }
 107  
         public void setDump(final Dump dump) {
 108  0
                 this.dump = dump;
 109  0
         }
 110  
         
 111  
         public static FieldDTO to(Fields field) {
 112  0
                 if (field == null) {
 113  0
                         return null;
 114  
                 }
 115  0
                 FieldDTO fieldDTO = new FieldDTO();
 116  0
                 fieldDTO.setDocId(field.getDocId());
 117  0
                 fieldDTO.setFieldName(field.getFiledName());
 118  0
                 fieldDTO.setFieldValue(field.getFieldValue());
 119  0
                 fieldDTO.setLockVerNbr(field.getLockVerNbr());
 120  0
                 return fieldDTO;
 121  
         }
 122  
         
 123  
         public static Fields from(FieldDTO fieldDTO, Dump dump) {
 124  0
                 if (fieldDTO == null) {
 125  0
                         return null;
 126  
                 }
 127  0
                 Fields fields = new Fields();
 128  0
                 fields.setDump(dump);
 129  0
                 fields.setDocId(fieldDTO.getDocId());
 130  0
                 fields.setFieldName(fieldDTO.getFiledName());
 131  0
                 fields.setFieldValue(fieldDTO.getFieldValue());
 132  0
                 fields.setLockVerNbr(fieldDTO.getLockVerNbr());
 133  0
                 return fields;
 134  
         }
 135  
 }
 136