View Javadoc
1   /**
2    * Copyright 2005-2014 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.kuali.rice.edl.framework.extract.FieldDTO;
30  import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
31  
32  import java.io.Serializable;
33  
34  /**
35   *
36   *
37   *
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   *
40   */
41  @Entity
42  @Table(name="KREW_EDL_FLD_DMP_T")
43  public class Fields implements Serializable {
44  
45      //	private static final long serialVersionUID = -6136544551121011531L;
46  
47      @Id
48      @GeneratedValue(generator="KREW_EDL_FLD_DMP_S")
49      @PortableSequenceGenerator(name = "KREW_EDL_FLD_DMP_S")
50      @Column(name="EDL_FIELD_DMP_ID")
51      private Long fieldId;
52  
53      @Column(name="DOC_HDR_ID")
54      private String docId;
55  
56      @Column(name="FLD_NM")
57      private String fieldName;
58  
59      @Column(name="FLD_VAL")
60      private String fieldValue;
61  
62      @Version
63      @Column(name="VER_NBR")
64      private Integer lockVerNbr;
65  
66      @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
67      @JoinColumn(name="DOC_HDR_ID", insertable=false, updatable=false)
68      private Dump dump;
69  
70      /**
71       * Returns the field id.
72       * @return the field id
73       */
74      public Long getFieldId() {
75          return fieldId;
76      }
77  
78      /**
79       *
80       * @see #getFieldId()
81       */
82      public void setFieldId(Long fieldId) {
83          this.fieldId = fieldId;
84      }
85  
86      /**
87       * Returns the doc id.
88       * @return the doc id
89       */
90      public String getDocId() {
91          return docId;
92      }
93  
94      /**
95       *
96       * @see #getDocId()
97       */
98      public void setDocId(final String docId) {
99          this.docId = docId;
100     }
101 
102     /**
103      * Returns the field value.
104      * @return the field value
105      */
106     public String getFieldValue() {
107         return fieldValue;
108     }
109 
110     /**
111      *
112      * @see #getFieldValue()
113      */
114     public void setFieldValue(final String fieldValue) {
115         this.fieldValue = fieldValue;
116     }
117 
118     /**
119      * Returns the field name.
120      * @return the field name
121      */
122     public String getFieldName() {
123         return fieldName;
124     }
125 
126     /**
127      *
128      * @see #getFieldName()
129      */
130     public void setFieldName(final String filedName) {
131         this.fieldName = filedName;
132     }
133 
134     /**
135      * Returns the lock version number.
136      * @return the lock version number
137      */
138     public Integer getLockVerNbr() {
139         return lockVerNbr;
140     }
141 
142     /**
143      *
144      * @see #getLockVerNbr()
145      */
146     public void setLockVerNbr(final Integer lockVerNbr) {
147         this.lockVerNbr = lockVerNbr;
148     }
149 
150     /**
151      * Returns a {@link Dump}
152      * @return a {@link Dump}
153      */
154     public Dump getDump() {
155         return dump;
156     }
157 
158     /**
159      *
160      * @see #getDump()
161      */
162     public void setDump(final Dump dump) {
163         this.dump = dump;
164     }
165 
166     /**
167      * Converts a {@link Fields} to a {@link FieldDTO}.
168      * @param field the {@link Fields} to convert.
169      * @return a {@link Fields}
170      */
171     public static FieldDTO to(Fields field) {
172         if (field == null) {
173             return null;
174         }
175         FieldDTO fieldDTO = new FieldDTO();
176         fieldDTO.setDocId(field.getDocId());
177         fieldDTO.setFieldName(field.getFieldName());
178         fieldDTO.setFieldValue(field.getFieldValue());
179         fieldDTO.setLockVerNbr(field.getLockVerNbr());
180         return fieldDTO;
181     }
182 
183     /**
184      * Converts a {@link FieldDTO} to a {@link Fields}
185      * @param fieldDTO the {@link FieldDTO} to convert.
186      * @param dump a {@link Dump}
187      * @return a {@link Fields}
188      */
189     public static Fields from(FieldDTO fieldDTO, Dump dump) {
190         if (fieldDTO == null) {
191             return null;
192         }
193         Fields fields = new Fields();
194         fields.setDump(dump);
195         fields.setDocId(fieldDTO.getDocId());
196         fields.setFieldName(fieldDTO.getFiledName());
197         fields.setFieldValue(fieldDTO.getFieldValue());
198         fields.setLockVerNbr(fieldDTO.getLockVerNbr());
199         return fields;
200     }
201 }
202